diff --git a/audio/adlib.cpp b/audio/adlib.cpp index 89a15b475f9..dc48c74f911 100644 --- a/audio/adlib.cpp +++ b/audio/adlib.cpp @@ -1405,7 +1405,7 @@ MidiDriver_ADLIB::MidiDriver_ADLIB() { _timerThreshold = 0x411B; _opl = 0; _adlibTimerProc = 0; - _adlibTimerParam = 0; + _adlibTimerParam = 0; _isOpen = false; } diff --git a/audio/audiostream.cpp b/audio/audiostream.cpp index a556f1266d1..7c8b01464c5 100644 --- a/audio/audiostream.cpp +++ b/audio/audiostream.cpp @@ -92,7 +92,7 @@ SeekableAudioStream *SeekableAudioStream::openStreamFile(const Common::String &b #pragma mark - LoopingAudioStream::LoopingAudioStream(RewindableAudioStream *stream, uint loops, DisposeAfterUse::Flag disposeAfterUse, bool rewind) - : _parent(stream, disposeAfterUse), _loops(loops), _completeIterations(0) { + : _parent(stream, disposeAfterUse), _loops(loops), _completeIterations(0) { assert(stream); if (rewind && !stream->rewind()) { @@ -171,15 +171,15 @@ AudioStream *makeLoopingAudioStream(SeekableAudioStream *stream, Timestamp start #pragma mark - SubLoopingAudioStream::SubLoopingAudioStream(SeekableAudioStream *stream, - uint loops, - const Timestamp loopStart, - const Timestamp loopEnd, - DisposeAfterUse::Flag disposeAfterUse) - : _parent(stream, disposeAfterUse), _loops(loops), - _pos(0, getRate() * (isStereo() ? 2 : 1)), - _loopStart(convertTimeToStreamPos(loopStart, getRate(), isStereo())), - _loopEnd(convertTimeToStreamPos(loopEnd, getRate(), isStereo())), - _done(false) { + uint loops, + const Timestamp loopStart, + const Timestamp loopEnd, + DisposeAfterUse::Flag disposeAfterUse) + : _parent(stream, disposeAfterUse), _loops(loops), + _pos(0, getRate() * (isStereo() ? 2 : 1)), + _loopStart(convertTimeToStreamPos(loopStart, getRate(), isStereo())), + _loopEnd(convertTimeToStreamPos(loopEnd, getRate(), isStereo())), + _done(false) { assert(loopStart < loopEnd); if (!_parent->rewind()) @@ -238,10 +238,10 @@ bool SubLoopingAudioStream::endOfStream() const { #pragma mark - SubSeekableAudioStream::SubSeekableAudioStream(SeekableAudioStream *parent, const Timestamp start, const Timestamp end, DisposeAfterUse::Flag disposeAfterUse) - : _parent(parent, disposeAfterUse), - _start(convertTimeToStreamPos(start, getRate(), isStereo())), - _pos(0, getRate() * (isStereo() ? 2 : 1)), - _length(convertTimeToStreamPos(end, getRate(), isStereo()) - _start) { + : _parent(parent, disposeAfterUse), + _start(convertTimeToStreamPos(start, getRate(), isStereo())), + _pos(0, getRate() * (isStereo() ? 2 : 1)), + _length(convertTimeToStreamPos(end, getRate(), isStereo()) - _start) { assert(_length.totalNumberOfFrames() % (isStereo() ? 2 : 1) == 0); _parent->seek(_start); @@ -472,10 +472,10 @@ AudioStream *makeLimitingAudioStream(AudioStream *parentStream, const Timestamp */ class NullAudioStream : public AudioStream { public: - bool isStereo() const { return false; } - int getRate() const; - int readBuffer(int16 *data, const int numSamples) { return 0; } - bool endOfData() const { return true; } + bool isStereo() const { return false; } + int getRate() const; + int readBuffer(int16 *data, const int numSamples) { return 0; } + bool endOfData() const { return true; } }; int NullAudioStream::getRate() const { diff --git a/audio/decoders/ac3.cpp b/audio/decoders/ac3.cpp index cc0b530a88a..aa06f710191 100644 --- a/audio/decoders/ac3.cpp +++ b/audio/decoders/ac3.cpp @@ -82,7 +82,7 @@ bool AC3Stream::init(Common::SeekableReadStream &firstPacket) { deinit(); // In theory, I should pass mm_accel() to a52_init(), but I don't know - // where that's supposed to be defined. + // where that's supposed to be defined. _a52State = a52_init(0); // Go through the header to find sync diff --git a/audio/decoders/adpcm.h b/audio/decoders/adpcm.h index 4c75915ea8d..3b693e99f0b 100644 --- a/audio/decoders/adpcm.h +++ b/audio/decoders/adpcm.h @@ -77,12 +77,12 @@ enum ADPCMType { * @return a new RewindableAudioStream, or NULL, if an error occurred */ SeekableAudioStream *makeADPCMStream( - Common::SeekableReadStream *stream, - DisposeAfterUse::Flag disposeAfterUse, - uint32 size, ADPCMType type, - int rate, - int channels, - uint32 blockAlign = 0); + Common::SeekableReadStream *stream, + DisposeAfterUse::Flag disposeAfterUse, + uint32 size, ADPCMType type, + int rate, + int channels, + uint32 blockAlign = 0); /** * Creates a PacketizedAudioStream that will automatically queue diff --git a/audio/decoders/qdm2.cpp b/audio/decoders/qdm2.cpp index a9cf30e9ef5..d5eba536f27 100644 --- a/audio/decoders/qdm2.cpp +++ b/audio/decoders/qdm2.cpp @@ -253,9 +253,9 @@ private: // half mpeg encoding window (full precision) const int32 ff_mpa_enwindow[257] = { - 0, -1, -1, -1, -1, -1, -1, -2, - -2, -2, -2, -3, -3, -4, -4, -5, - -5, -6, -7, -7, -8, -9, -10, -11, + 0, -1, -1, -1, -1, -1, -1, -2, + -2, -2, -2, -3, -3, -4, -4, -5, + -5, -6, -7, -7, -8, -9, -10, -11, -13, -14, -16, -17, -19, -21, -24, -26, -29, -31, -35, -38, -41, -45, -49, -53, -58, -63, -68, -73, -79, -85, -91, -97, @@ -278,7 +278,7 @@ const int32 ff_mpa_enwindow[257] = { -9727, -9838, -9916, -9959, -9966, -9935, -9863, -9750, -9592, -9389, -9139, -8840, -8492, -8092, -7640, -7134, 6574, 5959, 5288, 4561, 3776, 2935, 2037, 1082, - 70, -998, -2122, -3300, -4533, -5818, -7154, -8540, + 70, -998, -2122, -3300, -4533, -5818, -7154, -8540, -9975,-11455,-12980,-14548,-16155,-17799,-19478,-21189, -22929,-24694,-26482,-28289,-30112,-31947,-33791,-35640, -37489,-39336,-41176,-43006,-44821,-46617,-48390,-50137, @@ -595,9 +595,9 @@ static void dct32(int32 *out, int32 *tab) { // 32 samples. // XXX: optimize by avoiding ring buffer usage void ff_mpa_synth_filter(int16 *synth_buf_ptr, int *synth_buf_offset, - int16 *window, int *dither_state, - int16 *samples, int incr, - int32 sb_samples[32]) + int16 *window, int *dither_state, + int16 *samples, int incr, + int32 sb_samples[32]) { int16 *synth_buf; const int16 *w, *w2, *p; @@ -733,11 +733,11 @@ static int allocTable(VLC *vlc, int size, int use_static) { } static int build_table(VLC *vlc, int table_nb_bits, - int nb_codes, - const void *bits, int bits_wrap, int bits_size, - const void *codes, int codes_wrap, int codes_size, - const void *symbols, int symbols_wrap, int symbols_size, - int code_prefix, int n_prefix, int flags) + int nb_codes, + const void *bits, int bits_wrap, int bits_size, + const void *codes, int codes_wrap, int codes_size, + const void *symbols, int symbols_wrap, int symbols_size, + int code_prefix, int n_prefix, int flags) { int i, j, k, n, table_size, table_index, nb, n1, index, code_prefix2, symbol; uint32 code; @@ -1479,8 +1479,8 @@ void QDM2Stream::fill_tone_level_array(int flag) { * @param cm_table_select q->cm_table_select */ void QDM2Stream::fill_coding_method_array(sb_int8_array tone_level_idx, sb_int8_array tone_level_idx_temp, - sb_int8_array coding_method, int nb_channels, - int c, int superblocktype_2_3, int cm_table_select) { + sb_int8_array coding_method, int nb_channels, + int c, int superblocktype_2_3, int cm_table_select) { int ch, sb, j; int tmp, acc, esp_40, comp; int add1, add2, add3, add4; @@ -2160,7 +2160,7 @@ void QDM2Stream::qdm2_decode_super_block(void) { } void QDM2Stream::qdm2_fft_init_coefficient(int sub_packet, int offset, int duration, - int channel, int exp, int phase) { + int channel, int exp, int phase) { if (_fftCoefsMinIndex[duration] < 0) _fftCoefsMinIndex[duration] = _fftCoefsIndex; diff --git a/audio/decoders/qdm2.h b/audio/decoders/qdm2.h index 7f1ab8ffde4..a119ae705ed 100644 --- a/audio/decoders/qdm2.h +++ b/audio/decoders/qdm2.h @@ -44,7 +44,7 @@ class Codec; * @return a new Codec, or NULL, if an error occurred */ Codec *makeQDM2Decoder(Common::SeekableReadStream *extraData, - DisposeAfterUse::Flag disposeExtraData = DisposeAfterUse::NO); + DisposeAfterUse::Flag disposeExtraData = DisposeAfterUse::NO); } // End of namespace Audio diff --git a/audio/decoders/raw.cpp b/audio/decoders/raw.cpp index 2ecc7918702..d512ef93ddb 100644 --- a/audio/decoders/raw.cpp +++ b/audio/decoders/raw.cpp @@ -201,8 +201,8 @@ bool RawStream::seek(const Timestamp &where) { return new RawStream<1, UNSIGNED, false>(rate, isStereo, disposeAfterUse, stream) SeekableAudioStream *makeRawStream(Common::SeekableReadStream *stream, - int rate, byte flags, - DisposeAfterUse::Flag disposeAfterUse) { + int rate, byte flags, + DisposeAfterUse::Flag disposeAfterUse) { const bool isStereo = (flags & Audio::FLAG_STEREO) != 0; const int bytesPerSample = (flags & Audio::FLAG_24BITS ? 3 : (flags & Audio::FLAG_16BITS ? 2 : 1)); const bool isUnsigned = (flags & Audio::FLAG_UNSIGNED) != 0; @@ -218,8 +218,8 @@ SeekableAudioStream *makeRawStream(Common::SeekableReadStream *stream, } SeekableAudioStream *makeRawStream(const byte *buffer, uint32 size, - int rate, byte flags, - DisposeAfterUse::Flag disposeAfterUse) { + int rate, byte flags, + DisposeAfterUse::Flag disposeAfterUse) { return makeRawStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, flags, DisposeAfterUse::YES); } diff --git a/audio/decoders/raw.h b/audio/decoders/raw.h index a13f4fe4449..efd9fc095f0 100644 --- a/audio/decoders/raw.h +++ b/audio/decoders/raw.h @@ -76,8 +76,8 @@ enum RawFlags { * @return The new SeekableAudioStream (or 0 on failure). */ SeekableAudioStream *makeRawStream(const byte *buffer, uint32 size, - int rate, byte flags, - DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); + int rate, byte flags, + DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); /** * Creates an audio stream, which plays from the given stream. @@ -90,8 +90,8 @@ SeekableAudioStream *makeRawStream(const byte *buffer, uint32 size, * @return The new SeekableAudioStream (or 0 on failure). */ SeekableAudioStream *makeRawStream(Common::SeekableReadStream *stream, - int rate, byte flags, - DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); + int rate, byte flags, + DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); /** * Creates a PacketizedAudioStream that will automatically queue diff --git a/audio/decoders/util.h b/audio/decoders/util.h index d5e2eda5751..7db17db809b 100644 --- a/audio/decoders/util.h +++ b/audio/decoders/util.h @@ -35,7 +35,7 @@ static inline int16 floatToInt16(float src) { // Convert planar float samples into interleaved int16 samples static inline void floatToInt16Interleave(int16 *dst, const float **src, - uint32 length, uint8 channels) { + uint32 length, uint8 channels) { if (channels == 2) { for (uint32 i = 0; i < length; i++) { dst[2 * i ] = floatToInt16(src[0][i]); diff --git a/audio/decoders/wma.cpp b/audio/decoders/wma.cpp index 032934addf0..6f9fdf2aea9 100644 --- a/audio/decoders/wma.cpp +++ b/audio/decoders/wma.cpp @@ -50,13 +50,13 @@ static inline void butterflyFloats(float *v1, float *v2, int len) { } static inline void vectorFMulAdd(float *dst, const float *src0, - const float *src1, const float *src2, int len) { + const float *src1, const float *src2, int len) { while (len-- > 0) *dst++ = *src0++ * *src1++ + *src2++; } static inline void vectorFMulReverse(float *dst, const float *src0, - const float *src1, int len) { + const float *src1, int len) { src1 += len - 1; while (len-- > 0) @@ -767,7 +767,7 @@ int WMACodec::decodeBlock(Common::BitStream8MSB &bits) { } bool WMACodec::decodeChannels(Common::BitStream8MSB &bits, int bSize, - bool msStereo, bool *hasChannel) { + bool msStereo, bool *hasChannel) { int totalGain = readTotalGain(bits); int coefBitCount = totalGainToBits(totalGain); @@ -899,7 +899,7 @@ void WMACodec::calculateCoefCount(int *coefCount, int bSize) const { } bool WMACodec::decodeNoise(Common::BitStream8MSB &bits, int bSize, - bool *hasChannel, int *coefCount) { + bool *hasChannel, int *coefCount) { if (!_useNoiseCoding) return true; @@ -973,7 +973,7 @@ bool WMACodec::decodeExponents(Common::BitStream8MSB &bits, int bSize, bool *has } bool WMACodec::decodeSpectralCoef(Common::BitStream8MSB &bits, bool msStereo, bool *hasChannel, - int *coefCount, int coefBitCount) { + int *coefCount, int coefBitCount) { // Simple RLE encoding for (int i = 0; i < _channels; i++) { @@ -1009,7 +1009,7 @@ float WMACodec::getNormalizedMDCTLength() const { } void WMACodec::calculateMDCTCoefficients(int bSize, bool *hasChannel, - int *coefCount, int totalGain, float mdctNorm) { + int *coefCount, int totalGain, float mdctNorm) { for (int i = 0; i < _channels; i++) { if (!hasChannel[i]) @@ -1132,84 +1132,84 @@ void WMACodec::calculateMDCTCoefficients(int bSize, bool *hasChannel, } static const float powTab[] = { - 1.7782794100389e-04, 2.0535250264571e-04, - 2.3713737056617e-04, 2.7384196342644e-04, - 3.1622776601684e-04, 3.6517412725484e-04, - 4.2169650342858e-04, 4.8696752516586e-04, - 5.6234132519035e-04, 6.4938163157621e-04, - 7.4989420933246e-04, 8.6596432336006e-04, - 1.0000000000000e-03, 1.1547819846895e-03, - 1.3335214321633e-03, 1.5399265260595e-03, - 1.7782794100389e-03, 2.0535250264571e-03, - 2.3713737056617e-03, 2.7384196342644e-03, - 3.1622776601684e-03, 3.6517412725484e-03, - 4.2169650342858e-03, 4.8696752516586e-03, - 5.6234132519035e-03, 6.4938163157621e-03, - 7.4989420933246e-03, 8.6596432336006e-03, - 1.0000000000000e-02, 1.1547819846895e-02, - 1.3335214321633e-02, 1.5399265260595e-02, - 1.7782794100389e-02, 2.0535250264571e-02, - 2.3713737056617e-02, 2.7384196342644e-02, - 3.1622776601684e-02, 3.6517412725484e-02, - 4.2169650342858e-02, 4.8696752516586e-02, - 5.6234132519035e-02, 6.4938163157621e-02, - 7.4989420933246e-02, 8.6596432336007e-02, - 1.0000000000000e-01, 1.1547819846895e-01, - 1.3335214321633e-01, 1.5399265260595e-01, - 1.7782794100389e-01, 2.0535250264571e-01, - 2.3713737056617e-01, 2.7384196342644e-01, - 3.1622776601684e-01, 3.6517412725484e-01, - 4.2169650342858e-01, 4.8696752516586e-01, - 5.6234132519035e-01, 6.4938163157621e-01, - 7.4989420933246e-01, 8.6596432336007e-01, - 1.0000000000000e+00, 1.1547819846895e+00, - 1.3335214321633e+00, 1.5399265260595e+00, - 1.7782794100389e+00, 2.0535250264571e+00, - 2.3713737056617e+00, 2.7384196342644e+00, - 3.1622776601684e+00, 3.6517412725484e+00, - 4.2169650342858e+00, 4.8696752516586e+00, - 5.6234132519035e+00, 6.4938163157621e+00, - 7.4989420933246e+00, 8.6596432336007e+00, - 1.0000000000000e+01, 1.1547819846895e+01, - 1.3335214321633e+01, 1.5399265260595e+01, - 1.7782794100389e+01, 2.0535250264571e+01, - 2.3713737056617e+01, 2.7384196342644e+01, - 3.1622776601684e+01, 3.6517412725484e+01, - 4.2169650342858e+01, 4.8696752516586e+01, - 5.6234132519035e+01, 6.4938163157621e+01, - 7.4989420933246e+01, 8.6596432336007e+01, - 1.0000000000000e+02, 1.1547819846895e+02, - 1.3335214321633e+02, 1.5399265260595e+02, - 1.7782794100389e+02, 2.0535250264571e+02, - 2.3713737056617e+02, 2.7384196342644e+02, - 3.1622776601684e+02, 3.6517412725484e+02, - 4.2169650342858e+02, 4.8696752516586e+02, - 5.6234132519035e+02, 6.4938163157621e+02, - 7.4989420933246e+02, 8.6596432336007e+02, - 1.0000000000000e+03, 1.1547819846895e+03, - 1.3335214321633e+03, 1.5399265260595e+03, - 1.7782794100389e+03, 2.0535250264571e+03, - 2.3713737056617e+03, 2.7384196342644e+03, - 3.1622776601684e+03, 3.6517412725484e+03, - 4.2169650342858e+03, 4.8696752516586e+03, - 5.6234132519035e+03, 6.4938163157621e+03, - 7.4989420933246e+03, 8.6596432336007e+03, - 1.0000000000000e+04, 1.1547819846895e+04, - 1.3335214321633e+04, 1.5399265260595e+04, - 1.7782794100389e+04, 2.0535250264571e+04, - 2.3713737056617e+04, 2.7384196342644e+04, - 3.1622776601684e+04, 3.6517412725484e+04, - 4.2169650342858e+04, 4.8696752516586e+04, - 5.6234132519035e+04, 6.4938163157621e+04, - 7.4989420933246e+04, 8.6596432336007e+04, - 1.0000000000000e+05, 1.1547819846895e+05, - 1.3335214321633e+05, 1.5399265260595e+05, - 1.7782794100389e+05, 2.0535250264571e+05, - 2.3713737056617e+05, 2.7384196342644e+05, - 3.1622776601684e+05, 3.6517412725484e+05, - 4.2169650342858e+05, 4.8696752516586e+05, - 5.6234132519035e+05, 6.4938163157621e+05, - 7.4989420933246e+05, 8.6596432336007e+05, + 1.7782794100389e-04, 2.0535250264571e-04, + 2.3713737056617e-04, 2.7384196342644e-04, + 3.1622776601684e-04, 3.6517412725484e-04, + 4.2169650342858e-04, 4.8696752516586e-04, + 5.6234132519035e-04, 6.4938163157621e-04, + 7.4989420933246e-04, 8.6596432336006e-04, + 1.0000000000000e-03, 1.1547819846895e-03, + 1.3335214321633e-03, 1.5399265260595e-03, + 1.7782794100389e-03, 2.0535250264571e-03, + 2.3713737056617e-03, 2.7384196342644e-03, + 3.1622776601684e-03, 3.6517412725484e-03, + 4.2169650342858e-03, 4.8696752516586e-03, + 5.6234132519035e-03, 6.4938163157621e-03, + 7.4989420933246e-03, 8.6596432336006e-03, + 1.0000000000000e-02, 1.1547819846895e-02, + 1.3335214321633e-02, 1.5399265260595e-02, + 1.7782794100389e-02, 2.0535250264571e-02, + 2.3713737056617e-02, 2.7384196342644e-02, + 3.1622776601684e-02, 3.6517412725484e-02, + 4.2169650342858e-02, 4.8696752516586e-02, + 5.6234132519035e-02, 6.4938163157621e-02, + 7.4989420933246e-02, 8.6596432336007e-02, + 1.0000000000000e-01, 1.1547819846895e-01, + 1.3335214321633e-01, 1.5399265260595e-01, + 1.7782794100389e-01, 2.0535250264571e-01, + 2.3713737056617e-01, 2.7384196342644e-01, + 3.1622776601684e-01, 3.6517412725484e-01, + 4.2169650342858e-01, 4.8696752516586e-01, + 5.6234132519035e-01, 6.4938163157621e-01, + 7.4989420933246e-01, 8.6596432336007e-01, + 1.0000000000000e+00, 1.1547819846895e+00, + 1.3335214321633e+00, 1.5399265260595e+00, + 1.7782794100389e+00, 2.0535250264571e+00, + 2.3713737056617e+00, 2.7384196342644e+00, + 3.1622776601684e+00, 3.6517412725484e+00, + 4.2169650342858e+00, 4.8696752516586e+00, + 5.6234132519035e+00, 6.4938163157621e+00, + 7.4989420933246e+00, 8.6596432336007e+00, + 1.0000000000000e+01, 1.1547819846895e+01, + 1.3335214321633e+01, 1.5399265260595e+01, + 1.7782794100389e+01, 2.0535250264571e+01, + 2.3713737056617e+01, 2.7384196342644e+01, + 3.1622776601684e+01, 3.6517412725484e+01, + 4.2169650342858e+01, 4.8696752516586e+01, + 5.6234132519035e+01, 6.4938163157621e+01, + 7.4989420933246e+01, 8.6596432336007e+01, + 1.0000000000000e+02, 1.1547819846895e+02, + 1.3335214321633e+02, 1.5399265260595e+02, + 1.7782794100389e+02, 2.0535250264571e+02, + 2.3713737056617e+02, 2.7384196342644e+02, + 3.1622776601684e+02, 3.6517412725484e+02, + 4.2169650342858e+02, 4.8696752516586e+02, + 5.6234132519035e+02, 6.4938163157621e+02, + 7.4989420933246e+02, 8.6596432336007e+02, + 1.0000000000000e+03, 1.1547819846895e+03, + 1.3335214321633e+03, 1.5399265260595e+03, + 1.7782794100389e+03, 2.0535250264571e+03, + 2.3713737056617e+03, 2.7384196342644e+03, + 3.1622776601684e+03, 3.6517412725484e+03, + 4.2169650342858e+03, 4.8696752516586e+03, + 5.6234132519035e+03, 6.4938163157621e+03, + 7.4989420933246e+03, 8.6596432336007e+03, + 1.0000000000000e+04, 1.1547819846895e+04, + 1.3335214321633e+04, 1.5399265260595e+04, + 1.7782794100389e+04, 2.0535250264571e+04, + 2.3713737056617e+04, 2.7384196342644e+04, + 3.1622776601684e+04, 3.6517412725484e+04, + 4.2169650342858e+04, 4.8696752516586e+04, + 5.6234132519035e+04, 6.4938163157621e+04, + 7.4989420933246e+04, 8.6596432336007e+04, + 1.0000000000000e+05, 1.1547819846895e+05, + 1.3335214321633e+05, 1.5399265260595e+05, + 1.7782794100389e+05, 2.0535250264571e+05, + 2.3713737056617e+05, 2.7384196342644e+05, + 3.1622776601684e+05, 3.6517412725484e+05, + 4.2169650342858e+05, 4.8696752516586e+05, + 5.6234132519035e+05, 6.4938163157621e+05, + 7.4989420933246e+05, 8.6596432336007e+05, }; bool WMACodec::decodeExpHuffman(Common::BitStream8MSB &bits, int ch) { diff --git a/audio/mixer.cpp b/audio/mixer.cpp index beda136acf4..28b569eb6bc 100644 --- a/audio/mixer.cpp +++ b/audio/mixer.cpp @@ -497,11 +497,11 @@ int MixerImpl::getVolumeForSoundType(SoundType type) const { #pragma mark - Channel::Channel(Mixer *mixer, Mixer::SoundType type, AudioStream *stream, - DisposeAfterUse::Flag autofreeStream, bool reverseStereo, int id, bool permanent) - : _type(type), _mixer(mixer), _id(id), _permanent(permanent), _volume(Mixer::kMaxChannelVolume), - _balance(0), _pauseLevel(0), _samplesConsumed(0), _samplesDecoded(0), _mixerTimeStamp(0), - _pauseStartTime(0), _pauseTime(0), _converter(0), _volL(0), _volR(0), - _stream(stream, autofreeStream) { + DisposeAfterUse::Flag autofreeStream, bool reverseStereo, int id, bool permanent) + : _type(type), _mixer(mixer), _id(id), _permanent(permanent), _volume(Mixer::kMaxChannelVolume), + _balance(0), _pauseLevel(0), _samplesConsumed(0), _samplesDecoded(0), _mixerTimeStamp(0), + _pauseStartTime(0), _pauseTime(0), _converter(0), _volL(0), _volR(0), + _stream(stream, autofreeStream) { assert(mixer); assert(stream); diff --git a/backends/audiocd/sdl/sdl-audiocd.cpp b/backends/audiocd/sdl/sdl-audiocd.cpp index e2e4f1d0697..149e4139a9f 100644 --- a/backends/audiocd/sdl/sdl-audiocd.cpp +++ b/backends/audiocd/sdl/sdl-audiocd.cpp @@ -77,10 +77,10 @@ void SdlAudioCDManager::close() { DefaultAudioCDManager::close(); if (_cdrom) { - SDL_CDStop(_cdrom); - SDL_CDClose(_cdrom); + SDL_CDStop(_cdrom); + SDL_CDClose(_cdrom); _cdrom = 0; - } + } } void SdlAudioCDManager::stop() { diff --git a/backends/audiocd/win32/msvc/ntddcdrm.h b/backends/audiocd/win32/msvc/ntddcdrm.h index 18527e26759..02ff609259f 100644 --- a/backends/audiocd/win32/msvc/ntddcdrm.h +++ b/backends/audiocd/win32/msvc/ntddcdrm.h @@ -230,8 +230,8 @@ typedef struct _CDROM_TOC_CD_TEXT_DATA_BLOCK { UCHAR BlockNumber : 3; UCHAR Unicode : 1; _ANONYMOUS_UNION union { - UCHAR Text[12]; - WCHAR WText[6]; + UCHAR Text[12]; + WCHAR WText[6]; } DUMMYUNIONNAME; UCHAR CRC[2]; } CDROM_TOC_CD_TEXT_DATA_BLOCK, *PCDROM_TOC_CD_TEXT_DATA_BLOCK; diff --git a/backends/dialogs/morphos/morphos-dialogs.cpp b/backends/dialogs/morphos/morphos-dialogs.cpp index 5fe063b3b18..735a77c5c86 100644 --- a/backends/dialogs/morphos/morphos-dialogs.cpp +++ b/backends/dialogs/morphos/morphos-dialogs.cpp @@ -71,7 +71,7 @@ Common::DialogManager::DialogResult MorphosDialogManager::showFileBrowser(const Common::String utf8Title = title.encode(); struct Library *AslBase = OpenLibrary(AslName, 39); - if (AslBase) { + if (AslBase) { struct FileRequester *fr = NULL; diff --git a/backends/events/riscossdl/riscossdl-events.cpp b/backends/events/riscossdl/riscossdl-events.cpp index 201bca94bc6..8e053cff7ba 100644 --- a/backends/events/riscossdl/riscossdl-events.cpp +++ b/backends/events/riscossdl/riscossdl-events.cpp @@ -32,7 +32,7 @@ #include RISCOSSdlEventSource::RISCOSSdlEventSource() - : SdlEventSource() { + : SdlEventSource() { int messages[2]; messages[0] = 3; // Message_DataLoad messages[1] = 0; diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp index 764899ad523..e89d411011d 100644 --- a/backends/events/sdl/sdl-events.cpp +++ b/backends/events/sdl/sdl-events.cpp @@ -73,12 +73,12 @@ void SdlEventSource::loadGameControllerMappingFile() { #endif SdlEventSource::SdlEventSource() - : EventSource(), _scrollLock(false), _joystick(0), _lastScreenID(0), _graphicsManager(0), _queuedFakeMouseMove(false), - _lastHatPosition(SDL_HAT_CENTERED), _mouseX(0), _mouseY(0), _engineRunning(false) + : EventSource(), _scrollLock(false), _joystick(0), _lastScreenID(0), _graphicsManager(0), _queuedFakeMouseMove(false), + _lastHatPosition(SDL_HAT_CENTERED), _mouseX(0), _mouseY(0), _engineRunning(false) #if SDL_VERSION_ATLEAST(2, 0, 0) - , _queuedFakeKeyUp(false), _fakeKeyUp(), _controller(nullptr) + , _queuedFakeKeyUp(false), _fakeKeyUp(), _controller(nullptr) #endif - { + { int joystick_num = ConfMan.getInt("joystick_num"); if (joystick_num >= 0) { // Initialize SDL joystick subsystem @@ -757,9 +757,9 @@ void SdlEventSource::openJoystick(int joystickIndex) { _joystick = SDL_JoystickOpen(joystickIndex); debug("Using joystick: %s", #if SDL_VERSION_ATLEAST(2, 0, 0) - SDL_JoystickName(_joystick) + SDL_JoystickName(_joystick) #else - SDL_JoystickName(joystickIndex) + SDL_JoystickName(joystickIndex) #endif ); } diff --git a/backends/events/symbiansdl/symbiansdl-events.cpp b/backends/events/symbiansdl/symbiansdl-events.cpp index 2377fa49bf3..a44025cc891 100644 --- a/backends/events/symbiansdl/symbiansdl-events.cpp +++ b/backends/events/symbiansdl/symbiansdl-events.cpp @@ -34,9 +34,9 @@ #define JOY_DEADZONE 3200 SymbianSdlEventSource::zoneDesc SymbianSdlEventSource::_zones[TOTAL_ZONES] = { - { 0, 0, 320, 145 }, - { 0, 145, 150, 55 }, - { 150, 145, 170, 55 } + { 0, 0, 320, 145 }, + { 0, 145, 150, 55 }, + { 150, 145, 170, 55 } }; SymbianSdlEventSource::SymbianSdlEventSource() diff --git a/backends/fs/amigaos/amigaos-fs.cpp b/backends/fs/amigaos/amigaos-fs.cpp index 6404e357b1e..5f1ed71da09 100644 --- a/backends/fs/amigaos/amigaos-fs.cpp +++ b/backends/fs/amigaos/amigaos-fs.cpp @@ -171,10 +171,10 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayNam _bIsValid = true; } - IDOS->FreeDosObject(DOS_EXAMINEDATA, pExd); + IDOS->FreeDosObject(DOS_EXAMINEDATA, pExd); } else { debug(6, "IDOS->ExamineData() failed - ExamineDosObject returned NULL!"); - } + } LEAVE(); } diff --git a/backends/fs/chroot/chroot-fs-factory.cpp b/backends/fs/chroot/chroot-fs-factory.cpp index ac8d9b65f09..43127737990 100644 --- a/backends/fs/chroot/chroot-fs-factory.cpp +++ b/backends/fs/chroot/chroot-fs-factory.cpp @@ -35,7 +35,7 @@ #include "backends/fs/chroot/chroot-fs.h" ChRootFilesystemFactory::ChRootFilesystemFactory(const Common::String &root) - : _root(root) { + : _root(root) { } AbstractFSNode *ChRootFilesystemFactory::makeRootFileNode() const { diff --git a/backends/fs/morphos/morphos-fs.cpp b/backends/fs/morphos/morphos-fs.cpp index 9a14def638e..a15f5fc30ee 100644 --- a/backends/fs/morphos/morphos-fs.cpp +++ b/backends/fs/morphos/morphos-fs.cpp @@ -149,7 +149,7 @@ MorphOSFilesystemNode::MorphOSFilesystemNode(BPTR pLock, const char *pDisplayNam } else { _bIsValid = true; } - } + } FreeDosObject(DOS_FIB, fib); } diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp index df3af43f63a..9a978508201 100644 --- a/backends/fs/posix/posix-fs.cpp +++ b/backends/fs/posix/posix-fs.cpp @@ -157,7 +157,7 @@ bool POSIXFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, boo char drive_root[] = "A:/"; drive_root[0] += i; - POSIXFilesystemNode *entry = new POSIXFilesystemNode(); + POSIXFilesystemNode *entry = new POSIXFilesystemNode(); entry->_isDirectory = true; entry->_isValid = true; entry->_path = drive_root; diff --git a/backends/graphics/opengl/framebuffer.cpp b/backends/graphics/opengl/framebuffer.cpp index 02c913c830d..b7eb136abb9 100644 --- a/backends/graphics/opengl/framebuffer.cpp +++ b/backends/graphics/opengl/framebuffer.cpp @@ -27,8 +27,8 @@ namespace OpenGL { Framebuffer::Framebuffer() - : _viewport(), _projectionMatrix(), _isActive(false), _clearColor(), - _blendState(kBlendModeDisabled), _scissorTestState(false), _scissorBox() { + : _viewport(), _projectionMatrix(), _isActive(false), _clearColor(), + _blendState(kBlendModeDisabled), _scissorTestState(false), _scissorBox() { } void Framebuffer::activate() { @@ -187,7 +187,7 @@ void Backbuffer::setDimensions(uint width, uint height) { #if !USE_FORCED_GLES TextureTarget::TextureTarget() - : _texture(new GLTexture(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE)), _glFBO(0), _needUpdate(true) { + : _texture(new GLTexture(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE)), _glFBO(0), _needUpdate(true) { } TextureTarget::~TextureTarget() { diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index 086375cd07f..1163ebbb1c9 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -59,19 +59,19 @@ namespace OpenGL { OpenGLGraphicsManager::OpenGLGraphicsManager() - : _currentState(), _oldState(), _transactionMode(kTransactionNone), _screenChangeID(1 << (sizeof(int) * 8 - 2)), - _pipeline(nullptr), _stretchMode(STRETCH_FIT), - _defaultFormat(), _defaultFormatAlpha(), - _gameScreen(nullptr), _overlay(nullptr), - _cursor(nullptr), - _cursorHotspotX(0), _cursorHotspotY(0), - _cursorHotspotXScaled(0), _cursorHotspotYScaled(0), _cursorWidthScaled(0), _cursorHeightScaled(0), - _cursorKeyColor(0), _cursorDontScale(false), _cursorPaletteEnabled(false) + : _currentState(), _oldState(), _transactionMode(kTransactionNone), _screenChangeID(1 << (sizeof(int) * 8 - 2)), + _pipeline(nullptr), _stretchMode(STRETCH_FIT), + _defaultFormat(), _defaultFormatAlpha(), + _gameScreen(nullptr), _overlay(nullptr), + _cursor(nullptr), + _cursorHotspotX(0), _cursorHotspotY(0), + _cursorHotspotXScaled(0), _cursorHotspotYScaled(0), _cursorWidthScaled(0), _cursorHeightScaled(0), + _cursorKeyColor(0), _cursorDontScale(false), _cursorPaletteEnabled(false) #ifdef USE_OSD - , _osdMessageChangeRequest(false), _osdMessageAlpha(0), _osdMessageFadeStartTime(0), _osdMessageSurface(nullptr), - _osdIconSurface(nullptr) + , _osdMessageChangeRequest(false), _osdMessageAlpha(0), _osdMessageFadeStartTime(0), _osdMessageSurface(nullptr), + _osdIconSurface(nullptr) #endif - { + { memset(_gamePalette, 0, sizeof(_gamePalette)); g_context.reset(); } @@ -655,8 +655,8 @@ void OpenGLGraphicsManager::grabOverlay(void *buf, int pitch) const { namespace { template void multiplyColorWithAlpha(const byte *src, byte *dst, const uint w, const uint h, - const Graphics::PixelFormat &srcFmt, const Graphics::PixelFormat &dstFmt, - const uint srcPitch, const uint dstPitch, const SrcColor keyColor) { + const Graphics::PixelFormat &srcFmt, const Graphics::PixelFormat &dstFmt, + const uint srcPitch, const uint dstPitch, const SrcColor keyColor) { for (uint y = 0; y < h; ++y) { for (uint x = 0; x < w; ++x) { const uint32 color = *(const SrcColor *)src; diff --git a/backends/graphics/opengl/pipelines/clut8.cpp b/backends/graphics/opengl/pipelines/clut8.cpp index fca40074f04..172fba69be3 100644 --- a/backends/graphics/opengl/pipelines/clut8.cpp +++ b/backends/graphics/opengl/pipelines/clut8.cpp @@ -28,7 +28,7 @@ namespace OpenGL { #if !USE_FORCED_GLES CLUT8LookUpPipeline::CLUT8LookUpPipeline() - : ShaderPipeline(ShaderMan.query(ShaderManager::kCLUT8LookUp)), _paletteTexture(nullptr) { + : ShaderPipeline(ShaderMan.query(ShaderManager::kCLUT8LookUp)), _paletteTexture(nullptr) { } void CLUT8LookUpPipeline::drawTexture(const GLTexture &texture, const GLfloat *coordinates) { diff --git a/backends/graphics/opengl/pipelines/pipeline.cpp b/backends/graphics/opengl/pipelines/pipeline.cpp index 6a59cd28e78..921641ba48a 100644 --- a/backends/graphics/opengl/pipelines/pipeline.cpp +++ b/backends/graphics/opengl/pipelines/pipeline.cpp @@ -26,7 +26,7 @@ namespace OpenGL { Pipeline::Pipeline() - : _activeFramebuffer(nullptr), _isActive(false) { + : _activeFramebuffer(nullptr), _isActive(false) { } void Pipeline::activate() { diff --git a/backends/graphics/opengl/pipelines/shader.cpp b/backends/graphics/opengl/pipelines/shader.cpp index a2dabb7c222..8a2db45d57b 100644 --- a/backends/graphics/opengl/pipelines/shader.cpp +++ b/backends/graphics/opengl/pipelines/shader.cpp @@ -28,7 +28,7 @@ namespace OpenGL { #if !USE_FORCED_GLES ShaderPipeline::ShaderPipeline(Shader *shader) - : _activeShader(shader), _colorAttributes() { + : _activeShader(shader), _colorAttributes() { _vertexAttribLocation = shader->getAttributeLocation("position"); _texCoordAttribLocation = shader->getAttributeLocation("texCoordIn"); _colorAttribLocation = shader->getAttributeLocation("blendColorIn"); diff --git a/backends/graphics/opengl/shader.cpp b/backends/graphics/opengl/shader.cpp index 80b746b7b3f..1f3586dc876 100644 --- a/backends/graphics/opengl/shader.cpp +++ b/backends/graphics/opengl/shader.cpp @@ -111,7 +111,7 @@ void ShaderUniformMatrix44::set(GLint location) const { #pragma mark - Shader Implementation - Shader::Shader(const Common::String &vertex, const Common::String &fragment) - : _vertex(vertex), _fragment(fragment), _isActive(false), _program(0), _uniforms() { + : _vertex(vertex), _fragment(fragment), _isActive(false), _program(0), _uniforms() { recreate(); } diff --git a/backends/graphics/opengl/texture.cpp b/backends/graphics/opengl/texture.cpp index 2b6f9ce0a1b..5001aab82b7 100644 --- a/backends/graphics/opengl/texture.cpp +++ b/backends/graphics/opengl/texture.cpp @@ -34,10 +34,10 @@ namespace OpenGL { GLTexture::GLTexture(GLenum glIntFormat, GLenum glFormat, GLenum glType) - : _glIntFormat(glIntFormat), _glFormat(glFormat), _glType(glType), - _width(0), _height(0), _logicalWidth(0), _logicalHeight(0), - _texCoords(), _glFilter(GL_NEAREST), - _glTexture(0) { + : _glIntFormat(glIntFormat), _glFormat(glFormat), _glType(glType), + _width(0), _height(0), _logicalWidth(0), _logicalHeight(0), + _texCoords(), _glFilter(GL_NEAREST), + _glTexture(0) { create(); } @@ -162,7 +162,7 @@ void GLTexture::updateArea(const Common::Rect &area, const Graphics::Surface &sr // Surface::Surface() - : _allDirty(false), _dirtyArea() { + : _allDirty(false), _dirtyArea() { } void Surface::copyRectToTexture(uint x, uint y, uint w, uint h, const void *srcPtr, uint srcPitch) { @@ -216,8 +216,8 @@ Common::Rect Surface::getDirtyArea() const { // Texture::Texture(GLenum glIntFormat, GLenum glFormat, GLenum glType, const Graphics::PixelFormat &format) - : Surface(), _format(format), _glTexture(glIntFormat, glFormat, glType), - _textureData(), _userPixelData() { + : Surface(), _format(format), _glTexture(glIntFormat, glFormat, glType), + _textureData(), _userPixelData() { } Texture::~Texture() { @@ -306,7 +306,7 @@ void Texture::updateGLTexture() { } TextureCLUT8::TextureCLUT8(GLenum glIntFormat, GLenum glFormat, GLenum glType, const Graphics::PixelFormat &format) - : Texture(glIntFormat, glFormat, glType, format), _clut8Data(), _palette(new byte[256 * format.bytesPerPixel]) { + : Texture(glIntFormat, glFormat, glType, format), _clut8Data(), _palette(new byte[256 * format.bytesPerPixel]) { memset(_palette, 0, sizeof(byte) * format.bytesPerPixel); } @@ -421,8 +421,8 @@ void TextureCLUT8::updateGLTexture() { #if !USE_FORCED_GL FakeTexture::FakeTexture(GLenum glIntFormat, GLenum glFormat, GLenum glType, const Graphics::PixelFormat &format) - : Texture(glIntFormat, glFormat, glType, format), - _rgbData() { + : Texture(glIntFormat, glFormat, glType, format), + _rgbData() { } FakeTexture::~FakeTexture() { @@ -443,7 +443,7 @@ void FakeTexture::allocate(uint width, uint height) { } TextureRGB555::TextureRGB555() - : FakeTexture(GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)) { + : FakeTexture(GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)) { } Graphics::PixelFormat TextureRGB555::getFormat() const { @@ -485,11 +485,11 @@ void TextureRGB555::updateGLTexture() { TextureRGBA8888Swap::TextureRGBA8888Swap() #ifdef SCUMM_LITTLE_ENDIAN - : FakeTexture(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24)) // ABGR8888 + : FakeTexture(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24)) // ABGR8888 #else - : FakeTexture(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)) // RGBA8888 + : FakeTexture(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)) // RGBA8888 #endif - { + { } Graphics::PixelFormat TextureRGBA8888Swap::getFormat() const { @@ -540,11 +540,11 @@ void TextureRGBA8888Swap::updateGLTexture() { // problems, we need to switch to GL_R8 and GL_RED, but that is only supported // for ARB_texture_rg and GLES3+ (EXT_rexture_rg does not support GL_R8). TextureCLUT8GPU::TextureCLUT8GPU() - : _clut8Texture(GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE), - _paletteTexture(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE), - _target(new TextureTarget()), _clut8Pipeline(new CLUT8LookUpPipeline()), - _clut8Vertices(), _clut8Data(), _userPixelData(), _palette(), - _paletteDirty(false) { + : _clut8Texture(GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE), + _paletteTexture(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE), + _target(new TextureTarget()), _clut8Pipeline(new CLUT8LookUpPipeline()), + _clut8Vertices(), _clut8Data(), _userPixelData(), _palette(), + _paletteDirty(false) { // Allocate space for 256 colors. _paletteTexture.setSize(256, 1); diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index fcb643f2289..4d1a437c5ea 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -33,14 +33,14 @@ #endif OpenGLSdlGraphicsManager::OpenGLSdlGraphicsManager(SdlEventSource *eventSource, SdlWindow *window) - : SdlGraphicsManager(eventSource, window), _lastRequestedHeight(0), + : SdlGraphicsManager(eventSource, window), _lastRequestedHeight(0), #if SDL_VERSION_ATLEAST(2, 0, 0) - _glContext(), + _glContext(), #else - _lastVideoModeLoad(0), + _lastVideoModeLoad(0), #endif - _graphicsScale(2), _ignoreLoadVideoMode(false), _gotResize(false), _wantsFullScreen(false), _ignoreResizeEvents(0), - _desiredFullscreenWidth(0), _desiredFullscreenHeight(0) { + _graphicsScale(2), _ignoreLoadVideoMode(false), _gotResize(false), _wantsFullScreen(false), _ignoreResizeEvents(0), + _desiredFullscreenWidth(0), _desiredFullscreenHeight(0) { // Setup OpenGL attributes for SDL SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp index e89040548d6..bf36ca8339f 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp @@ -275,7 +275,7 @@ static void initGraphicsModes() { // 0 should be the normal1x mode s_defaultGraphicsMode = 0; for (uint i = 0; i < plugins.size(); ++i) { - ScalerPluginObject &plugin = plugins[i]->get(); + ScalerPluginObject &plugin = plugins[i]->get(); const Common::Array &factors = plugin.getFactors(); const char *name = plugin.getName(); const char *prettyName = plugin.getPrettyName(); @@ -1891,7 +1891,7 @@ void SurfaceSdlGraphicsManager::setMouseCursor(const void *buf, uint w, uint h, } else { assert(!_mouseOrigSurface); - // Allocate bigger surface because scalers will read past the boudaries. + // Allocate bigger surface because scalers will read past the boudaries. _mouseOrigSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, _mouseCurState.w + _maxExtraPixels * 2, _mouseCurState.h + _maxExtraPixels * 2, @@ -2108,10 +2108,10 @@ void SurfaceSdlGraphicsManager::blitCursor() { // HACK: AdvMame4x requires a height of at least 4 pixels, so we // fall back on the Normal scaler when a smaller cursor is supplied. if (_scalerPlugin->canDrawCursor() && (uint)_mouseCurState.h >= _extraPixels) { - _scalerPlugin->scale( - (byte *)_mouseOrigSurface->pixels + _mouseOrigSurface->pitch * _maxExtraPixels + _maxExtraPixels * _mouseOrigSurface->format->BytesPerPixel, - _mouseOrigSurface->pitch, (byte *)_mouseSurface->pixels, _mouseSurface->pitch, - _mouseCurState.w, _mouseCurState.h, 0, 0); + _scalerPlugin->scale( + (byte *)_mouseOrigSurface->pixels + _mouseOrigSurface->pitch * _maxExtraPixels + _maxExtraPixels * _mouseOrigSurface->format->BytesPerPixel, + _mouseOrigSurface->pitch, (byte *)_mouseSurface->pixels, _mouseSurface->pitch, + _mouseCurState.w, _mouseCurState.h, 0, 0); } else #endif { diff --git a/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp b/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp index 7ba75a991b1..7b69292a9a9 100644 --- a/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp +++ b/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp @@ -305,7 +305,7 @@ void OpenGLSdlGraphics3dManager::createOrUpdateScreen() { } Math::Rect2d OpenGLSdlGraphics3dManager::computeGameRect(bool renderToFrameBuffer, uint gameWidth, uint gameHeight, - uint screenWidth, uint screenHeight) { + uint screenWidth, uint screenHeight) { if (renderToFrameBuffer) { if (_lockAspectRatio) { // The game is scaled to fit the screen, keeping the same aspect ratio @@ -382,9 +382,9 @@ OpenGLSdlGraphics3dManager::OpenGLPixelFormat::OpenGLPixelFormat(uint screenByte } bool OpenGLSdlGraphics3dManager::createOrUpdateGLContext(uint gameWidth, uint gameHeight, - uint effectiveWidth, uint effectiveHeight, - bool renderToFramebuffer, - bool engineSupportsArbitraryResolutions) { + uint effectiveWidth, uint effectiveHeight, + bool renderToFramebuffer, + bool engineSupportsArbitraryResolutions) { // Build a list of OpenGL pixel formats usable by ScummVM Common::Array pixelFormats; if (_antialiasing > 0 && !renderToFramebuffer) { diff --git a/backends/keymapper/hardware-input.cpp b/backends/keymapper/hardware-input.cpp index f3e6c7923f0..ba8cce6492c 100644 --- a/backends/keymapper/hardware-input.cpp +++ b/backends/keymapper/hardware-input.cpp @@ -242,43 +242,43 @@ const ModifierTableEntry defaultModifiers[] = { }; const HardwareInputTableEntry defaultMouseButtons[] = { - { "MOUSE_LEFT", MOUSE_BUTTON_LEFT, _s("Left Mouse Button") }, - { "MOUSE_RIGHT", MOUSE_BUTTON_RIGHT, _s("Right Mouse Button") }, - { "MOUSE_MIDDLE", MOUSE_BUTTON_MIDDLE, _s("Middle Mouse Button") }, - { "MOUSE_WHEEL_UP", MOUSE_WHEEL_UP, _s("Mouse Wheel Up") }, - { "MOUSE_WHEEL_DOWN", MOUSE_WHEEL_DOWN, _s("Mouse Wheel Down") }, - { "MOUSE_X1", MOUSE_BUTTON_X1, _s("X1 Mouse Button") }, - { "MOUSE_X2", MOUSE_BUTTON_X2, _s("X2 Mouse Button") }, - { nullptr, 0, nullptr } + { "MOUSE_LEFT", MOUSE_BUTTON_LEFT, _s("Left Mouse Button") }, + { "MOUSE_RIGHT", MOUSE_BUTTON_RIGHT, _s("Right Mouse Button") }, + { "MOUSE_MIDDLE", MOUSE_BUTTON_MIDDLE, _s("Middle Mouse Button") }, + { "MOUSE_WHEEL_UP", MOUSE_WHEEL_UP, _s("Mouse Wheel Up") }, + { "MOUSE_WHEEL_DOWN", MOUSE_WHEEL_DOWN, _s("Mouse Wheel Down") }, + { "MOUSE_X1", MOUSE_BUTTON_X1, _s("X1 Mouse Button") }, + { "MOUSE_X2", MOUSE_BUTTON_X2, _s("X2 Mouse Button") }, + { nullptr, 0, nullptr } }; const HardwareInputTableEntry defaultJoystickButtons[] = { - { "JOY_A", JOYSTICK_BUTTON_A, _s("Joy A") }, - { "JOY_B", JOYSTICK_BUTTON_B, _s("Joy B") }, - { "JOY_X", JOYSTICK_BUTTON_X, _s("Joy X") }, - { "JOY_Y", JOYSTICK_BUTTON_Y, _s("Joy Y") }, - { "JOY_BACK", JOYSTICK_BUTTON_BACK, _s("Joy Back") }, - { "JOY_GUIDE", JOYSTICK_BUTTON_GUIDE, _s("Joy Guide") }, - { "JOY_START", JOYSTICK_BUTTON_START, _s("Joy Start") }, - { "JOY_LEFT_STICK", JOYSTICK_BUTTON_LEFT_STICK, _s("Left Stick") }, - { "JOY_RIGHT_STICK", JOYSTICK_BUTTON_RIGHT_STICK, _s("Right Stick") }, - { "JOY_LEFT_SHOULDER", JOYSTICK_BUTTON_LEFT_SHOULDER, _s("Left Shoulder") }, - { "JOY_RIGHT_SHOULDER", JOYSTICK_BUTTON_RIGHT_SHOULDER, _s("Right Shoulder") }, - { "JOY_UP", JOYSTICK_BUTTON_DPAD_UP, _s("D-pad Up") }, - { "JOY_DOWN", JOYSTICK_BUTTON_DPAD_DOWN, _s("D-pad Down") }, - { "JOY_LEFT", JOYSTICK_BUTTON_DPAD_LEFT, _s("D-pad Left") }, - { "JOY_RIGHT", JOYSTICK_BUTTON_DPAD_RIGHT, _s("D-pad Right") }, - { nullptr, 0, nullptr } + { "JOY_A", JOYSTICK_BUTTON_A, _s("Joy A") }, + { "JOY_B", JOYSTICK_BUTTON_B, _s("Joy B") }, + { "JOY_X", JOYSTICK_BUTTON_X, _s("Joy X") }, + { "JOY_Y", JOYSTICK_BUTTON_Y, _s("Joy Y") }, + { "JOY_BACK", JOYSTICK_BUTTON_BACK, _s("Joy Back") }, + { "JOY_GUIDE", JOYSTICK_BUTTON_GUIDE, _s("Joy Guide") }, + { "JOY_START", JOYSTICK_BUTTON_START, _s("Joy Start") }, + { "JOY_LEFT_STICK", JOYSTICK_BUTTON_LEFT_STICK, _s("Left Stick") }, + { "JOY_RIGHT_STICK", JOYSTICK_BUTTON_RIGHT_STICK, _s("Right Stick") }, + { "JOY_LEFT_SHOULDER", JOYSTICK_BUTTON_LEFT_SHOULDER, _s("Left Shoulder") }, + { "JOY_RIGHT_SHOULDER", JOYSTICK_BUTTON_RIGHT_SHOULDER, _s("Right Shoulder") }, + { "JOY_UP", JOYSTICK_BUTTON_DPAD_UP, _s("D-pad Up") }, + { "JOY_DOWN", JOYSTICK_BUTTON_DPAD_DOWN, _s("D-pad Down") }, + { "JOY_LEFT", JOYSTICK_BUTTON_DPAD_LEFT, _s("D-pad Left") }, + { "JOY_RIGHT", JOYSTICK_BUTTON_DPAD_RIGHT, _s("D-pad Right") }, + { nullptr, 0, nullptr } }; const AxisTableEntry defaultJoystickAxes[] = { - { "JOY_LEFT_TRIGGER", JOYSTICK_AXIS_LEFT_TRIGGER, kAxisTypeHalf, _s("Left Trigger") }, - { "JOY_RIGHT_TRIGGER", JOYSTICK_AXIS_RIGHT_TRIGGER, kAxisTypeHalf, _s("Right Trigger") }, - { "JOY_LEFT_STICK_X", JOYSTICK_AXIS_LEFT_STICK_X, kAxisTypeFull, _s("Left Stick X") }, - { "JOY_LEFT_STICK_Y", JOYSTICK_AXIS_LEFT_STICK_Y, kAxisTypeFull, _s("Left Stick Y") }, - { "JOY_RIGHT_STICK_X", JOYSTICK_AXIS_RIGHT_STICK_X, kAxisTypeFull, _s("Right Stick X") }, - { "JOY_RIGHT_STICK_Y", JOYSTICK_AXIS_RIGHT_STICK_Y, kAxisTypeFull, _s("Right Stick Y") }, - { nullptr, 0, kAxisTypeFull, nullptr } + { "JOY_LEFT_TRIGGER", JOYSTICK_AXIS_LEFT_TRIGGER, kAxisTypeHalf, _s("Left Trigger") }, + { "JOY_RIGHT_TRIGGER", JOYSTICK_AXIS_RIGHT_TRIGGER, kAxisTypeHalf, _s("Right Trigger") }, + { "JOY_LEFT_STICK_X", JOYSTICK_AXIS_LEFT_STICK_X, kAxisTypeFull, _s("Left Stick X") }, + { "JOY_LEFT_STICK_Y", JOYSTICK_AXIS_LEFT_STICK_Y, kAxisTypeFull, _s("Left Stick Y") }, + { "JOY_RIGHT_STICK_X", JOYSTICK_AXIS_RIGHT_STICK_X, kAxisTypeFull, _s("Right Stick X") }, + { "JOY_RIGHT_STICK_Y", JOYSTICK_AXIS_RIGHT_STICK_Y, kAxisTypeFull, _s("Right Stick Y") }, + { nullptr, 0, kAxisTypeFull, nullptr } }; HardwareInputSet::~HardwareInputSet() { diff --git a/backends/log/log.cpp b/backends/log/log.cpp index e37296aada3..51d6ea636b8 100644 --- a/backends/log/log.cpp +++ b/backends/log/log.cpp @@ -32,7 +32,7 @@ namespace Backends { namespace Log { Log::Log(OSystem *system) - : _system(system), _stream(0), _startOfLine(true) { + : _system(system), _stream(0), _startOfLine(true) { assert(system); } diff --git a/backends/platform/3ds/osystem-events.cpp b/backends/platform/3ds/osystem-events.cpp index 4e8d25ffae6..05af2daced8 100644 --- a/backends/platform/3ds/osystem-events.cpp +++ b/backends/platform/3ds/osystem-events.cpp @@ -45,32 +45,32 @@ static InputMode savedInputMode = MODE_DRAG; static aptHookCookie cookie; static const Common::HardwareInputTableEntry ctrJoystickButtons[] = { - { "JOY_A", Common::JOYSTICK_BUTTON_A, _s("A") }, - { "JOY_B", Common::JOYSTICK_BUTTON_B, _s("B") }, - { "JOY_X", Common::JOYSTICK_BUTTON_X, _s("X") }, - { "JOY_Y", Common::JOYSTICK_BUTTON_Y, _s("Y") }, - { "JOY_BACK", Common::JOYSTICK_BUTTON_BACK, _s("Select") }, - { "JOY_START", Common::JOYSTICK_BUTTON_START, _s("Start") }, - { "JOY_LEFT_STICK", Common::JOYSTICK_BUTTON_LEFT_STICK, _s("ZL") }, - { "JOY_RIGHT_STICK", Common::JOYSTICK_BUTTON_RIGHT_STICK, _s("ZR") }, - { "JOY_LEFT_SHOULDER", Common::JOYSTICK_BUTTON_LEFT_SHOULDER, _s("L") }, - { "JOY_RIGHT_SHOULDER", Common::JOYSTICK_BUTTON_RIGHT_SHOULDER, _s("R") }, - { "JOY_UP", Common::JOYSTICK_BUTTON_DPAD_UP, _s("D-pad Up") }, - { "JOY_DOWN", Common::JOYSTICK_BUTTON_DPAD_DOWN, _s("D-pad Down") }, - { "JOY_LEFT", Common::JOYSTICK_BUTTON_DPAD_LEFT, _s("D-pad Left") }, - { "JOY_RIGHT", Common::JOYSTICK_BUTTON_DPAD_RIGHT, _s("D-pad Right") }, - { nullptr, 0, nullptr } + { "JOY_A", Common::JOYSTICK_BUTTON_A, _s("A") }, + { "JOY_B", Common::JOYSTICK_BUTTON_B, _s("B") }, + { "JOY_X", Common::JOYSTICK_BUTTON_X, _s("X") }, + { "JOY_Y", Common::JOYSTICK_BUTTON_Y, _s("Y") }, + { "JOY_BACK", Common::JOYSTICK_BUTTON_BACK, _s("Select") }, + { "JOY_START", Common::JOYSTICK_BUTTON_START, _s("Start") }, + { "JOY_LEFT_STICK", Common::JOYSTICK_BUTTON_LEFT_STICK, _s("ZL") }, + { "JOY_RIGHT_STICK", Common::JOYSTICK_BUTTON_RIGHT_STICK, _s("ZR") }, + { "JOY_LEFT_SHOULDER", Common::JOYSTICK_BUTTON_LEFT_SHOULDER, _s("L") }, + { "JOY_RIGHT_SHOULDER", Common::JOYSTICK_BUTTON_RIGHT_SHOULDER, _s("R") }, + { "JOY_UP", Common::JOYSTICK_BUTTON_DPAD_UP, _s("D-pad Up") }, + { "JOY_DOWN", Common::JOYSTICK_BUTTON_DPAD_DOWN, _s("D-pad Down") }, + { "JOY_LEFT", Common::JOYSTICK_BUTTON_DPAD_LEFT, _s("D-pad Left") }, + { "JOY_RIGHT", Common::JOYSTICK_BUTTON_DPAD_RIGHT, _s("D-pad Right") }, + { nullptr, 0, nullptr } }; static const Common::AxisTableEntry ctrJoystickAxes[] = { - { "JOY_LEFT_STICK_X", Common::JOYSTICK_AXIS_LEFT_STICK_X, Common::kAxisTypeFull, _s("C-Pad X") }, - { "JOY_LEFT_STICK_Y", Common::JOYSTICK_AXIS_LEFT_STICK_Y, Common::kAxisTypeFull, _s("C-Pad Y") }, - { nullptr, 0, Common::kAxisTypeFull, nullptr } + { "JOY_LEFT_STICK_X", Common::JOYSTICK_AXIS_LEFT_STICK_X, Common::kAxisTypeFull, _s("C-Pad X") }, + { "JOY_LEFT_STICK_Y", Common::JOYSTICK_AXIS_LEFT_STICK_Y, Common::kAxisTypeFull, _s("C-Pad Y") }, + { nullptr, 0, Common::kAxisTypeFull, nullptr } }; const Common::HardwareInputTableEntry ctrMouseButtons[] = { - { "MOUSE_LEFT", Common::MOUSE_BUTTON_LEFT, _s("Touch") }, - { nullptr, 0, nullptr } + { "MOUSE_LEFT", Common::MOUSE_BUTTON_LEFT, _s("Touch") }, + { nullptr, 0, nullptr } }; static const int16 CIRCLE_MAX = 160; diff --git a/backends/platform/3ds/osystem-graphics.cpp b/backends/platform/3ds/osystem-graphics.cpp index abbc3882aa8..34a73b5d470 100644 --- a/backends/platform/3ds/osystem-graphics.cpp +++ b/backends/platform/3ds/osystem-graphics.cpp @@ -31,27 +31,27 @@ // Used to transfer the final rendered display to the framebuffer #define DISPLAY_TRANSFER_FLAGS \ - (GX_TRANSFER_FLIP_VERT(0) | GX_TRANSFER_OUT_TILED(0) | \ - GX_TRANSFER_RAW_COPY(0) | GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGBA8) | \ - GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB8) | \ - GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO)) + (GX_TRANSFER_FLIP_VERT(0) | GX_TRANSFER_OUT_TILED(0) | \ + GX_TRANSFER_RAW_COPY(0) | GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGBA8) | \ + GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB8) | \ + GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO)) #define TEXTURE_TRANSFER_FLAGS(fmt) \ - (GX_TRANSFER_FLIP_VERT(1) | GX_TRANSFER_OUT_TILED(1) | \ - GX_TRANSFER_RAW_COPY(0) | GX_TRANSFER_IN_FORMAT(fmt) | \ - GX_TRANSFER_OUT_FORMAT(fmt) | GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO)) + (GX_TRANSFER_FLIP_VERT(1) | GX_TRANSFER_OUT_TILED(1) | \ + GX_TRANSFER_RAW_COPY(0) | GX_TRANSFER_IN_FORMAT(fmt) | \ + GX_TRANSFER_OUT_FORMAT(fmt) | GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO)) #define DEFAULT_MODE _modeRGBA8 namespace N3DS { /* Group the various enums, values, etc. needed for * each graphics mode into instaces of GfxMode3DS */ static const GfxMode3DS _modeRGBA8 = { Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0), - GPU_RGBA8, TEXTURE_TRANSFER_FLAGS(GX_TRANSFER_FMT_RGBA8) }; + GPU_RGBA8, TEXTURE_TRANSFER_FLAGS(GX_TRANSFER_FMT_RGBA8) }; static const GfxMode3DS _modeRGB565 = { Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), - GPU_RGB565, TEXTURE_TRANSFER_FLAGS(GX_TRANSFER_FMT_RGB565) }; + GPU_RGB565, TEXTURE_TRANSFER_FLAGS(GX_TRANSFER_FMT_RGB565) }; static const GfxMode3DS _modeRGB555 = { Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0), - GPU_RGBA5551, TEXTURE_TRANSFER_FLAGS(GX_TRANSFER_FMT_RGB5A1) }; + GPU_RGBA5551, TEXTURE_TRANSFER_FLAGS(GX_TRANSFER_FMT_RGB5A1) }; static const GfxMode3DS _modeRGB5A1 = { Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0), - GPU_RGBA5551, TEXTURE_TRANSFER_FLAGS(GX_TRANSFER_FMT_RGB5A1) }; + GPU_RGBA5551, TEXTURE_TRANSFER_FLAGS(GX_TRANSFER_FMT_RGB5A1) }; static const GfxMode3DS _modeCLUT8 = _modeRGBA8; static const GfxMode3DS *gfxModes[] = { &_modeRGBA8, &_modeRGB565, &_modeRGB555, &_modeRGB5A1, &_modeCLUT8 }; @@ -187,7 +187,7 @@ bool OSystem_3DS::setGraphicsMode(GraphicsModeID modeID) { } void OSystem_3DS::initSize(uint width, uint height, - const Graphics::PixelFormat *format) { + const Graphics::PixelFormat *format) { debug("3ds initsize w:%d h:%d", width, height); int oldScreen = config.screen; loadConfig(); @@ -361,7 +361,7 @@ static void copyRect555To5551(const Graphics::Surface &srcSurface, Graphics::Sur } void OSystem_3DS::copyRectToScreen(const void *buf, int pitch, int x, - int y, int w, int h) { + int y, int w, int h) { Common::Rect rect(x, y, x+w, y+h); _gameScreen.copyRectToSurface(buf, pitch, x, y, w, h); Graphics::Surface subSurface = _gameScreen.getSubArea(rect); @@ -636,7 +636,7 @@ void OSystem_3DS::grabOverlay(void *buf, int pitch) { } void OSystem_3DS::copyRectToOverlay(const void *buf, int pitch, int x, - int y, int w, int h) { + int y, int w, int h) { _overlay.copyRectToSurface(buf, pitch, x, y, w, h); _overlay.markDirty(); } @@ -760,9 +760,9 @@ void OSystem_3DS::setCursorDelta(float deltaX, float deltaY) { } void OSystem_3DS::setMouseCursor(const void *buf, uint w, uint h, - int hotspotX, int hotspotY, - uint32 keycolor, bool dontScale, - const Graphics::PixelFormat *format) { + int hotspotX, int hotspotY, + uint32 keycolor, bool dontScale, + const Graphics::PixelFormat *format) { _cursorScalable = !dontScale; _cursorHotspotX = hotspotX; _cursorHotspotY = hotspotY; diff --git a/backends/platform/android3d/events.cpp b/backends/platform/android3d/events.cpp index 5f18bb4966b..19c4e96adeb 100644 --- a/backends/platform/android3d/events.cpp +++ b/backends/platform/android3d/events.cpp @@ -100,10 +100,10 @@ void OSystem_Android::scaleMouse(Common::Point &p, int x, int y, bool touchpadMo } void OSystem_Android::updateEventScale(const GLESBaseTexture *tex) { - if (tex && (tex->height() != 0) && (tex->width() != 0)) { + if (tex && (tex->height() != 0) && (tex->width() != 0)) { _eventScaleY = 100 * 480 / tex->height(); _eventScaleX = 100 * 640 / tex->width(); - } + } } void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, diff --git a/backends/platform/dc/audio.cpp b/backends/platform/dc/audio.cpp index 4759ddb7996..9a1122df260 100644 --- a/backends/platform/dc/audio.cpp +++ b/backends/platform/dc/audio.cpp @@ -42,35 +42,35 @@ void OSystem_Dreamcast::checkSound() int curr_ring_buffer_samples; if (!_mixer) - return; + return; if (read_sound_int(&SOUNDSTATUS->mode) != MODE_PLAY) - start_sound(); + start_sound(); curr_ring_buffer_samples = read_sound_int(&SOUNDSTATUS->ring_length); n = read_sound_int(&SOUNDSTATUS->samplepos); if ((n-=fillpos)<0) - n += curr_ring_buffer_samples; + n += curr_ring_buffer_samples; n = ADJUST_BUFFER_SIZE(n-10); if (n<100) - return; + return; _mixer->mixCallback((byte *)temp_sound_buffer, 2*SAMPLES_TO_BYTES(n)); if (fillpos+n > curr_ring_buffer_samples) { - int r = curr_ring_buffer_samples - fillpos; - memcpy4s(RING_BUF+fillpos, temp_sound_buffer, SAMPLES_TO_BYTES(r)); - fillpos = 0; - n -= r; - memcpy4s(RING_BUF, temp_sound_buffer+r, SAMPLES_TO_BYTES(n)); + int r = curr_ring_buffer_samples - fillpos; + memcpy4s(RING_BUF+fillpos, temp_sound_buffer, SAMPLES_TO_BYTES(r)); + fillpos = 0; + n -= r; + memcpy4s(RING_BUF, temp_sound_buffer+r, SAMPLES_TO_BYTES(n)); } else { - memcpy4s(RING_BUF+fillpos, temp_sound_buffer, SAMPLES_TO_BYTES(n)); + memcpy4s(RING_BUF+fillpos, temp_sound_buffer, SAMPLES_TO_BYTES(n)); } if ((fillpos += n) >= curr_ring_buffer_samples) - fillpos = 0; + fillpos = 0; } diff --git a/backends/platform/dc/dcloader.cpp b/backends/platform/dc/dcloader.cpp index 2627773b13b..0b592258ed8 100644 --- a/backends/platform/dc/dcloader.cpp +++ b/backends/platform/dc/dcloader.cpp @@ -115,17 +115,17 @@ static void purge_copyback() { int i; for (i=0; i!=(1<<14); i+=(1<<5)) - *(volatile unsigned int *)(0xf4000000+i) &= ~3; + *(volatile unsigned int *)(0xf4000000+i) &= ~3; } void DLObject::seterror(const char *fmt, ...) { if (errbuf) { - va_list va; - va_start(va, fmt); - vsnprintf(errbuf, MAXDLERRLEN, fmt, va); - va_end(va); + va_list va; + va_start(va, fmt); + vsnprintf(errbuf, MAXDLERRLEN, fmt, va); + va_end(va); } } @@ -150,34 +150,34 @@ bool DLObject::relocate(int fd, unsigned long offset, unsigned long size) Elf32_Rela *rela; if (!(rela = (Elf32_Rela *)malloc(size))) { - seterror("Out of memory."); - return false; + seterror("Out of memory."); + return false; } if (lseek(fd, offset, SEEK_SET)<0 || - read(fd, rela, size) != (ssize_t)size) { - seterror("Relocation table load failed."); - free(rela); - return false; + read(fd, rela, size) != (ssize_t)size) { + seterror("Relocation table load failed."); + free(rela); + return false; } int cnt = size / sizeof(*rela); for (int i=0; i>4)); + Elf32_Sym *sym = (Elf32_Sym *)(void *)(((char *)symtab)+(rela[i].r_info>>4)); - void *target = ((char *)segment)+rela[i].r_offset; + void *target = ((char *)segment)+rela[i].r_offset; - switch(rela[i].r_info & 0xf) { - case 1: /* DIR32 */ - if (sym->st_shndx < 0xff00) + switch(rela[i].r_info & 0xf) { + case 1: /* DIR32 */ + if (sym->st_shndx < 0xff00) *(unsigned long *)target += (unsigned long)segment; - break; - default: - seterror("Unknown relocation type %d.", rela[i].r_info & 0xf); - free(rela); - return false; - } + break; + default: + seterror("Unknown relocation type %d.", rela[i].r_info & 0xf); + free(rela); + return false; + } } @@ -194,105 +194,105 @@ bool DLObject::load(int fd) int symtab_sect = -1; if (read(fd, &ehdr, sizeof(ehdr)) != sizeof(ehdr) || - memcmp(ehdr.e_ident, ELFMAG, SELFMAG) || - ehdr.e_type != 2 || ehdr.e_machine != 42 || - ehdr.e_phentsize < sizeof(phdr) || ehdr.e_shentsize != sizeof(*shdr) || - ehdr.e_phnum != 1) { - seterror("Invalid file type."); - return false; + memcmp(ehdr.e_ident, ELFMAG, SELFMAG) || + ehdr.e_type != 2 || ehdr.e_machine != 42 || + ehdr.e_phentsize < sizeof(phdr) || ehdr.e_shentsize != sizeof(*shdr) || + ehdr.e_phnum != 1) { + seterror("Invalid file type."); + return false; } DBG(("phoff = %d, phentsz = %d, phnum = %d\n", - ehdr.e_phoff, ehdr.e_phentsize, ehdr.e_phnum)); + ehdr.e_phoff, ehdr.e_phentsize, ehdr.e_phnum)); if (lseek(fd, ehdr.e_phoff, SEEK_SET)<0 || - read(fd, &phdr, sizeof(phdr)) != sizeof(phdr)) { - seterror("Program header load failed."); - return false; + read(fd, &phdr, sizeof(phdr)) != sizeof(phdr)) { + seterror("Program header load failed."); + return false; } if (phdr.p_type != 1 || phdr.p_vaddr != 0 || phdr.p_paddr != 0 || - phdr.p_filesz > phdr.p_memsz) { - seterror("Invalid program header."); - return false; + phdr.p_filesz > phdr.p_memsz) { + seterror("Invalid program header."); + return false; } DBG(("offs = %d, filesz = %d, memsz = %d, align = %d\n", - phdr.p_offset, phdr.p_filesz, phdr.p_memsz, phdr.p_align)); + phdr.p_offset, phdr.p_filesz, phdr.p_memsz, phdr.p_align)); if (!(segment = memalign(phdr.p_align, phdr.p_memsz))) { - seterror("Out of memory."); - return false; + seterror("Out of memory."); + return false; } DBG(("segment @ %p\n", segment)); if (phdr.p_memsz > phdr.p_filesz) - memset(((char *)segment) + phdr.p_filesz, 0, phdr.p_memsz - phdr.p_filesz); + memset(((char *)segment) + phdr.p_filesz, 0, phdr.p_memsz - phdr.p_filesz); if (lseek(fd, phdr.p_offset, SEEK_SET)<0 || - read(fd, segment, phdr.p_filesz) != (ssize_t)phdr.p_filesz) { - seterror("Segment load failed."); - return false; + read(fd, segment, phdr.p_filesz) != (ssize_t)phdr.p_filesz) { + seterror("Segment load failed."); + return false; } DBG(("shoff = %d, shentsz = %d, shnum = %d\n", - ehdr.e_shoff, ehdr.e_shentsize, ehdr.e_shnum)); + ehdr.e_shoff, ehdr.e_shentsize, ehdr.e_shnum)); if (!(shdr = (Elf32_Shdr *)malloc(ehdr.e_shnum * sizeof(*shdr)))) { - seterror("Out of memory."); - return false; + seterror("Out of memory."); + return false; } if (lseek(fd, ehdr.e_shoff, SEEK_SET)<0 || - read(fd, shdr, ehdr.e_shnum * sizeof(*shdr)) != - (ssize_t)(ehdr.e_shnum * sizeof(*shdr))) { - seterror("Section headers load failed."); - free(shdr); - return false; + read(fd, shdr, ehdr.e_shnum * sizeof(*shdr)) != + (ssize_t)(ehdr.e_shnum * sizeof(*shdr))) { + seterror("Section headers load failed."); + free(shdr); + return false; } for (int i=0; ist_shndx < 0xff00) - s->st_value += (Elf32_Addr)segment; + if (s->st_shndx < 0xff00) + s->st_value += (Elf32_Addr)segment; for (int i=0; ist_info>>4 == 1 || s->st_info>>4 == 2) && - strtab[s->st_name] == '_' && !strcmp(name, strtab+s->st_name+1)) { - DBG(("=> %p\n", (void *)s->st_value)); - return (void *)s->st_value; - } + if ((s->st_info>>4 == 1 || s->st_info>>4 == 2) && + strtab[s->st_name] == '_' && !strcmp(name, strtab+s->st_name+1)) { + DBG(("=> %p\n", (void *)s->st_value)); + return (void *)s->st_value; + } seterror("Symbol \"%s\" not found.", name); return NULL; @@ -407,7 +407,7 @@ void *dlopen(const char *filename, int flags) { DLObject *obj = new DLObject(dlerr); if (obj->open(filename)) - return (void *)obj; + return (void *)obj; delete obj; return NULL; } @@ -416,12 +416,12 @@ int dlclose(void *handle) { DLObject *obj = (DLObject *)handle; if (obj == NULL) { - strcpy(dlerr, "Handle is NULL."); - return -1; + strcpy(dlerr, "Handle is NULL."); + return -1; } if (obj->close()) { - delete obj; - return 0; + delete obj; + return 0; } return -1; } @@ -429,8 +429,8 @@ int dlclose(void *handle) void *dlsym(void *handle, const char *symbol) { if (handle == NULL) { - strcpy(dlerr, "Handle is NULL."); - return NULL; + strcpy(dlerr, "Handle is NULL."); + return NULL; } return ((DLObject *)handle)->symbol(symbol); } @@ -443,5 +443,5 @@ const char *dlerror() void dlforgetsyms(void *handle) { if (handle != NULL) - ((DLObject *)handle)->discard_symtab(); + ((DLObject *)handle)->discard_symtab(); } diff --git a/backends/platform/dc/dcloader.h b/backends/platform/dc/dcloader.h index daa2802ec44..9e5a25b8ae0 100644 --- a/backends/platform/dc/dcloader.h +++ b/backends/platform/dc/dcloader.h @@ -48,7 +48,7 @@ class DLObject { void discard_symtab(); DLObject(char *_errbuf = NULL) : errbuf(_errbuf), segment(NULL),symtab(NULL), - strtab(NULL), symbol_cnt(0), dtors_start(NULL), dtors_end(NULL) {} + strtab(NULL), symbol_cnt(0), dtors_start(NULL), dtors_end(NULL) {} }; #define RTLD_LAZY 0 diff --git a/backends/platform/dc/dcmain.cpp b/backends/platform/dc/dcmain.cpp index cd2330c5261..c58eafcbc77 100644 --- a/backends/platform/dc/dcmain.cpp +++ b/backends/platform/dc/dcmain.cpp @@ -42,9 +42,9 @@ char gGameName[32]; OSystem_Dreamcast::OSystem_Dreamcast() : _devpoll(0), screen(NULL), mouse(NULL), overlay(NULL), _softkbd(this), - _ms_buf(NULL), _mixer(NULL), - _current_shake_x_pos(0), _current_shake_y_pos(0), _aspect_stretch(false), _softkbd_on(false), - _softkbd_motion(0), _enable_cursor_palette(false), _screenFormat(0) + _ms_buf(NULL), _mixer(NULL), + _current_shake_x_pos(0), _current_shake_y_pos(0), _aspect_stretch(false), _softkbd_on(false), + _softkbd_motion(0), _enable_cursor_palette(false), _screenFormat(0) { memset(screen_tx, 0, sizeof(screen_tx)); memset(mouse_tx, 0, sizeof(mouse_tx)); @@ -73,21 +73,21 @@ static bool find_track(int track, int &first_sec, int &last_sec) { struct TOC *toc = cdfs_gettoc(); if (!toc) - return false; + return false; int i, first, last; first = TOC_TRACK(toc->first); last = TOC_TRACK(toc->last); if (first < 1 || last > 99 || first > last) - return false; + return false; for (i=first; i<=last; i++) - if (!(TOC_CTRL(toc->entry[i-1])&4)) { - if (track==1) { + if (!(TOC_CTRL(toc->entry[i-1])&4)) { + if (track==1) { first_sec = TOC_LBA(toc->entry[i-1]); last_sec = TOC_LBA(toc->entry[i]); return true; - } else + } else --track; - } + } return false; } @@ -179,9 +179,9 @@ bool OSystem_Dreamcast::hasFeature(Feature f) case kFeatureVirtualKeyboard: case kFeatureOverlaySupportsAlpha: case kFeatureCursorPalette: - return true; + return true; default: - return false; + return false; } } @@ -189,18 +189,18 @@ void OSystem_Dreamcast::setFeatureState(Feature f, bool enable) { switch(f) { case kFeatureAspectRatioCorrection: - _aspect_stretch = enable; - if (screen) - setScaling(); - break; + _aspect_stretch = enable; + if (screen) + setScaling(); + break; case kFeatureVirtualKeyboard: - _softkbd_on = enable; - break; + _softkbd_on = enable; + break; case kFeatureCursorPalette: - _enable_cursor_palette = enable; - break; + _enable_cursor_palette = enable; + break; default: - break; + break; } } @@ -208,13 +208,13 @@ bool OSystem_Dreamcast::getFeatureState(Feature f) { switch(f) { case kFeatureAspectRatioCorrection: - return _aspect_stretch; + return _aspect_stretch; case kFeatureVirtualKeyboard: - return _softkbd_on; + return _softkbd_on; case kFeatureCursorPalette: - return _enable_cursor_palette; + return _enable_cursor_palette; default: - return false; + return false; } } @@ -250,53 +250,53 @@ void OSystem_Dreamcast::logMessage(LogMessageType::Type type, const char *messag namespace DC_Flash { static int syscall_info_flash(int sect, int *info) { - return (*(int (**)(int, void*, int, int))0x8c0000b8)(sect,info,0,0); + return (*(int (**)(int, void*, int, int))0x8c0000b8)(sect,info,0,0); } static int syscall_read_flash(int offs, void *buf, int cnt) { - return (*(int (**)(int, void*, int, int))0x8c0000b8)(offs,buf,cnt,1); + return (*(int (**)(int, void*, int, int))0x8c0000b8)(offs,buf,cnt,1); } static int flash_crc(const char *buf, int size) { - int i, c, n = -1; - for(i=0; i>6)-1-((info[1] + 0x7fff)>>15); - bmb = n+1; - for(b = 0; b < n; b++) { - if(!(b&511)) { + n = (info[1]>>6)-1-((info[1] + 0x7fff)>>15); + bmb = n+1; + for(b = 0; b < n; b++) { + if(!(b&511)) { if((r = syscall_read_flash(info[0] + (bmb++ << 6), bm, 64))<0) return r; - } - if(!(bm[(b>>3)&63] & (0x80>>(b&7)))) { + } + if(!(bm[(b>>3)&63] & (0x80>>(b&7)))) { if((r = syscall_read_flash(info[0] + ((b+1) << 6), buf, 64))<0) return r; else if((s=READ_LE_UINT16(buf+0)) == sec && @@ -304,33 +304,33 @@ namespace DC_Flash { memcpy(dst+(s-sec)*60, buf+2, 60); got=1; } - } - } - return got; + } + } + return got; } static int get_locale_setting() { - unsigned char data[60]; - if (flash_read_sector(2,5,data) == 1) - return data[5]; - else - return -1; + unsigned char data[60]; + if (flash_read_sector(2,5,data) == 1) + return data[5]; + else + return -1; } } // End of namespace DC_Flash Common::String OSystem_Dreamcast::getSystemLanguage() const { static const char *languages[] = { - "ja_JP", - "en_US", - "de_DE", - "fr_FR", - "es_ES", - "it_IT" + "ja_JP", + "en_US", + "de_DE", + "fr_FR", + "es_ES", + "it_IT" }; int l = DC_Flash::get_locale_setting(); if (l<0 || ((unsigned)l)>=sizeof(languages)/sizeof(languages[0])) - l = 1; + l = 1; return Common::String(languages[l]); } @@ -374,7 +374,7 @@ int DCLauncherDialog::runModal() Common::Platform platform = Common::kPlatformUnknown; if (!selectGame(engineId, gameId, dir, language, platform, icon)) - g_system->quit(); + g_system->quit(); // Set the game path. ConfMan.addGameDomain(gameId); @@ -382,15 +382,15 @@ int DCLauncherDialog::runModal() ConfMan.set("gameid", gameId, gameId); if (dir != NULL) - ConfMan.set("path", dir, gameId); + ConfMan.set("path", dir, gameId); // Set the game language. if (language != Common::UNK_LANG) - ConfMan.set("language", Common::getLanguageCode(language), gameId); + ConfMan.set("language", Common::getLanguageCode(language), gameId); // Set the game platform. if (platform != Common::kPlatformUnknown) - ConfMan.set("platform", Common::getPlatformCode(platform), gameId); + ConfMan.set("platform", Common::getPlatformCode(platform), gameId); // Set the target. ConfMan.setActiveDomain(gameId); diff --git a/backends/platform/dc/display.cpp b/backends/platform/dc/display.cpp index bb7919a5196..c1ddbaa945f 100644 --- a/backends/platform/dc/display.cpp +++ b/backends/platform/dc/display.cpp @@ -44,8 +44,8 @@ static const struct { operator const Graphics::PixelFormat&() const { return pixelFormat; } } screenFormats[] = { /* Note: These are ordered by _increasing_ preference, so that - CLUT8 appears at index 0. getSupportedFormats() will return - them in reversed order. */ + CLUT8 appears at index 0. getSupportedFormats() will return + them in reversed order. */ { Graphics::PixelFormat::createFormatCLUT8(), TA_TEXTUREMODE_ARGB1555 }, { Graphics::PixelFormat(2,4,4,4,4,8,4,0,12), TA_TEXTUREMODE_ARGB4444 }, { Graphics::PixelFormat(2,5,5,5,1,10,5,0,15), TA_TEXTUREMODE_ARGB1555 }, @@ -67,32 +67,32 @@ static void texture_memcpy64_pal(void *dest, void *src, int cnt, unsigned short { unsigned char *s = (unsigned char *)src; unsigned int *d = (unsigned int *)(void *) - (0xe0000000 | (((unsigned long)dest) & 0x03ffffc0)); + (0xe0000000 | (((unsigned long)dest) & 0x03ffffc0)); QACR0 = ((0xa4000000>>26)<<2)&0x1c; QACR1 = ((0xa4000000>>26)<<2)&0x1c; while (cnt--) { - COPYPIXEL(0); - COPYPIXEL(1); - COPYPIXEL(2); - COPYPIXEL(3); - asm("pref @%0" : : "r" (s+4*16)); - COPYPIXEL(4); - COPYPIXEL(5); - COPYPIXEL(6); - COPYPIXEL(7); - asm("pref @%0" : : "r" (d)); - d += 8; - COPYPIXEL(0); - COPYPIXEL(1); - COPYPIXEL(2); - COPYPIXEL(3); - asm("pref @%0" : : "r" (s+4*16)); - COPYPIXEL(4); - COPYPIXEL(5); - COPYPIXEL(6); - COPYPIXEL(7); - asm("pref @%0" : : "r" (d)); - d += 8; + COPYPIXEL(0); + COPYPIXEL(1); + COPYPIXEL(2); + COPYPIXEL(3); + asm("pref @%0" : : "r" (s+4*16)); + COPYPIXEL(4); + COPYPIXEL(5); + COPYPIXEL(6); + COPYPIXEL(7); + asm("pref @%0" : : "r" (d)); + d += 8; + COPYPIXEL(0); + COPYPIXEL(1); + COPYPIXEL(2); + COPYPIXEL(3); + asm("pref @%0" : : "r" (s+4*16)); + COPYPIXEL(4); + COPYPIXEL(5); + COPYPIXEL(6); + COPYPIXEL(7); + asm("pref @%0" : : "r" (d)); + d += 8; } } @@ -100,32 +100,32 @@ static void texture_memcpy64(void *dest, void *src, int cnt) { unsigned int *s = (unsigned int *)src; unsigned int *d = (unsigned int *)(void *) - (0xe0000000 | (((unsigned long)dest) & 0x03ffffc0)); + (0xe0000000 | (((unsigned long)dest) & 0x03ffffc0)); QACR0 = ((0xa4000000>>26)<<2)&0x1c; QACR1 = ((0xa4000000>>26)<<2)&0x1c; while (cnt--) { - d[0] = *s++; - d[1] = *s++; - d[2] = *s++; - d[3] = *s++; - asm("pref @%0" : : "r" (s+16)); - d[4] = *s++; - d[5] = *s++; - d[6] = *s++; - d[7] = *s++; - asm("pref @%0" : : "r" (d)); - d += 8; - d[0] = *s++; - d[1] = *s++; - d[2] = *s++; - d[3] = *s++; - asm("pref @%0" : : "r" (s+16)); - d[4] = *s++; - d[5] = *s++; - d[6] = *s++; - d[7] = *s++; - asm("pref @%0" : : "r" (d)); - d += 8; + d[0] = *s++; + d[1] = *s++; + d[2] = *s++; + d[3] = *s++; + asm("pref @%0" : : "r" (s+16)); + d[4] = *s++; + d[5] = *s++; + d[6] = *s++; + d[7] = *s++; + asm("pref @%0" : : "r" (d)); + d += 8; + d[0] = *s++; + d[1] = *s++; + d[2] = *s++; + d[3] = *s++; + asm("pref @%0" : : "r" (s+16)); + d[4] = *s++; + d[5] = *s++; + d[6] = *s++; + d[7] = *s++; + asm("pref @%0" : : "r" (d)); + d += 8; } } @@ -134,12 +134,12 @@ void commit_dummy_transpoly() struct polygon_list mypoly; mypoly.cmd = - TA_CMD_POLYGON|TA_CMD_POLYGON_TYPE_TRANSPARENT|TA_CMD_POLYGON_SUBLIST| - TA_CMD_POLYGON_STRIPLENGTH_2|TA_CMD_POLYGON_PACKED_COLOUR; + TA_CMD_POLYGON|TA_CMD_POLYGON_TYPE_TRANSPARENT|TA_CMD_POLYGON_SUBLIST| + TA_CMD_POLYGON_STRIPLENGTH_2|TA_CMD_POLYGON_PACKED_COLOUR; mypoly.mode1 = TA_POLYMODE1_Z_ALWAYS|TA_POLYMODE1_NO_Z_UPDATE; mypoly.mode2 = - TA_POLYMODE2_BLEND_SRC_ALPHA|TA_POLYMODE2_BLEND_DST_INVALPHA| - TA_POLYMODE2_FOG_DISABLED|TA_POLYMODE2_ENABLE_ALPHA; + TA_POLYMODE2_BLEND_SRC_ALPHA|TA_POLYMODE2_BLEND_DST_INVALPHA| + TA_POLYMODE2_FOG_DISABLED|TA_POLYMODE2_ENABLE_ALPHA; mypoly.texture = 0; mypoly.red = mypoly.green = mypoly.blue = mypoly.alpha = 0; ta_commit_list(&mypoly); @@ -150,12 +150,12 @@ void OSystem_Dreamcast::setPalette(const byte *colors, uint start, uint num) { unsigned short *dst = palette + start; if (num>0) - while ( num-- ) { - *dst++ = ((colors[0]<<7)&0x7c00)| + while ( num-- ) { + *dst++ = ((colors[0]<<7)&0x7c00)| ((colors[1]<<2)&0x03e0)| ((colors[2]>>3)&0x001f); - colors += 3; - } + colors += 3; + } _screen_dirty = true; } @@ -163,12 +163,12 @@ void OSystem_Dreamcast::setCursorPalette(const byte *colors, uint start, uint nu { unsigned short *dst = cursor_palette + start; if (num>0) - while ( num-- ) { - *dst++ = ((colors[0]<<7)&0x7c00)| + while ( num-- ) { + *dst++ = ((colors[0]<<7)&0x7c00)| ((colors[1]<<2)&0x03e0)| ((colors[2]>>3)&0x001f); - colors += 3; - } + colors += 3; + } _enable_cursor_palette = true; } @@ -176,13 +176,13 @@ void OSystem_Dreamcast::grabPalette(byte *colors, uint start, uint num) const { const unsigned short *src = palette + start; if (num>0) - while ( num-- ) { - unsigned short p = *src++; - colors[0] = ((p&0x7c00)>>7)|((p&0x7000)>>12); - colors[1] = ((p&0x03e0)>>2)|((p&0x0380)>>7); - colors[2] = ((p&0x001f)<<3)|((p&0x001c)>>2); - colors += 3; - } + while ( num-- ) { + unsigned short p = *src++; + colors[0] = ((p&0x7c00)>>7)|((p&0x7000)>>12); + colors[1] = ((p&0x03e0)>>2)|((p&0x0380)>>7); + colors[2] = ((p&0x001f)<<3)|((p&0x001c)>>2); + colors += 3; + } } Graphics::PixelFormat OSystem_Dreamcast::getScreenFormat() const @@ -195,22 +195,22 @@ Common::List OSystem_Dreamcast::getSupportedFormats() con Common::List list; unsigned i; for (i=0; i 400) { - _xscale = _yscale = 1.0; - _top_offset = (SCREEN_H-_screen_h)>>1; + _xscale = _yscale = 1.0; + _top_offset = (SCREEN_H-_screen_h)>>1; } else if (_aspect_stretch && _screen_w == 320 && _screen_h == 200) { - _xscale = SCREEN_W/320.0; - _yscale = SCREEN_H/200.0; - _top_offset = 0; + _xscale = SCREEN_W/320.0; + _yscale = SCREEN_H/200.0; + _top_offset = 0; } else { - _xscale = _yscale = 2.0; - _top_offset = (SCREEN_H>>1)-_screen_h; + _xscale = _yscale = 2.0; + _top_offset = (SCREEN_H>>1)-_screen_h; } } @@ -220,8 +220,8 @@ void OSystem_Dreamcast::initSize(uint w, uint h, const Graphics::PixelFormat *fo int i = 0; if (format != NULL) - for (i=NUM_FORMATS-1; i>0; --i) - if (*format == screenFormats[i]) + for (i=NUM_FORMATS-1; i>0; --i) + if (*format == screenFormats[i]) break; _screenFormat = i; @@ -236,18 +236,18 @@ void OSystem_Dreamcast::initSize(uint w, uint h, const Graphics::PixelFormat *fo setScaling(); ta_sync(); if (!screen) - screen = new unsigned char[SCREEN_W*SCREEN_H*2]; + screen = new unsigned char[SCREEN_W*SCREEN_H*2]; if (!overlay) - overlay = new unsigned short[OVL_W*OVL_H]; + overlay = new unsigned short[OVL_W*OVL_H]; for (i=0; i0; --i) - if (*format == screenFormats[i]) + for (i=NUM_FORMATS-1; i>0; --i) + if (*format == screenFormats[i]) break; _mouseFormat = i; free(_ms_buf); if (_mouseFormat != 0) - w <<= 1; + w <<= 1; _ms_buf = (byte *)malloc(w * h); memcpy(_ms_buf, buf, w * h); @@ -331,49 +331,49 @@ void OSystem_Dreamcast::updateScreenTextures(void) { if (_screen_dirty) { - _screen_buffer++; - _screen_buffer &= NUM_BUFFERS-1; + _screen_buffer++; + _screen_buffer &= NUM_BUFFERS-1; - unsigned short *dst = (unsigned short *)screen_tx[_screen_buffer]; - unsigned char *src = screen; + unsigned short *dst = (unsigned short *)screen_tx[_screen_buffer]; + unsigned char *src = screen; - // while ((*((volatile unsigned int *)(void *)0xa05f810c) & 0x3ff) != 200); - // *((volatile unsigned int *)(void *)0xa05f8040) = 0xff0000; + // while ((*((volatile unsigned int *)(void *)0xa05f810c) & 0x3ff) != 200); + // *((volatile unsigned int *)(void *)0xa05f8040) = 0xff0000; - if (_screenFormat == 0) - for ( int y = 0; y<_screen_h; y++ ) - { + if (_screenFormat == 0) + for ( int y = 0; y<_screen_h; y++ ) + { texture_memcpy64_pal( dst, src, _screen_w>>5, palette ); src += SCREEN_W*2; dst += SCREEN_W; - } - else - for ( int y = 0; y<_screen_h; y++ ) - { + } + else + for ( int y = 0; y<_screen_h; y++ ) + { texture_memcpy64( dst, src, _screen_w>>5 ); src += SCREEN_W*2; dst += SCREEN_W; - } + } - _screen_dirty = false; + _screen_dirty = false; } if ( _overlay_visible && _overlay_dirty ) { - _overlay_buffer++; - _overlay_buffer &= NUM_BUFFERS-1; + _overlay_buffer++; + _overlay_buffer &= NUM_BUFFERS-1; - unsigned short *dst = (unsigned short *)ovl_tx[_overlay_buffer]; - unsigned short *src = overlay; + unsigned short *dst = (unsigned short *)ovl_tx[_overlay_buffer]; + unsigned short *src = overlay; - for ( int y = 0; y>5 ); - src += OVL_W; - dst += OVL_TXSTRIDE; - } + for ( int y = 0; y>5 ); + src += OVL_W; + dst += OVL_TXSTRIDE; + } - _overlay_dirty = false; + _overlay_dirty = false; } } @@ -385,15 +385,15 @@ void OSystem_Dreamcast::updateScreenPolygons(void) // *((volatile unsigned int *)(void *)0xa05f8040) = 0x00ff00; mypoly.cmd = - TA_CMD_POLYGON|TA_CMD_POLYGON_TYPE_OPAQUE|TA_CMD_POLYGON_SUBLIST| - TA_CMD_POLYGON_STRIPLENGTH_2|TA_CMD_POLYGON_PACKED_COLOUR|TA_CMD_POLYGON_TEXTURED; + TA_CMD_POLYGON|TA_CMD_POLYGON_TYPE_OPAQUE|TA_CMD_POLYGON_SUBLIST| + TA_CMD_POLYGON_STRIPLENGTH_2|TA_CMD_POLYGON_PACKED_COLOUR|TA_CMD_POLYGON_TEXTURED; mypoly.mode1 = TA_POLYMODE1_Z_ALWAYS|TA_POLYMODE1_NO_Z_UPDATE; mypoly.mode2 = - TA_POLYMODE2_BLEND_SRC|TA_POLYMODE2_FOG_DISABLED|TA_POLYMODE2_TEXTURE_REPLACE| - TA_POLYMODE2_U_SIZE_1024|TA_POLYMODE2_V_SIZE_1024; + TA_POLYMODE2_BLEND_SRC|TA_POLYMODE2_FOG_DISABLED|TA_POLYMODE2_TEXTURE_REPLACE| + TA_POLYMODE2_U_SIZE_1024|TA_POLYMODE2_V_SIZE_1024; mypoly.texture = screenFormats[_screenFormat].textureFormat| - TA_TEXTUREMODE_NON_TWIDDLED|TA_TEXTUREMODE_STRIDE| - TA_TEXTUREMODE_ADDRESS(screen_tx[_screen_buffer]); + TA_TEXTUREMODE_NON_TWIDDLED|TA_TEXTUREMODE_STRIDE| + TA_TEXTUREMODE_ADDRESS(screen_tx[_screen_buffer]); mypoly.red = mypoly.green = mypoly.blue = mypoly.alpha = 0; @@ -430,70 +430,70 @@ void OSystem_Dreamcast::updateScreenPolygons(void) ta_commit_end(); if (_overlay_visible) { - if (_overlay_fade < 1.0) - _overlay_fade += 0.125; + if (_overlay_fade < 1.0) + _overlay_fade += 0.125; } else { - if (_overlay_fade > 0) - _overlay_fade -= 0.125; + if (_overlay_fade > 0) + _overlay_fade -= 0.125; } if (_overlay_fade > 0.0) { - mypoly.cmd = - TA_CMD_POLYGON|TA_CMD_POLYGON_TYPE_TRANSPARENT|TA_CMD_POLYGON_SUBLIST| - TA_CMD_POLYGON_STRIPLENGTH_2|TA_CMD_POLYGON_PACKED_COLOUR|TA_CMD_POLYGON_TEXTURED; - mypoly.mode1 = TA_POLYMODE1_Z_ALWAYS|TA_POLYMODE1_NO_Z_UPDATE; - mypoly.mode2 = - TA_POLYMODE2_BLEND_SRC/*_ALPHA*/|TA_POLYMODE2_BLEND_DST_INVALPHA| - TA_POLYMODE2_ENABLE_ALPHA| - TA_POLYMODE2_FOG_DISABLED|TA_POLYMODE2_TEXTURE_MODULATE_ALPHA| - TA_POLYMODE2_U_SIZE_512|TA_POLYMODE2_V_SIZE_512; - mypoly.texture = TA_TEXTUREMODE_ARGB4444|TA_TEXTUREMODE_NON_TWIDDLED| - TA_TEXTUREMODE_ADDRESS(ovl_tx[_overlay_buffer]); + mypoly.cmd = + TA_CMD_POLYGON|TA_CMD_POLYGON_TYPE_TRANSPARENT|TA_CMD_POLYGON_SUBLIST| + TA_CMD_POLYGON_STRIPLENGTH_2|TA_CMD_POLYGON_PACKED_COLOUR|TA_CMD_POLYGON_TEXTURED; + mypoly.mode1 = TA_POLYMODE1_Z_ALWAYS|TA_POLYMODE1_NO_Z_UPDATE; + mypoly.mode2 = + TA_POLYMODE2_BLEND_SRC/*_ALPHA*/|TA_POLYMODE2_BLEND_DST_INVALPHA| + TA_POLYMODE2_ENABLE_ALPHA| + TA_POLYMODE2_FOG_DISABLED|TA_POLYMODE2_TEXTURE_MODULATE_ALPHA| + TA_POLYMODE2_U_SIZE_512|TA_POLYMODE2_V_SIZE_512; + mypoly.texture = TA_TEXTUREMODE_ARGB4444|TA_TEXTUREMODE_NON_TWIDDLED| + TA_TEXTUREMODE_ADDRESS(ovl_tx[_overlay_buffer]); - mypoly.red = mypoly.green = mypoly.blue = mypoly.alpha = 0.0; + mypoly.red = mypoly.green = mypoly.blue = mypoly.alpha = 0.0; - ta_commit_list(&mypoly); + ta_commit_list(&mypoly); - myvertex.cmd = TA_CMD_VERTEX; - myvertex.ocolour = 0; - myvertex.colour = 0xffffff|(((int)(255*_overlay_fade))<<24); + myvertex.cmd = TA_CMD_VERTEX; + myvertex.ocolour = 0; + myvertex.colour = 0xffffff|(((int)(255*_overlay_fade))<<24); - myvertex.z = 0.5; - myvertex.u = 0.0; - myvertex.v = 0.0; + myvertex.z = 0.5; + myvertex.u = 0.0; + myvertex.v = 0.0; - myvertex.x = _overlay_x*_xscale+LEFT_OFFSET; - myvertex.y = _overlay_y*_yscale+TOP_OFFSET; - ta_commit_list(&myvertex); + myvertex.x = _overlay_x*_xscale+LEFT_OFFSET; + myvertex.y = _overlay_y*_yscale+TOP_OFFSET; + ta_commit_list(&myvertex); - myvertex.x += OVL_W*_xscale; - myvertex.u = OVL_W*(1.0/512.0); - ta_commit_list(&myvertex); + myvertex.x += OVL_W*_xscale; + myvertex.u = OVL_W*(1.0/512.0); + ta_commit_list(&myvertex); - myvertex.x = _overlay_x*_xscale; - myvertex.y += OVL_H*_yscale; - myvertex.u = 0.0; - myvertex.v = OVL_H*(1.0/512.0); - ta_commit_list(&myvertex); + myvertex.x = _overlay_x*_xscale; + myvertex.y += OVL_H*_yscale; + myvertex.u = 0.0; + myvertex.v = OVL_H*(1.0/512.0); + ta_commit_list(&myvertex); - myvertex.x += OVL_W*_xscale; - myvertex.u = OVL_W*(1.0/512.0); - myvertex.cmd |= TA_CMD_VERTEX_EOS; - ta_commit_list(&myvertex); + myvertex.x += OVL_W*_xscale; + myvertex.u = OVL_W*(1.0/512.0); + myvertex.cmd |= TA_CMD_VERTEX_EOS; + ta_commit_list(&myvertex); } if (_softkbd_on) - if (_softkbd_motion < 120) - _softkbd_motion += 10; - else - ; + if (_softkbd_motion < 120) + _softkbd_motion += 10; + else + ; else - if (_softkbd_motion > 0) - _softkbd_motion -= 10; + if (_softkbd_motion > 0) + _softkbd_motion -= 10; if (_softkbd_motion) - _softkbd.draw(330.0*sin(0.013*_softkbd_motion) - 320.0, 200.0, + _softkbd.draw(330.0*sin(0.013*_softkbd_motion) - 320.0, 200.0, 120-_softkbd_motion); // *((volatile unsigned int *)(void *)0xa05f8040) = 0xffff00; @@ -516,15 +516,15 @@ void OSystem_Dreamcast::maybeRefreshScreen(void) { unsigned int t = Timer(); if((int)(t-_last_screen_refresh) > USEC_TO_TIMER(30000)) - updateScreenPolygons(); + updateScreenPolygons(); } void OSystem_Dreamcast::drawMouse(int xdraw, int ydraw, int w, int h, unsigned char *buf, bool visible) { if (!visible || buf == NULL || !w || !h || w>MOUSE_W || h>MOUSE_H) { - commit_dummy_transpoly(); - return; + commit_dummy_transpoly(); + return; } struct polygon_list mypoly; @@ -537,26 +537,26 @@ void OSystem_Dreamcast::drawMouse(int xdraw, int ydraw, int w, int h, unsigned int texturemode = screenFormats[_mouseFormat].textureFormat; if (_mouseFormat == 0) { - unsigned short *pal = _enable_cursor_palette? cursor_palette : palette; - for (int y=0; y>1)|0x8000; } - dst += MOUSE_W-x; - } + dst += MOUSE_W-x; + } } else { - unsigned short *bufs = (unsigned short *)buf; - for (int y=0; y>16)&0xf000)| - ((p>>12)&0x0f00)| - ((p>> 8)&0x00f0)| - ((p>> 4)&0x000f); + int p = palette[n]; + pal[n] = + ((p>>16)&0xf000)| + ((p>>12)&0x0f00)| + ((p>> 8)&0x00f0)| + ((p>> 4)&0x000f); } for (int line = 0; line < 32; line++) { - memcpy(pix, &bitmap[32/2*(31-line)], 32/2); - pix += 32/2; + memcpy(pix, &bitmap[32/2*(31-line)], 32/2); + pix += 32/2; } } @@ -53,10 +53,10 @@ void Icon::create_texture() unsigned short *linebase; unsigned char *src = bitmap+sizeof(bitmap)-17; for (int y=0; y<16; y++) { - linebase = tex + (tt[y]<<1); - for (int x=0; x<16; x++, --src) - linebase[tt[x]] = src[16]|(src[0]<<8); - src -= 16; + linebase = tex + (tt[y]<<1); + for (int x=0; x<16; x++, --src) + linebase[tt[x]] = src[16]|(src[0]<<8); + src -= 16; } texture = tex; } @@ -65,7 +65,7 @@ void Icon::setPalette(int pal) { unsigned int (*hwpal)[64][16] = (unsigned int (*)[64][16])0xa05f9000; for (int n = 0; n<16; n++) - (*hwpal)[pal][n] = palette[n]; + (*hwpal)[pal][n] = palette[n]; } void Icon::draw(float x1, float y1, float x2, float y2, int pal, @@ -75,16 +75,16 @@ void Icon::draw(float x1, float y1, float x2, float y2, int pal, struct packed_colour_vertex_list myvertex; mypoly.cmd = - TA_CMD_POLYGON|TA_CMD_POLYGON_TYPE_TRANSPARENT|TA_CMD_POLYGON_SUBLIST| - TA_CMD_POLYGON_STRIPLENGTH_2|TA_CMD_POLYGON_PACKED_COLOUR|TA_CMD_POLYGON_TEXTURED; + TA_CMD_POLYGON|TA_CMD_POLYGON_TYPE_TRANSPARENT|TA_CMD_POLYGON_SUBLIST| + TA_CMD_POLYGON_STRIPLENGTH_2|TA_CMD_POLYGON_PACKED_COLOUR|TA_CMD_POLYGON_TEXTURED; mypoly.mode1 = TA_POLYMODE1_Z_ALWAYS|TA_POLYMODE1_NO_Z_UPDATE; mypoly.mode2 = - TA_POLYMODE2_BLEND_SRC_ALPHA|TA_POLYMODE2_BLEND_DST_INVALPHA| - TA_POLYMODE2_FOG_DISABLED|TA_POLYMODE2_ENABLE_ALPHA| - TA_POLYMODE2_TEXTURE_MODULATE_ALPHA|TA_POLYMODE2_U_SIZE_32| - TA_POLYMODE2_V_SIZE_32; + TA_POLYMODE2_BLEND_SRC_ALPHA|TA_POLYMODE2_BLEND_DST_INVALPHA| + TA_POLYMODE2_FOG_DISABLED|TA_POLYMODE2_ENABLE_ALPHA| + TA_POLYMODE2_TEXTURE_MODULATE_ALPHA|TA_POLYMODE2_U_SIZE_32| + TA_POLYMODE2_V_SIZE_32; mypoly.texture = TA_TEXTUREMODE_CLUT4|TA_TEXTUREMODE_CLUTBANK4(pal)| - TA_TEXTUREMODE_ADDRESS(texture); + TA_TEXTUREMODE_ADDRESS(texture); mypoly.red = mypoly.green = mypoly.blue = mypoly.alpha = 0; @@ -123,59 +123,59 @@ int Icon::find_unused_pixel(const unsigned char *mask) memset(use, 0, sizeof(use)); unsigned char *p = bitmap; for (int n=0; n<32*32/2/4; n++) { - unsigned char mbits = ~*mask++; - for (int i=0; i<4; i++) { - unsigned char pix = *p++; - if(mbits & 64) + unsigned char mbits = ~*mask++; + for (int i=0; i<4; i++) { + unsigned char pix = *p++; + if(mbits & 64) use[pix&0xf]++; - if(mbits & 128) + if(mbits & 128) use[pix>>4]++; - mbits <<= 2; - } + mbits <<= 2; + } } for (int i=0; i<16; i++) - if (!use[i]) - return i; + if (!use[i]) + return i; return -1; } bool Icon::load_image2(const void *data, int len) { struct { - int size, w, h; - short pla, bitcnt; - int comp, sizeimg, xres, yres, used, imp; + int size, w, h; + short pla, bitcnt; + int comp, sizeimg, xres, yres, used, imp; } hdr; if (len < 40) - return false; + return false; memcpy(&hdr, data, 40); if (hdr.size != 40 || /* hdr.sizeimg<=0 || */ hdr.w<0 || hdr.h<0 || - hdr.bitcnt<0 || hdr.used<0) - return false; + hdr.bitcnt<0 || hdr.used<0) + return false; if (!hdr.used) - hdr.used = 1<>= 1; /* Fix incorrect sizeimg (The Dig) */ if (hdr.sizeimg < ((hdr.w*hdr.h*(1+hdr.bitcnt)+7)>>3)) - hdr.sizeimg = ((hdr.w*hdr.h*(1+hdr.bitcnt)+7)>>3); + hdr.sizeimg = ((hdr.w*hdr.h*(1+hdr.bitcnt)+7)>>3); if (hdr.size + (hdr.used<<2) + hdr.sizeimg > len /* || - hdr.sizeimg < ((hdr.w*hdr.h*(1+hdr.bitcnt)+7)>>3) */) - return false; + hdr.sizeimg < ((hdr.w*hdr.h*(1+hdr.bitcnt)+7)>>3) */) + return false; if (hdr.w != 32 || hdr.h != 32 || hdr.bitcnt != 4 || hdr.used > 16) - return false; + return false; memcpy(palette, ((const char *)data)+hdr.size, hdr.used<<2); memcpy(bitmap, ((const char *)data)+hdr.size+(hdr.used<<2), 32*32/2); for (int i=0; i<16; i++) - palette[i] |= 0xff000000; + palette[i] |= 0xff000000; for (int i=hdr.used; i<16; i++) - palette[i] = 0; + palette[i] = 0; const unsigned char *mask = - ((const unsigned char *)data)+hdr.size+(hdr.used<<2)+32*32/2; + ((const unsigned char *)data)+hdr.size+(hdr.used<<2)+32*32/2; int unused = find_unused_pixel(mask); if (unused >= 0) { - unsigned char *pix = bitmap; - for (int y=0; y<32; y++) - for (int x=0; x<32/8; x++) { + unsigned char *pix = bitmap; + for (int y=0; y<32; y++) + for (int x=0; x<32/8; x++) { unsigned char mbits = *mask++; for (int z=0; z<4; z++) { unsigned char pbits = *pix; @@ -184,8 +184,8 @@ bool Icon::load_image2(const void *data, int len) *pix++ = pbits; mbits <<= 2; } - } - palette[unused] = 0; + } + palette[unused] = 0; } return true; } @@ -193,17 +193,17 @@ bool Icon::load_image2(const void *data, int len) bool Icon::load_image1(const void *data, int len, int offs) { struct { - char w, h, colors, rsrv; - short pla, bitcnt; - int bytes, offs; + char w, h, colors, rsrv; + short pla, bitcnt; + int bytes, offs; } hdr; if (len < offs+16) - return false; + return false; memcpy(&hdr, ((const char *)data)+offs, 16); if (hdr.bytes > 0 && hdr.offs >= 0 && hdr.offs+hdr.bytes <= len) - return load_image2(((const char *)data)+hdr.offs, hdr.bytes); + return load_image2(((const char *)data)+hdr.offs, hdr.bytes); else - return false; + return false; } bool Icon::load(const void *data, int len, int offs) @@ -213,13 +213,13 @@ bool Icon::load(const void *data, int len, int offs) memset(palette, 0, sizeof(palette)); texture = NULL; if (len < offs+6) - return false; + return false; memcpy(&hdr, ((const char *)data)+offs, 6); if (hdr.type != 1 || hdr.cnt < 1 || offs+6+(hdr.cnt<<4) > len) - return false; + return false; for (int i=0; i=0) { - int sz; - sz = read(fd, buf, sizeof(buf)); - close(fd); - if (sz>0) - return load(buf, sz); + int sz; + sz = read(fd, buf, sizeof(buf)); + close(fd); + if (sz>0) + return load(buf, sz); } return false; } diff --git a/backends/platform/dc/input.cpp b/backends/platform/dc/input.cpp index a69bb3b78f6..850a4db84bd 100644 --- a/backends/platform/dc/input.cpp +++ b/backends/platform/dc/input.cpp @@ -38,49 +38,49 @@ int handleInput(struct mapledev *pad, int &mouse_x, int &mouse_y, static int8 mouse_wheel = 0, lastwheel = 0; shiftFlags = 0; for (int i=0; i<4; i++, pad++) - if (pad->func & MAPLE_FUNC_CONTROLLER) { - int buttons = pad->cond.controller.buttons; + if (pad->func & MAPLE_FUNC_CONTROLLER) { + int buttons = pad->cond.controller.buttons; - if (!(buttons & 0x060e)) exit(0); + if (!(buttons & 0x060e)) exit(0); - if (!(buttons & 4)) lmb++; - if (!(buttons & 2)) rmb++; + if (!(buttons & 4)) lmb++; + if (!(buttons & 2)) rmb++; - if (!(buttons & 8)) newkey = Common::KEYCODE_F5; - else if (!(buttons & 512)) newkey = ' '; - else if (!(buttons & 1024)) newkey = numpadmap[(buttons>>4)&15]; + if (!(buttons & 8)) newkey = Common::KEYCODE_F5; + else if (!(buttons & 512)) newkey = ' '; + else if (!(buttons & 1024)) newkey = numpadmap[(buttons>>4)&15]; - if (!(buttons & 128)) { if (inter) newkey = 1001; else mouse_x++; } - if (!(buttons & 64)) { if (inter) newkey = 1002; else mouse_x--; } - if (!(buttons & 32)) { if (inter) newkey = 1003; else mouse_y++; } - if (!(buttons & 16)) { if (inter) newkey = 1004; else mouse_y--; } + if (!(buttons & 128)) { if (inter) newkey = 1001; else mouse_x++; } + if (!(buttons & 64)) { if (inter) newkey = 1002; else mouse_x--; } + if (!(buttons & 32)) { if (inter) newkey = 1003; else mouse_y++; } + if (!(buttons & 16)) { if (inter) newkey = 1004; else mouse_y--; } - mouse_x += ((int)pad->cond.controller.joyx-128)>>4; - mouse_y += ((int)pad->cond.controller.joyy-128)>>4; + mouse_x += ((int)pad->cond.controller.joyx-128)>>4; + mouse_y += ((int)pad->cond.controller.joyy-128)>>4; - if (pad->cond.controller.ltrigger > 200) newkey = 1005; - else if (pad->cond.controller.rtrigger > 200) newkey = 1006; + if (pad->cond.controller.ltrigger > 200) newkey = 1005; + else if (pad->cond.controller.rtrigger > 200) newkey = 1006; - } else if (pad->func & MAPLE_FUNC_MOUSE) { - int buttons = pad->cond.mouse.buttons; + } else if (pad->func & MAPLE_FUNC_MOUSE) { + int buttons = pad->cond.mouse.buttons; - if (!(buttons & 4)) lmb++; - if (!(buttons & 2)) rmb++; + if (!(buttons & 4)) lmb++; + if (!(buttons & 2)) rmb++; - if (!(buttons & 8)) newkey = Common::KEYCODE_F5; + if (!(buttons & 8)) newkey = Common::KEYCODE_F5; - mouse_x += pad->cond.mouse.axis1; - mouse_y += pad->cond.mouse.axis2; - mouse_wheel += pad->cond.mouse.axis3; + mouse_x += pad->cond.mouse.axis1; + mouse_y += pad->cond.mouse.axis2; + mouse_wheel += pad->cond.mouse.axis3; - if (inter) + if (inter) inter->mouse(mouse_x, mouse_y); - pad->cond.mouse.axis1 = 0; - pad->cond.mouse.axis2 = 0; - pad->cond.mouse.axis3 = 0; - } else if (pad->func & MAPLE_FUNC_KEYBOARD) { - for (int p=0; p<6; p++) { + pad->cond.mouse.axis1 = 0; + pad->cond.mouse.axis2 = 0; + pad->cond.mouse.axis3 = 0; + } else if (pad->func & MAPLE_FUNC_KEYBOARD) { + for (int p=0; p<6; p++) { int shift = pad->cond.kbd.shift; int key = pad->cond.kbd.key[p]; if (shift & 0x08) lmb++; @@ -134,56 +134,56 @@ int handleInput(struct mapledev *pad, int &mouse_x, int &mouse_y, case 0x89: newkey = ((shift & 0x22)? '|' : '?'); break; } - } - } + } + } if (lmb && inter && !lastlmb) { - newkey = 1000; - lmb = 0; + newkey = 1000; + lmb = 0; } if (lmb && !lastlmb) { - lastlmb = 1; - return -Common::EVENT_LBUTTONDOWN; + lastlmb = 1; + return -Common::EVENT_LBUTTONDOWN; } else if (lastlmb && !lmb) { - lastlmb = 0; - return -Common::EVENT_LBUTTONUP; + lastlmb = 0; + return -Common::EVENT_LBUTTONUP; } if (rmb && !lastrmb) { - lastrmb = 1; - return -Common::EVENT_RBUTTONDOWN; + lastrmb = 1; + return -Common::EVENT_RBUTTONDOWN; } else if (lastrmb && !rmb) { - lastrmb = 0; - return -Common::EVENT_RBUTTONUP; + lastrmb = 0; + return -Common::EVENT_RBUTTONUP; } if (mouse_wheel != lastwheel) { - if (((int8)(mouse_wheel - lastwheel)) > 0) { - lastwheel++; - return -Common::EVENT_WHEELDOWN; - } else { - --lastwheel; - return -Common::EVENT_WHEELUP; - } + if (((int8)(mouse_wheel - lastwheel)) > 0) { + lastwheel++; + return -Common::EVENT_WHEELDOWN; + } else { + --lastwheel; + return -Common::EVENT_WHEELUP; + } } if (newkey && inter && newkey != lastkey) { - int transkey = inter->key(newkey, shiftFlags); - if (transkey) { - newkey = transkey; - inter = NULL; - } + int transkey = inter->key(newkey, shiftFlags); + if (transkey) { + newkey = transkey; + inter = NULL; + } } if (!newkey || (lastkey && newkey != lastkey)) { - int upkey = lastkey; - lastkey = 0; - if (upkey) - return upkey | (1<<30); + int upkey = lastkey; + lastkey = 0; + if (upkey) + return upkey | (1<<30); } else if (!lastkey) { - lastkey = newkey; - if (newkey >= 1000 || !inter) - return newkey; + lastkey = newkey; + if (newkey >= 1000 || !inter) + return newkey; } return 0; @@ -194,13 +194,13 @@ bool OSystem_Dreamcast::pollEvent(Common::Event &event) unsigned int t = Timer(); if (_timerManager != NULL) - ((DefaultTimerManager *)_timerManager)->handler(); + ((DefaultTimerManager *)_timerManager)->handler(); if (((int)(t-_devpoll))<0) - return false; + return false; _devpoll += USEC_TO_TIMER(17000); if (((int)(t-_devpoll))>=0) - _devpoll = t + USEC_TO_TIMER(17000); + _devpoll = t + USEC_TO_TIMER(17000); maybeRefreshScreen(); @@ -217,36 +217,36 @@ bool OSystem_Dreamcast::pollEvent(Common::Event &event) event.mouse.x = _ms_cur_x; event.mouse.y = _ms_cur_y; if (_overlay_visible) { - event.mouse.x -= _overlay_x; - event.mouse.y -= _overlay_y; + event.mouse.x -= _overlay_x; + event.mouse.y -= _overlay_y; } event.kbd.ascii = 0; event.kbd.keycode = Common::KEYCODE_INVALID; if (e<0) { - event.type = (Common::EventType)-e; - return true; + event.type = (Common::EventType)-e; + return true; } else if (e>0) { - bool processed = false, down = !(e&(1<<30)); - e &= ~(1<<30); - if (e < 1000) { - event.type = (down? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP); - event.kbd.keycode = (Common::KeyCode)e; - event.kbd.ascii = (e>='a' && e<='z' && (event.kbd.flags & Common::KBD_SHIFT)? + bool processed = false, down = !(e&(1<<30)); + e &= ~(1<<30); + if (e < 1000) { + event.type = (down? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP); + event.kbd.keycode = (Common::KeyCode)e; + event.kbd.ascii = (e>='a' && e<='z' && (event.kbd.flags & Common::KBD_SHIFT)? e &~ 0x20 : e); - processed = true; - } else if (down) { - if (e == 1005) + processed = true; + } else if (down) { + if (e == 1005) setFeatureState(kFeatureVirtualKeyboard, !getFeatureState(kFeatureVirtualKeyboard)); - } - return processed; + } + return processed; } else if (_ms_cur_x != _ms_old_x || _ms_cur_y != _ms_old_y) { - event.type = Common::EVENT_MOUSEMOVE; - _ms_old_x = _ms_cur_x; - _ms_old_y = _ms_cur_y; - return true; + event.type = Common::EVENT_MOUSEMOVE; + _ms_old_x = _ms_cur_x; + _ms_old_y = _ms_cur_y; + return true; } else { - event.type = (Common::EventType)0; - return false; + event.type = (Common::EventType)0; + return false; } } diff --git a/backends/platform/dc/label.cpp b/backends/platform/dc/label.cpp index 46bff0db11a..ba60697b205 100644 --- a/backends/platform/dc/label.cpp +++ b/backends/platform/dc/label.cpp @@ -30,11 +30,11 @@ void *get_romfont_address() __asm__(".get_romfont_address"); __asm__("\ \n\ .get_romfont_address: \n\ - mov.l 1f,r0 \n\ - mov.l @r0,r0 \n\ - jmp @r0 \n\ - mov #0,r1 \n\ - .align 2 \n\ + mov.l 1f,r0 \n\ + mov.l @r0,r0 \n\ + jmp @r0 \n\ + mov #0,r1 \n\ + .align 2 \n\ 1: .long 0x8c0000b4 \n\ \n\ "); @@ -48,26 +48,26 @@ static void draw_char(unsigned short *dst, int mod, int c, void *font_base) if (c<128) c -= 32; else c -= 64; src = c*36 + (unsigned char *)font_base; for (i=0; i<12; i++) { - int n = (src[0]<<16)|(src[1]<<8)|src[2]; - for (j=0; j<12; j++, n<<=1) - if (n & (1<<23)) { + int n = (src[0]<<16)|(src[1]<<8)|src[2]; + for (j=0; j<12; j++, n<<=1) + if (n & (1<<23)) { dst[j] = 0xffff; dst[j+1] = 0xffff; dst[j+2] = 0xa108; dst[j+mod] = 0xa108; dst[j+mod+1] = 0xa108; - } - dst += mod; - for (j=0; j<12; j++, n<<=1) - if (n & (1<<23)) { + } + dst += mod; + for (j=0; j<12; j++, n<<=1) + if (n & (1<<23)) { dst[j] = 0xffff; dst[j+1] = 0xffff; dst[j+2] = 0xa108; dst[j+mod] = 0xa108; dst[j+mod+1] = 0xa108; - } - dst += mod; - src += 3; + } + dst += mod; + src += 3; } } @@ -81,10 +81,10 @@ void Label::create_texture(const char *text) int tsz = u*32; unsigned short *tex = (unsigned short *)ta_txalloc(tsz*2); for (int i=0; i0) - draw_char(tex+(p-=14), u, text[--l], font); + draw_char(tex+(p-=14), u, text[--l], font); texture = tex; } @@ -94,15 +94,15 @@ void Label::draw(float x, float y, unsigned int argb, float scale) struct packed_colour_vertex_list myvertex; mypoly.cmd = - TA_CMD_POLYGON|TA_CMD_POLYGON_TYPE_TRANSPARENT|TA_CMD_POLYGON_SUBLIST| - TA_CMD_POLYGON_STRIPLENGTH_2|TA_CMD_POLYGON_PACKED_COLOUR|TA_CMD_POLYGON_TEXTURED; + TA_CMD_POLYGON|TA_CMD_POLYGON_TYPE_TRANSPARENT|TA_CMD_POLYGON_SUBLIST| + TA_CMD_POLYGON_STRIPLENGTH_2|TA_CMD_POLYGON_PACKED_COLOUR|TA_CMD_POLYGON_TEXTURED; mypoly.mode1 = TA_POLYMODE1_Z_ALWAYS|TA_POLYMODE1_NO_Z_UPDATE; mypoly.mode2 = - TA_POLYMODE2_BLEND_SRC_ALPHA|TA_POLYMODE2_BLEND_DST_INVALPHA| - TA_POLYMODE2_FOG_DISABLED|TA_POLYMODE2_ENABLE_ALPHA| - TA_POLYMODE2_TEXTURE_MODULATE_ALPHA|TA_POLYMODE2_V_SIZE_32|tex_u; + TA_POLYMODE2_BLEND_SRC_ALPHA|TA_POLYMODE2_BLEND_DST_INVALPHA| + TA_POLYMODE2_FOG_DISABLED|TA_POLYMODE2_ENABLE_ALPHA| + TA_POLYMODE2_TEXTURE_MODULATE_ALPHA|TA_POLYMODE2_V_SIZE_32|tex_u; mypoly.texture = TA_TEXTUREMODE_ARGB1555|TA_TEXTUREMODE_NON_TWIDDLED| - TA_TEXTUREMODE_ADDRESS(texture); + TA_TEXTUREMODE_ADDRESS(texture); mypoly.red = mypoly.green = mypoly.blue = mypoly.alpha = 0; diff --git a/backends/platform/dc/plugins.cpp b/backends/platform/dc/plugins.cpp index cf1558eaa8f..68ebf39bd54 100644 --- a/backends/platform/dc/plugins.cpp +++ b/backends/platform/dc/plugins.cpp @@ -134,7 +134,7 @@ void OSystem_Dreamcast::addCustomDirectories(Common::FSList &dirs) const { FilePluginProvider::addCustomDirectories(dirs); if (pluginCustomDirectory != NULL) - dirs.push_back(Common::FSNode(pluginCustomDirectory)); + dirs.push_back(Common::FSNode(pluginCustomDirectory)); } PluginList OSystem_Dreamcast::getPlugins() @@ -142,12 +142,12 @@ PluginList OSystem_Dreamcast::getPlugins() pluginCustomDirectory = NULL; PluginList list = FilePluginProvider::getPlugins(); if (list.empty()) { - Common::String selection; - if (selectPluginDir(selection, Common::FSNode("plugins"))) { - pluginCustomDirectory = selection.c_str(); - list = FilePluginProvider::getPlugins(); - pluginCustomDirectory = NULL; - } + Common::String selection; + if (selectPluginDir(selection, Common::FSNode("plugins"))) { + pluginCustomDirectory = selection.c_str(); + list = FilePluginProvider::getPlugins(); + pluginCustomDirectory = NULL; + } } return list; } diff --git a/backends/platform/dc/selector.cpp b/backends/platform/dc/selector.cpp index f70ce67d51f..c14f869418c 100644 --- a/backends/platform/dc/selector.cpp +++ b/backends/platform/dc/selector.cpp @@ -49,12 +49,12 @@ void draw_solid_quad(float x1, float y1, float x2, float y2, struct packed_colour_vertex_list myvertex; mypoly.cmd = - TA_CMD_POLYGON|TA_CMD_POLYGON_TYPE_OPAQUE|TA_CMD_POLYGON_SUBLIST| - TA_CMD_POLYGON_STRIPLENGTH_2|TA_CMD_POLYGON_PACKED_COLOUR| - TA_CMD_POLYGON_GOURAUD_SHADING; + TA_CMD_POLYGON|TA_CMD_POLYGON_TYPE_OPAQUE|TA_CMD_POLYGON_SUBLIST| + TA_CMD_POLYGON_STRIPLENGTH_2|TA_CMD_POLYGON_PACKED_COLOUR| + TA_CMD_POLYGON_GOURAUD_SHADING; mypoly.mode1 = TA_POLYMODE1_Z_ALWAYS|TA_POLYMODE1_NO_Z_UPDATE; mypoly.mode2 = - TA_POLYMODE2_BLEND_SRC|TA_POLYMODE2_FOG_DISABLED; + TA_POLYMODE2_BLEND_SRC|TA_POLYMODE2_FOG_DISABLED; mypoly.texture = 0; mypoly.red = mypoly.green = mypoly.blue = mypoly.alpha = 0; @@ -94,13 +94,13 @@ void draw_trans_quad(float x1, float y1, float x2, float y2, struct packed_colour_vertex_list myvertex; mypoly.cmd = - TA_CMD_POLYGON|TA_CMD_POLYGON_TYPE_TRANSPARENT|TA_CMD_POLYGON_SUBLIST| - TA_CMD_POLYGON_STRIPLENGTH_2|TA_CMD_POLYGON_PACKED_COLOUR| - TA_CMD_POLYGON_GOURAUD_SHADING; + TA_CMD_POLYGON|TA_CMD_POLYGON_TYPE_TRANSPARENT|TA_CMD_POLYGON_SUBLIST| + TA_CMD_POLYGON_STRIPLENGTH_2|TA_CMD_POLYGON_PACKED_COLOUR| + TA_CMD_POLYGON_GOURAUD_SHADING; mypoly.mode1 = TA_POLYMODE1_Z_ALWAYS|TA_POLYMODE1_NO_Z_UPDATE; mypoly.mode2 = - TA_POLYMODE2_BLEND_SRC_ALPHA|TA_POLYMODE2_BLEND_DST_INVALPHA| - TA_POLYMODE2_FOG_DISABLED|TA_POLYMODE2_ENABLE_ALPHA; + TA_POLYMODE2_BLEND_SRC_ALPHA|TA_POLYMODE2_BLEND_DST_INVALPHA| + TA_POLYMODE2_FOG_DISABLED|TA_POLYMODE2_ENABLE_ALPHA; mypoly.texture = 0; mypoly.red = mypoly.green = mypoly.blue = mypoly.alpha = 0; @@ -165,15 +165,15 @@ static bool loadIcon(Game &game, Dir *dirs, int num_dirs) char icofn[520]; sprintf(icofn, "%s%s.ICO", game.dir, game.filename_base); if (game.icon.load(icofn)) - return true; - for (int i=0; idir) && /*!strcmp(dir, games->dir) &&*/ !scumm_stricmp(base, games->filename_base) && lang == games->language && plf == games->platform) - return false; - else - games++; + return false; + else + games++; return true; } @@ -216,23 +216,23 @@ static int findGames(Game *games, int max, bool use_ini) int curr_game = 0, curr_dir = 0, num_dirs = 0; if (use_ini) { - ConfMan.loadDefaultConfigFile(); - const Common::ConfigManager::DomainMap &game_domains = ConfMan.getGameDomains(); - for(Common::ConfigManager::DomainMap::const_iterator i = + ConfMan.loadDefaultConfigFile(); + const Common::ConfigManager::DomainMap &game_domains = ConfMan.getGameDomains(); + for(Common::ConfigManager::DomainMap::const_iterator i = game_domains.begin(); curr_game < max && i != game_domains.end(); i++) { - Common::String path = (*i)._value["path"]; - if (path.size() && path.lastChar() != '/') + Common::String path = (*i)._value["path"]; + if (path.size() && path.lastChar() != '/') path += "/"; - int j; - for (j=0; j= num_dirs) { + if (j >= num_dirs) { if (num_dirs >= MAX_DIR) continue; dirs[j = num_dirs++].node = Common::FSNode(path); - } - if (curr_game < max) { + } + if (curr_game < max) { strcpy(games[curr_game].filename_base, (*i)._key.c_str()); strncpy(games[curr_game].engine_id, (*i)._value["engineid"].c_str(), 256); games[curr_game].engine_id[255] = '\0'; @@ -242,24 +242,24 @@ static int findGames(Game *games, int max, bool use_ini) games[curr_game].platform = Common::kPlatformUnknown; strcpy(games[curr_game].text, (*i)._value["description"].c_str()); curr_game++; - } - } + } + } } else { - dirs[num_dirs++].node = Common::FSNode(""); + dirs[num_dirs++].node = Common::FSNode(""); } while ((curr_game < max || use_ini) && curr_dir < num_dirs) { - strncpy(dirs[curr_dir].name, dirs[curr_dir].node.getPath().c_str(), 251); - dirs[curr_dir].name[250] = '\0'; - if (!dirs[curr_dir].name[0] || + strncpy(dirs[curr_dir].name, dirs[curr_dir].node.getPath().c_str(), 251); + dirs[curr_dir].name[250] = '\0'; + if (!dirs[curr_dir].name[0] || dirs[curr_dir].name[strlen(dirs[curr_dir].name)-1] != '/') - strcat(dirs[curr_dir].name, "/"); - dirs[curr_dir].deficon[0] = '\0'; - Common::FSList files, fslist; - dirs[curr_dir++].node.getChildren(fslist, Common::FSNode::kListAll); - for (Common::FSList::const_iterator entry = fslist.begin(); entry != fslist.end(); + strcat(dirs[curr_dir].name, "/"); + dirs[curr_dir].deficon[0] = '\0'; + Common::FSList files, fslist; + dirs[curr_dir++].node.getChildren(fslist, Common::FSNode::kListAll); + for (Common::FSList::const_iterator entry = fslist.begin(); entry != fslist.end(); ++entry) { - if (entry->isDirectory()) { + if (entry->isDirectory()) { if (!use_ini && num_dirs < MAX_DIR) { dirs[num_dirs].node = *entry; num_dirs++; @@ -267,18 +267,18 @@ static int findGames(Game *games, int max, bool use_ini) /* Toonstruck detector needs directories to be present too */ if(!use_ini) files.push_back(*entry); - } else + } else if (isIcon(*entry)) strcpy(dirs[curr_dir-1].deficon, entry->getDisplayName().c_str()); else if(!use_ini) files.push_back(*entry); - } + } - if (!use_ini) { - DetectionResults detectionResults = EngineMan.detectGames(files); - DetectedGames candidates = detectionResults.listRecognizedGames(); + if (!use_ini) { + DetectionResults detectionResults = EngineMan.detectGames(files); + DetectedGames candidates = detectionResults.listRecognizedGames(); - for (DetectedGames::const_iterator ge = candidates.begin(); + for (DetectedGames::const_iterator ge = candidates.begin(); ge != candidates.end(); ++ge) if (curr_game < max) { strcpy(games[curr_game].engine_id, ge->engineId.c_str()); @@ -303,12 +303,12 @@ static int findGames(Game *games, int max, bool use_ini) curr_game++; } } - } + } } for (int i=0; i= 6) - wasopen = 1; - if (s > 0 && s < 6 && wasopen) { - cdfs_reinit(); - chdir("/"); - chdir("/"); - ta_sync(); - ta_txrelease(mark); - return; - } + int s = getCdState(); + if (s >= 6) + wasopen = 1; + if (s > 0 && s < 6 && wasopen) { + cdfs_reinit(); + chdir("/"); + chdir("/"); + ta_sync(); + ta_txrelease(mark); + return; + } - ta_begin_frame(); + ta_begin_frame(); - drawBackground(); + drawBackground(); - ta_commit_end(); + ta_commit_end(); - lab.draw(166.0, 200.0, 0xffff2020); + lab.draw(166.0, 200.0, 0xffff2020); - ta_commit_frame(); + ta_commit_frame(); - int mousex = 0, mousey = 0; - byte shiftFlags; + int mousex = 0, mousey = 0; + byte shiftFlags; - int mask = getimask(); - setimask(15); - handleInput(locked_get_pads(), mousex, mousey, shiftFlags); - setimask(mask); + int mask = getimask(); + setimask(15); + handleInput(locked_get_pads(), mousex, mousey, shiftFlags); + setimask(mask); } } @@ -383,47 +383,47 @@ int gameMenu(Game *games, int num_games) float y; if (!num_games) - return -1; + return -1; for (;;) { - if (getCdState()>=6) - return -1; + if (getCdState()>=6) + return -1; - ta_begin_frame(); + ta_begin_frame(); - drawBackground(); + drawBackground(); - ta_commit_end(); + ta_commit_end(); - y = 40.0; - for (int i=top_game, cnt=0; cnt<10 && i=16) { - if (selector_pos + top_game + 1 < num_games) + if (mousey>=16) { + if (selector_pos + top_game + 1 < num_games) if (++selector_pos >= 10) { --selector_pos; ++top_game; } - mousey -= 16; - } else if (mousey<=-16) { - if (selector_pos + top_game > 0) + mousey -= 16; + } else if (mousey<=-16) { + if (selector_pos + top_game > 0) if (--selector_pos < 0) { ++selector_pos; --top_game; } - mousey += 16; - } + mousey += 16; + } } } @@ -478,50 +478,50 @@ bool selectGame(char *&engineId, char *&ret, char *&dir_ret, Common::Language &l void *mark = ta_txmark(); for (;;) { - num_games = findGames(games, MAX_GAMES, true); - if (!num_games) - num_games = findGames(games, MAX_GAMES, false); + num_games = findGames(games, MAX_GAMES, true); + if (!num_games) + num_games = findGames(games, MAX_GAMES, false); - for (int i=0; i= num_games) - selected = -1; + selected = -1; if (selected >= 0) - the_game = games[selected]; + the_game = games[selected]; delete[] games; if (selected>=0) { #if 0 - chdir(the_game.dir); + chdir(the_game.dir); #else - chdir("/"); - dir_ret = the_game.dir; + chdir("/"); + dir_ret = the_game.dir; #endif - engineId = the_game.engine_id; - ret = the_game.filename_base; - lang_ret = the_game.language; - plf_ret = the_game.platform; - icon = the_game.icon; - return true; + engineId = the_game.engine_id; + ret = the_game.filename_base; + lang_ret = the_game.language; + plf_ret = the_game.platform; + icon = the_game.icon; + return true; } else - return false; + return false; } #ifdef DYNAMIC_MODULES @@ -531,15 +531,15 @@ static int findPluginDirs(Game *plugin_dirs, int max, const Common::FSNode &base int curr_dir = 0; base.getChildren(fslist, Common::FSNode::kListDirectoriesOnly); for (Common::FSList::const_iterator entry = fslist.begin(); entry != fslist.end(); - ++entry) { - if (entry->isDirectory()) { - if (curr_dir >= max) + ++entry) { + if (entry->isDirectory()) { + if (curr_dir >= max) break; - strncpy(plugin_dirs[curr_dir].dir, (*entry).getPath().c_str(), 256); - strncpy(plugin_dirs[curr_dir].text, (*entry).getDisplayName().c_str(), 256); - plugin_dirs[curr_dir].icon.load(NULL, 0, 0); - curr_dir++; - } + strncpy(plugin_dirs[curr_dir].dir, (*entry).getPath().c_str(), 256); + strncpy(plugin_dirs[curr_dir].text, (*entry).getDisplayName().c_str(), 256); + plugin_dirs[curr_dir].icon.load(NULL, 0, 0); + curr_dir++; + } } return curr_dir; } @@ -555,8 +555,8 @@ bool selectPluginDir(Common::String &selection, const Common::FSNode &base) num_plugin_dirs = findPluginDirs(plugin_dirs, MAX_PLUGIN_DIRS, base); for (int i=0; i= num_plugin_dirs) - selected = -1; + selected = -1; if (selected >= 0) - selection = plugin_dirs[selected].dir; + selection = plugin_dirs[selected].dir; delete[] plugin_dirs; diff --git a/backends/platform/dc/softkbd.cpp b/backends/platform/dc/softkbd.cpp index 19f7b409a12..7aa1e889f7a 100644 --- a/backends/platform/dc/softkbd.cpp +++ b/backends/platform/dc/softkbd.cpp @@ -48,16 +48,16 @@ static const char key_names[] = static const short key_codes[] = { - Common::KEYCODE_ESCAPE, Common::KEYCODE_F1, Common::KEYCODE_F2, Common::KEYCODE_F3, Common::KEYCODE_F4, Common::KEYCODE_F5, Common::KEYCODE_F6, Common::KEYCODE_F7, Common::KEYCODE_F8, Common::KEYCODE_F9, Common::KEYCODE_F10, - K('1','!'), K('2','"'), K('3','#'), K('4','$'), K('5','%'), - K('6','&'), K('7','\''), K('8','('), K('9',')'), K('0','~'), K('-','='), - K('q','Q'), K('w','W'), K('e','E'), K('r','R'), K('t','T'), - K('y','Y'), K('u','U'), K('i','I'), K('o','O'), K('p','P'), K('@','`'), - K('a','A'), K('s','S'), K('d','D'), K('f','F'), K('g','G'), - K('h','H'), K('j','J'), K('k','K'), K('l','L'), K(';','+'), K(':','*'), - K('z','Z'), K('x','X'), K('c','C'), K('v','V'), K('b','B'), - K('n','N'), K('m','M'), K(',','<'), K('.','>'), K('/','?'), K('\\','_'), - ~Common::KBD_SHIFT, ~Common::KBD_CTRL, ~Common::KBD_ALT, ' ', Common::KEYCODE_BACKSPACE, Common::KEYCODE_RETURN + Common::KEYCODE_ESCAPE, Common::KEYCODE_F1, Common::KEYCODE_F2, Common::KEYCODE_F3, Common::KEYCODE_F4, Common::KEYCODE_F5, Common::KEYCODE_F6, Common::KEYCODE_F7, Common::KEYCODE_F8, Common::KEYCODE_F9, Common::KEYCODE_F10, + K('1','!'), K('2','"'), K('3','#'), K('4','$'), K('5','%'), + K('6','&'), K('7','\''), K('8','('), K('9',')'), K('0','~'), K('-','='), + K('q','Q'), K('w','W'), K('e','E'), K('r','R'), K('t','T'), + K('y','Y'), K('u','U'), K('i','I'), K('o','O'), K('p','P'), K('@','`'), + K('a','A'), K('s','S'), K('d','D'), K('f','F'), K('g','G'), + K('h','H'), K('j','J'), K('k','K'), K('l','L'), K(';','+'), K(':','*'), + K('z','Z'), K('x','X'), K('c','C'), K('v','V'), K('b','B'), + K('n','N'), K('m','M'), K(',','<'), K('.','>'), K('/','?'), K('\\','_'), + ~Common::KBD_SHIFT, ~Common::KBD_CTRL, ~Common::KBD_ALT, ' ', Common::KEYCODE_BACKSPACE, Common::KEYCODE_RETURN }; SoftKeyboard::SoftKeyboard(const OSystem_Dreamcast *_os) @@ -67,12 +67,12 @@ SoftKeyboard::SoftKeyboard(const OSystem_Dreamcast *_os) const char *np = key_names; for (int i=0; i8192) { - labels[1][i].create_texture(np); - np += strlen(np)+1; - } + labels[0][i].create_texture(np); + np += strlen(np)+1; + if (key_codes[i]>8192) { + labels[1][i].create_texture(np); + np += strlen(np)+1; + } } } @@ -89,22 +89,22 @@ void SoftKeyboard::draw(float x, float y, int transp) x0 = x += 4.0; y += 4.0; for (int i=0; i8192 && (shiftState & Common::KBD_SHIFT)) - labels[1][i].draw(x+2, y+5, txt_alpha_mask|0x000000, 0.5); - else - labels[0][i].draw(x+2, y+5, txt_alpha_mask|0x000000, 0.5); - x += w+4.0; - if (++c == 11) { - c = 0; - x = x0; - y += 28.0; - } + draw_trans_quad(x, y, x+w, y+24.0, bg, bg, bg, bg); + if (key_codes[i]<0 && (shiftState & ~key_codes[i])) + labels[0][i].draw(x+2, y+5, txt_alpha_mask|0xffffff, 0.5); + else if (key_codes[i]>8192 && (shiftState & Common::KBD_SHIFT)) + labels[1][i].draw(x+2, y+5, txt_alpha_mask|0x000000, 0.5); + else + labels[0][i].draw(x+2, y+5, txt_alpha_mask|0x000000, 0.5); + x += w+4.0; + if (++c == 11) { + c = 0; + x = x0; + y += 28.0; + } } } @@ -112,47 +112,47 @@ int SoftKeyboard::key(int k, byte &shiftFlags) { switch(k) { case 1001: - if (++keySel == SK_NUM_KEYS) - keySel = 0; - break; + if (++keySel == SK_NUM_KEYS) + keySel = 0; + break; case 1002: - if (--keySel < 0) - keySel = SK_NUM_KEYS - 1; - break; + if (--keySel < 0) + keySel = SK_NUM_KEYS - 1; + break; case 1003: - if (keySel >= 55) { - if (keySel > 58) + if (keySel >= 55) { + if (keySel > 58) keySel += 5; - keySel -= 55; - } else if (keySel > 47) { - if ((keySel += 6) < 59) + keySel -= 55; + } else if (keySel > 47) { + if ((keySel += 6) < 59) keySel = 59; - } else - keySel += 11; - break; + } else + keySel += 11; + break; case 1004: - if (keySel > 58) - keySel -= 6; - else if ((keySel -= 11) < 0) - if ((keySel += 66) > 58) + if (keySel > 58) + keySel -= 6; + else if ((keySel -= 11) < 0) + if ((keySel += 66) > 58) if ((keySel -= 5) < 59) keySel = 59; - break; + break; case 1000: case 13: case 32: case 319: - if (key_codes[keySel]<0) - shiftState ^= ~key_codes[keySel]; - else { - shiftFlags = shiftState; - if (key_codes[keySel] > 8192) + if (key_codes[keySel]<0) + shiftState ^= ~key_codes[keySel]; + else { + shiftFlags = shiftState; + if (key_codes[keySel] > 8192) return ((shiftState & Common::KBD_SHIFT)? (key_codes[keySel]>>8): key_codes[keySel]) & 0xff; - else + else return key_codes[keySel]; - } - break; + } + break; } return 0; } @@ -161,8 +161,8 @@ void SoftKeyboard::mouse(int x, int y) { os->mouseToSoftKbd(x, y, x, y); if (x >= 0 && x < 11*28 && y >= 0 && y < 6*28 && - x%28 >= 4 && y%28 >= 4) - if ((keySel = 11*(y/28)+(x/28)) > 58) - if ((keySel -= 5) < 59) + x%28 >= 4 && y%28 >= 4) + if ((keySel = 11*(y/28)+(x/28)) > 58) + if ((keySel -= 5) < 59) keySel = 58; } diff --git a/backends/platform/dc/time.cpp b/backends/platform/dc/time.cpp index ada53bf7555..2520e6596d6 100644 --- a/backends/platform/dc/time.cpp +++ b/backends/platform/dc/time.cpp @@ -48,9 +48,9 @@ void OSystem_Dreamcast::delayMillis(uint msecs) unsigned int t, start = Timer(); int time = (((unsigned int)msecs)*3125U)>>6; while (((int)((t = Timer())-start))handler(); - checkSound(); + if (_timerManager != NULL) + ((DefaultTimerManager *)_timerManager)->handler(); + checkSound(); } getMillis(); } diff --git a/backends/platform/dc/vmsave.cpp b/backends/platform/dc/vmsave.cpp index c10144d41cf..06934fc62e5 100644 --- a/backends/platform/dc/vmsave.cpp +++ b/backends/platform/dc/vmsave.cpp @@ -52,20 +52,20 @@ static void displaySaveResult(vmsaveResult res) switch(res) { case VMSAVE_OK: - sprintf(buf, "Game saved on unit %c%d", 'A'+(lastvm/6), lastvm%6); - break; + sprintf(buf, "Game saved on unit %c%d", 'A'+(lastvm/6), lastvm%6); + break; case VMSAVE_NOVM: - strcpy(buf, "No memory card present!"); - break; + strcpy(buf, "No memory card present!"); + break; case VMSAVE_NOSPACE: - strcpy(buf, "Not enough space available!"); - break; + strcpy(buf, "Not enough space available!"); + break; case VMSAVE_WRITEERROR: - strcpy(buf, "Write error!!!"); - break; + strcpy(buf, "Write error!!!"); + break; default: - strcpy(buf, "Unknown error!!!"); - break; + strcpy(buf, "Unknown error!!!"); + break; } GUI::MessageDialog dialog(buf); @@ -85,14 +85,14 @@ static vmsaveResult trySave(const char *gamename, const char *data, int size, unsigned char iconbuffer[512+32]; if (!vmsfs_check_unit(vm, 0, &info)) - return VMSAVE_NOVM; + return VMSAVE_NOVM; if (!vmsfs_get_superblock(&info, &super)) - return VMSAVE_NOVM; + return VMSAVE_NOVM; int free_cnt = vmsfs_count_free(&super); if (vmsfs_open_file(&super, filename, &file)) - free_cnt += file.blks; + free_cnt += file.blks; if (((128+512+size+511)>>9) > free_cnt) - return VMSAVE_NOSPACE; + return VMSAVE_NOSPACE; memset(&header, 0, sizeof(header)); strncpy(header.shortdesc, "ScummVM savegame", 16); @@ -117,9 +117,9 @@ static vmsaveResult trySave(const char *gamename, const char *data, int size, if (!vmsfs_create_file(&super, filename, &header, iconbuffer+sizeof(header.palette), NULL, data, size, &tstamp)) { - fprintf(stderr, "%s\n", vmsfs_describe_error()); - vmsfs_beep(&info, 0); - return VMSAVE_WRITEERROR; + fprintf(stderr, "%s\n", vmsfs_describe_error()); + vmsfs_beep(&info, 0); + return VMSAVE_WRITEERROR; } vmsfs_beep(&info, 0); @@ -133,16 +133,16 @@ static bool tryLoad(char *&buffer, int &size, const char *filename, int vm) struct vms_file file; if (!vmsfs_check_unit(vm, 0, &info)) - return false; + return false; if (!vmsfs_get_superblock(&info, &super)) - return false; + return false; if (!vmsfs_open_file(&super, filename, &file)) - return false; + return false; buffer = new char[size = file.size]; if (vmsfs_read_file(&file, (unsigned char *)buffer, size)) - return true; + return true; delete[] buffer; buffer = NULL; @@ -155,12 +155,12 @@ static bool tryDelete(const char *filename, int vm) struct superblock super; if (!vmsfs_check_unit(vm, 0, &info)) - return false; + return false; if (!vmsfs_get_superblock(&info, &super)) - return false; + return false; if (!vmsfs_delete_file(&super, filename)) - return false; + return false; return true; } @@ -173,18 +173,18 @@ static void tryList(const Common::String &glob, int vm, Common::StringArray &lis struct dir_entry de; if (!vmsfs_check_unit(vm, 0, &info)) - return; + return; if (!vmsfs_get_superblock(&info, &super)) - return; + return; vmsfs_open_dir(&super, &iter); while (vmsfs_next_dir_entry(&iter, &de)) - if (de.entry[0]) { - char buf[16]; - strncpy(buf, (char *)de.entry+4, 12); - buf[12] = 0; - if (Common::matchString(buf, glob.c_str())) + if (de.entry[0]) { + char buf[16]; + strncpy(buf, (char *)de.entry+4, 12); + buf[12] = 0; + if (Common::matchString(buf, glob.c_str())) list.push_back(buf); - } + } } vmsaveResult writeSaveGame(const char *gamename, const char *data, int size, @@ -193,15 +193,15 @@ vmsaveResult writeSaveGame(const char *gamename, const char *data, int size, vmsaveResult r, res = VMSAVE_NOVM; if (lastvm >= 0 && - (res = trySave(gamename, data, size, filename, icon, lastvm)) == VMSAVE_OK) - return res; + (res = trySave(gamename, data, size, filename, icon, lastvm)) == VMSAVE_OK) + return res; for (int i=0; i<24; i++) - if ((r = trySave(gamename, data, size, filename, icon, i)) == VMSAVE_OK) { - lastvm = i; - return r; - } else if (r > res) - res = r; + if ((r = trySave(gamename, data, size, filename, icon, i)) == VMSAVE_OK) { + lastvm = i; + return r; + } else if (r > res) + res = r; return res; } @@ -209,14 +209,14 @@ vmsaveResult writeSaveGame(const char *gamename, const char *data, int size, bool readSaveGame(char *&buffer, int &size, const char *filename) { if (lastvm >= 0 && - tryLoad(buffer, size, filename, lastvm)) - return true; + tryLoad(buffer, size, filename, lastvm)) + return true; for (int i=0; i<24; i++) - if (tryLoad(buffer, size, filename, i)) { - lastvm = i; - return true; - } + if (tryLoad(buffer, size, filename, i)) { + lastvm = i; + return true; + } return false; } @@ -224,14 +224,14 @@ bool readSaveGame(char *&buffer, int &size, const char *filename) bool deleteSaveGame(const char *filename) { if (lastvm >= 0 && - tryDelete(filename, lastvm)) - return true; + tryDelete(filename, lastvm)) + return true; for (int i=0; i<24; i++) - if (tryDelete(filename, i)) { - lastvm = i; - return true; - } + if (tryDelete(filename, i)) { + lastvm = i; + return true; + } return false; } @@ -249,12 +249,12 @@ private: public: InVMSave() - : _pos(0), buffer(NULL), _eos(false) + : _pos(0), buffer(NULL), _eos(false) { } ~InVMSave() { - delete[] buffer; + delete[] buffer; } bool eos() const override { return _eos; } @@ -278,10 +278,10 @@ public: virtual int32 pos() const { return _pos; } OutVMSave(const char *_filename) - : _pos(0), committed(-1), iofailed(false) + : _pos(0), committed(-1), iofailed(false) { - strncpy(filename, _filename, 16); - buffer = new char[size = MAX_SAVE_SIZE]; + strncpy(filename, _filename, 16); + buffer = new char[size = MAX_SAVE_SIZE]; } ~OutVMSave(); @@ -344,7 +344,7 @@ void OutVMSave::finalize() extern Icon icon; if (committed >= _pos) - return; + return; char *data = buffer; int len = _pos; @@ -352,7 +352,7 @@ void OutVMSave::finalize() vmsaveResult r = writeSaveGame(gGameName, data, len, filename, icon); committed = _pos; if (r != VMSAVE_OK) - iofailed = true; + iofailed = true; displaySaveResult(r); } @@ -366,12 +366,12 @@ uint32 InVMSave::read(void *buf, uint32 cnt) { int nbyt = cnt; if (_pos + nbyt > _size) { - cnt = (_size - _pos); - _eos = true; - nbyt = cnt; + cnt = (_size - _pos); + _eos = true; + nbyt = cnt; } if (nbyt) - memcpy(buf, buffer + _pos, nbyt); + memcpy(buf, buffer + _pos, nbyt); _pos += nbyt; return cnt; } @@ -380,7 +380,7 @@ bool InVMSave::skip(uint32 offset) { int nbyt = offset; if (_pos + nbyt > _size) - nbyt = (_size - _pos); + nbyt = (_size - _pos); _pos += nbyt; return true; } @@ -389,19 +389,19 @@ bool InVMSave::seek(int32 offs, int whence) { switch(whence) { case SEEK_SET: - _pos = offs; - break; + _pos = offs; + break; case SEEK_CUR: - _pos += offs; - break; + _pos += offs; + break; case SEEK_END: - _pos = _size + offs; - break; + _pos = _size + offs; + break; } if (_pos < 0) - _pos = 0; + _pos = 0; else if (_pos > _size) - _pos = _size; + _pos = _size; _eos = false; return true; } @@ -410,11 +410,11 @@ uint32 OutVMSave::write(const void *buf, uint32 cnt) { int nbyt = cnt; if (_pos + nbyt > size) { - cnt = (size - _pos); - nbyt = cnt; + cnt = (size - _pos); + nbyt = cnt; } if (nbyt) - memcpy(buffer + _pos, buf, nbyt); + memcpy(buffer + _pos, buf, nbyt); _pos += nbyt; return cnt; } @@ -425,7 +425,7 @@ Common::StringArray VMSaveManager::listSavefiles(const Common::String &pattern) Common::StringArray list; for (int i=0; i<24; i++) - tryList(pattern, i, list); + tryList(pattern, i, list); return list; } diff --git a/backends/platform/ds/background.cpp b/backends/platform/ds/background.cpp index 155a21ac417..f4e5730f59f 100644 --- a/backends/platform/ds/background.cpp +++ b/backends/platform/ds/background.cpp @@ -158,7 +158,7 @@ void Background::init(Background *surface, int layer, bool isSub, int mapBase, b } static void dmaBlit(uint16 *dst, const uint dstPitch, const uint16 *src, const uint srcPitch, - const uint w, const uint h, const uint bytesPerPixel) { + const uint w, const uint h, const uint bytesPerPixel) { if (dstPitch == srcPitch && ((w * bytesPerPixel) == dstPitch)) { dmaCopy(src, dst, dstPitch * h); return; diff --git a/backends/platform/ds/osystem_ds.cpp b/backends/platform/ds/osystem_ds.cpp index 4a958e4b32a..ce96045db77 100644 --- a/backends/platform/ds/osystem_ds.cpp +++ b/backends/platform/ds/osystem_ds.cpp @@ -137,28 +137,28 @@ void OSystem_DS::logMessage(LogMessageType::Type type, const char *message) { } static const Common::HardwareInputTableEntry ndsJoystickButtons[] = { - { "JOY_A", Common::JOYSTICK_BUTTON_A, _s("A") }, - { "JOY_B", Common::JOYSTICK_BUTTON_B, _s("B") }, - { "JOY_X", Common::JOYSTICK_BUTTON_X, _s("X") }, - { "JOY_Y", Common::JOYSTICK_BUTTON_Y, _s("Y") }, - { "JOY_BACK", Common::JOYSTICK_BUTTON_BACK, _s("Select") }, - { "JOY_START", Common::JOYSTICK_BUTTON_START, _s("Start") }, - { "JOY_LEFT_SHOULDER", Common::JOYSTICK_BUTTON_LEFT_SHOULDER, _s("L") }, - { "JOY_RIGHT_SHOULDER", Common::JOYSTICK_BUTTON_RIGHT_SHOULDER, _s("R") }, - { "JOY_UP", Common::JOYSTICK_BUTTON_DPAD_UP, _s("D-pad Up") }, - { "JOY_DOWN", Common::JOYSTICK_BUTTON_DPAD_DOWN, _s("D-pad Down") }, - { "JOY_LEFT", Common::JOYSTICK_BUTTON_DPAD_LEFT, _s("D-pad Left") }, - { "JOY_RIGHT", Common::JOYSTICK_BUTTON_DPAD_RIGHT, _s("D-pad Right") }, - { nullptr, 0, nullptr } + { "JOY_A", Common::JOYSTICK_BUTTON_A, _s("A") }, + { "JOY_B", Common::JOYSTICK_BUTTON_B, _s("B") }, + { "JOY_X", Common::JOYSTICK_BUTTON_X, _s("X") }, + { "JOY_Y", Common::JOYSTICK_BUTTON_Y, _s("Y") }, + { "JOY_BACK", Common::JOYSTICK_BUTTON_BACK, _s("Select") }, + { "JOY_START", Common::JOYSTICK_BUTTON_START, _s("Start") }, + { "JOY_LEFT_SHOULDER", Common::JOYSTICK_BUTTON_LEFT_SHOULDER, _s("L") }, + { "JOY_RIGHT_SHOULDER", Common::JOYSTICK_BUTTON_RIGHT_SHOULDER, _s("R") }, + { "JOY_UP", Common::JOYSTICK_BUTTON_DPAD_UP, _s("D-pad Up") }, + { "JOY_DOWN", Common::JOYSTICK_BUTTON_DPAD_DOWN, _s("D-pad Down") }, + { "JOY_LEFT", Common::JOYSTICK_BUTTON_DPAD_LEFT, _s("D-pad Left") }, + { "JOY_RIGHT", Common::JOYSTICK_BUTTON_DPAD_RIGHT, _s("D-pad Right") }, + { nullptr, 0, nullptr } }; static const Common::AxisTableEntry ndsJoystickAxes[] = { - { nullptr, 0, Common::kAxisTypeFull, nullptr } + { nullptr, 0, Common::kAxisTypeFull, nullptr } }; const Common::HardwareInputTableEntry ndsMouseButtons[] = { - { "MOUSE_LEFT", Common::MOUSE_BUTTON_LEFT, _s("Touch") }, - { nullptr, 0, nullptr } + { "MOUSE_LEFT", Common::MOUSE_BUTTON_LEFT, _s("Touch") }, + { nullptr, 0, nullptr } }; Common::HardwareInputSet *OSystem_DS::getHardwareInputSet() { diff --git a/backends/platform/ios7/ios7_osys_main.h b/backends/platform/ios7/ios7_osys_main.h index fc100ace184..73fec9d1844 100644 --- a/backends/platform/ios7/ios7_osys_main.h +++ b/backends/platform/ios7/ios7_osys_main.h @@ -139,7 +139,7 @@ public: virtual int16 getHeight() override; virtual int16 getWidth() override; - bool touchpadModeEnabled() const; + bool touchpadModeEnabled() const; #ifdef USE_RGB_COLOR virtual Graphics::PixelFormat getScreenFormat() const override { return _framebuffer.format; } diff --git a/backends/platform/psp/mp3.cpp b/backends/platform/psp/mp3.cpp index 9e55fc72f5b..1bde7cce311 100644 --- a/backends/platform/psp/mp3.cpp +++ b/backends/platform/psp/mp3.cpp @@ -97,20 +97,20 @@ bool Mp3PspStream::initDecoder() { // Based on PSP firmware version, we need to do different things to do Media Engine processing uint32 firmware = sceKernelDevkitVersion(); PSP_DEBUG_PRINT("Firmware version 0x%x\n", firmware); - if (firmware == 0x01050001){ + if (firmware == 0x01050001){ if (!loadStartAudioModule("flash0:/kd/me_for_vsh.prx", PSP_MEMORY_PARTITION_KERNEL)) { PSP_ERROR("failed to load me_for_vsh.prx. ME cannot start.\n"); _decoderFail = true; return false; } - if (!loadStartAudioModule("flash0:/kd/audiocodec.prx", PSP_MEMORY_PARTITION_KERNEL)) { + if (!loadStartAudioModule("flash0:/kd/audiocodec.prx", PSP_MEMORY_PARTITION_KERNEL)) { PSP_ERROR("failed to load audiocodec.prx. ME cannot start.\n"); _decoderFail = true; return false; } - } else { - if (sceUtilityLoadAvModule(PSP_AV_MODULE_AVCODEC) < 0) { + } else { + if (sceUtilityLoadAvModule(PSP_AV_MODULE_AVCODEC) < 0) { PSP_ERROR("failed to load AVCODEC module. ME cannot start.\n"); _decoderFail = true; return false; @@ -130,15 +130,15 @@ bool Mp3PspStream::stopDecoder() { return true; // Based on PSP firmware version, we need to do different things to do Media Engine processing - if (sceKernelDevkitVersion() == 0x01050001){ // TODO: how do we unload? + if (sceKernelDevkitVersion() == 0x01050001){ // TODO: how do we unload? /* if (!unloadAudioModule("flash0:/kd/me_for_vsh.prx", PSP_MEMORY_PARTITION_KERNEL) || !unloadAudioModule("flash0:/kd/audiocodec.prx", PSP_MEMORY_PARTITION_KERNEL) { PSP_ERROR("failed to unload audio module\n"); return false; } */ - }else{ - if (sceUtilityUnloadModule(PSP_MODULE_AV_AVCODEC) < 0) { + }else{ + if (sceUtilityUnloadModule(PSP_MODULE_AV_AVCODEC) < 0) { PSP_ERROR("failed to unload avcodec module\n"); return false; } @@ -152,26 +152,26 @@ bool Mp3PspStream::stopDecoder() { bool Mp3PspStream::loadStartAudioModule(const char *modname, int partition){ DEBUG_ENTER_FUNC(); - SceKernelLMOption option; - SceUID modid; + SceKernelLMOption option; + SceUID modid; - memset(&option, 0, sizeof(option)); - option.size = sizeof(option); - option.mpidtext = partition; - option.mpiddata = partition; - option.position = 0; - option.access = 1; + memset(&option, 0, sizeof(option)); + option.size = sizeof(option); + option.mpidtext = partition; + option.mpiddata = partition; + option.position = 0; + option.access = 1; - modid = sceKernelLoadModule(modname, 0, &option); - if (modid < 0) { + modid = sceKernelLoadModule(modname, 0, &option); + if (modid < 0) { PSP_ERROR("Failed to load module %s. Got error 0x%x\n", modname, modid); - return false; + return false; } - int ret = sceKernelStartModule(modid, 0, NULL, NULL, NULL); + int ret = sceKernelStartModule(modid, 0, NULL, NULL, NULL); if (ret < 0) { PSP_ERROR("Failed to start module %s. Got error 0x%x\n", modname, ret); - return false; + return false; } return true; } diff --git a/backends/platform/psp/psppixelformat.cpp b/backends/platform/psp/psppixelformat.cpp index 83f5935eee7..72302b4d9fb 100644 --- a/backends/platform/psp/psppixelformat.cpp +++ b/backends/platform/psp/psppixelformat.cpp @@ -67,9 +67,9 @@ void PSPPixelFormat::set(Type type, bool swap /* = false */) { // Convert from ScummVM general PixelFormat to our pixel format // For buffer and palette. void PSPPixelFormat::convertFromScummvmPixelFormat(const Graphics::PixelFormat *pf, - PSPPixelFormat::Type &bufferType, - PSPPixelFormat::Type &paletteType, - bool &swapRedBlue) { + PSPPixelFormat::Type &bufferType, + PSPPixelFormat::Type &paletteType, + bool &swapRedBlue) { swapRedBlue = false; // no red-blue swap by default PSPPixelFormat::Type *target = 0; // which one we'll be filling diff --git a/backends/platform/psp/thread.cpp b/backends/platform/psp/thread.cpp index 669a682c21b..22d294e05a3 100644 --- a/backends/platform/psp/thread.cpp +++ b/backends/platform/psp/thread.cpp @@ -193,38 +193,38 @@ bool PspMutex::unlock() { // Release all threads waiting on the condition void PspCondition::releaseAll() { - _mutex.lock(); - if (_waitingThreads > _signaledThreads) { // we have signals to issue - int numWaiting = _waitingThreads - _signaledThreads; // threads we haven't signaled - _signaledThreads = _waitingThreads; + _mutex.lock(); + if (_waitingThreads > _signaledThreads) { // we have signals to issue + int numWaiting = _waitingThreads - _signaledThreads; // threads we haven't signaled + _signaledThreads = _waitingThreads; _waitSem.give(numWaiting); - _mutex.unlock(); - for (int i=0; i 0 ) { - _doneSem.give(); // let the thread know - _signaledThreads--; - } - _waitingThreads--; - _mutex.unlock(); + if (_signaledThreads > 0 ) { + _doneSem.give(); // let the thread know + _signaledThreads--; + } + _waitingThreads--; + _mutex.unlock(); - externalMutex.lock(); // must lock external mutex here for continuation + externalMutex.lock(); // must lock external mutex here for continuation } diff --git a/backends/platform/psp/trace.h b/backends/platform/psp/trace.h index 43ccaea52af..6115c39bd13 100644 --- a/backends/platform/psp/trace.h +++ b/backends/platform/psp/trace.h @@ -60,13 +60,13 @@ extern int psp_debug_indent; // class PSPStackDebugFuncs { - Common::String _name; + Common::String _name; public: PSPStackDebugFuncs(const char *name) : _name(name) { PSP_INFO_PRINT_INDENT("++ %s\n", _name.c_str()); psp_debug_indent++; - } + } ~PSPStackDebugFuncs() { psp_debug_indent--; diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp index 331e56e54d7..793473c5a6a 100644 --- a/backends/platform/sdl/macosx/macosx.cpp +++ b/backends/platform/sdl/macosx/macosx.cpp @@ -150,9 +150,9 @@ bool OSystem_MacOSX::displayLogFile() { if (_logFilePath.empty()) return false; - CFURLRef url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (const UInt8 *)_logFilePath.c_str(), _logFilePath.size(), false); - OSStatus err = LSOpenCFURLRef(url, NULL); - CFRelease(url); + CFURLRef url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (const UInt8 *)_logFilePath.c_str(), _logFilePath.size(), false); + OSStatus err = LSOpenCFURLRef(url, NULL); + CFRelease(url); return err != noErr; } diff --git a/backends/platform/sdl/ps3/ps3.cpp b/backends/platform/sdl/ps3/ps3.cpp index 1243508affb..2dd4788f334 100644 --- a/backends/platform/sdl/ps3/ps3.cpp +++ b/backends/platform/sdl/ps3/ps3.cpp @@ -38,32 +38,32 @@ #include static const Common::HardwareInputTableEntry playstationJoystickButtons[] = { - { "JOY_A", Common::JOYSTICK_BUTTON_A, _s("Cross") }, - { "JOY_B", Common::JOYSTICK_BUTTON_B, _s("Circle") }, - { "JOY_X", Common::JOYSTICK_BUTTON_X, _s("Square") }, - { "JOY_Y", Common::JOYSTICK_BUTTON_Y, _s("Triangle") }, - { "JOY_BACK", Common::JOYSTICK_BUTTON_BACK, _s("Select") }, - { "JOY_GUIDE", Common::JOYSTICK_BUTTON_GUIDE, _s("PS") }, - { "JOY_START", Common::JOYSTICK_BUTTON_START, _s("Start") }, - { "JOY_LEFT_STICK", Common::JOYSTICK_BUTTON_LEFT_STICK, _s("L3") }, - { "JOY_RIGHT_STICK", Common::JOYSTICK_BUTTON_RIGHT_STICK, _s("R3") }, - { "JOY_LEFT_SHOULDER", Common::JOYSTICK_BUTTON_LEFT_SHOULDER, _s("L1") }, - { "JOY_RIGHT_SHOULDER", Common::JOYSTICK_BUTTON_RIGHT_SHOULDER, _s("R1") }, - { "JOY_UP", Common::JOYSTICK_BUTTON_DPAD_UP, _s("D-pad Up") }, - { "JOY_DOWN", Common::JOYSTICK_BUTTON_DPAD_DOWN, _s("D-pad Down") }, - { "JOY_LEFT", Common::JOYSTICK_BUTTON_DPAD_LEFT, _s("D-pad Left") }, - { "JOY_RIGHT", Common::JOYSTICK_BUTTON_DPAD_RIGHT, _s("D-pad Right") }, - { nullptr, 0, nullptr } + { "JOY_A", Common::JOYSTICK_BUTTON_A, _s("Cross") }, + { "JOY_B", Common::JOYSTICK_BUTTON_B, _s("Circle") }, + { "JOY_X", Common::JOYSTICK_BUTTON_X, _s("Square") }, + { "JOY_Y", Common::JOYSTICK_BUTTON_Y, _s("Triangle") }, + { "JOY_BACK", Common::JOYSTICK_BUTTON_BACK, _s("Select") }, + { "JOY_GUIDE", Common::JOYSTICK_BUTTON_GUIDE, _s("PS") }, + { "JOY_START", Common::JOYSTICK_BUTTON_START, _s("Start") }, + { "JOY_LEFT_STICK", Common::JOYSTICK_BUTTON_LEFT_STICK, _s("L3") }, + { "JOY_RIGHT_STICK", Common::JOYSTICK_BUTTON_RIGHT_STICK, _s("R3") }, + { "JOY_LEFT_SHOULDER", Common::JOYSTICK_BUTTON_LEFT_SHOULDER, _s("L1") }, + { "JOY_RIGHT_SHOULDER", Common::JOYSTICK_BUTTON_RIGHT_SHOULDER, _s("R1") }, + { "JOY_UP", Common::JOYSTICK_BUTTON_DPAD_UP, _s("D-pad Up") }, + { "JOY_DOWN", Common::JOYSTICK_BUTTON_DPAD_DOWN, _s("D-pad Down") }, + { "JOY_LEFT", Common::JOYSTICK_BUTTON_DPAD_LEFT, _s("D-pad Left") }, + { "JOY_RIGHT", Common::JOYSTICK_BUTTON_DPAD_RIGHT, _s("D-pad Right") }, + { nullptr, 0, nullptr } }; static const Common::AxisTableEntry playstationJoystickAxes[] = { - { "JOY_LEFT_TRIGGER", Common::JOYSTICK_AXIS_LEFT_TRIGGER, Common::kAxisTypeHalf, _s("L2") }, - { "JOY_RIGHT_TRIGGER", Common::JOYSTICK_AXIS_RIGHT_TRIGGER, Common::kAxisTypeHalf, _s("R2") }, - { "JOY_LEFT_STICK_X", Common::JOYSTICK_AXIS_LEFT_STICK_X, Common::kAxisTypeFull, _s("Left Stick X") }, - { "JOY_LEFT_STICK_Y", Common::JOYSTICK_AXIS_LEFT_STICK_Y, Common::kAxisTypeFull, _s("Left Stick Y") }, - { "JOY_RIGHT_STICK_X", Common::JOYSTICK_AXIS_RIGHT_STICK_X, Common::kAxisTypeFull, _s("Right Stick X") }, - { "JOY_RIGHT_STICK_Y", Common::JOYSTICK_AXIS_RIGHT_STICK_Y, Common::kAxisTypeFull, _s("Right Stick Y") }, - { nullptr, 0, Common::kAxisTypeFull, nullptr } + { "JOY_LEFT_TRIGGER", Common::JOYSTICK_AXIS_LEFT_TRIGGER, Common::kAxisTypeHalf, _s("L2") }, + { "JOY_RIGHT_TRIGGER", Common::JOYSTICK_AXIS_RIGHT_TRIGGER, Common::kAxisTypeHalf, _s("R2") }, + { "JOY_LEFT_STICK_X", Common::JOYSTICK_AXIS_LEFT_STICK_X, Common::kAxisTypeFull, _s("Left Stick X") }, + { "JOY_LEFT_STICK_Y", Common::JOYSTICK_AXIS_LEFT_STICK_Y, Common::kAxisTypeFull, _s("Left Stick Y") }, + { "JOY_RIGHT_STICK_X", Common::JOYSTICK_AXIS_RIGHT_STICK_X, Common::kAxisTypeFull, _s("Right Stick X") }, + { "JOY_RIGHT_STICK_Y", Common::JOYSTICK_AXIS_RIGHT_STICK_Y, Common::kAxisTypeFull, _s("Right Stick Y") }, + { nullptr, 0, Common::kAxisTypeFull, nullptr } }; int access(const char *pathname, int mode) { diff --git a/backends/platform/sdl/psp2/psp2.cpp b/backends/platform/sdl/psp2/psp2.cpp index fc86480c1b2..1d308d7de51 100644 --- a/backends/platform/sdl/psp2/psp2.cpp +++ b/backends/platform/sdl/psp2/psp2.cpp @@ -41,27 +41,27 @@ #endif static const Common::HardwareInputTableEntry psp2JoystickButtons[] = { - { "JOY_A", Common::JOYSTICK_BUTTON_A, _s("Cross") }, - { "JOY_B", Common::JOYSTICK_BUTTON_B, _s("Circle") }, - { "JOY_X", Common::JOYSTICK_BUTTON_X, _s("Square") }, - { "JOY_Y", Common::JOYSTICK_BUTTON_Y, _s("Triangle") }, - { "JOY_BACK", Common::JOYSTICK_BUTTON_BACK, _s("Select") }, - { "JOY_START", Common::JOYSTICK_BUTTON_START, _s("Start") }, - { "JOY_LEFT_SHOULDER", Common::JOYSTICK_BUTTON_LEFT_SHOULDER, _s("L") }, - { "JOY_RIGHT_SHOULDER", Common::JOYSTICK_BUTTON_RIGHT_SHOULDER, _s("R") }, - { "JOY_UP", Common::JOYSTICK_BUTTON_DPAD_UP, _s("D-pad Up") }, - { "JOY_DOWN", Common::JOYSTICK_BUTTON_DPAD_DOWN, _s("D-pad Down") }, - { "JOY_LEFT", Common::JOYSTICK_BUTTON_DPAD_LEFT, _s("D-pad Left") }, - { "JOY_RIGHT", Common::JOYSTICK_BUTTON_DPAD_RIGHT, _s("D-pad Right") }, - { nullptr, 0, nullptr } + { "JOY_A", Common::JOYSTICK_BUTTON_A, _s("Cross") }, + { "JOY_B", Common::JOYSTICK_BUTTON_B, _s("Circle") }, + { "JOY_X", Common::JOYSTICK_BUTTON_X, _s("Square") }, + { "JOY_Y", Common::JOYSTICK_BUTTON_Y, _s("Triangle") }, + { "JOY_BACK", Common::JOYSTICK_BUTTON_BACK, _s("Select") }, + { "JOY_START", Common::JOYSTICK_BUTTON_START, _s("Start") }, + { "JOY_LEFT_SHOULDER", Common::JOYSTICK_BUTTON_LEFT_SHOULDER, _s("L") }, + { "JOY_RIGHT_SHOULDER", Common::JOYSTICK_BUTTON_RIGHT_SHOULDER, _s("R") }, + { "JOY_UP", Common::JOYSTICK_BUTTON_DPAD_UP, _s("D-pad Up") }, + { "JOY_DOWN", Common::JOYSTICK_BUTTON_DPAD_DOWN, _s("D-pad Down") }, + { "JOY_LEFT", Common::JOYSTICK_BUTTON_DPAD_LEFT, _s("D-pad Left") }, + { "JOY_RIGHT", Common::JOYSTICK_BUTTON_DPAD_RIGHT, _s("D-pad Right") }, + { nullptr, 0, nullptr } }; static const Common::AxisTableEntry psp2JoystickAxes[] = { - { "JOY_LEFT_STICK_X", Common::JOYSTICK_AXIS_LEFT_STICK_X, Common::kAxisTypeFull, _s("Left Stick X") }, - { "JOY_LEFT_STICK_Y", Common::JOYSTICK_AXIS_LEFT_STICK_Y, Common::kAxisTypeFull, _s("Left Stick Y") }, - { "JOY_RIGHT_STICK_X", Common::JOYSTICK_AXIS_RIGHT_STICK_X, Common::kAxisTypeFull, _s("Right Stick X") }, - { "JOY_RIGHT_STICK_Y", Common::JOYSTICK_AXIS_RIGHT_STICK_Y, Common::kAxisTypeFull, _s("Right Stick Y") }, - { nullptr, 0, Common::kAxisTypeFull, nullptr } + { "JOY_LEFT_STICK_X", Common::JOYSTICK_AXIS_LEFT_STICK_X, Common::kAxisTypeFull, _s("Left Stick X") }, + { "JOY_LEFT_STICK_Y", Common::JOYSTICK_AXIS_LEFT_STICK_Y, Common::kAxisTypeFull, _s("Left Stick Y") }, + { "JOY_RIGHT_STICK_X", Common::JOYSTICK_AXIS_RIGHT_STICK_X, Common::kAxisTypeFull, _s("Right Stick X") }, + { "JOY_RIGHT_STICK_Y", Common::JOYSTICK_AXIS_RIGHT_STICK_Y, Common::kAxisTypeFull, _s("Right Stick Y") }, + { nullptr, 0, Common::kAxisTypeFull, nullptr } }; int access(const char *pathname, int mode) { diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 285cf092401..3710a42d2de 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -728,9 +728,9 @@ AudioCDManager *OSystem_SDL::createAudioCDManager() { Common::SaveFileManager *OSystem_SDL::getSavefileManager() { #ifdef ENABLE_EVENTRECORDER - return g_eventRec.getSaveManager(_savefileManager); + return g_eventRec.getSaveManager(_savefileManager); #else - return _savefileManager; + return _savefileManager; #endif } diff --git a/backends/platform/sdl/switch/switch.cpp b/backends/platform/sdl/switch/switch.cpp index f4b3eb28853..36c61773554 100644 --- a/backends/platform/sdl/switch/switch.cpp +++ b/backends/platform/sdl/switch/switch.cpp @@ -35,32 +35,32 @@ #include "backends/keymapper/hardware-input.h" static const Common::HardwareInputTableEntry switchJoystickButtons[] = { - { "JOY_A", Common::JOYSTICK_BUTTON_A, _s("B") }, - { "JOY_B", Common::JOYSTICK_BUTTON_B, _s("A") }, - { "JOY_X", Common::JOYSTICK_BUTTON_X, _s("Y") }, - { "JOY_Y", Common::JOYSTICK_BUTTON_Y, _s("X") }, - { "JOY_BACK", Common::JOYSTICK_BUTTON_BACK, _s("Minus") }, - { "JOY_START", Common::JOYSTICK_BUTTON_START, _s("Plus") }, - { "JOY_GUIDE", Common::JOYSTICK_BUTTON_START, _s("Plus") }, - { "JOY_LEFT_STICK", Common::JOYSTICK_BUTTON_LEFT_STICK, _s("L3") }, - { "JOY_RIGHT_STICK", Common::JOYSTICK_BUTTON_RIGHT_STICK, _s("R3") }, - { "JOY_LEFT_SHOULDER", Common::JOYSTICK_BUTTON_LEFT_SHOULDER, _s("L") }, - { "JOY_RIGHT_SHOULDER", Common::JOYSTICK_BUTTON_RIGHT_SHOULDER, _s("R") }, - { "JOY_UP", Common::JOYSTICK_BUTTON_DPAD_UP, _s("D-pad Up") }, - { "JOY_DOWN", Common::JOYSTICK_BUTTON_DPAD_DOWN, _s("D-pad Down") }, - { "JOY_LEFT", Common::JOYSTICK_BUTTON_DPAD_LEFT, _s("D-pad Left") }, - { "JOY_RIGHT", Common::JOYSTICK_BUTTON_DPAD_RIGHT, _s("D-pad Right") }, - { nullptr, 0, nullptr } + { "JOY_A", Common::JOYSTICK_BUTTON_A, _s("B") }, + { "JOY_B", Common::JOYSTICK_BUTTON_B, _s("A") }, + { "JOY_X", Common::JOYSTICK_BUTTON_X, _s("Y") }, + { "JOY_Y", Common::JOYSTICK_BUTTON_Y, _s("X") }, + { "JOY_BACK", Common::JOYSTICK_BUTTON_BACK, _s("Minus") }, + { "JOY_START", Common::JOYSTICK_BUTTON_START, _s("Plus") }, + { "JOY_GUIDE", Common::JOYSTICK_BUTTON_START, _s("Plus") }, + { "JOY_LEFT_STICK", Common::JOYSTICK_BUTTON_LEFT_STICK, _s("L3") }, + { "JOY_RIGHT_STICK", Common::JOYSTICK_BUTTON_RIGHT_STICK, _s("R3") }, + { "JOY_LEFT_SHOULDER", Common::JOYSTICK_BUTTON_LEFT_SHOULDER, _s("L") }, + { "JOY_RIGHT_SHOULDER", Common::JOYSTICK_BUTTON_RIGHT_SHOULDER, _s("R") }, + { "JOY_UP", Common::JOYSTICK_BUTTON_DPAD_UP, _s("D-pad Up") }, + { "JOY_DOWN", Common::JOYSTICK_BUTTON_DPAD_DOWN, _s("D-pad Down") }, + { "JOY_LEFT", Common::JOYSTICK_BUTTON_DPAD_LEFT, _s("D-pad Left") }, + { "JOY_RIGHT", Common::JOYSTICK_BUTTON_DPAD_RIGHT, _s("D-pad Right") }, + { nullptr, 0, nullptr } }; static const Common::AxisTableEntry switchJoystickAxes[] = { - { "JOY_LEFT_TRIGGER", Common::JOYSTICK_AXIS_LEFT_TRIGGER, Common::kAxisTypeHalf, _s("ZL") }, - { "JOY_RIGHT_TRIGGER", Common::JOYSTICK_AXIS_RIGHT_TRIGGER, Common::kAxisTypeHalf, _s("ZR") }, - { "JOY_LEFT_STICK_X", Common::JOYSTICK_AXIS_LEFT_STICK_X, Common::kAxisTypeFull, _s("Left Stick X") }, - { "JOY_LEFT_STICK_Y", Common::JOYSTICK_AXIS_LEFT_STICK_Y, Common::kAxisTypeFull, _s("Left Stick Y") }, - { "JOY_RIGHT_STICK_X", Common::JOYSTICK_AXIS_RIGHT_STICK_X, Common::kAxisTypeFull, _s("Right Stick X") }, - { "JOY_RIGHT_STICK_Y", Common::JOYSTICK_AXIS_RIGHT_STICK_Y, Common::kAxisTypeFull, _s("Right Stick Y") }, - { nullptr, 0, Common::kAxisTypeFull, nullptr } + { "JOY_LEFT_TRIGGER", Common::JOYSTICK_AXIS_LEFT_TRIGGER, Common::kAxisTypeHalf, _s("ZL") }, + { "JOY_RIGHT_TRIGGER", Common::JOYSTICK_AXIS_RIGHT_TRIGGER, Common::kAxisTypeHalf, _s("ZR") }, + { "JOY_LEFT_STICK_X", Common::JOYSTICK_AXIS_LEFT_STICK_X, Common::kAxisTypeFull, _s("Left Stick X") }, + { "JOY_LEFT_STICK_Y", Common::JOYSTICK_AXIS_LEFT_STICK_Y, Common::kAxisTypeFull, _s("Left Stick Y") }, + { "JOY_RIGHT_STICK_X", Common::JOYSTICK_AXIS_RIGHT_STICK_X, Common::kAxisTypeFull, _s("Right Stick X") }, + { "JOY_RIGHT_STICK_Y", Common::JOYSTICK_AXIS_RIGHT_STICK_Y, Common::kAxisTypeFull, _s("Right Stick Y") }, + { nullptr, 0, Common::kAxisTypeFull, nullptr } }; void OSystem_Switch::init() { diff --git a/backends/platform/symbian/src/SymbianActions.h b/backends/platform/symbian/src/SymbianActions.h index cf060aed44c..592f1ce6b02 100644 --- a/backends/platform/symbian/src/SymbianActions.h +++ b/backends/platform/symbian/src/SymbianActions.h @@ -37,15 +37,15 @@ namespace GUI { #define ACTION_VERSION 7 enum actionType { - ACTION_UP = 0, - ACTION_DOWN, - ACTION_LEFT, - ACTION_RIGHT, - ACTION_LEFTCLICK, - ACTION_RIGHTCLICK, - ACTION_SAVE, - ACTION_SKIP, - ACTION_ZONE, + ACTION_UP = 0, + ACTION_DOWN, + ACTION_LEFT, + ACTION_RIGHT, + ACTION_LEFTCLICK, + ACTION_RIGHTCLICK, + ACTION_SAVE, + ACTION_SKIP, + ACTION_ZONE, ACTION_MULTI, ACTION_SWAPCHAR, ACTION_SKIP_TEXT, diff --git a/backends/platform/symbian/src/portdefs.h b/backends/platform/symbian/src/portdefs.h index 411ff3c9071..eab8f123155 100644 --- a/backends/platform/symbian/src/portdefs.h +++ b/backends/platform/symbian/src/portdefs.h @@ -175,9 +175,9 @@ namespace std #ifndef signbit #define signbit(x) \ - ((sizeof (x) == sizeof (float)) ? __signbitf(x) \ - : (sizeof (x) == sizeof (double)) ? __signbit(x) \ - : __signbitl(x)) + ((sizeof (x) == sizeof (float)) ? __signbitf(x) \ + : (sizeof (x) == sizeof (double)) ? __signbit(x) \ + : __signbitl(x)) #endif // Functions from openlibm not declared in Symbian math.h diff --git a/backends/platform/symbian/src/vsnprintf.h b/backends/platform/symbian/src/vsnprintf.h index 1e25716cd8d..d6e239c536b 100644 --- a/backends/platform/symbian/src/vsnprintf.h +++ b/backends/platform/symbian/src/vsnprintf.h @@ -213,15 +213,15 @@ #define fast_memcpy(d,s,n) \ { size_t nn = (size_t)(n); \ - if (nn >= breakeven_point) memcpy((d), (s), nn); \ - else if (nn > 0) { /* proc call overhead is worth only for large strings*/\ + if (nn >= breakeven_point) memcpy((d), (s), nn); \ + else if (nn > 0) { /* proc call overhead is worth only for large strings*/\ char *dd; const char *ss; \ for (ss=(s), dd=(d); nn>0; nn--) *dd++ = *ss++; } } #define fast_memset(d,c,n) \ { size_t nn = (size_t)(n); \ - if (nn >= breakeven_point) memset((d), (int)(c), nn); \ - else if (nn > 0) { /* proc call overhead is worth only for large strings*/\ + if (nn >= breakeven_point) memset((d), (int)(c), nn); \ + else if (nn > 0) { /* proc call overhead is worth only for large strings*/\ char *dd; const int cc=(int)(c); \ for (dd=(d); nn>0; nn--) *dd++ = cc; } } diff --git a/backends/platform/wii/main.cpp b/backends/platform/wii/main.cpp index 72d2514d90e..f25f5388888 100644 --- a/backends/platform/wii/main.cpp +++ b/backends/platform/wii/main.cpp @@ -54,8 +54,8 @@ bool reset_btn_pressed = false; bool power_btn_pressed = false; #if ((_V_MAJOR_ > 1) || \ - (_V_MAJOR_ == 1 && _V_MINOR_ > 8 ) || \ - (_V_MAJOR_ == 1 && _V_MINOR_ == 8 && _V_PATCH_ >= 18)) + (_V_MAJOR_ == 1 && _V_MINOR_ > 8 ) || \ + (_V_MAJOR_ == 1 && _V_MINOR_ == 8 && _V_PATCH_ >= 18)) void reset_cb(u32, void *) { #else void reset_cb(void) { diff --git a/backends/taskbar/unity/unity-taskbar.h b/backends/taskbar/unity/unity-taskbar.h index d818ed9ff18..b8d7a387450 100644 --- a/backends/taskbar/unity/unity-taskbar.h +++ b/backends/taskbar/unity/unity-taskbar.h @@ -43,7 +43,7 @@ public: virtual void setCount(int count); // Implementation of the EventSource interface - virtual bool pollEvent(Common::Event &event); + virtual bool pollEvent(Common::Event &event); private: GMainLoop *_loop; diff --git a/backends/updates/win32/win32-updates.cpp b/backends/updates/win32/win32-updates.cpp index 74964319510..f53f5a274d9 100644 --- a/backends/updates/win32/win32-updates.cpp +++ b/backends/updates/win32/win32-updates.cpp @@ -60,79 +60,79 @@ Win32UpdateManager::Win32UpdateManager(SdlWindow_Win32 *window) { win_sparkle_set_appcast_url(appcastUrl); win_sparkle_set_can_shutdown_callback(canShutdownCallback); win_sparkle_set_shutdown_request_callback(shutdownRequestCallback); - win_sparkle_init(); + win_sparkle_init(); - if (!ConfMan.hasKey("updates_check") - || ConfMan.getInt("updates_check") == Common::UpdateManager::kUpdateIntervalNotSupported) { - setAutomaticallyChecksForUpdates(kUpdateStateDisabled); - } else { - setAutomaticallyChecksForUpdates(kUpdateStateEnabled); - setUpdateCheckInterval(normalizeInterval(ConfMan.getInt("updates_check"))); - } + if (!ConfMan.hasKey("updates_check") + || ConfMan.getInt("updates_check") == Common::UpdateManager::kUpdateIntervalNotSupported) { + setAutomaticallyChecksForUpdates(kUpdateStateDisabled); + } else { + setAutomaticallyChecksForUpdates(kUpdateStateEnabled); + setUpdateCheckInterval(normalizeInterval(ConfMan.getInt("updates_check"))); + } } Win32UpdateManager::~Win32UpdateManager() { - win_sparkle_cleanup(); + win_sparkle_cleanup(); } void Win32UpdateManager::checkForUpdates() { - win_sparkle_check_update_with_ui(); + win_sparkle_check_update_with_ui(); } void Win32UpdateManager::setAutomaticallyChecksForUpdates(UpdateManager::UpdateState state) { - if (state == kUpdateStateNotSupported) - return; + if (state == kUpdateStateNotSupported) + return; - win_sparkle_set_automatic_check_for_updates(state == kUpdateStateEnabled ? 1 : 0); + win_sparkle_set_automatic_check_for_updates(state == kUpdateStateEnabled ? 1 : 0); } Common::UpdateManager::UpdateState Win32UpdateManager::getAutomaticallyChecksForUpdates() { - if (win_sparkle_get_automatic_check_for_updates() == 1) - return kUpdateStateEnabled; - else - return kUpdateStateDisabled; + if (win_sparkle_get_automatic_check_for_updates() == 1) + return kUpdateStateEnabled; + else + return kUpdateStateDisabled; } void Win32UpdateManager::setUpdateCheckInterval(int interval) { - if (interval == kUpdateIntervalNotSupported) - return; + if (interval == kUpdateIntervalNotSupported) + return; - interval = normalizeInterval(interval); + interval = normalizeInterval(interval); - win_sparkle_set_update_check_interval(interval); + win_sparkle_set_update_check_interval(interval); } int Win32UpdateManager::getUpdateCheckInterval() { - // This is kind of a hack but necessary, as the value stored by Sparkle - // might have been changed outside of ScummVM (in which case we return the - // default interval of one day) + // This is kind of a hack but necessary, as the value stored by Sparkle + // might have been changed outside of ScummVM (in which case we return the + // default interval of one day) - int updateInterval = win_sparkle_get_update_check_interval(); - switch (updateInterval) { - case kUpdateIntervalOneDay: - case kUpdateIntervalOneWeek: - case kUpdateIntervalOneMonth: - return updateInterval; + int updateInterval = win_sparkle_get_update_check_interval(); + switch (updateInterval) { + case kUpdateIntervalOneDay: + case kUpdateIntervalOneWeek: + case kUpdateIntervalOneMonth: + return updateInterval; - default: - // Return the default value (one day) - return kUpdateIntervalOneDay; - } + default: + // Return the default value (one day) + return kUpdateIntervalOneDay; + } } bool Win32UpdateManager::getLastUpdateCheckTimeAndDate(TimeDate &t) { - time_t updateTime = win_sparkle_get_last_check_time(); - tm *ut = localtime(&updateTime); + time_t updateTime = win_sparkle_get_last_check_time(); + tm *ut = localtime(&updateTime); - t.tm_wday = ut->tm_wday; - t.tm_year = ut->tm_year; - t.tm_mon = ut->tm_mon; - t.tm_mday = ut->tm_mday; - t.tm_hour = ut->tm_hour; - t.tm_min = ut->tm_min; - t.tm_sec = ut->tm_sec; + t.tm_wday = ut->tm_wday; + t.tm_year = ut->tm_year; + t.tm_mon = ut->tm_mon; + t.tm_mday = ut->tm_mday; + t.tm_hour = ut->tm_hour; + t.tm_min = ut->tm_min; + t.tm_sec = ut->tm_sec; - return true; + return true; } // WinSparkle calls this to ask if we can shut down. diff --git a/backends/vkeybd/virtual-keyboard-parser.h b/backends/vkeybd/virtual-keyboard-parser.h index c8a2c4158e5..4728c457591 100644 --- a/backends/vkeybd/virtual-keyboard-parser.h +++ b/backends/vkeybd/virtual-keyboard-parser.h @@ -32,9 +32,9 @@ /** - *************************************** - ** Virtual Keyboard Pack File Format ** - *************************************** + *************************************** + ** Virtual Keyboard Pack File Format ** + *************************************** The new virtual keyboard for ScummVM is implemented in the same way as a HTML ImageMap. It uses a single bitmap of the entire keyboard layout and then a @@ -45,42 +45,42 @@ keyboard. The HTML image map description is contained in a larger XML file that can describe all the different modes of the keyboard, and also different keyboard layouts for different screen resolutions. - ******************************************** - ** Example keyboard pack description file ** - ******************************************** + ******************************************** + ** Example keyboard pack description file ** + ******************************************** - - - - - - ... - - - - - ... - - - - - ... - + + + + + + ... + + + + + ... + + + + + ... + - - - - ... - - - - - - ... + + + + ... + + + + + + ... diff --git a/backends/vkeybd/virtual-keyboard.cpp b/backends/vkeybd/virtual-keyboard.cpp index 164e404591f..3d010e2b9d0 100644 --- a/backends/vkeybd/virtual-keyboard.cpp +++ b/backends/vkeybd/virtual-keyboard.cpp @@ -227,16 +227,16 @@ void VirtualKeyboard::handleMouseUp(int16 x, int16 y) { // If no GUI opened before the virtual keyboard, kKeymapTypeGui is not yet initialized // Check and do it if needed void VirtualKeyboard::initKeymap() { - using namespace Common; + using namespace Common; - Keymapper *mapper = _system->getEventManager()->getKeymapper(); + Keymapper *mapper = _system->getEventManager()->getKeymapper(); - // Do not try to recreate same keymap over again - if (mapper->getKeymap(kGuiKeymapName) != 0) - return; + // Do not try to recreate same keymap over again + if (mapper->getKeymap(kGuiKeymapName) != 0) + return; - Keymap *guiMap = g_gui.getKeymap(); - mapper->addGlobalKeymap(guiMap); + Keymap *guiMap = g_gui.getKeymap(); + mapper->addGlobalKeymap(guiMap); } void VirtualKeyboard::show() { diff --git a/base/commandLine.cpp b/base/commandLine.cpp index bc7df2550f2..e1f8638b56b 100644 --- a/base/commandLine.cpp +++ b/base/commandLine.cpp @@ -144,12 +144,12 @@ static const char HELP_STRING[] = " --output-rate=RATE Select output sample rate in Hz (e.g. 22050)\n" " --opl-driver=DRIVER Select AdLib (OPL) emulator (db, mame" #ifndef DISABLE_NUKED_OPL - ", nuked" + ", nuked" #endif #ifdef ENABLE_OPL2LPT - ", opl2lpt" + ", opl2lpt" #endif - ")\n" + ")\n" " --show-fps Set the turn on display FPS info in 3D games\n" " --no-show-fps Set the turn off display FPS info in 3D games\n" " --renderer=RENDERER Select 3D renderer (software, opengl, opengl_shaders)\n" diff --git a/base/detection/detection.cpp b/base/detection/detection.cpp index 6274e871137..132fa7d7276 100644 --- a/base/detection/detection.cpp +++ b/base/detection/detection.cpp @@ -30,25 +30,25 @@ class DetectionDynamic : public Detection { public: - DetectionDynamic() {} - ~DetectionDynamic() {} + DetectionDynamic() {} + ~DetectionDynamic() {} - const char *getName() const override { - return "detection"; - } + const char *getName() const override { + return "detection"; + } - PluginList getPlugins() const override { - PluginList pl; + PluginList getPlugins() const override { + PluginList pl; - #define LINK_PLUGIN(ID) \ + #define LINK_PLUGIN(ID) \ extern PluginType g_##ID##_type; \ extern PluginObject *g_##ID##_getObject(); \ pl.push_back(new StaticPlugin(g_##ID##_getObject(), g_##ID##_type)); - #include "engines/detection_table.h" + #include "engines/detection_table.h" - return pl; - } + return pl; + } }; REGISTER_PLUGIN_DYNAMIC(DETECTION_DYNAMIC, PLUGIN_TYPE_DETECTION, DetectionDynamic); diff --git a/base/detection/detection.h b/base/detection/detection.h index 181afd5a4be..f3b61f9a6cd 100644 --- a/base/detection/detection.h +++ b/base/detection/detection.h @@ -24,9 +24,9 @@ class Detection : public PluginObject { public: - Detection() {} - virtual ~Detection() {} + Detection() {} + virtual ~Detection() {} - virtual const char *getName() const = 0; - virtual PluginList getPlugins() const = 0; + virtual const char *getName() const = 0; + virtual PluginList getPlugins() const = 0; }; diff --git a/common/algorithm.h b/common/algorithm.h index 96a5c69056c..d3cf7d5e1d6 100644 --- a/common/algorithm.h +++ b/common/algorithm.h @@ -385,10 +385,10 @@ T nextHigher2(T v) { template void replace(It begin, It end, const Dat &original, const Dat &replaced) { for (; begin != end; ++begin) { - if (*begin == original) { - *begin = replaced; - } - } + if (*begin == original) { + *begin = replaced; + } + } } /** @} */ diff --git a/common/archive.cpp b/common/archive.cpp index 4f70ac2796d..4f87000291d 100644 --- a/common/archive.cpp +++ b/common/archive.cpp @@ -81,9 +81,9 @@ SearchSet::ArchiveNodeList::const_iterator SearchSet::find(const String &name) c } /* - Keep the nodes sorted according to descending priorities. - In case two or node nodes have the same priority, insertion - order prevails. + Keep the nodes sorted according to descending priorities. + In case two or node nodes have the same priority, insertion + order prevails. */ void SearchSet::insert(const Node &node) { ArchiveNodeList::iterator it = _list.begin(); diff --git a/common/array.h b/common/array.h index 934d8838135..11082a7486b 100644 --- a/common/array.h +++ b/common/array.h @@ -150,7 +150,7 @@ public: insert_aux(end(), &element, &element + 1); } - /** Append an element to the end of the array. */ + /** Append an element to the end of the array. */ void push_back(const Array &array) { if (_size + array.size() <= _capacity) { uninitialized_copy(array.begin(), array.end(), end()); @@ -201,12 +201,12 @@ public: return _storage[_size-1]; } - /** Insert an element into the array at the given position. */ + /** Insert an element into the array at the given position. */ void insert_at(size_type idx, const T &element) { assert(idx <= _size); insert_aux(_storage + idx, &element, &element + 1); } - + /** Insert copies of all the elements from the given array into this array at the given position. */ void insert_at(size_type idx, const Array &array) { assert(idx <= _size); @@ -219,7 +219,7 @@ public: void insert(iterator pos, const T &element) { insert_aux(pos, &element, &element + 1); } - + /** Remove an element at the given position from the array and return the value of that element. */ T remove_at(size_type idx) { assert(idx < _size); @@ -239,13 +239,13 @@ public: return _storage[idx]; } - /** Return a const reference to the element at the given position in the array. */ + /** Return a const reference to the element at the given position in the array. */ const T &operator[](size_type idx) const { assert(idx < _size); return _storage[idx]; } - /** Assign the given @p array to this array. */ + /** Assign the given @p array to this array. */ Array &operator=(const Array &array) { if (this == &array) return *this; @@ -259,7 +259,7 @@ public: } #ifdef USE_CXX11 - /** Assign the given array to this array using the C++11 move semantic. */ + /** Assign the given array to this array using the C++11 move semantic. */ Array &operator=(Array &&old) { if (this == &old) return *this; @@ -277,12 +277,12 @@ public: } #endif - /** Return the size of the array. */ + /** Return the size of the array. */ size_type size() const { return _size; } - /** Clear the array of all its elements. */ + /** Clear the array of all its elements. */ void clear() { freeStorage(_storage, _size); _storage = nullptr; @@ -290,7 +290,7 @@ public: _capacity = 0; } - /** Erase the element at @p pos position and return an iterator pointing to the next element in the array. */ + /** Erase the element at @p pos position and return an iterator pointing to the next element in the array. */ iterator erase(iterator pos) { copy(pos + 1, _storage + _size, pos); _size--; @@ -298,13 +298,13 @@ public: _storage[_size].~T(); return pos; } - - /** Check whether the array is empty. */ + + /** Check whether the array is empty. */ bool empty() const { return (_size == 0); } - /** Check whether two arrays are identical. */ + /** Check whether two arrays are identical. */ bool operator==(const Array &other) const { if (this == &other) return true; @@ -317,32 +317,32 @@ public: return true; } - /** Check if two arrays are different. */ + /** Check if two arrays are different. */ bool operator!=(const Array &other) const { return !(*this == other); } - /** Return an iterator pointing to the first element in the array. */ + /** Return an iterator pointing to the first element in the array. */ iterator begin() { return _storage; } - /** Return an iterator pointing past the last element in the array. */ + /** Return an iterator pointing past the last element in the array. */ iterator end() { return _storage + _size; } - /** Return a const iterator pointing to the first element in the array. */ + /** Return a const iterator pointing to the first element in the array. */ const_iterator begin() const { return _storage; } - /** Return a const iterator pointing past the last element in the array. */ + /** Return a const iterator pointing past the last element in the array. */ const_iterator end() const { return _storage + _size; } - /** Reserve enough memory in the array so that it can store at least the given number of elements. + /** Reserve enough memory in the array so that it can store at least the given number of elements. * The current content of the array is not modified. */ void reserve(size_type newCapacity) { @@ -359,7 +359,7 @@ public: } } - /** Change the size of the array. */ + /** Change the size of the array. */ void resize(size_type newSize) { reserve(newSize); for (size_type i = newSize; i < _size; ++i) @@ -369,7 +369,7 @@ public: _size = newSize; } - /** Assign to this array the elements between the given iterators from another array, + /** Assign to this array the elements between the given iterators from another array, * from @p first included to @p last excluded. */ void assign(const_iterator first, const_iterator last) { @@ -380,7 +380,7 @@ public: } protected: - /** Round up capacity to the next power of 2. + /** Round up capacity to the next power of 2. * A minimal capacity of 8 is used. */ static size_type roundUpCapacity(size_type capacity) { @@ -390,7 +390,7 @@ protected: return capa; } - /** Allocate a specific capacity for the array. */ + /** Allocate a specific capacity for the array. */ void allocCapacity(size_type capacity) { _capacity = capacity; if (capacity) { @@ -402,7 +402,7 @@ protected: } } - /** Free the storage used by the array. */ + /** Free the storage used by the array. */ void freeStorage(T *storage, const size_type elements) { for (size_type i = 0; i < elements; ++i) storage[i].~T(); diff --git a/common/base-str.cpp b/common/base-str.cpp index 588410b9b41..0073c110538 100644 --- a/common/base-str.cpp +++ b/common/base-str.cpp @@ -69,7 +69,7 @@ static uint32 computeCapacity(uint32 len) { TEMPLATE BASESTRING::BaseString(const BASESTRING &str) - : _size(str._size) { + : _size(str._size) { if (str.isStorageIntern()) { // String in internal storage: just copy it memcpy(_storage, str._storage, _builtinCapacity * sizeof(value_type)); diff --git a/common/config-manager.h b/common/config-manager.h index 3383e0f4b0a..918c8cb077a 100644 --- a/common/config-manager.h +++ b/common/config-manager.h @@ -70,7 +70,7 @@ public: bool empty() const { return _entries.empty(); } /*!< Return true if the configuration is empty, i.e. has no [key, value] pairs, and false otherwise. */ bool contains(const String &key) const { return _entries.contains(key); } /*!< Check whether the domain contains a @p key. */ - /** Return the configuration value for the given key. + /** Return the configuration value for the given key. * If no entry exists for the given key in the configuration, it is created. */ /** Return the configuration value for the given key. @@ -84,11 +84,11 @@ public: String &getOrCreateVal(const String &key) { return _entries.getOrCreateVal(key); } String &getVal(const String &key) { return _entries.getVal(key); } /*!< Retrieve the value of a @p key. */ const String &getVal(const String &key) const { return _entries.getVal(key); } /*!< @overload */ - /** - * Retrieve the value of @p key if it exists and leave the referenced variable unchanged if the key does not exist. - * @return True if the key exists, false otherwise. - * You can use this method if you frequently attempt to access keys that do not exist. - */ + /** + * Retrieve the value of @p key if it exists and leave the referenced variable unchanged if the key does not exist. + * @return True if the key exists, false otherwise. + * You can use this method if you frequently attempt to access keys that do not exist. + */ const String &getValOrDefault(const String &key) const { return _entries.getValOrDefault(key); } bool tryGetVal(const String &key, String &out) const { return _entries.tryGetVal(key, out); } @@ -133,7 +133,7 @@ public: const Domain *getDomain(const String &domName) const; /*!< @overload */ - /** + /** * @name Generic access methods * @brief No domain specified, use the values from the * various domains in the order of their priority. @@ -143,7 +143,7 @@ public: bool hasKey(const String &key) const; /*!< Check if a given @p key exists. */ const String &get(const String &key) const; /*!< Get the value of a @p key. */ void set(const String &key, const String &value); /*!< Assign a @p value to a @p key. */ - /** @} */ + /** @} */ /** * Update a configuration entry for the active domain and flush @@ -152,7 +152,7 @@ public: void setAndFlush(const String &key, const Common::String &value); #if 1 - /** + /** * @name Domain-specific access methods * @brief Access one specific domain and modify it. * @@ -170,7 +170,7 @@ public: /** @} */ #endif - /** + /** * @name Additional convenience accessors * @{ */ diff --git a/common/coroutines.cpp b/common/coroutines.cpp index 0e7a1098cf7..3cb1a374890 100644 --- a/common/coroutines.cpp +++ b/common/coroutines.cpp @@ -399,7 +399,7 @@ void CoroutineScheduler::waitForSingleObject(CORO_PARAM, int pid, uint32 duratio } void CoroutineScheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, bool bWaitAll, - uint32 duration, bool *expired) { + uint32 duration, bool *expired) { if (!pCurrent) error("Called CoroutineScheduler::waitForMultipleObjects from the main process"); diff --git a/common/coroutines.h b/common/coroutines.h index 275ccfa4717..a0b2388004c 100644 --- a/common/coroutines.h +++ b/common/coroutines.h @@ -363,7 +363,7 @@ private: Common::List _events; #ifdef DEBUG - /** Diagnostic process counters. */ + /** Diagnostic process counters. */ int numProcs; int maxProcs; diff --git a/common/error.h b/common/error.h index 810eb724e79..85116c4c9a2 100644 --- a/common/error.h +++ b/common/error.h @@ -65,7 +65,7 @@ enum ErrorCode { /** Failed to find a MetaEnginePlugin. This should never happen, because all MetaEngines must always * be built into the executable, regardless if the engine plugins are present or not. - */ + */ kMetaEnginePluginNotFound, kEnginePluginNotFound, ///< Failed to find an Engine plugin to handle target. diff --git a/common/events.h b/common/events.h index 8a41945d60a..fb98674cc0c 100644 --- a/common/events.h +++ b/common/events.h @@ -75,8 +75,8 @@ enum EventType { /** * The backend requests the AGI engine's predictive dialog to be shown. - * - * @todo Fingolfin suggests that it would be of better value to expand + * + * @todo Fingolfin suggests that it would be of better value to expand * on this notion by generalizing its use. For example the backend could * use events to ask for the save game dialog or to pause the engine. * An associated enumerated type can accomplish this. @@ -219,7 +219,7 @@ struct Event { * screen area as defined by the most recent call to initSize(). */ Point mouse; - + /** Refers to an event generated by @ref ArtificialEventSource. */ CustomEventType customType; @@ -287,7 +287,7 @@ class ArtificialEventSource : public EventSource { protected: Queue _artificialEventQueue; public: - /** Put the specified event into the queue. */ + /** Put the specified event into the queue. */ void addEvent(const Event &ev) { _artificialEventQueue.push(ev); } @@ -518,7 +518,7 @@ public: // TODO: Consider removing OSystem::getScreenChangeID and // replacing it by a generic getScreenChangeID method here - /** Return the @ref Keymapper object. */ + /** Return the @ref Keymapper object. */ virtual Keymapper *getKeymapper() = 0; /** Return the global @ref Keymap object. */ virtual Keymap *getGlobalKeymap() = 0; diff --git a/common/fs.cpp b/common/fs.cpp index aac774714c8..c3b2290bfaf 100644 --- a/common/fs.cpp +++ b/common/fs.cpp @@ -174,22 +174,22 @@ FSDirectory::FSDirectory(const FSNode &node, int depth, bool flat, bool ignoreCl } FSDirectory::FSDirectory(const String &prefix, const FSNode &node, int depth, bool flat, - bool ignoreClashes, bool includeDirectories) + bool ignoreClashes, bool includeDirectories) : _node(node), _cached(false), _depth(depth), _flat(flat), _ignoreClashes(ignoreClashes), - _includeDirectories(includeDirectories) { + _includeDirectories(includeDirectories) { setPrefix(prefix); } FSDirectory::FSDirectory(const String &name, int depth, bool flat, bool ignoreClashes, bool includeDirectories) : _node(name), _cached(false), _depth(depth), _flat(flat), _ignoreClashes(ignoreClashes), - _includeDirectories(includeDirectories) { + _includeDirectories(includeDirectories) { } FSDirectory::FSDirectory(const String &prefix, const String &name, int depth, bool flat, - bool ignoreClashes, bool includeDirectories) + bool ignoreClashes, bool includeDirectories) : _node(name), _cached(false), _depth(depth), _flat(flat), _ignoreClashes(ignoreClashes), - _includeDirectories(includeDirectories) { + _includeDirectories(includeDirectories) { setPrefix(prefix); } @@ -264,7 +264,7 @@ FSDirectory *FSDirectory::getSubDirectory(const String &name, int depth, bool fl } FSDirectory *FSDirectory::getSubDirectory(const String &prefix, const String &name, int depth, - bool flat, bool ignoreClashes) { + bool flat, bool ignoreClashes) { if (name.empty() || !_node.isDirectory()) return nullptr; diff --git a/common/hashmap.h b/common/hashmap.h index 6a63cd03457..e565558df3e 100644 --- a/common/hashmap.h +++ b/common/hashmap.h @@ -300,7 +300,7 @@ public: } // TODO: insert() method? - /** Return true if hashmap is empty. */ + /** Return true if hashmap is empty. */ bool empty() const { return (_size == 0); } diff --git a/common/list.h b/common/list.h index fd1347fa828..e2ce6f5f511 100644 --- a/common/list.h +++ b/common/list.h @@ -33,7 +33,7 @@ namespace Common { * * @brief API for managing doubly linked lists. * - * + * * @{ */ @@ -176,7 +176,7 @@ public: return static_cast(_anchor._prev)->_data; } - /** Assign a given @p list to this list. */ + /** Assign a given @p list to this list. */ List &operator=(const List &list) { if (this != &list) { iterator i; @@ -197,7 +197,7 @@ public: return *this; } - /** Return the size of the list. */ + /** Return the size of the list. */ size_type size() const { size_type n = 0; for (const NodeBase *cur = _anchor._next; cur != &_anchor; cur = cur->_next) @@ -205,7 +205,7 @@ public: return n; } - /** Remove all elements from the list. */ + /** Remove all elements from the list. */ void clear() { NodeBase *pos = _anchor._next; while (pos != &_anchor) { @@ -218,12 +218,12 @@ public: _anchor._next = &_anchor; } - /** Check whether the list is empty. */ + /** Check whether the list is empty. */ bool empty() const { return (&_anchor == _anchor._next); } - /** Return an iterator to the start of the list. + /** Return an iterator to the start of the list. * This can be used, for example, to iterate from the first element * of the list to the last element of the list. */ @@ -231,7 +231,7 @@ public: return iterator(_anchor._next); } - /** Return a reverse iterator to the start of the list. + /** Return a reverse iterator to the start of the list. * This can be used, for example, to iterate from the last element * of the list to the first element of the list. */ @@ -239,12 +239,12 @@ public: return iterator(_anchor._prev); } - /** Return an iterator to the end of the list. */ + /** Return an iterator to the end of the list. */ iterator end() { return iterator(&_anchor); } - /** Return a const iterator to the start of the list. + /** Return a const iterator to the start of the list. * This can be used, for example, to iterate from the first element * of the list to the last element of the list. */ @@ -252,7 +252,7 @@ public: return const_iterator(_anchor._next); } - /** Return a const reverse iterator to the start of the list. + /** Return a const reverse iterator to the start of the list. * This can be used, for example, to iterate from the last element * of the list to the first element of the list. */ @@ -260,13 +260,13 @@ public: return const_iterator(_anchor._prev); } - /** Return a const iterator to the end of the list. */ + /** Return a const iterator to the end of the list. */ const_iterator end() const { return const_iterator(const_cast(&_anchor)); } protected: - /** + /** * Erase an element at @p pos. */ NodeBase erase(NodeBase *pos) { diff --git a/common/math.h b/common/math.h index 5c8b82372a9..a391d855804 100644 --- a/common/math.h +++ b/common/math.h @@ -111,7 +111,7 @@ inline int intLog2(uint32 v) { // Input and Output type can be different template inline OutputT trunc(InputT x) { - return (x > 0) ? floor(x) : ceil(x); + return (x > 0) ? floor(x) : ceil(x); } // Round a number towards zero diff --git a/common/rect.h b/common/rect.h index 8585accbb13..020a9cbe90d 100644 --- a/common/rect.h +++ b/common/rect.h @@ -50,53 +50,53 @@ struct Point { Point() : x(0), y(0) {} /** - * Create a point with position defined by @p x1 and @p y1. - */ + * Create a point with position defined by @p x1 and @p y1. + */ Point(int16 x1, int16 y1) : x(x1), y(y1) {} /** - * Determine whether the position of two points is the same. - */ + * Determine whether the position of two points is the same. + */ bool operator==(const Point &p) const { return x == p.x && y == p.y; } /** - * Determine whether the position of two points is not the same. - */ + * Determine whether the position of two points is not the same. + */ bool operator!=(const Point &p) const { return x != p.x || y != p.y; } /** - * Create a point by adding the @p delta value to a point. - */ + * Create a point by adding the @p delta value to a point. + */ Point operator+(const Point &delta) const { return Point(x + delta.x, y + delta.y); } /** - * Create a point by subtracting the @p delta value from a point. - */ + * Create a point by subtracting the @p delta value from a point. + */ Point operator-(const Point &delta) const { return Point(x - delta.x, y - delta.y); } /** - * Create a point by dividing a point by the (int) @p divisor value. - */ + * Create a point by dividing a point by the (int) @p divisor value. + */ Point operator/(int divisor) const { return Point(x / divisor, y / divisor); } /** - * Create a point by multiplying a point by the (int) @p multiplier value. - */ + * Create a point by multiplying a point by the (int) @p multiplier value. + */ Point operator*(int multiplier) const { return Point(x * multiplier, y * multiplier); } /** - * Create a point by dividing a point by the (double) @p divisor value. - */ + * Create a point by dividing a point by the (double) @p divisor value. + */ Point operator/(double divisor) const { return Point(x / divisor, y / divisor); } /** - * Create a point by multiplying a point by the (double) @p multiplier value. - */ + * Create a point by multiplying a point by the (double) @p multiplier value. + */ Point operator*(double multiplier) const { return Point(x * multiplier, y * multiplier); } - /** - * Change a point's position by adding @p delta to its x and y coordinates. - */ + /** + * Change a point's position by adding @p delta to its x and y coordinates. + */ void operator+=(const Point &delta) { x += delta.x; y += delta.y; } - /** - * Change a point's position by subtracting @p delta from its x and y arguments. - */ + /** + * Change a point's position by subtracting @p delta from its x and y arguments. + */ void operator-=(const Point &delta) { x -= delta.x; y -= delta.y; @@ -148,29 +148,29 @@ struct Rect { Rect() : top(0), left(0), bottom(0), right(0) {} /** - * Create a rectangle with the top-left corner at position (0, 0) and the given width @p w and height @p h. - */ + * Create a rectangle with the top-left corner at position (0, 0) and the given width @p w and height @p h. + */ Rect(int16 w, int16 h) : top(0), left(0), bottom(h), right(w) {} /** - * Create a rectangle with the top-left corner at the given position (x1, y1) + * Create a rectangle with the top-left corner at the given position (x1, y1) * and the bottom-right corner at the position (x2, y2). * * The @p x2 value must be greater or equal @p x1 and @p y2 must be greater or equal @p y1. - */ + */ Rect(int16 x1, int16 y1, int16 x2, int16 y2) : top(y1), left(x1), bottom(y2), right(x2) { assert(isValidRect()); } /** - * Check if two rectangles are identical. + * Check if two rectangles are identical. * * @return True if the rectangles are identical, false otherwise. - */ + */ bool operator==(const Rect &rhs) const { return equals(rhs); } - /** - * Check if two rectangles are different. + /** + * Check if two rectangles are different. * * @return True if the rectangles are different, false otherwise. - */ + */ bool operator!=(const Rect &rhs) const { return !equals(rhs); } int16 width() const { return right - left; } /*!< Return the width of a rectangle. */ @@ -316,14 +316,14 @@ struct Rect { return (left >= right || top >= bottom); } - /** + /** * Check if this is a valid rectangle. */ bool isValidRect() const { return (left <= right && top <= bottom); } - /** + /** * Move this rectangle to the position defined by @p x, @p y. */ void moveTo(int16 x, int16 y) { @@ -341,14 +341,14 @@ struct Rect { top += dy; bottom += dy; } - /** + /** * Move this rectangle to the position of the point @p p. */ void moveTo(const Point &p) { moveTo(p.x, p.y); } - /** + /** * Print debug messages related to this class. */ void debugPrint(int debuglevel = 0, const char *caption = "Rect:") const { diff --git a/common/safe-bool.h b/common/safe-bool.h index 978040ece40..f51cd8c2361 100644 --- a/common/safe-bool.h +++ b/common/safe-bool.h @@ -40,14 +40,14 @@ namespace Common { }; } - /** - * @defgroup common_safe_bool Safe Boolean - * @ingroup common - * - * @brief Template for a SafeBool function. - * - * @{ - */ + /** + * @defgroup common_safe_bool Safe Boolean + * @ingroup common + * + * @brief Template for a SafeBool function. + * + * @{ + */ /** * Prevents `operator bool` from implicitly converting to other types. diff --git a/common/savefile.h b/common/savefile.h index 03893ce1dec..c674306c7de 100644 --- a/common/savefile.h +++ b/common/savefile.h @@ -60,14 +60,14 @@ public: OutSaveFile(WriteStream *w); /*!< Create an OutSaveFile that uses the given WriteStream to write the data. */ virtual ~OutSaveFile(); - /** + /** * Return true if an I/O failure occurred. * This flag is never cleared automatically. In order to clear it, * you must call clearErr() explicitly. */ virtual bool err() const; - /** + /** * Reset the I/O error status as returned by err(). */ virtual void clearErr(); @@ -93,11 +93,11 @@ public: virtual bool flush(); /** - * Write data into the stream. + * Write data into the stream. * * @param dataPtr Pointer to the data to be written. * @param dataSize Number of bytes to be written. - */ + */ virtual uint32 write(const void *dataPtr, uint32 dataSize); /** diff --git a/common/str-enc.cpp b/common/str-enc.cpp index 9ffb200d56d..f78ee39c993 100644 --- a/common/str-enc.cpp +++ b/common/str-enc.cpp @@ -777,7 +777,7 @@ getReverseConversionTable(CodePage page) { } void U32String::decodeOneByte(const char *src, uint32 len, CodePage page) { - const uint16 *conversionTable = getConversionTable(page); + const uint16 *conversionTable = getConversionTable(page); if (conversionTable == nullptr) { conversionTable = kASCIIConversionTable; diff --git a/common/system.h b/common/system.h index e1d16c07e86..894db3f4f5f 100644 --- a/common/system.h +++ b/common/system.h @@ -635,7 +635,7 @@ public: virtual const GraphicsMode *getSupportedGraphicsModes() const { static const GraphicsMode noGraphicsModes[] = {{"NONE", "Normal", 0}, {nullptr, nullptr, 0 }}; return noGraphicsModes; - } + } /** * Return the ID of the 'default' graphics mode. What exactly this means @@ -1517,7 +1517,7 @@ public: * @param icon The icon to display on the screen. */ virtual void displayActivityIconOnOSD(const Graphics::Surface *icon) = 0; - /** @} */ + /** @} */ /** * @addtogroup common_system_module @@ -1584,7 +1584,7 @@ public: * @return The FSNode factory for the current architecture. */ virtual FilesystemFactory *getFilesystemFactory(); - /** @} */ + /** @} */ /** * @addtogroup common_system_misc diff --git a/common/translation.h b/common/translation.h index 5662454434d..c66f15d814b 100644 --- a/common/translation.h +++ b/common/translation.h @@ -78,7 +78,7 @@ typedef Array TLangArray; struct PoMessageEntry { int msgid; /*!< ID of the message. */ String msgctxt; /*!< Context of the message. It can be empty. - Can be used to solve ambiguities. */ + Can be used to solve ambiguities. */ U32String msgstr; /*!< Message string. */ }; diff --git a/common/unzip.cpp b/common/unzip.cpp index 2e7a3f8b810..152b5bb8126 100644 --- a/common/unzip.cpp +++ b/common/unzip.cpp @@ -96,9 +96,9 @@ typedef long z_off_t; typedef unsigned char Byte; typedef Byte Bytef; typedef struct { - Bytef *next_in, *next_out; - uInt avail_in, avail_out; - uLong total_out; + Bytef *next_in, *next_out; + uInt avail_in, avail_out; + uLong total_out; } z_stream; #endif // !USE_ZLIB @@ -149,23 +149,23 @@ typedef struct { /* unz_file_info contain information about a file in the zipfile */ typedef struct { - uLong version; /* version made by 2 bytes */ - uLong version_needed; /* version needed to extract 2 bytes */ - uLong flag; /* general purpose bit flag 2 bytes */ - uLong compression_method; /* compression method 2 bytes */ - uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ - uLong crc; /* crc-32 4 bytes */ - uLong compressed_size; /* compressed size 4 bytes */ - uLong uncompressed_size; /* uncompressed size 4 bytes */ - uLong size_filename; /* filename length 2 bytes */ - uLong size_file_extra; /* extra field length 2 bytes */ - uLong size_file_comment; /* file comment length 2 bytes */ + uLong version; /* version made by 2 bytes */ + uLong version_needed; /* version needed to extract 2 bytes */ + uLong flag; /* general purpose bit flag 2 bytes */ + uLong compression_method; /* compression method 2 bytes */ + uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ + uLong crc; /* crc-32 4 bytes */ + uLong compressed_size; /* compressed size 4 bytes */ + uLong uncompressed_size; /* uncompressed size 4 bytes */ + uLong size_filename; /* filename length 2 bytes */ + uLong size_file_extra; /* extra field length 2 bytes */ + uLong size_file_comment; /* file comment length 2 bytes */ - uLong disk_num_start; /* disk number start 2 bytes */ - uLong internal_fa; /* internal file attributes 2 bytes */ - uLong external_fa; /* external file attributes 4 bytes */ + uLong disk_num_start; /* disk number start 2 bytes */ + uLong internal_fa; /* internal file attributes 2 bytes */ + uLong external_fa; /* external file attributes 4 bytes */ - tm_unz tmu_date; + tm_unz tmu_date; } unz_file_info; int unzStringFileNameCompare(const char* fileName1, @@ -183,11 +183,11 @@ int unzStringFileNameCompare(const char* fileName1, /* Open a Zip file. path contain the full pathname (by example, - on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer + on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer "zlib/zlib111.zip". If the zipfile cannot be opened (file don't exist or in not valid), the return value is NULL. - Else, the return value is a unzFile Handle, usable with other function + Else, the return value is a unzFile Handle, usable with other function of this unzip package. */ @@ -195,7 +195,7 @@ int unzClose(unzFile file); /* Close a ZipFile opened with unzipOpen. If there is files inside the .Zip opened with unzOpenCurrentFile (see later), - these files MUST be closed with unzipCloseCurrentFile before call unzipClose. + these files MUST be closed with unzipCloseCurrentFile before call unzipClose. return UNZ_OK if there is no problem. */ int unzGetGlobalInfo(unzFile file, @@ -289,7 +289,7 @@ int unzReadCurrentFile(unzFile file, voidp buf, unsigned len); return the number of byte copied if somes bytes are copied return 0 if the end of file was reached return <0 with error code if there is an error - (UNZ_ERRNO for IO error, or zLib error for uncompress error) + (UNZ_ERRNO for IO error, or zLib error for uncompress error) */ z_off_t unztell(unzFile file); @@ -306,7 +306,7 @@ int unzGetLocalExtrafield(unzFile file, voidp buf, unsigned len); /* Read extra field from the current file (opened by unzOpenCurrentFile) This is the local-header version of the extra field (sometimes, there is - more info in the local-header version than in the central-header) + more info in the local-header version than in the central-header) if buf==NULL, it return the size of the local extra field @@ -317,7 +317,7 @@ int unzGetLocalExtrafield(unzFile file, voidp buf, unsigned len); */ #if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) && \ - !defined(CASESENSITIVITYDEFAULT_NO) + !defined(CASESENSITIVITYDEFAULT_NO) #define CASESENSITIVITYDEFAULT_NO #endif @@ -341,12 +341,12 @@ const char unz_copyright[] = /* unz_file_info_interntal contain internal info about a file in zipfile*/ typedef struct { - uLong offset_curfile;/* relative offset of local header 4 bytes */ + uLong offset_curfile;/* relative offset of local header 4 bytes */ } unz_file_info_internal; /* file_in_zip_read_info_s contain internal information about a file in zipfile, - when reading and decompress it */ + when reading and decompress it */ typedef struct { char *read_buffer; /* internal buffer for compressed data */ z_stream stream; /* zLib stream structure for inflate */ @@ -401,22 +401,22 @@ typedef struct { } unz_s; /* =========================================================================== - Read a byte from a gz_stream; update next_in and avail_in. Return EOF + Read a byte from a gz_stream; update next_in and avail_in. Return EOF for end of file. IN assertion: the stream s has been successfully opened for reading. */ /*static int unzlocal_getByte(Common::SeekableReadStream &fin, int *pi) { - unsigned char c = fin.readByte(); - *pi = (int)c; - return UNZ_OK; - } else { - if (fin.err()) - return UNZ_ERRNO; - else - return UNZ_EOF; - } + unsigned char c = fin.readByte(); + *pi = (int)c; + return UNZ_OK; + } else { + if (fin.err()) + return UNZ_ERRNO; + else + return UNZ_EOF; + } }*/ @@ -444,9 +444,9 @@ static int unzlocal_getLong(Common::SeekableReadStream *fin, uLong *pX) { Compare two filename (fileName1,fileName2). If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi - or strcasecmp) + or strcasecmp) If iCaseSenisivity = 0, case sensitivity is defaut of your operating system - (like 1 on Unix, 2 on Windows) + (like 1 on Unix, 2 on Windows) */ int unzStringFileNameCompare(const char* fileName1, const char* fileName2, int iCaseSensitivity) { @@ -463,7 +463,7 @@ int unzStringFileNameCompare(const char* fileName1, const char* fileName2, int i /* Locate the Central directory of a zipfile (at the end, just before - the global comment) + the global comment) */ static uLong unzlocal_SearchCentralDir(Common::SeekableReadStream &fin) { unsigned char* buf; @@ -494,7 +494,7 @@ static uLong unzlocal_SearchCentralDir(Common::SeekableReadStream &fin) { uReadPos = uSizeFile-uBackRead; uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? - (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); + (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); fin.seek(uReadPos, SEEK_SET); if (fin.err()) break; @@ -502,7 +502,7 @@ static uLong unzlocal_SearchCentralDir(Common::SeekableReadStream &fin) { if (fin.read(buf,(uInt)uReadSize)!=uReadSize) break; - for (i=(int)uReadSize-3; (i--)>0;) + for (i=(int)uReadSize-3; (i--)>0;) if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) { @@ -519,11 +519,11 @@ static uLong unzlocal_SearchCentralDir(Common::SeekableReadStream &fin) { /* Open a Zip file. path contain the full pathname (by example, - on a Windows NT computer "c:\\test\\zlib109.zip" or on an Unix computer + on a Windows NT computer "c:\\test\\zlib109.zip" or on an Unix computer "zlib/zlib109.zip". If the zipfile cannot be opened (file don't exist or in not valid), the return value is NULL. - Else, the return value is a unzFile Handle, usable with other function + Else, the return value is a unzFile Handle, usable with other function of this unzip package. */ unzFile unzOpen(Common::SeekableReadStream *stream) { @@ -633,7 +633,7 @@ unzFile unzOpen(Common::SeekableReadStream *stream) { /* Close a ZipFile opened with unzipOpen. If there is files inside the .Zip opened with unzipOpenCurrentFile (see later), - these files MUST be closed with unzipCloseCurrentFile before call unzipClose. + these files MUST be closed with unzipCloseCurrentFile before call unzipClose. return UNZ_OK if there is no problem. */ int unzClose(unzFile file) { unz_s *s; @@ -683,22 +683,22 @@ static void unzlocal_DosDateToTmuDate(uLong ulDosDate, tm_unz* ptm) { Get Info about the current file in the zipfile, with internal only info */ static int unzlocal_GetCurrentFileInfoInternal(unzFile file, - unz_file_info *pfile_info, - unz_file_info_internal - *pfile_info_internal, - char *szFileName, + unz_file_info *pfile_info, + unz_file_info_internal + *pfile_info_internal, + char *szFileName, uLong fileNameBufferSize, - void *extraField, + void *extraField, uLong extraFieldBufferSize, - char *szComment, + char *szComment, uLong commentBufferSize); static int unzlocal_GetCurrentFileInfoInternal(unzFile file, - unz_file_info *pfile_info, - unz_file_info_internal *pfile_info_internal, - char *szFileName, uLong fileNameBufferSize, - void *extraField, uLong extraFieldBufferSize, - char *szComment, uLong commentBufferSize) + unz_file_info *pfile_info, + unz_file_info_internal *pfile_info_internal, + char *szFileName, uLong fileNameBufferSize, + void *extraField, uLong extraFieldBufferSize, + char *szComment, uLong commentBufferSize) { unz_s* s; unz_file_info file_info; @@ -848,10 +848,10 @@ static int unzlocal_GetCurrentFileInfoInternal(unzFile file, return UNZ_OK if there is no problem. */ int unzGetCurrentFileInfo(unzFile file, - unz_file_info *pfile_info, - char *szFileName, uLong fileNameBufferSize, - void *extraField, uLong extraFieldBufferSize, - char *szComment, uLong commentBufferSize) + unz_file_info *pfile_info, + char *szFileName, uLong fileNameBufferSize, + void *extraField, uLong extraFieldBufferSize, + char *szComment, uLong commentBufferSize) { return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,nullptr, szFileName,fileNameBufferSize, @@ -947,9 +947,9 @@ int unzLocateFile(unzFile file, const char *szFileName, int iCaseSensitivity) { /* Read the local header of the current zipfile Check the coherency of the local header and info in the end of central - directory about this file + directory about this file store in *piSizeVar the size of extra info in local header - (filename and size of extra field data) + (filename and size of extra field data) */ static int unzlocal_CheckCurrentFileCoherencyHeader(unz_s* s, uInt* piSizeVar, uLong *poffset_local_extrafield, @@ -1133,7 +1133,7 @@ int unzOpenCurrentFile (unzFile file) { return the number of byte copied if somes bytes are copied return 0 if the end of file was reached return <0 with error code if there is an error - (UNZ_ERRNO for IO error, or zLib error for uncompress error) + (UNZ_ERRNO for IO error, or zLib error for uncompress error) */ int unzReadCurrentFile(unzFile file, voidp buf, unsigned len) { int err=UNZ_OK; @@ -1295,7 +1295,7 @@ int unzeof(unzFile file) { /* Read extra field from the current file (opened by unzOpenCurrentFile) This is the local-header version of the extra field (sometimes, there is - more info in the local-header version than in the central-header) + more info in the local-header version than in the central-header) if buf==NULL, it return the size of the local extra field that can be read diff --git a/common/ustr.h b/common/ustr.h index 84f90671245..b5b7024856e 100644 --- a/common/ustr.h +++ b/common/ustr.h @@ -186,9 +186,9 @@ public: private: void decodeInternal(const char *str, uint32 len, CodePage page); void decodeOneByte(const char *str, uint32 len, CodePage page); - void decodeWindows932(const char *src, uint32 len); + void decodeWindows932(const char *src, uint32 len); void decodeWindows949(const char *src, uint32 len); - void decodeWindows950(const char *src, uint32 len); + void decodeWindows950(const char *src, uint32 len); void decodeUTF8(const char *str, uint32 len); friend class String; diff --git a/common/util.h b/common/util.h index cc78100e87d..0f634464c0f 100644 --- a/common/util.h +++ b/common/util.h @@ -40,7 +40,7 @@ * Note that 'alignment' must be a power of two! */ #define IS_ALIGNED(value, alignment) \ - ((((size_t)value) & ((alignment) - 1)) == 0) + ((((size_t)value) & ((alignment) - 1)) == 0) #ifdef ABS #undef ABS diff --git a/common/zlib.cpp b/common/zlib.cpp index 94fc7bb87bd..1f6e7f66c0d 100644 --- a/common/zlib.cpp +++ b/common/zlib.cpp @@ -32,13 +32,13 @@ #if defined(USE_ZLIB) #ifdef __SYMBIAN32__ - #include + #include #elif defined(__MORPHOS__) #define _NO_PPCINLINE #include #undef _NO_PPCINLINE #else - #include + #include #endif #if ZLIB_VERNUM < 0x1204 diff --git a/devtools/create_cryomni3d/create_cryomni3d_dat.cpp b/devtools/create_cryomni3d/create_cryomni3d_dat.cpp index 55b99712fd8..9296e938062 100644 --- a/devtools/create_cryomni3d/create_cryomni3d_dat.cpp +++ b/devtools/create_cryomni3d/create_cryomni3d_dat.cpp @@ -43,11 +43,11 @@ struct Parts { }; #define DEFINE_GAME_PLATFORM_LANG_FUNCS(game, platform, lang) \ - size_t write ## game ## _ ## platform ## _ ## lang ## _Header(FILE *f, \ - uint32 offset, uint32 size); \ - size_t write ## game ## _ ## platform ## _ ## lang ## _Data(FILE *f); + size_t write ## game ## _ ## platform ## _ ## lang ## _Header(FILE *f, \ + uint32 offset, uint32 size); \ + size_t write ## game ## _ ## platform ## _ ## lang ## _Data(FILE *f); #define GAME_PLATFORM_LANG_PART(game, platform, lang) { write ## game ## _ ## platform ## _ ## lang ## _Header, \ - write ## game ## _ ## platform ## _ ## lang ## _Data, 0, 0 } + write ## game ## _ ## platform ## _ ## lang ## _Data, 0, 0 } DEFINE_GAME_PLATFORM_LANG_FUNCS(Versailles, ALL, FR) DEFINE_GAME_PLATFORM_LANG_FUNCS(Versailles, ALL, BR) @@ -86,7 +86,7 @@ size_t writeFileHeader(FILE *f, uint16 games) { } size_t writeGameHeader(FILE *f, uint32 gameId, uint16 version, uint16 lang, uint32 platforms, - uint32 offset, uint32 size) { + uint32 offset, uint32 size) { size_t headerSize = 0; headerSize += writeUint32BE(f, gameId); // BE to keep the tag readable headerSize += writeUint16LE(f, version); diff --git a/devtools/create_cryomni3d/create_cryomni3d_dat.h b/devtools/create_cryomni3d/create_cryomni3d_dat.h index 47f77fb7d85..9f9a4e74b66 100644 --- a/devtools/create_cryomni3d/create_cryomni3d_dat.h +++ b/devtools/create_cryomni3d/create_cryomni3d_dat.h @@ -29,7 +29,7 @@ size_t writeFileHeader(FILE *f, uint16 games = 0xdead); size_t writeGameHeader(FILE *f, uint32 gameId, uint16 version, uint16 lang, uint32 platforms, - uint32 offset = 0xdeadfeed, uint32 size = 0xdeadfeed); + uint32 offset = 0xdeadfeed, uint32 size = 0xdeadfeed); #define PLATFORM_WIN 0x1 #define PLATFORM_DOS 0x2 diff --git a/devtools/create_cryomni3d/versailles.cpp b/devtools/create_cryomni3d/versailles.cpp index f476b8a2d1d..e6a9b18d3c3 100644 --- a/devtools/create_cryomni3d/versailles.cpp +++ b/devtools/create_cryomni3d/versailles.cpp @@ -59,67 +59,67 @@ size_t writeVersaillesSubtitles16(FILE *fp, Subtitle const *subtitles, uint16 el // In Versailles platform doesn't seem to change anything #define DEFINE_FUNCS(lang) \ - size_t writeVersailles_ALL_ ## lang ## _Header(FILE *f, uint32 offset, uint32 size) { \ - return writeGameHeader(f, VERSAILLES_GAMEID, VERSAILLES_VERSION, LANG_ ## lang, PLATFORM_ALL, \ - offset, size); \ - } \ - \ - size_t writeVersailles_ALL_ ## lang ## _Data(FILE *f) { \ - size_t size = 0; \ - \ - assert(VERSAILLES_LOCALIZED_FILENAMES_COUNT == ARRAYSIZE(versailles ## lang ## localizedFilenames)); \ - size += writeString16Array16(f, versailles ## lang ## localizedFilenames, \ - VERSAILLES_LOCALIZED_FILENAMES_COUNT); \ - \ - size += writeString16(f, versailles ## lang ## EpilMsg); \ - size += writeString16(f, versailles ## lang ## EpilPwd); \ - \ - size += writeString16(f, versailles ## lang ## BombPwd); \ - \ - assert(VERSAILLES_MESSAGES_COUNT == ARRAYSIZE(versailles ## lang ## messages)); \ - size += writeString16Array16(f, versailles ## lang ## messages, ARRAYSIZE(versailles ## lang ## messages)); \ - \ - assert(VERSAILLES_PAINTINGS_COUNT == ARRAYSIZE(versailles ## lang ## paintings)); \ - size += writeString16Array16(f, versailles ## lang ## paintings, ARRAYSIZE(versailles ## lang ## paintings)); \ - \ - size += writePadding(f); \ - return size; \ - } + size_t writeVersailles_ALL_ ## lang ## _Header(FILE *f, uint32 offset, uint32 size) { \ + return writeGameHeader(f, VERSAILLES_GAMEID, VERSAILLES_VERSION, LANG_ ## lang, PLATFORM_ALL, \ + offset, size); \ + } \ + \ + size_t writeVersailles_ALL_ ## lang ## _Data(FILE *f) { \ + size_t size = 0; \ + \ + assert(VERSAILLES_LOCALIZED_FILENAMES_COUNT == ARRAYSIZE(versailles ## lang ## localizedFilenames)); \ + size += writeString16Array16(f, versailles ## lang ## localizedFilenames, \ + VERSAILLES_LOCALIZED_FILENAMES_COUNT); \ + \ + size += writeString16(f, versailles ## lang ## EpilMsg); \ + size += writeString16(f, versailles ## lang ## EpilPwd); \ + \ + size += writeString16(f, versailles ## lang ## BombPwd); \ + \ + assert(VERSAILLES_MESSAGES_COUNT == ARRAYSIZE(versailles ## lang ## messages)); \ + size += writeString16Array16(f, versailles ## lang ## messages, ARRAYSIZE(versailles ## lang ## messages)); \ + \ + assert(VERSAILLES_PAINTINGS_COUNT == ARRAYSIZE(versailles ## lang ## paintings)); \ + size += writeString16Array16(f, versailles ## lang ## paintings, ARRAYSIZE(versailles ## lang ## paintings)); \ + \ + size += writePadding(f); \ + return size; \ + } #define DEFINE_FUNCS_CJK(lang) \ - size_t writeVersailles_ALL_ ## lang ## _Header(FILE *f, uint32 offset, uint32 size) { \ - return writeGameHeader(f, VERSAILLES_GAMEID, VERSAILLES_VERSION, LANG_ ## lang, PLATFORM_ALL, \ - offset, size); \ - } \ - \ - size_t writeVersailles_ALL_ ## lang ## _Data(FILE *f) { \ - size_t size = 0; \ - \ - assert(VERSAILLES_LOCALIZED_FILENAMES_COUNT == ARRAYSIZE(versailles ## lang ## localizedFilenames)); \ - size += writeString16Array16(f, versailles ## lang ## localizedFilenames, \ - VERSAILLES_LOCALIZED_FILENAMES_COUNT); \ - \ - size += writeString16(f, versailles ## lang ## EpilMsg); \ - size += writeString16(f, versailles ## lang ## EpilPwd); \ - \ - if ((LANG_ ## lang == LANG_JA)) { \ - assert(VERSAILLES_JA_BOMB_ALPHABET_SIZE + 1 == sizeof(versaillesJABombAlphabet)); \ - size += writeString16(f, versaillesJABombAlphabet); \ - } \ - size += writeString16(f, versailles ## lang ## BombPwd); \ - \ - assert(VERSAILLES_MESSAGES_COUNT_CJK == ARRAYSIZE(versailles ## lang ## messages)); \ - size += writeString16Array16(f, versailles ## lang ## messages, ARRAYSIZE(versailles ## lang ## messages)); \ - \ - assert(VERSAILLES_PAINTINGS_COUNT == ARRAYSIZE(versailles ## lang ## paintings)); \ - size += writeString16Array16(f, versailles ## lang ## paintings, ARRAYSIZE(versailles ## lang ## paintings)); \ - \ - /* No need to assert as we don't expect a fixed count in engine */ \ - size += writeVersaillesSubtitles16(f, versailles ## lang ## subtitles, ARRAYSIZE(versailles ## lang ## subtitles)); \ - \ - size += writePadding(f); \ - return size; \ - } + size_t writeVersailles_ALL_ ## lang ## _Header(FILE *f, uint32 offset, uint32 size) { \ + return writeGameHeader(f, VERSAILLES_GAMEID, VERSAILLES_VERSION, LANG_ ## lang, PLATFORM_ALL, \ + offset, size); \ + } \ + \ + size_t writeVersailles_ALL_ ## lang ## _Data(FILE *f) { \ + size_t size = 0; \ + \ + assert(VERSAILLES_LOCALIZED_FILENAMES_COUNT == ARRAYSIZE(versailles ## lang ## localizedFilenames)); \ + size += writeString16Array16(f, versailles ## lang ## localizedFilenames, \ + VERSAILLES_LOCALIZED_FILENAMES_COUNT); \ + \ + size += writeString16(f, versailles ## lang ## EpilMsg); \ + size += writeString16(f, versailles ## lang ## EpilPwd); \ + \ + if ((LANG_ ## lang == LANG_JA)) { \ + assert(VERSAILLES_JA_BOMB_ALPHABET_SIZE + 1 == sizeof(versaillesJABombAlphabet)); \ + size += writeString16(f, versaillesJABombAlphabet); \ + } \ + size += writeString16(f, versailles ## lang ## BombPwd); \ + \ + assert(VERSAILLES_MESSAGES_COUNT_CJK == ARRAYSIZE(versailles ## lang ## messages)); \ + size += writeString16Array16(f, versailles ## lang ## messages, ARRAYSIZE(versailles ## lang ## messages)); \ + \ + assert(VERSAILLES_PAINTINGS_COUNT == ARRAYSIZE(versailles ## lang ## paintings)); \ + size += writeString16Array16(f, versailles ## lang ## paintings, ARRAYSIZE(versailles ## lang ## paintings)); \ + \ + /* No need to assert as we don't expect a fixed count in engine */ \ + size += writeVersaillesSubtitles16(f, versailles ## lang ## subtitles, ARRAYSIZE(versailles ## lang ## subtitles)); \ + \ + size += writePadding(f); \ + return size; \ + } DEFINE_FUNCS(FR) DEFINE_FUNCS(BR) diff --git a/devtools/create_cryomni3d/versailles.h b/devtools/create_cryomni3d/versailles.h index 46bee5a7c5f..8f3cda6a5d3 100644 --- a/devtools/create_cryomni3d/versailles.h +++ b/devtools/create_cryomni3d/versailles.h @@ -126,123 +126,123 @@ static char const versaillesZTEpilPwd[] = "FOXANDCRANE"; static char const versaillesFRBombPwd[] = "JEMENVAISMAISLETATDEMEURERATOUJOURS"; static char const versaillesBRBombPwd[] = "O PODER DE UM REI NAO O TORNA IMORTAL"; static char const versaillesDEBombPwd[] = - "MONARCHEN IST ES NICHT GEGEBEN VOLLKOMMENHEIT ZU ERREICHEN"; + "MONARCHEN IST ES NICHT GEGEBEN VOLLKOMMENHEIT ZU ERREICHEN"; static char const versaillesENBombPwd[] = "IT IS NOT IN THE POWER OF KINGS TO ATTAIN PERFECTION"; static char const versaillesESBombPwd[] = "NO ES PODER DE REYES EL ALCANZAR LA PERFECCION"; static char const versaillesITBombPwd[] = "AI SOVRANI NON E DATO RAGGIUNGERE LA PERFEZIONE"; static char const versaillesJABombPwd[] = "\203V\203A\203K\203\212\203m\203_\203\223\203J\203C" - "\203j\203C\203^\203c\203^\203m\203K\203R\203N\203I\203E\203^\203`\203j\203`\203J\203\211\203K" - "\203A\203\213\203R\203g\203j\203i\203\211\203i\203C\203m\203_"; + "\203j\203C\203^\203c\203^\203m\203K\203R\203N\203I\203E\203^\203`\203j\203`\203J\203\211\203K" + "\203A\203\213\203R\203g\203j\203i\203\211\203i\203C\203m\203_"; static char const versaillesKOBombPwd[] = "IT IS NOT IN THE POWER OF KINGS TO ATTAIN PERFECTION"; static char const versaillesZTBombPwd[] = "IT IS NOT IN THE POWER OF KINGS TO ATTAIN PERFECTION"; #define VERSAILLES_JA_BOMB_ALPHABET_SIZE 2490 static char const versaillesJABombAlphabet[] = - "\202\323\202\255\202\353\202\244\202\306\221\274\202\314\222\271\202\275\202\277\210\253\202\242" - "\202\323\202\255\202\353\202\244\202\252\222\213\212\324\201A\222\271\202\275\202\277\202\360" - "\212l\202\350\202\311\217o\202\251\202\257\222\271\202\275\202\277\202\315\217W\202\334" - "\202\301\202\304\211\236\220\355\217X\202\255\202\267\202\254\202\270\224\374\202\265\202\267" - "\202\254\202\270\223\313\202\301\202\302\202\253\201A\220\330\202\350\227\364\202\253\201A" - "\215\217\202\361\202\305\202\277\202\254\202\351\227Y\214{\202\306\203_\203C\203A" - "\203\202\203\223\203h\227Y\214{\202\252\201A\345v\222\216\202\360\222T\202\265" - "\202\304\222n\226\312\202\360\214@\202\301\202\304\202\242\202\351\202\306\203_\203C" - "\203A\203\202\203\223\203h\202\360\214@\202\350\223\226\202\304\202\275\227Y\214{" - "\202\252\214\276\202\244\202\311\202\315\201A\202\261\202\361\202\310\220\316\202\261\202\353" - "\202\252\211\275\202\314\226\360\202\311\202\275\202\302\201H\224a\202\314\202\331\202\244" - "\202\252\202\334\202\276\202\334\202\265\202\310\202\314\202\311\224L\202\306\203l\203Y" - "\203~\224L\202\252\216\200\202\361\202\276\202\323\202\350\202\360\202\265\202\304\203l" - "\203Y\203~\202\360\202\275\202\255\202\263\202\361\225\337\202\334\202\246\202\275\202\340" - "\202\301\202\306\225\337\202\334\202\246\202\346\202\244\202\306\201A\217\254\224\236\225\262" - "\202\311\202\334\202\335\202\352\202\304\211B\202\352\202\304\202\242\202\351\202\306\224N" - "\212\361\202\350\203l\203Y\203~\202\252\225@\202\360\202\255\202\361\202\255\202\361" - "\224L\202\346\202\350\217\254\224\236\225\262\202\314\202\331\202\244\202\252\202\250\202\242" - "\202\265\202\273\202\244\202\276\227\263\202\306\202\342\202\267\202\350\227\263\202\252\202\342" - "\202\267\202\350\202\360\202\251\202\266\202\301\202\304\202\242\202\351\202\306\202\342\202\267" - "\202\350\202\252\220\324\226\332\202\314\227\263\202\311\220q\202\313\202\275\202\310\202\272" - "\214\343\220\346\202\340\215l\202\246\202\270\201A\341\222\341\233\202\360\213N\202\261" - "\202\265\202\304\226l\202\360\202\251\202\266\202\351\202\314\201H\214\253\202\242\202\240" - "\202\310\202\275\202\314\216\225\202\252\202\310\202\255\202\310\202\301\202\304\202\265\202\334" - "\202\244\202\346\202\253\202\302\202\313\202\306\222\337\202\253\202\302\202\313\202\252\222\337" - "\202\360\220H\216\226\202\311\217\265\202\242\202\304\225\275\202\327\202\301\202\275\202\242" - "\216M\202\311\223\374\202\352\202\304\217o\202\265\202\275\216\251\225\252\202\315\202\346" - "\202\276\202\352\202\360\202\275\202\347\202\265\202\310\202\252\202\347\216M\202\360\202\330" - "\202\353\202\330\202\353\232{\202\314\222\267\202\242\222\337\202\315\202\275\202\276\202\267" - "\202\267\202\351\202\276\202\257\201B\222\337\202\306\202\253\202\302\202\313\202\261\202\361" - "\202\307\202\315\222\337\202\252\202\253\202\302\202\313\202\360\217\265\202\242\202\304\215\327" - "\222\267\202\242\202\302\202\332\202\311\223\374\202\352\202\304\217o\202\265\202\275\222\337" - "\202\315\202\250\225\240\210\352\224t\220H\202\327\202\275\202\350\210\371\202\361\202\276" - "\202\350\202\251\202\255\202\265\202\304\225\234\217Q\202\315\220\213\202\260\202\347\202\352" - "\202\275\201B\216\223\214{\202\306\203q\203\210\203R\202\275\202\277\202\306\202\361" - "\202\321\202\252\227\326\202\360\202\251\202\242\202\304\224\362\202\361\202\305\202\242\202\351" - "\202\314\202\360\214\251\202\302\202\257\202\275\216\223\214{\202\240\202\355\202\304\202\304" - "\203q\203\210\203R\202\275\202\277\202\360\214{\217\254\211\256\202\326\202\265\202\251" - "\202\265\216\251\225\252\202\252\220H\202\327\202\347\202\352\202\304\202\240\202\355\202\352" - "\202\310\203q\203\210\203R\202\275\202\277\202\315\212O\202\326\202\340\217o\202\347" - "\202\352\202\270\201A\225\302\202\266\202\261\202\337\202\347\202\352\202\275\202\334\202\334" - "\230V\202\242\202\304\202\242\202\255\201B\230T\202\306\222\337\230T\202\252\215\234" - "\202\360\202\314\202\335\202\261\202\361\202\305\201A\202\314\202\307\202\311\216h\202\263" - "\202\301\202\304\222\311\202\255\202\304\202\275\202\334\202\347\202\310\202\242\202\273\202\261" - "\202\305\222\337\202\311\201A\202\250\212\350\202\242\202\276\202\251\202\347\202\261\202\314" - "\215\234\202\360\202\306\202\301\202\304\202\277\202\345\202\244\202\276\202\242\201A\202\273" - "\202\314\202\251\202\355\202\350\215\234\202\360\202\306\202\301\202\304\202\340\202\347\202\301" - "\202\304\202\340\214N\202\314\202\261\202\306\202\360\220H\202\327\202\275\202\350\202\265" - "\202\310\202\242\202\251\202\347\230T\202\315\201A\202\273\202\244\214\276\202\242\202\310" - "\202\252\202\347\202\340\202\323\202\255\202\352\202\301\226\312\221\351\202\306\217\254\222\271" - "\202\275\202\277\221\351\202\252\217\254\222\271\202\275\202\277\202\360\220H\216\226\202\311" - "\217\265\202\242\202\275\222a\220\266\223\372\202\314\202\250\217j\202\242\202\360\202\267" - "\202\351\202\251\202\347\221\201\202\255\227\210\202\304\211\272\202\263\202\242\217\254\222\271" - "\202\275\202\277\202\252\217W\202\334\202\301\202\304\217j\202\242\202\314\220\310\202\311" - "\202\302\202\255\202\306\221\351\202\315\202\267\202\256\202\263\202\334\217P\202\242\202\251" - "\202\251\202\350\201A\202\262\202\277\202\273\202\244\202\311\202\240\202\350\202\302\202\242" - "\202\275\202\251\202\246\202\351\202\306\203W\203\205\203s\203^\201[\211\244\227l" - "\202\276\202\346\201A\202\306\203W\203\205\203s\203^\201[\202\252\202\255\202\352" - "\202\275\212\333\221\276\202\315\221\345\202\265\202\275\225\250\202\266\202\341\202\310\202\251" - "\202\301\202\275\202\306\202\251\202\246\202\351\202\275\202\277\202\315\203K\201[\203K" - "\201[\225\266\213\345\202\316\202\251\202\350\202\273\202\261\202\305\203W\203\205\203s" - "\203^\201[\202\315\203R\203E\203m\203g\203\212\202\360\202\302\202\251\202\355" - "\202\265\202\304\202\251\202\246\202\351\202\275\202\277\202\360\202\335\202\361\202\310\220H" - "\202\327\202\263\202\271\202\275\230h\202\306\202\244\202\263\202\254\202\306\202\251\202\324" - "\202\306\222\216\230h\202\252\202\244\202\263\202\254\202\360\202\302\202\251\202\334\202\246" - "\202\275\202\244\202\263\202\254\202\314\227F\222B\202\314\202\251\202\324\202\306\222\216" - "\202\252\201A\202\307\202\244\202\251\202\244\202\263\202\254\202\360\217\225\202\257\202\304" - "\202\342\202\301\202\304\211\272\202\263\202\242\202\265\202\251\202\265\230h\202\315\202\244" - "\202\263\202\254\202\360\220H\202\327\202\304\202\265\202\334\202\242\202\251\202\324\202\306" - "\222\216\202\315\230h\202\360\215\246\202\361\202\305\201A\230h\202\314\216Y\202\361" - "\202\276\227\221\202\360\221S\225\224\225\262\201X\202\311\215\323\202\242\202\304\202\265" - "\202\334\202\301\202\275\203l\203Y\203~\202\306\224L\202\306\217\254\202\263\202\310" - "\227Y\214{\216q\203l\203Y\203~\202\252\202\250\225\352\202\263\202\361\202\311" - "\201A\202\332\202\255\202\315\227Y\214{\202\315\202\253\202\347\202\242\202\276\202\257" - "\202\307\224L\202\315\221\345\215D\202\253\202\267\202\351\202\306\202\250\225\352\202\263" - "\202\361\202\315\201A\211\275\202\360\214\276\202\244\202\314\202\250\202\277\202\321\202\277" - "\202\341\202\361\201A\224L\202\315\216\204\202\275\202\277\202\360\220H\202\327\202\304" - "\202\240\202\361\202\310\202\311\221\276\202\301\202\304\202\251\202\301\202\261\202\346\202\255" - "\202\310\202\301\202\275\202\314\202\346\202\305\202\340\227Y\214{\202\252\202\342\202\271" - "\202\304\212i\215D\202\252\210\253\202\242\202\314\202\315\201A\216\204\202\275\202\277" - "\203l\203Y\203~\202\360\202\302\202\251\202\334\202\246\202\347\202\352\202\310\202\242" - "\202\251\202\347\202\310\202\314\202\346\224\222\222\271\202\306\203R\203E\203m\203g" - "\203\212\224\222\222\271\202\252\220\205\225\323\202\305\224\374\202\265\202\242\220\272\202\305" - "\211\314\202\301\202\304\202\242\202\351\202\306\202\307\202\244\202\265\202\304\211\314\202\301" - "\202\304\202\242\202\351\202\314\201H\202\306\222m\202\350\202\275\202\252\202\350\211\256" - "\202\314\203R\203E\203m\203g\203\212\202\276\202\301\202\304\216\204\202\315\202\340" - "\202\244\202\267\202\256\216\200\202\312\202\361\202\276\202\301\202\304\214\374\202\261\202\244" - "\202\251\202\347\202\242\202\242\222m\202\347\202\271\202\252\223\315\202\242\202\275\202\361" - "\202\305\202\267\202\340\202\314\202\250\202\250\202\251\202\335\202\306\222\244\221\234\214\216" - "\202\314\214\365\202\305\201A\222\244\221\234\202\252\223\256\202\242\202\275\202\346\202\244" - "\202\311\214\251\202\246\202\275\202\314\202\305\201A\202\250\202\250\202\251\202\335\202\315" - "\225\337\202\334\202\246\202\346\202\244\202\306\220g\215\\\202\246\202\275\202\305\202\340" - "\216c\224O\202\310\202\252\202\347\222\244\221\234\202\311\202\315\220\316\202\314\221\314" - "\202\360\223\256\202\251\202\267\202\275\202\337\202\314\220S\202\340\202\310\202\242\202\265" - "\212\264\217\356\202\340\202\310\202\242\201A\215l\202\246\202\340\217\356\224M\202\340" - "\201A\210\244\202\340\202\310\202\242\202\240\202\320\202\351\202\306\203X\203p\203j" - "\203G\203\213\214\242\203X\203p\203j\203G\203\213\214\242\202\252\226\260\202\301" - "\202\304\202\242\202\351\203A\203q\203\213\202\311\202\251\202\335\202\302\202\261\202\244" - "\202\306\202\267\202\351\202\306\203A\203q\203\213\202\315\202\267\202\316\202\342\202\255" - "\223\246\202\260\202\304\203K\201[\203K\201[\226\302\202\253\202\310\202\252\202\347" - "\214\242\202\360\202\261\202\244\224l\202\301\202\275\216\251\225\252\202\314\216\350\202\311" - "\223\315\202\251\202\310\202\242\202\340\202\314\202\360\222\307\202\242\202\251\202\257\202\351" - "\202\310\202\361\202\304\201A\214N\202\315\211\275\202\304\202\244\202\312\202\332\202\352" - "\202\342\202\305\202\250\202\353\202\251\216\322\202\310\202\361\202\276"; + "\202\323\202\255\202\353\202\244\202\306\221\274\202\314\222\271\202\275\202\277\210\253\202\242" + "\202\323\202\255\202\353\202\244\202\252\222\213\212\324\201A\222\271\202\275\202\277\202\360" + "\212l\202\350\202\311\217o\202\251\202\257\222\271\202\275\202\277\202\315\217W\202\334" + "\202\301\202\304\211\236\220\355\217X\202\255\202\267\202\254\202\270\224\374\202\265\202\267" + "\202\254\202\270\223\313\202\301\202\302\202\253\201A\220\330\202\350\227\364\202\253\201A" + "\215\217\202\361\202\305\202\277\202\254\202\351\227Y\214{\202\306\203_\203C\203A" + "\203\202\203\223\203h\227Y\214{\202\252\201A\345v\222\216\202\360\222T\202\265" + "\202\304\222n\226\312\202\360\214@\202\301\202\304\202\242\202\351\202\306\203_\203C" + "\203A\203\202\203\223\203h\202\360\214@\202\350\223\226\202\304\202\275\227Y\214{" + "\202\252\214\276\202\244\202\311\202\315\201A\202\261\202\361\202\310\220\316\202\261\202\353" + "\202\252\211\275\202\314\226\360\202\311\202\275\202\302\201H\224a\202\314\202\331\202\244" + "\202\252\202\334\202\276\202\334\202\265\202\310\202\314\202\311\224L\202\306\203l\203Y" + "\203~\224L\202\252\216\200\202\361\202\276\202\323\202\350\202\360\202\265\202\304\203l" + "\203Y\203~\202\360\202\275\202\255\202\263\202\361\225\337\202\334\202\246\202\275\202\340" + "\202\301\202\306\225\337\202\334\202\246\202\346\202\244\202\306\201A\217\254\224\236\225\262" + "\202\311\202\334\202\335\202\352\202\304\211B\202\352\202\304\202\242\202\351\202\306\224N" + "\212\361\202\350\203l\203Y\203~\202\252\225@\202\360\202\255\202\361\202\255\202\361" + "\224L\202\346\202\350\217\254\224\236\225\262\202\314\202\331\202\244\202\252\202\250\202\242" + "\202\265\202\273\202\244\202\276\227\263\202\306\202\342\202\267\202\350\227\263\202\252\202\342" + "\202\267\202\350\202\360\202\251\202\266\202\301\202\304\202\242\202\351\202\306\202\342\202\267" + "\202\350\202\252\220\324\226\332\202\314\227\263\202\311\220q\202\313\202\275\202\310\202\272" + "\214\343\220\346\202\340\215l\202\246\202\270\201A\341\222\341\233\202\360\213N\202\261" + "\202\265\202\304\226l\202\360\202\251\202\266\202\351\202\314\201H\214\253\202\242\202\240" + "\202\310\202\275\202\314\216\225\202\252\202\310\202\255\202\310\202\301\202\304\202\265\202\334" + "\202\244\202\346\202\253\202\302\202\313\202\306\222\337\202\253\202\302\202\313\202\252\222\337" + "\202\360\220H\216\226\202\311\217\265\202\242\202\304\225\275\202\327\202\301\202\275\202\242" + "\216M\202\311\223\374\202\352\202\304\217o\202\265\202\275\216\251\225\252\202\315\202\346" + "\202\276\202\352\202\360\202\275\202\347\202\265\202\310\202\252\202\347\216M\202\360\202\330" + "\202\353\202\330\202\353\232{\202\314\222\267\202\242\222\337\202\315\202\275\202\276\202\267" + "\202\267\202\351\202\276\202\257\201B\222\337\202\306\202\253\202\302\202\313\202\261\202\361" + "\202\307\202\315\222\337\202\252\202\253\202\302\202\313\202\360\217\265\202\242\202\304\215\327" + "\222\267\202\242\202\302\202\332\202\311\223\374\202\352\202\304\217o\202\265\202\275\222\337" + "\202\315\202\250\225\240\210\352\224t\220H\202\327\202\275\202\350\210\371\202\361\202\276" + "\202\350\202\251\202\255\202\265\202\304\225\234\217Q\202\315\220\213\202\260\202\347\202\352" + "\202\275\201B\216\223\214{\202\306\203q\203\210\203R\202\275\202\277\202\306\202\361" + "\202\321\202\252\227\326\202\360\202\251\202\242\202\304\224\362\202\361\202\305\202\242\202\351" + "\202\314\202\360\214\251\202\302\202\257\202\275\216\223\214{\202\240\202\355\202\304\202\304" + "\203q\203\210\203R\202\275\202\277\202\360\214{\217\254\211\256\202\326\202\265\202\251" + "\202\265\216\251\225\252\202\252\220H\202\327\202\347\202\352\202\304\202\240\202\355\202\352" + "\202\310\203q\203\210\203R\202\275\202\277\202\315\212O\202\326\202\340\217o\202\347" + "\202\352\202\270\201A\225\302\202\266\202\261\202\337\202\347\202\352\202\275\202\334\202\334" + "\230V\202\242\202\304\202\242\202\255\201B\230T\202\306\222\337\230T\202\252\215\234" + "\202\360\202\314\202\335\202\261\202\361\202\305\201A\202\314\202\307\202\311\216h\202\263" + "\202\301\202\304\222\311\202\255\202\304\202\275\202\334\202\347\202\310\202\242\202\273\202\261" + "\202\305\222\337\202\311\201A\202\250\212\350\202\242\202\276\202\251\202\347\202\261\202\314" + "\215\234\202\360\202\306\202\301\202\304\202\277\202\345\202\244\202\276\202\242\201A\202\273" + "\202\314\202\251\202\355\202\350\215\234\202\360\202\306\202\301\202\304\202\340\202\347\202\301" + "\202\304\202\340\214N\202\314\202\261\202\306\202\360\220H\202\327\202\275\202\350\202\265" + "\202\310\202\242\202\251\202\347\230T\202\315\201A\202\273\202\244\214\276\202\242\202\310" + "\202\252\202\347\202\340\202\323\202\255\202\352\202\301\226\312\221\351\202\306\217\254\222\271" + "\202\275\202\277\221\351\202\252\217\254\222\271\202\275\202\277\202\360\220H\216\226\202\311" + "\217\265\202\242\202\275\222a\220\266\223\372\202\314\202\250\217j\202\242\202\360\202\267" + "\202\351\202\251\202\347\221\201\202\255\227\210\202\304\211\272\202\263\202\242\217\254\222\271" + "\202\275\202\277\202\252\217W\202\334\202\301\202\304\217j\202\242\202\314\220\310\202\311" + "\202\302\202\255\202\306\221\351\202\315\202\267\202\256\202\263\202\334\217P\202\242\202\251" + "\202\251\202\350\201A\202\262\202\277\202\273\202\244\202\311\202\240\202\350\202\302\202\242" + "\202\275\202\251\202\246\202\351\202\306\203W\203\205\203s\203^\201[\211\244\227l" + "\202\276\202\346\201A\202\306\203W\203\205\203s\203^\201[\202\252\202\255\202\352" + "\202\275\212\333\221\276\202\315\221\345\202\265\202\275\225\250\202\266\202\341\202\310\202\251" + "\202\301\202\275\202\306\202\251\202\246\202\351\202\275\202\277\202\315\203K\201[\203K" + "\201[\225\266\213\345\202\316\202\251\202\350\202\273\202\261\202\305\203W\203\205\203s" + "\203^\201[\202\315\203R\203E\203m\203g\203\212\202\360\202\302\202\251\202\355" + "\202\265\202\304\202\251\202\246\202\351\202\275\202\277\202\360\202\335\202\361\202\310\220H" + "\202\327\202\263\202\271\202\275\230h\202\306\202\244\202\263\202\254\202\306\202\251\202\324" + "\202\306\222\216\230h\202\252\202\244\202\263\202\254\202\360\202\302\202\251\202\334\202\246" + "\202\275\202\244\202\263\202\254\202\314\227F\222B\202\314\202\251\202\324\202\306\222\216" + "\202\252\201A\202\307\202\244\202\251\202\244\202\263\202\254\202\360\217\225\202\257\202\304" + "\202\342\202\301\202\304\211\272\202\263\202\242\202\265\202\251\202\265\230h\202\315\202\244" + "\202\263\202\254\202\360\220H\202\327\202\304\202\265\202\334\202\242\202\251\202\324\202\306" + "\222\216\202\315\230h\202\360\215\246\202\361\202\305\201A\230h\202\314\216Y\202\361" + "\202\276\227\221\202\360\221S\225\224\225\262\201X\202\311\215\323\202\242\202\304\202\265" + "\202\334\202\301\202\275\203l\203Y\203~\202\306\224L\202\306\217\254\202\263\202\310" + "\227Y\214{\216q\203l\203Y\203~\202\252\202\250\225\352\202\263\202\361\202\311" + "\201A\202\332\202\255\202\315\227Y\214{\202\315\202\253\202\347\202\242\202\276\202\257" + "\202\307\224L\202\315\221\345\215D\202\253\202\267\202\351\202\306\202\250\225\352\202\263" + "\202\361\202\315\201A\211\275\202\360\214\276\202\244\202\314\202\250\202\277\202\321\202\277" + "\202\341\202\361\201A\224L\202\315\216\204\202\275\202\277\202\360\220H\202\327\202\304" + "\202\240\202\361\202\310\202\311\221\276\202\301\202\304\202\251\202\301\202\261\202\346\202\255" + "\202\310\202\301\202\275\202\314\202\346\202\305\202\340\227Y\214{\202\252\202\342\202\271" + "\202\304\212i\215D\202\252\210\253\202\242\202\314\202\315\201A\216\204\202\275\202\277" + "\203l\203Y\203~\202\360\202\302\202\251\202\334\202\246\202\347\202\352\202\310\202\242" + "\202\251\202\347\202\310\202\314\202\346\224\222\222\271\202\306\203R\203E\203m\203g" + "\203\212\224\222\222\271\202\252\220\205\225\323\202\305\224\374\202\265\202\242\220\272\202\305" + "\211\314\202\301\202\304\202\242\202\351\202\306\202\307\202\244\202\265\202\304\211\314\202\301" + "\202\304\202\242\202\351\202\314\201H\202\306\222m\202\350\202\275\202\252\202\350\211\256" + "\202\314\203R\203E\203m\203g\203\212\202\276\202\301\202\304\216\204\202\315\202\340" + "\202\244\202\267\202\256\216\200\202\312\202\361\202\276\202\301\202\304\214\374\202\261\202\244" + "\202\251\202\347\202\242\202\242\222m\202\347\202\271\202\252\223\315\202\242\202\275\202\361" + "\202\305\202\267\202\340\202\314\202\250\202\250\202\251\202\335\202\306\222\244\221\234\214\216" + "\202\314\214\365\202\305\201A\222\244\221\234\202\252\223\256\202\242\202\275\202\346\202\244" + "\202\311\214\251\202\246\202\275\202\314\202\305\201A\202\250\202\250\202\251\202\335\202\315" + "\225\337\202\334\202\246\202\346\202\244\202\306\220g\215\\\202\246\202\275\202\305\202\340" + "\216c\224O\202\310\202\252\202\347\222\244\221\234\202\311\202\315\220\316\202\314\221\314" + "\202\360\223\256\202\251\202\267\202\275\202\337\202\314\220S\202\340\202\310\202\242\202\265" + "\212\264\217\356\202\340\202\310\202\242\201A\215l\202\246\202\340\217\356\224M\202\340" + "\201A\210\244\202\340\202\310\202\242\202\240\202\320\202\351\202\306\203X\203p\203j" + "\203G\203\213\214\242\203X\203p\203j\203G\203\213\214\242\202\252\226\260\202\301" + "\202\304\202\242\202\351\203A\203q\203\213\202\311\202\251\202\335\202\302\202\261\202\244" + "\202\306\202\267\202\351\202\306\203A\203q\203\213\202\315\202\267\202\316\202\342\202\255" + "\223\246\202\260\202\304\203K\201[\203K\201[\226\302\202\253\202\310\202\252\202\347" + "\214\242\202\360\202\261\202\244\224l\202\301\202\275\216\251\225\252\202\314\216\350\202\311" + "\223\315\202\251\202\310\202\242\202\340\202\314\202\360\222\307\202\242\202\251\202\257\202\351" + "\202\310\202\361\202\304\201A\214N\202\315\211\275\202\304\202\244\202\312\202\332\202\352" + "\202\342\202\305\202\250\202\353\202\251\216\322\202\310\202\361\202\276"; #define VERSAILLES_MESSAGES_COUNT 146 #define VERSAILLES_MESSAGES_COUNT_CJK 151 diff --git a/devtools/create_project/cmake.cpp b/devtools/create_project/cmake.cpp index dfec5d3614b..b91232d0ef3 100644 --- a/devtools/create_project/cmake.cpp +++ b/devtools/create_project/cmake.cpp @@ -234,7 +234,7 @@ void CMakeProvider::writeSubEngines(const BuildSetup &setup, std::ofstream &work } void CMakeProvider::createProjectFile(const std::string &name, const std::string &, const BuildSetup &setup, const std::string &moduleDir, - const StringList &includeList, const StringList &excludeList) { + const StringList &includeList, const StringList &excludeList) { const std::string projectFile = setup.outputDir + "/CMakeLists.txt"; std::ofstream project(projectFile.c_str(), std::ofstream::out | std::ofstream::app); @@ -320,7 +320,7 @@ void CMakeProvider::writeDefines(const BuildSetup &setup, std::ofstream &output) } void CMakeProvider::writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int indentation, - const std::string &objPrefix, const std::string &filePrefix) { + const std::string &objPrefix, const std::string &filePrefix) { std::string lastName; for (FileNode::NodeList::const_iterator i = dir.children.begin(); i != dir.children.end(); ++i) { diff --git a/devtools/create_project/codeblocks.cpp b/devtools/create_project/codeblocks.cpp index 06f16f5da80..a0d7d20156f 100644 --- a/devtools/create_project/codeblocks.cpp +++ b/devtools/create_project/codeblocks.cpp @@ -96,7 +96,7 @@ StringList getFeatureLibraries(const BuildSetup &setup) { } void CodeBlocksProvider::createProjectFile(const std::string &name, const std::string &, const BuildSetup &setup, const std::string &moduleDir, - const StringList &includeList, const StringList &excludeList) { + const StringList &includeList, const StringList &excludeList) { const std::string projectFile = setup.outputDir + '/' + name + getProjectExtension(); std::ofstream project(projectFile.c_str()); @@ -242,7 +242,7 @@ void CodeBlocksProvider::writeDefines(const StringList &defines, std::ofstream & } void CodeBlocksProvider::writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int indentation, - const std::string &objPrefix, const std::string &filePrefix) { + const std::string &objPrefix, const std::string &filePrefix) { for (FileNode::NodeList::const_iterator i = dir.children.begin(); i != dir.children.end(); ++i) { const FileNode *node = *i; diff --git a/devtools/create_project/create_project.cpp b/devtools/create_project/create_project.cpp index b30be619c17..da7cbb1ac45 100644 --- a/devtools/create_project/create_project.cpp +++ b/devtools/create_project/create_project.cpp @@ -1512,7 +1512,7 @@ FileNode *scanFiles(const std::string &dir, const StringList &includeList, const // Project Provider methods ////////////////////////////////////////////////////////////////////////// ProjectProvider::ProjectProvider(StringList &global_warnings, std::map &project_warnings, const int version) - : _version(version), _globalWarnings(global_warnings), _projectWarnings(project_warnings) { + : _version(version), _globalWarnings(global_warnings), _projectWarnings(project_warnings) { } void ProjectProvider::createProject(BuildSetup &setup) { @@ -1765,8 +1765,8 @@ std::string ProjectProvider::getLastPathComponent(const std::string &path) { } void ProjectProvider::addFilesToProject(const std::string &dir, std::ofstream &projectFile, - const StringList &includeList, const StringList &excludeList, - const std::string &filePrefix) { + const StringList &includeList, const StringList &excludeList, + const std::string &filePrefix) { FileNode *files = scanFiles(dir, includeList, excludeList); writeFileListToProject(*files, projectFile, 0, std::string(), filePrefix + '/'); diff --git a/devtools/create_project/msbuild.cpp b/devtools/create_project/msbuild.cpp index f71c2370a8c..4abccdf12ea 100644 --- a/devtools/create_project/msbuild.cpp +++ b/devtools/create_project/msbuild.cpp @@ -33,7 +33,7 @@ namespace CreateProjectTool { ////////////////////////////////////////////////////////////////////////// MSBuildProvider::MSBuildProvider(StringList &global_warnings, std::map &project_warnings, const int version, const MSVCVersion &msvc) - : MSVCProvider(global_warnings, project_warnings, version, msvc) { + : MSVCProvider(global_warnings, project_warnings, version, msvc) { _archs.push_back(ARCH_X86); _archs.push_back(ARCH_AMD64); @@ -74,7 +74,7 @@ inline void outputProperties(std::ostream &project, const std::string &config, c } // End of anonymous namespace void MSBuildProvider::createProjectFile(const std::string &name, const std::string &uuid, const BuildSetup &setup, const std::string &moduleDir, - const StringList &includeList, const StringList &excludeList) { + const StringList &includeList, const StringList &excludeList) { const std::string projectFile = setup.outputDir + '/' + name + getProjectExtension(); std::ofstream project(projectFile.c_str()); if (!project || !project.is_open()) { @@ -493,7 +493,7 @@ void MSBuildProvider::outputNasmCommand(std::ostream &projectFile, const std::st } void MSBuildProvider::writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int, - const std::string &objPrefix, const std::string &filePrefix) { + const std::string &objPrefix, const std::string &filePrefix) { // Reset lists _filters.clear(); _compileFiles.clear(); diff --git a/devtools/create_project/msvc.cpp b/devtools/create_project/msvc.cpp index 410185a76f5..9ed3984ad64 100644 --- a/devtools/create_project/msvc.cpp +++ b/devtools/create_project/msvc.cpp @@ -33,7 +33,7 @@ namespace CreateProjectTool { // MSVC Provider (Base class) ////////////////////////////////////////////////////////////////////////// MSVCProvider::MSVCProvider(StringList &global_warnings, std::map &project_warnings, const int version, const MSVCVersion &msvc) - : ProjectProvider(global_warnings, project_warnings, version), _msvcVersion(msvc) { + : ProjectProvider(global_warnings, project_warnings, version), _msvcVersion(msvc) { _enableLanguageExtensions = tokenize(ENABLE_LANGUAGE_EXTENSIONS, ','); _disableEditAndContinue = tokenize(DISABLE_EDIT_AND_CONTINUE, ','); diff --git a/devtools/create_project/visualstudio.cpp b/devtools/create_project/visualstudio.cpp index fa67b025ab9..f8196d65e44 100644 --- a/devtools/create_project/visualstudio.cpp +++ b/devtools/create_project/visualstudio.cpp @@ -33,7 +33,7 @@ namespace CreateProjectTool { ////////////////////////////////////////////////////////////////////////// VisualStudioProvider::VisualStudioProvider(StringList &global_warnings, std::map &project_warnings, const int version, const MSVCVersion &msvc) - : MSVCProvider(global_warnings, project_warnings, version, msvc) { + : MSVCProvider(global_warnings, project_warnings, version, msvc) { _archs.push_back(ARCH_X86); _archs.push_back(ARCH_AMD64); @@ -48,7 +48,7 @@ const char *VisualStudioProvider::getPropertiesExtension() { } void VisualStudioProvider::createProjectFile(const std::string &name, const std::string &uuid, const BuildSetup &setup, const std::string &moduleDir, - const StringList &includeList, const StringList &excludeList) { + const StringList &includeList, const StringList &excludeList) { const std::string projectFile = setup.outputDir + '/' + name + getProjectExtension(); std::ofstream project(projectFile.c_str()); if (!project || !project.is_open()) { @@ -314,7 +314,7 @@ void VisualStudioProvider::createBuildProp(const BuildSetup &setup, bool isRelea } void VisualStudioProvider::writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int indentation, - const std::string &objPrefix, const std::string &filePrefix) { + const std::string &objPrefix, const std::string &filePrefix) { const std::string indentString = getIndent(indentation + 2); if (indentation) @@ -354,7 +354,7 @@ void VisualStudioProvider::writeFileListToProject(const FileNode &dir, std::ofst } void VisualStudioProvider::writeFileToProject(std::ofstream &projectFile, const std::string &filePath, MSVC_Architecture arch, - const std::string &indentString, const std::string &toolLine) { + const std::string &indentString, const std::string &toolLine) { projectFile << indentString << "\n" << indentString << "\t\n" << toolLine diff --git a/devtools/create_project/xcode.cpp b/devtools/create_project/xcode.cpp index 7ef429f31d7..e4554991500 100644 --- a/devtools/create_project/xcode.cpp +++ b/devtools/create_project/xcode.cpp @@ -318,7 +318,7 @@ void XcodeProvider::createOtherBuildFiles(const BuildSetup &setup) { // Store information about a project here, for use at the end void XcodeProvider::createProjectFile(const std::string &, const std::string &, const BuildSetup &setup, const std::string &moduleDir, - const StringList &includeList, const StringList &excludeList) { + const StringList &includeList, const StringList &excludeList) { std::string modulePath; if (!moduleDir.compare(0, setup.srcDir.size(), setup.srcDir)) { modulePath = moduleDir.substr(setup.srcDir.size()); @@ -377,7 +377,7 @@ void XcodeProvider::outputMainProjectFile(const BuildSetup &setup) { // Files ////////////////////////////////////////////////////////////////////////// void XcodeProvider::writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int indentation, - const std::string &objPrefix, const std::string &filePrefix) { + const std::string &objPrefix, const std::string &filePrefix) { // Ensure that top-level groups are generated for i.e. engines/ Group *group = touchGroupsForPath(filePrefix); diff --git a/devtools/create_titanic/zlib.cpp b/devtools/create_titanic/zlib.cpp index 8c0ffabfd4f..f24b2bb9b77 100644 --- a/devtools/create_titanic/zlib.cpp +++ b/devtools/create_titanic/zlib.cpp @@ -31,9 +31,9 @@ #if defined(USE_ZLIB) #ifdef __SYMBIAN32__ - #include + #include #else - #include + #include #endif #if ZLIB_VERNUM < 0x1204 diff --git a/devtools/sci/scidisasm.cpp b/devtools/sci/scidisasm.cpp index 6c7049e639d..24c6283c414 100644 --- a/devtools/sci/scidisasm.cpp +++ b/devtools/sci/scidisasm.cpp @@ -405,7 +405,7 @@ get_class_name(disasm_state_t *d, int class_no) { static void script_dump_object(disasm_state_t *d, script_state_t *s, - unsigned char *data, int seeker, int objsize, int pass_no) { + unsigned char *data, int seeker, int objsize, int pass_no) { int selectors, overloads, selectorsize; int species = getInt16(data + 8 + seeker); int superclass = getInt16(data + 10 + seeker); @@ -479,7 +479,7 @@ script_dump_object(disasm_state_t *d, script_state_t *s, static void script_dump_class(disasm_state_t *d, script_state_t *s, - unsigned char *data, int seeker, int objsize, int pass_no) { + unsigned char *data, int seeker, int objsize, int pass_no) { word selectors, overloads, selectorsize; int species = getInt16(data + 8 + seeker); int superclass = getInt16(data + 10 + seeker); @@ -606,7 +606,7 @@ script_dump_said_string(disasm_state_t *d, unsigned char *data, int seeker) { static void script_dump_said(disasm_state_t *d, script_state_t *s, - unsigned char *data, int seeker, int objsize, int pass_no) { + unsigned char *data, int seeker, int objsize, int pass_no) { int _seeker = seeker + objsize - 4; if (pass_no == 1) { @@ -625,7 +625,7 @@ script_dump_said(disasm_state_t *d, script_state_t *s, static void script_dump_synonyms(disasm_state_t *d, script_state_t *s, - unsigned char *data, int seeker, int objsize, int pass_no) { + unsigned char *data, int seeker, int objsize, int pass_no) { int _seeker = seeker + objsize - 4; sciprintf("Synonyms:\n"); @@ -642,7 +642,7 @@ script_dump_synonyms(disasm_state_t *d, script_state_t *s, static void script_dump_strings(disasm_state_t *d, script_state_t *s, - unsigned char *data, int seeker, int objsize, int pass_no) { + unsigned char *data, int seeker, int objsize, int pass_no) { int endptr = seeker + objsize - 4; if (pass_no == 1) { @@ -659,7 +659,7 @@ script_dump_strings(disasm_state_t *d, script_state_t *s, static void script_dump_exports(disasm_state_t *d, script_state_t *s, - unsigned char *data, int seeker, int objsize, int pass_no) { + unsigned char *data, int seeker, int objsize, int pass_no) { byte *pexport = (byte *)(data + seeker); word export_count = getUInt16(pexport); int i; @@ -684,7 +684,7 @@ script_dump_exports(disasm_state_t *d, script_state_t *s, static void script_disassemble_code(disasm_state_t *d, script_state_t *s, - unsigned char *data, int seeker, int objsize, int pass_no) { + unsigned char *data, int seeker, int objsize, int pass_no) { int endptr = seeker + objsize - 4; int i = 0; int cur_class = -1; @@ -882,7 +882,7 @@ script_disassemble_code(disasm_state_t *d, script_state_t *s, void disassemble_script_pass(disasm_state_t *d, script_state_t *s, - resource_t *script, int pass_no) { + resource_t *script, int pass_no) { int _seeker = 0; word id = getInt16(script->data); diff --git a/devtools/skycpt/cptcompiler.cpp b/devtools/skycpt/cptcompiler.cpp index eb2c287a1d6..9a444d697b9 100644 --- a/devtools/skycpt/cptcompiler.cpp +++ b/devtools/skycpt/cptcompiler.cpp @@ -75,7 +75,7 @@ void processMainLists(FILE *inf, CptObj *destArr, uint16 *idList) { uint16 destId = (uint16)strtoul(line + 2, &stopCh, 16); assert(stopCh == (line + 6)); assert((stopCh[0] == ':') && (stopCh[1] == ':')); - resBuf[resPos] = destId; + resBuf[resPos] = destId; resPos++; } else break; @@ -169,7 +169,7 @@ void processTurntabs(FILE *inf, CptObj *destArr) { uint16 destId = (uint16)strtoul(line + 2, &stopCh, 16); assert(stopCh == (line + 6)); assert((stopCh[0] == '-') && (stopCh[1] == '>')); - resBuf[resPos] = destId; + resBuf[resPos] = destId; resPos++; } else break; @@ -211,7 +211,7 @@ void processBins(FILE *inf, CptObj *destArr, const char *typeName, const char *o uint16 destId = (uint16)strtoul(line + 2, &stopCh, 16); assert(stopCh == (line + 6)); assert(*stopCh == '\0'); - resBuf[resPos] = destId; + resBuf[resPos] = destId; resPos++; } else break; @@ -425,7 +425,7 @@ void doCompile(FILE *inf, FILE *debOutf, FILE *resOutf, TextFile *cptDef, FILE * assert(id); diff[diffDest++] = id; diff[diffDest++] = 0; - pos++; + pos++; uint16 len = (uint16)strtoul(pos, &pos, 10); diff[diffDest++] = len; assert(len); diff --git a/engines/access/metaengine.cpp b/engines/access/metaengine.cpp index 3bfe4bdb177..12e514c00e3 100644 --- a/engines/access/metaengine.cpp +++ b/engines/access/metaengine.cpp @@ -74,7 +74,7 @@ public: return "access"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; diff --git a/engines/adl/metaengine.cpp b/engines/adl/metaengine.cpp index 72409a86a16..e6f56b279ad 100644 --- a/engines/adl/metaengine.cpp +++ b/engines/adl/metaengine.cpp @@ -69,11 +69,11 @@ Common::Platform getPlatform(const AdlGameDescription &adlDesc) { class AdlMetaEngine : public AdvancedMetaEngine { public: - const char *getName() const override { + const char *getName() const override { return "adl"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override; int getMaximumSaveSlot() const override { return 'O' - 'A'; } SaveStateList listSaves(const char *target) const override; diff --git a/engines/agi/loader_v3.cpp b/engines/agi/loader_v3.cpp index abfe65010ec..7eddb82feae 100644 --- a/engines/agi/loader_v3.cpp +++ b/engines/agi/loader_v3.cpp @@ -67,7 +67,7 @@ int AgiLoader_v3::detectGame() { } int AgiLoader_v3::loadDir(struct AgiDir *agid, Common::File *fp, - uint32 offs, uint32 len) { + uint32 offs, uint32 len) { int ec = errOK; uint8 *mem; unsigned int i; diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp index cca2c8b0e67..b1ecf190e46 100644 --- a/engines/agi/saveload.cpp +++ b/engines/agi/saveload.cpp @@ -1018,7 +1018,7 @@ bool AgiEngine::saveGameDialog() { void AgiEngine::recordImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3, - int16 p4, int16 p5, int16 p6, int16 p7) { + int16 p4, int16 p5, int16 p6, int16 p7) { ImageStackElement pnew; pnew.type = type; @@ -1035,7 +1035,7 @@ void AgiEngine::recordImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3, } void AgiEngine::replayImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3, - int16 p4, int16 p5, int16 p6, int16 p7) { + int16 p4, int16 p5, int16 p6, int16 p7) { switch (type) { case ADD_PIC: debugC(8, kDebugLevelMain, "--- decoding picture %d ---", p1); diff --git a/engines/agi/sound_2gs.cpp b/engines/agi/sound_2gs.cpp index 0f6738ef97a..63d50ed52c3 100644 --- a/engines/agi/sound_2gs.cpp +++ b/engines/agi/sound_2gs.cpp @@ -667,7 +667,7 @@ static const IIgsMidiProgramMapping progToInstMappingV1 = { }; /** Newer Apple IIGS AGI MIDI program change to instrument number mapping. - FIXME: Some instrument choices sound wrong. */ + FIXME: Some instrument choices sound wrong. */ static const IIgsMidiProgramMapping progToInstMappingV2 = { { 21, 22, 24, 25, 23, 26, 6, 6, 6, 6, diff --git a/engines/agi/wagparser.cpp b/engines/agi/wagparser.cpp index 03a93aefa02..59837c9e9ee 100644 --- a/engines/agi/wagparser.cpp +++ b/engines/agi/wagparser.cpp @@ -243,7 +243,7 @@ bool WagFileParser::endOfProperties(const Common::SeekableReadStream &stream) co void WagProperty::setPropCode(WagPropertyCode propCode) { - _propCode = propCode; + _propCode = propCode; } void WagProperty::setPropDataSize(Common::String str) { diff --git a/engines/agi/wagparser.h b/engines/agi/wagparser.h index 36b3880f94b..8fa547ea5cf 100644 --- a/engines/agi/wagparser.h +++ b/engines/agi/wagparser.h @@ -180,17 +180,17 @@ public: */ const char *getData() const { return _propData; } - /** - * Set property's code - * @param propCode the code value to set - */ - void setPropCode(WagPropertyCode propCode); + /** + * Set property's code + * @param propCode the code value to set + */ + void setPropCode(WagPropertyCode propCode); - /** - * Set property's data and property's size - * @param str the string that according to it these are set - */ - void setPropDataSize(Common::String str); + /** + * Set property's data and property's size + * @param str the string that according to it these are set + */ + void setPropDataSize(Common::String str); // Member variables protected: diff --git a/engines/agos/drivers/simon1/adlib.cpp b/engines/agos/drivers/simon1/adlib.cpp index 7f1370e8bdb..c73f7048b31 100644 --- a/engines/agos/drivers/simon1/adlib.cpp +++ b/engines/agos/drivers/simon1/adlib.cpp @@ -36,13 +36,13 @@ enum { }; MidiDriver_Simon1_AdLib::Voice::Voice() - : channel(kChannelUnused), note(0), instrTotalLevel(0), instrScalingLevel(0), frequency(0) { + : channel(kChannelUnused), note(0), instrTotalLevel(0), instrScalingLevel(0), frequency(0) { } MidiDriver_Simon1_AdLib::MidiDriver_Simon1_AdLib(const byte *instrumentData) - : _isOpen(false), _opl(nullptr), _timerProc(nullptr), _timerParam(nullptr), - _melodyVoices(0), _amvdrBits(0), _rhythmEnabled(false), _voices(), _midiPrograms(), - _instruments(instrumentData) { + : _isOpen(false), _opl(nullptr), _timerProc(nullptr), _timerParam(nullptr), + _melodyVoices(0), _amvdrBits(0), _rhythmEnabled(false), _voices(), _midiPrograms(), + _instruments(instrumentData) { } MidiDriver_Simon1_AdLib::~MidiDriver_Simon1_AdLib() { diff --git a/engines/agos/metaengine.cpp b/engines/agos/metaengine.cpp index 2d2fd3098a3..c33a6b994bc 100644 --- a/engines/agos/metaengine.cpp +++ b/engines/agos/metaengine.cpp @@ -36,11 +36,11 @@ class AgosMetaEngine : public AdvancedMetaEngine { public: - const char *getName() const override { + const char *getName() const override { return "agos"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; Common::Error createInstance(OSystem *syst, Engine **engine) const override { Engines::upgradeTargetIfNecessary(obsoleteGameIDsTable); diff --git a/engines/ags/engine/ac/dialog.cpp b/engines/ags/engine/ac/dialog.cpp index 7dc2367c1e5..c4cd66b8965 100644 --- a/engines/ags/engine/ac/dialog.cpp +++ b/engines/ags/engine/ac/dialog.cpp @@ -305,8 +305,8 @@ int run_dialog_script(DialogTopic *dtpp, int dialogID, int offse, int optionInde } int write_dialog_options(Bitmap *ds, bool ds_has_alpha, int dlgxp, int curyp, int numdisp, int mouseison, int areawid, - int bullet_wid, int usingfont, DialogTopic *dtop, char *disporder, short *dispyp, - int linespacing, int utextcol, int padding) { + int bullet_wid, int usingfont, DialogTopic *dtop, char *disporder, short *dispyp, + int linespacing, int utextcol, int padding) { int ww; color_t text_color; diff --git a/engines/ags/engine/ac/draw.cpp b/engines/ags/engine/ac/draw.cpp index ab14d933646..057479f81cf 100644 --- a/engines/ags/engine/ac/draw.cpp +++ b/engines/ags/engine/ac/draw.cpp @@ -661,7 +661,7 @@ void putpixel_compensate(Bitmap *ds, int xx, int yy, int col) { void draw_sprite_support_alpha(Bitmap *ds, bool ds_has_alpha, int xpos, int ypos, Bitmap *image, bool src_has_alpha, - BlendMode blend_mode, int alpha) { + BlendMode blend_mode, int alpha) { if (alpha <= 0) return; @@ -678,7 +678,7 @@ void draw_sprite_support_alpha(Bitmap *ds, bool ds_has_alpha, int xpos, int ypos } void draw_sprite_slot_support_alpha(Bitmap *ds, bool ds_has_alpha, int xpos, int ypos, int src_slot, - BlendMode blend_mode, int alpha) { + BlendMode blend_mode, int alpha) { draw_sprite_support_alpha(ds, ds_has_alpha, xpos, ypos, _GP(spriteset)[src_slot], (_GP(game).SpriteInfos[src_slot].Flags & SPF_ALPHACHANNEL) != 0, blend_mode, alpha); } @@ -988,9 +988,9 @@ Bitmap *recycle_bitmap(Bitmap *bimp, int coldep, int wid, int hit, bool make_tra // tint_amnt will be set to 0 if there is no tint enabled // if this is the case, then light_lev holds the light level (0=none) void get_local_tint(int xpp, int ypp, int nolight, - int *tint_amnt, int *tint_r, int *tint_g, - int *tint_b, int *tint_lit, - int *light_lev) { + int *tint_amnt, int *tint_r, int *tint_g, + int *tint_b, int *tint_lit, + int *light_lev) { int tint_level = 0, light_level = 0; int tint_amount = 0; @@ -1072,9 +1072,9 @@ void get_local_tint(int xpp, int ypp, int nolight, // Applies the specified RGB Tint or Light Level to the _G(actsps) // sprite indexed with actspsindex void apply_tint_or_light(int actspsindex, int light_level, - int tint_amount, int tint_red, int tint_green, - int tint_blue, int tint_light, int coldept, - Bitmap *blitFrom) { + int tint_amount, int tint_red, int tint_green, + int tint_blue, int tint_light, int coldept, + Bitmap *blitFrom) { // In a 256-colour game, we cannot do tinting or lightening // (but we can do darkening, if light_level < 0) @@ -1140,8 +1140,8 @@ void apply_tint_or_light(int actspsindex, int light_level, // Returns 1 if something was drawn to _G(actsps); returns 0 if no // scaling or stretching was required, in which case nothing was done int scale_and_flip_sprite(int useindx, int coldept, int zoom_level, - int sppic, int newwidth, int newheight, - int isMirrored) { + int sppic, int newwidth, int newheight, + int isMirrored) { int actsps_used = 1; diff --git a/engines/ags/engine/game/savegame_components.cpp b/engines/ags/engine/game/savegame_components.cpp index f87b032243a..374cfa74457 100644 --- a/engines/ags/engine/game/savegame_components.cpp +++ b/engines/ags/engine/game/savegame_components.cpp @@ -139,7 +139,7 @@ inline bool AssertGameContent(HSaveError &err, int new_val, int original_val, co } inline bool AssertGameObjectContent(HSaveError &err, int new_val, int original_val, const char *content_name, - const char *obj_type, int obj_id) { + const char *obj_type, int obj_id) { if (new_val != original_val) { err = new SavegameError(kSvgErr_GameContentAssertion, String::FromFormat("Mismatching number of %s, %s #%d (game: %d, save: %d).", @@ -150,7 +150,7 @@ inline bool AssertGameObjectContent(HSaveError &err, int new_val, int original_v } inline bool AssertGameObjectContent2(HSaveError &err, int new_val, int original_val, const char *content_name, - const char *obj1_type, int obj1_id, const char *obj2_type, int obj2_id) { + const char *obj1_type, int obj1_id, const char *obj2_type, int obj2_id) { if (new_val != original_val) { err = new SavegameError(kSvgErr_GameContentAssertion, String::FromFormat("Mismatching number of %s, %s #%d, %s #%d (game: %d, save: %d).", diff --git a/engines/ags/engine/script/cc_instance.cpp b/engines/ags/engine/script/cc_instance.cpp index 56ccd586465..62be478e6a6 100644 --- a/engines/ags/engine/script/cc_instance.cpp +++ b/engines/ags/engine/script/cc_instance.cpp @@ -1635,82 +1635,82 @@ bool ccInstance::CreateRuntimeCodeFixups(PScript scri) { /* bool ccInstance::ReadOperation(ScriptOperation &op, int32_t at_pc) { - op.Instruction.Code = code[at_pc]; - op.Instruction.InstanceId = (op.Instruction.Code >> INSTANCE_ID_SHIFT) & INSTANCE_ID_MASK; - op.Instruction.Code &= INSTANCE_ID_REMOVEMASK; // now this is pure instruction code + op.Instruction.Code = code[at_pc]; + op.Instruction.InstanceId = (op.Instruction.Code >> INSTANCE_ID_SHIFT) & INSTANCE_ID_MASK; + op.Instruction.Code &= INSTANCE_ID_REMOVEMASK; // now this is pure instruction code - int want_args = sccmd_info[op.Instruction.Code].ArgCount; - if (at_pc + want_args >= codesize) - { - cc_error("unexpected end of code data at %d", at_pc + want_args); - return false; - } - op.ArgCount = want_args; + int want_args = sccmd_info[op.Instruction.Code].ArgCount; + if (at_pc + want_args >= codesize) + { + cc_error("unexpected end of code data at %d", at_pc + want_args); + return false; + } + op.ArgCount = want_args; - at_pc++; - for (int i = 0; i < op.ArgCount; ++i, ++at_pc) - { - char fixup = code_fixups[at_pc]; - if (fixup > 0) - { - // could be relative pointer or import address - if (!FixupArgument(code[at_pc], fixup, op.Args[i])) - { - return false; - } - } - else - { - // should be a numeric literal (int32 or float) - op.Args[i].SetInt32( (int32_t)code[at_pc] ); - } - } + at_pc++; + for (int i = 0; i < op.ArgCount; ++i, ++at_pc) + { + char fixup = code_fixups[at_pc]; + if (fixup > 0) + { + // could be relative pointer or import address + if (!FixupArgument(code[at_pc], fixup, op.Args[i])) + { + return false; + } + } + else + { + // should be a numeric literal (int32 or float) + op.Args[i].SetInt32( (int32_t)code[at_pc] ); + } + } - return true; + return true; } */ /* bool ccInstance::FixupArgument(intptr_t code_value, char fixup_type, RuntimeScriptValue &argument) { - switch (fixup_type) - { - case FIXUP_GLOBALDATA: - { - ScriptVariable *gl_var = (ScriptVariable*)code_value; - argument.SetGlobalVar(&gl_var->RValue); - } - break; - case FIXUP_FUNCTION: - // originally commented -- CHECKME: could this be used in very old versions of AGS? - // code[fixup] += (long)&code[0]; - // This is a program counter value, presumably will be used as SCMD_CALL argument - argument.SetInt32((int32_t)code_value); - break; - case FIXUP_STRING: - argument.SetStringLiteral(&strings[0] + code_value); - break; - case FIXUP_IMPORT: - { - const ScriptImport *import = _GP(simp).getByIndex((int32_t)code_value); - if (import) - { - argument = import->Value; - } - else - { - cc_error("cannot resolve import, key = %ld", code_value); - return false; - } - } - break; - case FIXUP_STACK: - argument = GetStackPtrOffsetFw((int32_t)code_value); - break; - default: - cc_error("internal fixup type error: %d", fixup_type); - return false;; - } - return true; + switch (fixup_type) + { + case FIXUP_GLOBALDATA: + { + ScriptVariable *gl_var = (ScriptVariable*)code_value; + argument.SetGlobalVar(&gl_var->RValue); + } + break; + case FIXUP_FUNCTION: + // originally commented -- CHECKME: could this be used in very old versions of AGS? + // code[fixup] += (long)&code[0]; + // This is a program counter value, presumably will be used as SCMD_CALL argument + argument.SetInt32((int32_t)code_value); + break; + case FIXUP_STRING: + argument.SetStringLiteral(&strings[0] + code_value); + break; + case FIXUP_IMPORT: + { + const ScriptImport *import = _GP(simp).getByIndex((int32_t)code_value); + if (import) + { + argument = import->Value; + } + else + { + cc_error("cannot resolve import, key = %ld", code_value); + return false; + } + } + break; + case FIXUP_STACK: + argument = GetStackPtrOffsetFw((int32_t)code_value); + break; + default: + cc_error("internal fixup type error: %d", fixup_type); + return false;; + } + return true; } */ //----------------------------------------------------------------------------- diff --git a/engines/ags/lib/aastr-0.1.1/aautil.cpp b/engines/ags/lib/aastr-0.1.1/aautil.cpp index 75cf50a36db..edd5dabd263 100644 --- a/engines/ags/lib/aastr-0.1.1/aautil.cpp +++ b/engines/ags/lib/aastr-0.1.1/aautil.cpp @@ -1553,7 +1553,7 @@ void _aa_masked_put_rgb16(byte *addr, int _x) { #ifdef ALLEGRO_COLOR24 void _aa_masked_put_rgb24 (byte *addr, int _x) { if (!_aa.transparent) - bmp_write24 (addr + 3 * _x, makecol24 (_aa.r, _aa.g, _aa.b)); + bmp_write24 (addr + 3 * _x, makecol24 (_aa.r, _aa.g, _aa.b)); } #endif diff --git a/engines/ags/lib/aastr-0.1.1/aautil.h b/engines/ags/lib/aastr-0.1.1/aautil.h index 7dce41fe140..8c74adfddb7 100644 --- a/engines/ags/lib/aastr-0.1.1/aautil.h +++ b/engines/ags/lib/aastr-0.1.1/aautil.h @@ -70,15 +70,15 @@ namespace AGS3 { int yw = (_yw); \ \ if ((xw == 0) || ((yw < xw) && (yw > -xw))) { \ - (inc) = 0; \ + (inc) = 0; \ } \ else { \ - (inc) = yw / xw; \ - yw %= xw; \ + (inc) = yw / xw; \ + yw %= xw; \ } \ if (yw < 0) { \ - (inc) -= 1; \ - yw += xw; \ + (inc) -= 1; \ + yw += xw; \ } \ (i2) = ((dd) = ((i1) = 2 * yw) - xw) - xw; \ } @@ -87,9 +87,9 @@ namespace AGS3 { #define aa_ADVANCE(y,inc,dd,i1,i2) \ { \ if ((dd) >= 0) \ - (y) += (inc) + 1, (dd) += (i2); \ + (y) += (inc) + 1, (dd) += (i2); \ else \ - (y) += (inc), (dd) += (i1); \ + (y) += (inc), (dd) += (i1); \ } diff --git a/engines/ags/lib/allegro/base.h b/engines/ags/lib/allegro/base.h index e85f4f7bfee..9fa3bab87ec 100644 --- a/engines/ags/lib/allegro/base.h +++ b/engines/ags/lib/allegro/base.h @@ -39,8 +39,8 @@ namespace AGS3 { /* Returns the median of x, y, z */ #define MID(x,y,z) ((x) > (y) ? ((y) > (z) ? (y) : ((x) > (z) ? \ - (z) : (x))) : ((y) > (z) ? ((z) > (x) ? (z) : \ - (x)): (y))) + (z) : (x))) : ((y) > (z) ? ((z) > (x) ? (z) : \ + (x)): (y))) #define AL_ID MKTAG diff --git a/engines/ags/lib/allegro/color.cpp b/engines/ags/lib/allegro/color.cpp index c674f8ac2bd..9c095882399 100644 --- a/engines/ags/lib/allegro/color.cpp +++ b/engines/ags/lib/allegro/color.cpp @@ -663,11 +663,11 @@ void create_rgb_table(RGB_MAP *table, AL_CONST PALETTE pal, void (*callback)(int /* checking of position */ #define dopos(rp, gp, bp, ts) \ - if ((rp > -1 || r > 0) && (rp < 1 || r < 61) && \ + if ((rp > -1 || r > 0) && (rp < 1 || r < 61) && \ (gp > -1 || g > 0) && (gp < 1 || g < 61) && \ (bp > -1 || b > 0) && (bp < 1 || b < 61)) { \ i = first + rp * 32 * 32 + gp * 32 + bp; \ - if (!data[i]) { \ + if (!data[i]) { \ data[i] = val; \ add1(i); \ } \ @@ -680,7 +680,7 @@ void create_rgb_table(RGB_MAP *table, AL_CONST PALETTE pal, void (*callback)(int add1(i); \ } \ } \ - } + } int i, curr, r, g, b, val, dist2; unsigned int r2, g2, b2; diff --git a/engines/ags/lib/allegro/gfx.h b/engines/ags/lib/allegro/gfx.h index 14b8e183512..d2907f8e6de 100644 --- a/engines/ags/lib/allegro/gfx.h +++ b/engines/ags/lib/allegro/gfx.h @@ -117,62 +117,62 @@ namespace AGS3 { #define COLORCONV_KEEP_TRANS 0x4000000 #define COLORCONV_DITHER (COLORCONV_DITHER_PAL | \ - COLORCONV_DITHER_HI) + COLORCONV_DITHER_HI) #define COLORCONV_EXPAND_256 (COLORCONV_8_TO_15 | \ - COLORCONV_8_TO_16 | \ - COLORCONV_8_TO_24 | \ - COLORCONV_8_TO_32) + COLORCONV_8_TO_16 | \ + COLORCONV_8_TO_24 | \ + COLORCONV_8_TO_32) #define COLORCONV_REDUCE_TO_256 (COLORCONV_15_TO_8 | \ - COLORCONV_16_TO_8 | \ - COLORCONV_24_TO_8 | \ - COLORCONV_32_TO_8 | \ - COLORCONV_32A_TO_8) + COLORCONV_16_TO_8 | \ + COLORCONV_24_TO_8 | \ + COLORCONV_32_TO_8 | \ + COLORCONV_32A_TO_8) #define COLORCONV_EXPAND_15_TO_16 COLORCONV_15_TO_16 #define COLORCONV_REDUCE_16_TO_15 COLORCONV_16_TO_15 #define COLORCONV_EXPAND_HI_TO_TRUE (COLORCONV_15_TO_24 | \ - COLORCONV_15_TO_32 | \ - COLORCONV_16_TO_24 | \ - COLORCONV_16_TO_32) + COLORCONV_15_TO_32 | \ + COLORCONV_16_TO_24 | \ + COLORCONV_16_TO_32) #define COLORCONV_REDUCE_TRUE_TO_HI (COLORCONV_24_TO_15 | \ - COLORCONV_24_TO_16 | \ - COLORCONV_32_TO_15 | \ - COLORCONV_32_TO_16) + COLORCONV_24_TO_16 | \ + COLORCONV_32_TO_15 | \ + COLORCONV_32_TO_16) #define COLORCONV_24_EQUALS_32 (COLORCONV_24_TO_32 | \ - COLORCONV_32_TO_24) + COLORCONV_32_TO_24) #define COLORCONV_TOTAL (COLORCONV_EXPAND_256 | \ - COLORCONV_REDUCE_TO_256 | \ - COLORCONV_EXPAND_15_TO_16 | \ - COLORCONV_REDUCE_16_TO_15 | \ - COLORCONV_EXPAND_HI_TO_TRUE | \ - COLORCONV_REDUCE_TRUE_TO_HI | \ - COLORCONV_24_EQUALS_32 | \ - COLORCONV_32A_TO_15 | \ - COLORCONV_32A_TO_16 | \ - COLORCONV_32A_TO_24) + COLORCONV_REDUCE_TO_256 | \ + COLORCONV_EXPAND_15_TO_16 | \ + COLORCONV_REDUCE_16_TO_15 | \ + COLORCONV_EXPAND_HI_TO_TRUE | \ + COLORCONV_REDUCE_TRUE_TO_HI | \ + COLORCONV_24_EQUALS_32 | \ + COLORCONV_32A_TO_15 | \ + COLORCONV_32A_TO_16 | \ + COLORCONV_32A_TO_24) #define COLORCONV_PARTIAL (COLORCONV_EXPAND_15_TO_16 | \ - COLORCONV_REDUCE_16_TO_15 | \ - COLORCONV_24_EQUALS_32) + COLORCONV_REDUCE_16_TO_15 | \ + COLORCONV_24_EQUALS_32) #define COLORCONV_MOST (COLORCONV_EXPAND_15_TO_16 | \ - COLORCONV_REDUCE_16_TO_15 | \ - COLORCONV_EXPAND_HI_TO_TRUE | \ - COLORCONV_REDUCE_TRUE_TO_HI | \ - COLORCONV_24_EQUALS_32) + COLORCONV_REDUCE_16_TO_15 | \ + COLORCONV_EXPAND_HI_TO_TRUE | \ + COLORCONV_REDUCE_TRUE_TO_HI | \ + COLORCONV_24_EQUALS_32) #define COLORCONV_KEEP_ALPHA (COLORCONV_TOTAL \ - & ~(COLORCONV_32A_TO_8 | \ - COLORCONV_32A_TO_15 | \ - COLORCONV_32A_TO_16 | \ - COLORCONV_32A_TO_24)) + & ~(COLORCONV_32A_TO_8 | \ + COLORCONV_32A_TO_15 | \ + COLORCONV_32A_TO_16 | \ + COLORCONV_32A_TO_24)) AL_FUNC(void, set_color_conversion, (int mode)); AL_FUNC(int, get_color_conversion, ()); diff --git a/engines/ags/lib/std/map.h b/engines/ags/lib/std/map.h index 65272ff7048..185dcbfecdf 100644 --- a/engines/ags/lib/std/map.h +++ b/engines/ags/lib/std/map.h @@ -193,7 +193,7 @@ public: }; template, - class EqualFunc = Common::EqualTo > + class EqualFunc = Common::EqualTo > class unordered_map : public Common::HashMap { public: pair insert(pair elem) { diff --git a/engines/ags/plugins/ags_galaxy_steam/ags_wadjeteye_steam.h b/engines/ags/plugins/ags_galaxy_steam/ags_wadjeteye_steam.h index 6c004cf965f..5285de45257 100644 --- a/engines/ags/plugins/ags_galaxy_steam/ags_wadjeteye_steam.h +++ b/engines/ags/plugins/ags_galaxy_steam/ags_wadjeteye_steam.h @@ -34,7 +34,7 @@ private: static void AGS_EngineStartup(IAGSEngine *engine); static void AddAchievement(ScriptMethodParams ¶ms); static void AddStat(ScriptMethodParams ¶ms); - + public: AGSWadjetEyeSteam(); }; diff --git a/engines/ags/plugins/ags_pal_render/ags_pal_render.cpp b/engines/ags/plugins/ags_pal_render/ags_pal_render.cpp index 034c410db79..9245a7f8813 100644 --- a/engines/ags/plugins/ags_pal_render/ags_pal_render.cpp +++ b/engines/ags/plugins/ags_pal_render/ags_pal_render.cpp @@ -182,9 +182,9 @@ void Make_Sin_Lut() { /* void PreMultiply_Alphas () //Ha ha, this isn't the kind of premultiplcation you're thinking of. { - for (int y=0;y<64;y++) - for (int x=0;x<64;x++) - alphamultiply [y*64+x] = y*x; + for (int y=0;y<64;y++) + for (int x=0;x<64;x++) + alphamultiply [y*64+x] = y*x; } */ @@ -593,60 +593,60 @@ void DoFire(ScriptMethodParams ¶ms) { /* unsigned char MixColorAlpha (unsigned char fg,unsigned char bg,unsigned char alpha) { - //unsigned char rfg = cycle_remap [fg]; //Automatic remapping of palette slots. - //unsigned char rbg = cycle_remap [bg]; //Saves on typing elsewhere. - //BITMAP *clutspr = engine->GetSpriteGraphic (clutslot); - //if (!clutspr) engine->AbortGame ("MixColorAlpha: Can't load CLUT sprite into memory."); - //uint8 *clutarray = engine->GetRawBitmapSurface (clutspr); - AGSColor *palette = engine->GetPalette (); - int i=0; - int out_r = (palette[fg].r>>1) * alpha + (palette[bg].r>>1) * (255 - alpha); - int out_g = palette[fg].g * alpha + palette[bg].g * (255 - alpha); - int out_b = (palette[fg].b>>1) * alpha + (palette[bg].b>>1) * (255 - alpha); - //unsigned char ralpha = alpha>>2; - //unsigned char invralpha = 64-ralpha; - //if (ralpha > alpha) engine->AbortGame ("wtf"); - //int out_r = alphamultiply[(palette[fg].r>>1)][ralpha] + alphamultiply[(palette[bg].r>>1)][(invralpha)]; - //int out_g = alphamultiply[(palette[fg].g)][ralpha] + alphamultiply[(palette[bg].g)][(invralpha)]; - //int out_b = alphamultiply[(palette[fg].b>>1)][ralpha] + alphamultiply[(palette[bg].b>>1)][(invralpha)]; - out_r = (out_r + 1 + (out_r >> 8)) >> 8; - out_g = (out_g + 1 + (out_g >> 8)) >> 8; - out_b = (out_b + 1 + (out_b >> 8)) >> 8; - i = ((out_r << 11) | (out_g << 5) | out_b); - unsigned char (*clutp) = clut; - //unsigned char result = cycle_remap [clut[i>>8][i%256]]; //Once again, to make sure that the palette slot used is the right one. - unsigned char result = cycle_remap [*(clutp+i)]; //Once again, to make sure that the palette slot used is the right one. - //engine->ReleaseBitmapSurface (clutspr); - return result; + //unsigned char rfg = cycle_remap [fg]; //Automatic remapping of palette slots. + //unsigned char rbg = cycle_remap [bg]; //Saves on typing elsewhere. + //BITMAP *clutspr = engine->GetSpriteGraphic (clutslot); + //if (!clutspr) engine->AbortGame ("MixColorAlpha: Can't load CLUT sprite into memory."); + //uint8 *clutarray = engine->GetRawBitmapSurface (clutspr); + AGSColor *palette = engine->GetPalette (); + int i=0; + int out_r = (palette[fg].r>>1) * alpha + (palette[bg].r>>1) * (255 - alpha); + int out_g = palette[fg].g * alpha + palette[bg].g * (255 - alpha); + int out_b = (palette[fg].b>>1) * alpha + (palette[bg].b>>1) * (255 - alpha); + //unsigned char ralpha = alpha>>2; + //unsigned char invralpha = 64-ralpha; + //if (ralpha > alpha) engine->AbortGame ("wtf"); + //int out_r = alphamultiply[(palette[fg].r>>1)][ralpha] + alphamultiply[(palette[bg].r>>1)][(invralpha)]; + //int out_g = alphamultiply[(palette[fg].g)][ralpha] + alphamultiply[(palette[bg].g)][(invralpha)]; + //int out_b = alphamultiply[(palette[fg].b>>1)][ralpha] + alphamultiply[(palette[bg].b>>1)][(invralpha)]; + out_r = (out_r + 1 + (out_r >> 8)) >> 8; + out_g = (out_g + 1 + (out_g >> 8)) >> 8; + out_b = (out_b + 1 + (out_b >> 8)) >> 8; + i = ((out_r << 11) | (out_g << 5) | out_b); + unsigned char (*clutp) = clut; + //unsigned char result = cycle_remap [clut[i>>8][i%256]]; //Once again, to make sure that the palette slot used is the right one. + unsigned char result = cycle_remap [*(clutp+i)]; //Once again, to make sure that the palette slot used is the right one. + //engine->ReleaseBitmapSurface (clutspr); + return result; } unsigned char MixColorAdditive (unsigned char fg,unsigned char bg,unsigned char alpha) { - //unsigned char rfg = cycle_remap [fg]; //Automatic remapping of palette slots. - //unsigned char rbg = cycle_remap [bg]; //Saves on typing elsewhere. - //BITMAP *clutspr = engine->GetSpriteGraphic (clutslot); - //if (!clutspr) engine->AbortGame ("MixColorAlpha: Can't load CLUT sprite into memory."); - //uint8 *clutarray = engine->GetRawBitmapSurface (clutspr); - AGSColor *palette = engine->GetPalette (); - int i=0; - int add_r,add_b,add_g = 0; - char ralpha = alpha>>2; - //if (ralpha > alpha) engine->AbortGame ("wtf"); - //add_r = (((palette[fg].r>>1) * (alpha))>>8); - //add_b = (((palette[fg].b>>1) * (alpha))>>8); - //add_g = (((palette[fg].g) * (alpha))>>8); - add_r = ((alphamultiply[(palette[fg].r>>1)*64+ralpha])>>6); - add_b = ((alphamultiply[(palette[fg].b>>1)*64+ralpha])>>6); - add_g = ((alphamultiply[(palette[fg].g )*64+ralpha])>>6); - int out_r = min(31,(palette[bg].r>>1) + add_r); - int out_g = min(63, palette[bg].g + add_g); - int out_b = min(31,(palette[bg].b>>1) + add_b); - i = ((out_r << 11) | (out_g << 5) | out_b); - unsigned char (*clutp) = clut; - unsigned char result = cycle_remap [*(clutp+i)]; //Once again, to make sure that the palette slot used is the right one. - //unsigned char result = cycle_remap [clut[i>>8][i%256]]; //Once again, to make sure that the palette slot used is the right one. - //engine->ReleaseBitmapSurface (clutspr); - return result; + //unsigned char rfg = cycle_remap [fg]; //Automatic remapping of palette slots. + //unsigned char rbg = cycle_remap [bg]; //Saves on typing elsewhere. + //BITMAP *clutspr = engine->GetSpriteGraphic (clutslot); + //if (!clutspr) engine->AbortGame ("MixColorAlpha: Can't load CLUT sprite into memory."); + //uint8 *clutarray = engine->GetRawBitmapSurface (clutspr); + AGSColor *palette = engine->GetPalette (); + int i=0; + int add_r,add_b,add_g = 0; + char ralpha = alpha>>2; + //if (ralpha > alpha) engine->AbortGame ("wtf"); + //add_r = (((palette[fg].r>>1) * (alpha))>>8); + //add_b = (((palette[fg].b>>1) * (alpha))>>8); + //add_g = (((palette[fg].g) * (alpha))>>8); + add_r = ((alphamultiply[(palette[fg].r>>1)*64+ralpha])>>6); + add_b = ((alphamultiply[(palette[fg].b>>1)*64+ralpha])>>6); + add_g = ((alphamultiply[(palette[fg].g )*64+ralpha])>>6); + int out_r = min(31,(palette[bg].r>>1) + add_r); + int out_g = min(63, palette[bg].g + add_g); + int out_b = min(31,(palette[bg].b>>1) + add_b); + i = ((out_r << 11) | (out_g << 5) | out_b); + unsigned char (*clutp) = clut; + unsigned char result = cycle_remap [*(clutp+i)]; //Once again, to make sure that the palette slot used is the right one. + //unsigned char result = cycle_remap [clut[i>>8][i%256]]; //Once again, to make sure that the palette slot used is the right one. + //engine->ReleaseBitmapSurface (clutspr); + return result; } */ void GetColor565(ScriptMethodParams ¶ms) { diff --git a/engines/ags/plugins/ags_pal_render/raycast.cpp b/engines/ags/plugins/ags_pal_render/raycast.cpp index 6820f7af3d3..aa7438a1a5a 100644 --- a/engines/ags/plugins/ags_pal_render/raycast.cpp +++ b/engines/ags/plugins/ags_pal_render/raycast.cpp @@ -1520,14 +1520,14 @@ void MoveBackward(ScriptMethodParams &) { /* void MoveBackward () { - double newposx; - if (dirX > 0) newposx = -0.2 + posX - dirX * moveSpeed; - else newposx = 0.2 + posX - dirX * moveSpeed; - double newposy; - if (dirY > 0) newposy = -0.2 + posY - dirY * moveSpeed; - else newposy = 0.2 + posY - dirY * moveSpeed; - if(worldMap[int(newposx)][int(posY)] == false || worldMap[int(newposx)][int(posY)] > 8) posX -= dirX * moveSpeed; - if(worldMap[int(posX)][int(newposy)] == false || worldMap[int(posX)][int(newposy)] > 8) posY -= dirY * moveSpeed; + double newposx; + if (dirX > 0) newposx = -0.2 + posX - dirX * moveSpeed; + else newposx = 0.2 + posX - dirX * moveSpeed; + double newposy; + if (dirY > 0) newposy = -0.2 + posY - dirY * moveSpeed; + else newposy = 0.2 + posY - dirY * moveSpeed; + if(worldMap[int(newposx)][int(posY)] == false || worldMap[int(newposx)][int(posY)] > 8) posX -= dirX * moveSpeed; + if(worldMap[int(posX)][int(newposy)] == false || worldMap[int(posX)][int(newposy)] > 8) posY -= dirY * moveSpeed; } */ diff --git a/engines/ags/shared/util/misc.cpp b/engines/ags/shared/util/misc.cpp index a261420bd19..3304301b3c1 100644 --- a/engines/ags/shared/util/misc.cpp +++ b/engines/ags/shared/util/misc.cpp @@ -28,14 +28,14 @@ modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of Shawn R. Walker nor names of contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Shawn R. Walker nor names of contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE diff --git a/engines/ags/shared/util/misc.h b/engines/ags/shared/util/misc.h index c84500c9290..a9ff6acb575 100644 --- a/engines/ags/shared/util/misc.h +++ b/engines/ags/shared/util/misc.h @@ -28,14 +28,14 @@ modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of Shawn R. Walker nor names of contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Shawn R. Walker nor names of contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE diff --git a/engines/avalanche/parser.cpp b/engines/avalanche/parser.cpp index 26c3cbd75ab..09282919c0c 100644 --- a/engines/avalanche/parser.cpp +++ b/engines/avalanche/parser.cpp @@ -528,7 +528,7 @@ void Parser::cursorOff() { * Asks the parsekey proc in Dropdown if it knows it. */ void Parser::tryDropdown() { - // TODO: Implement at the same time with Dropdown's keyboard handling. + // TODO: Implement at the same time with Dropdown's keyboard handling. warning("STUB: Parser::tryDropdown()"); } diff --git a/engines/bbvs/metaengine.cpp b/engines/bbvs/metaengine.cpp index 2d8e0eae06c..ead8186c7aa 100644 --- a/engines/bbvs/metaengine.cpp +++ b/engines/bbvs/metaengine.cpp @@ -43,7 +43,7 @@ public: return "bbvs"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; int getMaximumSaveSlot() const override; diff --git a/engines/bladerunner/debugger.cpp b/engines/bladerunner/debugger.cpp index e1103b7368d..c0ac863dc2d 100644 --- a/engines/bladerunner/debugger.cpp +++ b/engines/bladerunner/debugger.cpp @@ -603,27 +603,27 @@ bool isAllZeroes(Common::String valStr) { // which is played at the NightClub Row (NR01), is "kSfxMUSBLEED" (looping). // TODO maybe support those too? const char* kMusicTracksArr[] = {"Animoid Row (G)", // kMusicArabLoop - "Battle Theme", // kMusicBatl226M - "Blade Runner Blues", // kMusicBRBlues - "Etsuko Theme", // kMusicKyoto - "One More Time, Love (G)", // kMusicOneTime - "Gothic Club 2", // kMusicGothic3 - "Arcane Dragon Fly (G)", // kMusicArkdFly1 - "Arcane Dance (G)", // kMusicArkDnce1 - "Taffy's Club 2", // kMusicTaffy2 - "Enigma Drift", // kMusicTaffy3 - "Late Call", // kMusicTaffy4 - "Nexus (aka Beating 1)", // kMusicBeating1 - "Awakenings (aka Crystal Dies 1)", // kMusicCrysDie1 - "Gothic Club", // kMusicGothic1 - "Transition", // kMusicGothic2 - "The Eyes Follow", // kMusicStrip1 - "Dektora's Dance (G)", // kMusicDkoDnce1 - "End Credits", // kMusicCredits - "Ending (aka Moraji)", // kMusicMoraji - "Remorse (aka Clovis Dies 1)", // kMusicClovDie1 - "Solitude (aka Clovis Dies)", // kMusicClovDies - "Love Theme"}; // kMusicLoveSong + "Battle Theme", // kMusicBatl226M + "Blade Runner Blues", // kMusicBRBlues + "Etsuko Theme", // kMusicKyoto + "One More Time, Love (G)", // kMusicOneTime + "Gothic Club 2", // kMusicGothic3 + "Arcane Dragon Fly (G)", // kMusicArkdFly1 + "Arcane Dance (G)", // kMusicArkDnce1 + "Taffy's Club 2", // kMusicTaffy2 + "Enigma Drift", // kMusicTaffy3 + "Late Call", // kMusicTaffy4 + "Nexus (aka Beating 1)", // kMusicBeating1 + "Awakenings (aka Crystal Dies 1)", // kMusicCrysDie1 + "Gothic Club", // kMusicGothic1 + "Transition", // kMusicGothic2 + "The Eyes Follow", // kMusicStrip1 + "Dektora's Dance (G)", // kMusicDkoDnce1 + "End Credits", // kMusicCredits + "Ending (aka Moraji)", // kMusicMoraji + "Remorse (aka Clovis Dies 1)", // kMusicClovDie1 + "Solitude (aka Clovis Dies)", // kMusicClovDies + "Love Theme"}; // kMusicLoveSong bool Debugger::cmdMusic(int argc, const char** argv) { if (argc != 2) { diff --git a/engines/bladerunner/metaengine.cpp b/engines/bladerunner/metaengine.cpp index b467b5b71c0..fb65516f9ad 100644 --- a/engines/bladerunner/metaengine.cpp +++ b/engines/bladerunner/metaengine.cpp @@ -33,7 +33,7 @@ class BladeRunnerMetaEngine : public AdvancedMetaEngine { public: - const char *getName() const override; + const char *getName() const override; Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; bool hasFeature(MetaEngineFeature f) const override; diff --git a/engines/bladerunner/obstacles.cpp b/engines/bladerunner/obstacles.cpp index e1542098435..9882b1e1150 100644 --- a/engines/bladerunner/obstacles.cpp +++ b/engines/bladerunner/obstacles.cpp @@ -460,7 +460,7 @@ bool Obstacles::findNextWaypoint(const Vector3 &from, const Vector3 &to, Vector3 #endif bool Obstacles::findIntersectionNearest(int polygonIndex, Vector2 from, Vector2 to, - int *outVertexIndex, float *outDistance, Vector2 *out) const + int *outVertexIndex, float *outDistance, Vector2 *out) const { float minDistance = 0.0f; Vector2 minIntersection; @@ -492,7 +492,7 @@ bool Obstacles::findIntersectionNearest(int polygonIndex, Vector2 from, Vector2 } bool Obstacles::findIntersectionFarthest(int polygonIndex, Vector2 from, Vector2 to, - int *outVertexIndex, float *outDistance, Vector2 *out) const + int *outVertexIndex, float *outDistance, Vector2 *out) const { float maxDistance = 0.0f; Vector2 maxIntersection; diff --git a/engines/bladerunner/script/scene/ma07.cpp b/engines/bladerunner/script/scene/ma07.cpp index ec69b3d3d54..c42c1c6f321 100644 --- a/engines/bladerunner/script/scene/ma07.cpp +++ b/engines/bladerunner/script/scene/ma07.cpp @@ -143,7 +143,7 @@ void SceneScriptMA07::PlayerWalkedIn() { Actor_Set_Goal_Number(kActorRachael, kGoalRachaelIsOutWalksToPoliceHQAct3); } else if (_vm->_cutContent && Actor_Query_Goal_Number(kActorRachael) == kGoalRachaelIsOutsideMcCoysBuildingAct4) { Actor_Set_Goal_Number(kActorRachael, kGoalRachaelIsOutWalksToPoliceHQAct4); - } + } if (Game_Flag_Query(kFlagMA06toMA07)) { Game_Flag_Reset(kFlagMA06toMA07); diff --git a/engines/bladerunner/ui/kia_section_base.cpp b/engines/bladerunner/ui/kia_section_base.cpp index 95f025e3368..4580efb84be 100644 --- a/engines/bladerunner/ui/kia_section_base.cpp +++ b/engines/bladerunner/ui/kia_section_base.cpp @@ -25,8 +25,8 @@ namespace BladeRunner { KIASectionBase::KIASectionBase(BladeRunnerEngine *vm) { - _vm = vm; - _scheduledSwitch = false; + _vm = vm; + _scheduledSwitch = false; } KIASectionBase::~KIASectionBase() { diff --git a/engines/bladerunner/ui/kia_section_crimes.cpp b/engines/bladerunner/ui/kia_section_crimes.cpp index a1d365f3389..34f88e788f2 100644 --- a/engines/bladerunner/ui/kia_section_crimes.cpp +++ b/engines/bladerunner/ui/kia_section_crimes.cpp @@ -88,14 +88,14 @@ KIASectionCrimes::~KIASectionCrimes() { void KIASectionCrimes::reset() { _acquiredClueCount = 0; - _crimesFoundCount = 0; - _suspectsFoundCount = 0; - _mouseX = 0; - _mouseY = 0; - _suspectSelected = -1; - _crimeSelected = -1; - _suspectPhotoShapeId = -1; - _suspectPhotoNotUsed = -1; + _crimesFoundCount = 0; + _suspectsFoundCount = 0; + _mouseX = 0; + _mouseY = 0; + _suspectSelected = -1; + _crimeSelected = -1; + _suspectPhotoShapeId = -1; + _suspectPhotoNotUsed = -1; } void KIASectionCrimes::open() { diff --git a/engines/bladerunner/ui/ui_image_picker.cpp b/engines/bladerunner/ui/ui_image_picker.cpp index d6c01301f19..27aa5202e58 100644 --- a/engines/bladerunner/ui/ui_image_picker.cpp +++ b/engines/bladerunner/ui/ui_image_picker.cpp @@ -199,10 +199,10 @@ bool UIImagePicker::resetActiveImage(int i) { } void UIImagePicker::activate(UIImagePickerCallback *mouseInCallback, - UIImagePickerCallback *mouseOutCallback, - UIImagePickerCallback *mouseDownCallback, - UIImagePickerCallback *mouseUpCallback, - void *callbackData) { + UIImagePickerCallback *mouseOutCallback, + UIImagePickerCallback *mouseDownCallback, + UIImagePickerCallback *mouseUpCallback, + void *callbackData) { _isButtonDown = false; _mouseInCallback = mouseInCallback; _mouseOutCallback = mouseOutCallback; diff --git a/engines/bladerunner/ui/vk.cpp b/engines/bladerunner/ui/vk.cpp index ee926926ced..2afbd7b9e8a 100644 --- a/engines/bladerunner/ui/vk.cpp +++ b/engines/bladerunner/ui/vk.cpp @@ -958,8 +958,8 @@ void VK::setAdjustmentFromMouse() { * It will search through all questions to find a related question Id and its intensity */ void VK::findRelatedQuestionBySentenceId(int inSentenceId, int &outRelatedQuestionId, int &outRelatedIntensity) { - outRelatedQuestionId = -1; - outRelatedIntensity = -1; + outRelatedQuestionId = -1; + outRelatedIntensity = -1; for (int intensity = 0; intensity < 3; ++intensity) { for (int i = 0; i < (int)_questions[intensity].size(); ++i) { diff --git a/engines/cge/metaengine.cpp b/engines/cge/metaengine.cpp index c3c63051a61..ede99e91290 100644 --- a/engines/cge/metaengine.cpp +++ b/engines/cge/metaengine.cpp @@ -37,7 +37,7 @@ public: return "cge"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; diff --git a/engines/cge2/snail.cpp b/engines/cge2/snail.cpp index ccb6f1e7dee..ce05d763e67 100644 --- a/engines/cge2/snail.cpp +++ b/engines/cge2/snail.cpp @@ -45,8 +45,8 @@ const char *CommandHandler::_commandText[] = { CommandHandler::CommandHandler(CGE2Engine *vm, bool turbo) : _turbo(turbo), _textDelay(false), _timerExpiry(0), _talkEnable(true), - _head(0), _tail(0), _commandList((Command *)malloc(sizeof(Command)* 256)), - _vm(vm) { + _head(0), _tail(0), _commandList((Command *)malloc(sizeof(Command)* 256)), + _vm(vm) { } CommandHandler::~CommandHandler() { diff --git a/engines/cge2/vga13h.cpp b/engines/cge2/vga13h.cpp index 524e547f35a..d4ef418d1b7 100644 --- a/engines/cge2/vga13h.cpp +++ b/engines/cge2/vga13h.cpp @@ -127,17 +127,17 @@ Seq Sprite::_stdSeq8[] = SprExt::SprExt(CGE2Engine *vm) : _p0(vm, 0, 0), _p1(vm, 0, 0), - _b0(nullptr), _b1(nullptr), _shpList(nullptr), - _location(0), _seq(nullptr), _name(nullptr) { + _b0(nullptr), _b1(nullptr), _shpList(nullptr), + _location(0), _seq(nullptr), _name(nullptr) { for (int i = 0; i < kActions; i++) _actions[i] = nullptr; } Sprite::Sprite(CGE2Engine *vm) : _siz(_vm, 0, 0), _seqPtr(kNoSeq), _seqCnt(0), _shpCnt(0), - _next(nullptr), _prev(nullptr), _time(0), - _ext(nullptr), _ref(-1), _scene(0), _vm(vm), - _pos2D(_vm, kScrWidth >> 1, 0), _pos3D(kScrWidth >> 1, 0, 0) { + _next(nullptr), _prev(nullptr), _time(0), + _ext(nullptr), _ref(-1), _scene(0), _vm(vm), + _pos2D(_vm, kScrWidth >> 1, 0), _pos3D(kScrWidth >> 1, 0, 0) { memset(_actionCtrl, 0, sizeof(_actionCtrl)); memset(_file, 0, sizeof(_file)); memset(&_flags, 0, sizeof(_flags)); @@ -146,9 +146,9 @@ Sprite::Sprite(CGE2Engine *vm) Sprite::Sprite(CGE2Engine *vm, BitmapPtr shpP, int cnt) : _siz(_vm, 0, 0), _seqPtr(kNoSeq), _seqCnt(0), _shpCnt(0), - _next(nullptr), _prev(nullptr), _time(0), - _ext(nullptr), _ref(-1), _scene(0), _vm(vm), - _pos2D(_vm, kScrWidth >> 1, 0), _pos3D(kScrWidth >> 1, 0, 0) { + _next(nullptr), _prev(nullptr), _time(0), + _ext(nullptr), _ref(-1), _scene(0), _vm(vm), + _pos2D(_vm, kScrWidth >> 1, 0), _pos3D(kScrWidth >> 1, 0, 0) { memset(_actionCtrl, 0, sizeof(_actionCtrl)); memset(_file, 0, sizeof(_file)); memset(&_flags, 0, sizeof(_flags)); diff --git a/engines/chewy/metaengine.cpp b/engines/chewy/metaengine.cpp index 1a55a79983f..df9479b9b27 100644 --- a/engines/chewy/metaengine.cpp +++ b/engines/chewy/metaengine.cpp @@ -47,7 +47,7 @@ public: return "chewy"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; SaveStateList listSaves(const char *target) const override; diff --git a/engines/cine/anim.cpp b/engines/cine/anim.cpp index d5b9a44c505..35f41ff37b2 100644 --- a/engines/cine/anim.cpp +++ b/engines/cine/anim.cpp @@ -304,7 +304,7 @@ byte AnimData::getColor(int x, int y) { * @param transparent Transparent color (for ANIM_MASKSPRITE) */ void AnimData::load(byte *d, int type, uint16 w, uint16 h, int16 file, - int16 frame, const char *n, byte transparent) { + int16 frame, const char *n, byte transparent) { assert(d); if (_data) { diff --git a/engines/cine/saveload.h b/engines/cine/saveload.h index 821a5105e40..95aee2d75bb 100644 --- a/engines/cine/saveload.h +++ b/engines/cine/saveload.h @@ -88,7 +88,7 @@ Version 0: Color count was not saved, was assumed to be 256. BGIncrust.bgIdx doe Version 1: Saving of real color count was added but still 256 colors were always saved. Version 2: BGIncrust.bgIdx was added. Version 3: Saving real values for current music name, music playing status, current background index, - scroll background index and background scrolling was added. + scroll background index and background scrolling was added. */ static const uint32 LAST_TEMP_OS_SAVE_VER = 3; diff --git a/engines/cine/script_fw.cpp b/engines/cine/script_fw.cpp index 50c77a1376b..d020bef00b7 100644 --- a/engines/cine/script_fw.cpp +++ b/engines/cine/script_fw.cpp @@ -591,7 +591,7 @@ RawObjectScript::RawObjectScript(uint16 s, uint16 p1, uint16 p2, uint16 p3) * @param p3 Third object script parameter */ RawObjectScript::RawObjectScript(const FWScriptInfo &info, const byte *data, - uint16 s, uint16 p1, uint16 p2, uint16 p3) + uint16 s, uint16 p1, uint16 p2, uint16 p3) : RawScript(info, data, s), _runCount(0), _param1(p1), _param2(p2), _param3(p3) { } diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp index 5f41b2628e5..85a0d6f47fa 100644 --- a/engines/cine/various.cpp +++ b/engines/cine/various.cpp @@ -1603,7 +1603,7 @@ void modifySeqListElement(uint16 objIdx, int16 var4Test, int16 param1, int16 par } void computeMove1(SeqListElement &element, int16 x, int16 y, int16 param1, - int16 param2, int16 x2, int16 y2) { + int16 param2, int16 x2, int16 y2) { element.var16 = 0; element.var14 = 0; diff --git a/engines/composer/metaengine.cpp b/engines/composer/metaengine.cpp index 7fdeaf8a09d..a605133f2d6 100644 --- a/engines/composer/metaengine.cpp +++ b/engines/composer/metaengine.cpp @@ -67,7 +67,7 @@ bool ComposerEngine::loadDetectedConfigFile(Common::INIFile &configFile) const { class ComposerMetaEngine : public AdvancedMetaEngine { public: - const char *getName() const override { + const char *getName() const override { return "composer"; } diff --git a/engines/cruise/cruise_main.cpp b/engines/cruise/cruise_main.cpp index 4955c4bd974..0857712e0a6 100644 --- a/engines/cruise/cruise_main.cpp +++ b/engines/cruise/cruise_main.cpp @@ -263,7 +263,7 @@ ovlData3Struct *scriptFunc1Sub2(int32 scriptNumber, int32 param) { } void scriptFunc2(int scriptNumber, scriptInstanceStruct * scriptHandle, - int param, int param2) { + int param, int param2) { if (scriptHandle->nextScriptPtr) { if (scriptNumber == scriptHandle->nextScriptPtr->overlayNumber || scriptNumber != -1) { diff --git a/engines/cruise/decompiler.cpp b/engines/cruise/decompiler.cpp index 7691a1bba77..677f81e7dbc 100644 --- a/engines/cruise/decompiler.cpp +++ b/engines/cruise/decompiler.cpp @@ -297,7 +297,7 @@ void addDecomp(char *string, ...) { } void resolveVarName(char *ovlIdxString, int varType, char *varIdxString, - char *outputName) { + char *outputName) { int varIdx = atoi(varIdxString); strcpy(outputName, ""); diff --git a/engines/cruise/font.cpp b/engines/cruise/font.cpp index fe3b93d1a7f..c04796da0f7 100644 --- a/engines/cruise/font.cpp +++ b/engines/cruise/font.cpp @@ -53,7 +53,7 @@ int32 getLineHeight(int16 charCount, const FontEntry *fontPtr) { * This function determines how many lines the text will have */ int32 getTextLineCount(int32 rightBorder_X, int16 wordSpacingWidth, - const FontEntry *fontData, const char *textString) { + const FontEntry *fontData, const char *textString) { const char *localString = textString; const char *tempPtr = textString; uint8 ch; @@ -188,7 +188,7 @@ void flipGen(void *var, int32 length) { } void renderWord(const uint8 *fontPtr_Data, uint8 *outBufferPtr, int xOffset, int yOffset, - int32 height, int32 param4, int32 stringRenderBufferSize, int32 width, int32 charWidth) { + int32 height, int32 param4, int32 stringRenderBufferSize, int32 width, int32 charWidth) { const uint8 *fontPtr_Data2 = fontPtr_Data + height * 2; outBufferPtr += yOffset * width + xOffset; @@ -214,7 +214,7 @@ void renderWord(const uint8 *fontPtr_Data, uint8 *outBufferPtr, int xOffset, int // returns character count and pixel size (via pointer) per line of the string (old: prepareWordRender(int32 param, int32 var1, int16* out2, uint8* ptr3, uint8* string)) int32 prepareWordRender(int32 inRightBorder_X, int16 wordSpacingWidth, - int16 *strPixelLength, const FontEntry *fontData, const char *textString) { + int16 *strPixelLength, const FontEntry *fontData, const char *textString) { const char *localString = textString; int32 counter = 0; diff --git a/engines/cruise/font.h b/engines/cruise/font.h index 12745c5b596..e530d6e4bb6 100644 --- a/engines/cruise/font.h +++ b/engines/cruise/font.h @@ -60,11 +60,11 @@ int32 getLineHeight(int16 charCount, const FontEntry *fontPtr, const uint8 *font int32 getTextLineCount(int32 rightBorder_X, int32 wordSpacingWidth, const FontEntry *fontData, const char *textString); void renderWord(uint8 *fontPtr_Data, uint8 *outBufferPtr, - int32 drawPosPixel_X, int32 heightOff, int32 height, int32 param4, - int32 stringRenderBufferSize, int32 width, int32 charWidth); + int32 drawPosPixel_X, int32 heightOff, int32 height, int32 param4, + int32 stringRenderBufferSize, int32 width, int32 charWidth); gfxEntryStruct *renderText(int inRightBorder_X, const char *string); void drawString(int32 x, int32 y, const char *string, uint8 * buffer, uint8 fontColor, - int32 inRightBorder_X); + int32 inRightBorder_X); void freeGfx(gfxEntryStruct *pGfx); } // End of namespace Cruise diff --git a/engines/cruise/menu.h b/engines/cruise/menu.h index c6f607506ec..8aba10d6777 100644 --- a/engines/cruise/menu.h +++ b/engines/cruise/menu.h @@ -38,7 +38,7 @@ extern menuStruct *menuTable[8]; menuStruct *createMenu(int X, int Y, const char *menuName); void addSelectableMenuEntry(int var0, int var1, menuStruct * pMenu, int var2, - int color, const char *menuText); + int color, const char *menuText); void updateMenuMouse(int mouseX, int mouseY, menuStruct * pMenu); int processMenu(menuStruct * pMenu); void freeMenu(menuStruct * pMenu); diff --git a/engines/cruise/metaengine.cpp b/engines/cruise/metaengine.cpp index 06864f414ed..4578ebf859a 100644 --- a/engines/cruise/metaengine.cpp +++ b/engines/cruise/metaengine.cpp @@ -50,7 +50,7 @@ public: return "cruise"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; int getMaximumSaveSlot() const override { return 99; } SaveStateList listSaves(const char *target) const override; diff --git a/engines/cruise/perso.cpp b/engines/cruise/perso.cpp index ff33eca14bf..7360ed1fae2 100644 --- a/engines/cruise/perso.cpp +++ b/engines/cruise/perso.cpp @@ -169,9 +169,9 @@ int cor_droite(int x1, int y1, int x2, int y2, point* outputTable) { } void processActorWalk(MovementEntry &resx_y, int16 *inc_droite, int16 *inc_droite0, - int16 *inc_chemin, point* cor_joueur, - int16 solution0[NUM_NODES + 3][2], int16 *inc_jo1, int16 *inc_jo2, - int16 *dir_perso, int16 *inc_jo0, int16 num) { + int16 *inc_chemin, point* cor_joueur, + int16 solution0[NUM_NODES + 3][2], int16 *inc_jo1, int16 *inc_jo2, + int16 *dir_perso, int16 *inc_jo0, int16 num) { int u = 0; inc_jo = *inc_jo0; diff --git a/engines/cryo/cryolib.cpp b/engines/cryo/cryolib.cpp index 2018a517b1b..32a60b4d199 100644 --- a/engines/cryo/cryolib.cpp +++ b/engines/cryo/cryolib.cpp @@ -196,7 +196,7 @@ void CLBlitter_OneBlackFlash() { } void CLBlitter_CopyView2ViewSimpleSize(byte *src, int16 srcw, int16 srcp, int16 srch, - byte *dst, int16 dstw, int16 dstp, int16 dsth) { + byte *dst, int16 dstw, int16 dstp, int16 dsth) { for (int16 y = 0; y < srch; y++) { for (int16 x = 0; x < srcw; x++) *dst++ = *src++; diff --git a/engines/cryo/cryolib.h b/engines/cryo/cryolib.h index d88ed6fae6a..63ae29003fa 100644 --- a/engines/cryo/cryolib.h +++ b/engines/cryo/cryolib.h @@ -86,7 +86,7 @@ void CLBlitter_CopyViewRect(View *view1, View *view2, Common::Rect *rect1, Commo void CLBlitter_Send2ScreenNextCopy(color_t *palette, uint16 first, uint16 count); void CLBlitter_OneBlackFlash(); void CLBlitter_CopyView2ViewSimpleSize(byte *src, int16 srcw, int16 srcp, int16 srch, - byte *dst, int16 dstw, int16 dstp, int16 dsth); + byte *dst, int16 dstw, int16 dstp, int16 dsth); void CLBlitter_CopyView2ScreenCUSTOM(View *view); void CLBlitter_CopyView2Screen(View *view); void CLBlitter_UpdateScreen(); diff --git a/engines/cryo/defs.h b/engines/cryo/defs.h index 3f371489c0a..f7faa8cb1c9 100644 --- a/engines/cryo/defs.h +++ b/engines/cryo/defs.h @@ -45,7 +45,7 @@ Glossary object - inventory item icon - clickable rectangle with some action tied to it dialog - a set of of dialog lines for character. further divided by categories and each entry may have associated - condition to be validated + condition to be validated global - game-wide storage area. must be preserved when saving/loading phase - current story progress. Incremented by 1 for minor events, by 0x10 for major advancements */ diff --git a/engines/cryo/metaengine.cpp b/engines/cryo/metaengine.cpp index db6afe46128..7baaaaf210f 100644 --- a/engines/cryo/metaengine.cpp +++ b/engines/cryo/metaengine.cpp @@ -41,7 +41,7 @@ public: return "cryo"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; }; diff --git a/engines/cryomni3d/cryomni3d.cpp b/engines/cryomni3d/cryomni3d.cpp index 74389342466..484063d915b 100644 --- a/engines/cryomni3d/cryomni3d.cpp +++ b/engines/cryomni3d/cryomni3d.cpp @@ -41,7 +41,7 @@ namespace CryOmni3D { CryOmni3DEngine::CryOmni3DEngine(OSystem *syst, - const CryOmni3DGameDescription *gamedesc) : Engine(syst), _gameDescription(gamedesc), + const CryOmni3DGameDescription *gamedesc) : Engine(syst), _gameDescription(gamedesc), _canLoadSave(false), _fontManager(), _sprites(), _dragStatus(kDragStatus_NoDrag), _lastMouseButton(0), _autoRepeatNextEvent(uint(-1)), _hnmHasClip(false) { if (!_mixer->isReady()) { @@ -100,7 +100,7 @@ DATSeekableStream *CryOmni3DEngine::getStaticData(uint32 gameId, uint16 version) } Common::String CryOmni3DEngine::prepareFileName(const Common::String &baseName, - const char *const *extensions) const { + const char *const *extensions) const { Common::String fname(baseName); int lastDotPos = fname.size() - 1; @@ -134,7 +134,7 @@ Common::String CryOmni3DEngine::prepareFileName(const Common::String &baseName, } void CryOmni3DEngine::playHNM(const Common::String &filename, Audio::Mixer::SoundType soundType, - HNMCallback beforeDraw, HNMCallback afterDraw) { + HNMCallback beforeDraw, HNMCallback afterDraw) { const char *const extensions[] = { "hns", "hnm", nullptr }; Common::String fname(prepareFileName(filename, extensions)); diff --git a/engines/cryomni3d/datstream.cpp b/engines/cryomni3d/datstream.cpp index 4ce46504543..0a00f5bbb99 100644 --- a/engines/cryomni3d/datstream.cpp +++ b/engines/cryomni3d/datstream.cpp @@ -26,7 +26,7 @@ namespace CryOmni3D { DATSeekableStream *DATSeekableStream::getGame(Common::SeekableReadStream *stream, - uint32 gameId, uint16 version, Common::Language lang, Common::Platform platform) { + uint32 gameId, uint16 version, Common::Language lang, Common::Platform platform) { if (stream == nullptr) { return nullptr; } diff --git a/engines/cryomni3d/detection_tables.h b/engines/cryomni3d/detection_tables.h index 330d37ae8ff..f8afa50f1e3 100644 --- a/engines/cryomni3d/detection_tables.h +++ b/engines/cryomni3d/detection_tables.h @@ -28,11 +28,11 @@ namespace CryOmni3D { // We use files common to all installations except the documentation links and the binary // We only check the file presence to simplify and use program to discriminate the version #define VERSAILLES_ENTRY(f, x, s, lien_doc_ext) { \ - { "11D_LEB1.HNM", 0, nullptr, -1}, \ - { "COFBOUM.HNM", 0, nullptr, -1}, \ - { "lien_doc." lien_doc_ext, 0, nullptr, -1}, \ - { f, 0, x, s}, \ - AD_LISTEND} + { "11D_LEB1.HNM", 0, nullptr, -1}, \ + { "COFBOUM.HNM", 0, nullptr, -1}, \ + { "lien_doc." lien_doc_ext, 0, nullptr, -1}, \ + { f, 0, x, s}, \ + AD_LISTEND} #define VERSAILLES_ENTRY_DEF(f, x, s) VERSAILLES_ENTRY(f, x, s, "txt") diff --git a/engines/cryomni3d/dialogs_manager.cpp b/engines/cryomni3d/dialogs_manager.cpp index 680f27f928f..94ca3a0aaca 100644 --- a/engines/cryomni3d/dialogs_manager.cpp +++ b/engines/cryomni3d/dialogs_manager.cpp @@ -349,7 +349,7 @@ bool DialogsManager::play(const Common::String &sequence, bool &slowStop) { } Common::Array DialogsManager::executeAfterPlayAndBuildGotoList( - const char *actions) { + const char *actions) { Common::Array gotos; for (; actions && *actions != ':'; actions = nextLine(actions)) { @@ -486,7 +486,7 @@ void DialogsManager::executeShow(const char *showLine) { } const char *DialogsManager::executePlayerQuestion(const char *text, bool dryRun, - const char **realLabel) { + const char **realLabel) { // Go after the text const char *actions = nextLine(text); @@ -551,7 +551,7 @@ const char *DialogsManager::parseIf(const char *ifLine) { } void DialogsManager::registerSubtitlesSettings(const Common::String &videoName, - const SubtitlesSettings &settings) { + const SubtitlesSettings &settings) { _subtitlesSettings[videoName] = settings; } diff --git a/engines/cryomni3d/fixed_image.cpp b/engines/cryomni3d/fixed_image.cpp index cdae1a737be..647ca17af03 100644 --- a/engines/cryomni3d/fixed_image.cpp +++ b/engines/cryomni3d/fixed_image.cpp @@ -30,9 +30,9 @@ namespace CryOmni3D { ZonFixedImage::ZonFixedImage(CryOmni3DEngine &engine, - Inventory &inventory, - const Sprites &sprites, - const FixedImageConfiguration *configuration) : + Inventory &inventory, + const Sprites &sprites, + const FixedImageConfiguration *configuration) : _engine(engine), _inventory(inventory), _sprites(sprites), _configuration(configuration), _callback(nullptr), _imageDecoder(nullptr), _imageSurface(nullptr), diff --git a/engines/cryomni3d/font_manager.cpp b/engines/cryomni3d/font_manager.cpp index 704198c6173..6c40cc52941 100644 --- a/engines/cryomni3d/font_manager.cpp +++ b/engines/cryomni3d/font_manager.cpp @@ -55,7 +55,7 @@ FontManager::~FontManager() { } void FontManager::loadFonts(const Common::Array &fontFiles, - Common::CodePage codepage) { + Common::CodePage codepage) { assert(codepage != Common::kCodePageInvalid); _codepage = codepage; setupWrapParameters(); @@ -210,7 +210,7 @@ void FontManager::setSpaceWidth(uint additionalSpace) { } uint FontManager::displayStr_(uint x, uint y, - const Common::U32String &text) const { + const Common::U32String &text) const { uint offset = 0; for (Common::U32String::const_iterator it = text.begin(); it != text.end(); it++) { _currentFont->drawChar(_currentSurface, *it, x + offset, y, _foreColor); @@ -233,7 +233,7 @@ uint FontManager::getStrWidth(const Common::U32String &text) const { } bool FontManager::displayBlockText(const Common::U32String &text, - Common::U32String::const_iterator begin) { + Common::U32String::const_iterator begin) { bool notEnoughSpace = false; Common::U32String::const_iterator ptr = begin; Common::Array words; @@ -351,8 +351,8 @@ uint FontManager::getLinesCount(const Common::U32String &text, uint width) { } void FontManager::calculateWordWrap(const Common::U32String &text, - Common::U32String::const_iterator *position, uint *finalPos, bool *hasCr, - Common::Array &words) const { + Common::U32String::const_iterator *position, uint *finalPos, bool *hasCr, + Common::Array &words) const { *hasCr = false; uint offset = 0; bool wordWrap = false; diff --git a/engines/cryomni3d/image/codecs/hlz.cpp b/engines/cryomni3d/image/codecs/hlz.cpp index adbea2d6eff..754c0cc0ca9 100644 --- a/engines/cryomni3d/image/codecs/hlz.cpp +++ b/engines/cryomni3d/image/codecs/hlz.cpp @@ -57,7 +57,7 @@ Graphics::PixelFormat HLZDecoder::getPixelFormat() const { } static inline uint getReg(Common::SeekableReadStream &stream, uint32 *size, uint32 *reg, - int *regBits) { + int *regBits) { if (*regBits == 0) { if (*size < 4) { error("Can't feed register: not enough data"); diff --git a/engines/cryomni3d/metaengine.cpp b/engines/cryomni3d/metaengine.cpp index ad89db1ecbc..5a31f796672 100644 --- a/engines/cryomni3d/metaengine.cpp +++ b/engines/cryomni3d/metaengine.cpp @@ -69,7 +69,7 @@ bool CryOmni3DEngine::hasFeature(EngineFeature f) const { class CryOmni3DMetaEngine : public AdvancedMetaEngine { public: - const char *getName() const override { + const char *getName() const override { return "cryomni3d"; } diff --git a/engines/cryomni3d/mouse_boxes.cpp b/engines/cryomni3d/mouse_boxes.cpp index 85c4cd79f13..b77d87761ba 100644 --- a/engines/cryomni3d/mouse_boxes.cpp +++ b/engines/cryomni3d/mouse_boxes.cpp @@ -42,7 +42,7 @@ void MouseBoxes::reset() { } void MouseBoxes::setupBox(int box_id, int left, int top, int right, int bottom, - const Common::String *text) { + const Common::String *text) { MouseBox &box = _boxes[box_id]; box.left = left; box.top = top; diff --git a/engines/cryomni3d/sprites.cpp b/engines/cryomni3d/sprites.cpp index c6ee7721dc7..0ec6288f479 100644 --- a/engines/cryomni3d/sprites.cpp +++ b/engines/cryomni3d/sprites.cpp @@ -31,11 +31,11 @@ namespace CryOmni3D { #define MAP_ID(id) \ - do { \ - if (_map) { \ - id = (*_map)[id]; \ - } \ - } while(false) + do { \ + if (_map) { \ + id = (*_map)[id]; \ + } \ + } while(false) Sprites::Sprites() : _map(nullptr) { _surface = new Graphics::Surface(); diff --git a/engines/cryomni3d/versailles/data.cpp b/engines/cryomni3d/versailles/data.cpp index d04420bc01a..d5d0dcd7690 100644 --- a/engines/cryomni3d/versailles/data.cpp +++ b/engines/cryomni3d/versailles/data.cpp @@ -72,7 +72,7 @@ const FakeTransitionActionPlace CryOmni3DEngine_Versailles::kFakeTransitions[] = }; static void readSubtitles(Common::HashMap > &subtitles, - DATSeekableStream *data) { + DATSeekableStream *data) { uint16 vidsCount = data->readUint16LE(); for (uint16 i = 0; i < vidsCount; i++) { Common::String vidName = data->readString16(); diff --git a/engines/cryomni3d/versailles/dialogs_manager.cpp b/engines/cryomni3d/versailles/dialogs_manager.cpp index bb3630ed50e..f8ede020a1e 100644 --- a/engines/cryomni3d/versailles/dialogs_manager.cpp +++ b/engines/cryomni3d/versailles/dialogs_manager.cpp @@ -33,7 +33,7 @@ namespace CryOmni3D { namespace Versailles { Versailles_DialogsManager::Versailles_DialogsManager(CryOmni3DEngine_Versailles *engine, - bool padAudioFileName) : + bool padAudioFileName) : _engine(engine), _padAudioFileName(padAudioFileName) { } @@ -93,7 +93,7 @@ void Versailles_DialogsManager::executeShow(const Common::String &show) { } void Versailles_DialogsManager::playDialog(const Common::String &video, const Common::String &sound, - const Common::String &text, const SubtitlesSettings &settings) { + const Common::String &text, const SubtitlesSettings &settings) { // Don't look for HNS file here Common::String videoFName(_engine->prepareFileName(video, "hnm")); Common::String soundFName(sound); @@ -250,7 +250,7 @@ void Versailles_DialogsManager::displayMessage(const Common::String &text) { } uint Versailles_DialogsManager::askPlayerQuestions(const Common::String &video, - const Common::StringArray &questions) { + const Common::StringArray &questions) { if (_lastImage.empty()) { loadFrame(video); } diff --git a/engines/cryomni3d/versailles/documentation.cpp b/engines/cryomni3d/versailles/documentation.cpp index 54bfe43aac6..6bc1721dafe 100644 --- a/engines/cryomni3d/versailles/documentation.cpp +++ b/engines/cryomni3d/versailles/documentation.cpp @@ -82,8 +82,8 @@ const Versailles_Documentation::TimelineEntry Versailles_Documentation::kTimelin }; void Versailles_Documentation::init(const Sprites *sprites, FontManager *fontManager, - const Common::StringArray *messages, CryOmni3DEngine *engine, - const Common::String &allDocsFileName, const Common::String &linksDocsFileName) { + const Common::StringArray *messages, CryOmni3DEngine *engine, + const Common::String &allDocsFileName, const Common::String &linksDocsFileName) { _sprites = sprites; _fontManager = fontManager; _messages = messages; @@ -669,7 +669,7 @@ void Versailles_Documentation::docAreaPrepareNavigation() { } void Versailles_Documentation::docAreaPrepareRecord(Graphics::ManagedSurface &surface, - MouseBoxes &boxes) { + MouseBoxes &boxes) { boxes.reset(); setupRecordBoxes(true, boxes); @@ -698,7 +698,7 @@ void Versailles_Documentation::docAreaPrepareRecord(Graphics::ManagedSurface &su } uint Versailles_Documentation::docAreaHandleRecord(Graphics::ManagedSurface &surface, - MouseBoxes &boxes, Common::String &nextRecord) { + MouseBoxes &boxes, Common::String &nextRecord) { // Hovering is only handled for timeline entries _engine->setCursor(181); _engine->showMouse(true); @@ -1318,7 +1318,7 @@ Common::String Versailles_Documentation::docAreaHandleCastleMap() { } void Versailles_Documentation::inGamePrepareRecord(Graphics::ManagedSurface &surface, - MouseBoxes &boxes) { + MouseBoxes &boxes) { _categoryStartRecord = ""; _categoryEndRecord = ""; _categoryTitle = ""; @@ -1350,7 +1350,7 @@ void Versailles_Documentation::inGamePrepareRecord(Graphics::ManagedSurface &sur } uint Versailles_Documentation::inGameHandleRecord(Graphics::ManagedSurface &surface, - MouseBoxes &boxes, Common::String &nextRecord) { + MouseBoxes &boxes, Common::String &nextRecord) { _engine->setCursor(181); _engine->showMouse(true); @@ -1401,8 +1401,8 @@ uint Versailles_Documentation::inGameHandleRecord(Graphics::ManagedSurface &surf } void Versailles_Documentation::drawRecordData(Graphics::ManagedSurface &surface, - const Common::String &text, const Common::String &title, - const Common::String &subtitle, const Common::String &caption) { + const Common::String &text, const Common::String &title, + const Common::String &subtitle, const Common::String &caption) { unsigned char foreColor = 247; Common::String background; Common::Rect blockTitle; @@ -1621,7 +1621,7 @@ void Versailles_Documentation::setupRecordBoxes(bool inDocArea, MouseBoxes &boxe } void Versailles_Documentation::drawRecordBoxes(Graphics::ManagedSurface &surface, bool inDocArea, - MouseBoxes &boxes) { + MouseBoxes &boxes) { if (_visitTrace.size()) { surface.transBlitFrom(_sprites->getSurface(105), boxes.getBoxOrigin(0), _sprites->getKeyColor(105)); } @@ -1662,9 +1662,9 @@ void Versailles_Documentation::drawRecordBoxes(Graphics::ManagedSurface &surface } uint Versailles_Documentation::handlePopupMenu(const Graphics::ManagedSurface - &originalSurface, - const Common::Point &anchor, bool rightAligned, uint itemHeight, - const Common::StringArray &items) { + &originalSurface, + const Common::Point &anchor, bool rightAligned, uint itemHeight, + const Common::StringArray &items) { uint maxTextWidth = 0; @@ -1952,7 +1952,7 @@ const char *Versailles_Documentation::getRecordSubtitle(char *start, char *end) } void Versailles_Documentation::getRecordHyperlinks(char *start, char *end, - Common::StringArray &hyperlinks) { + Common::StringArray &hyperlinks) { const char *const hyperlinksPatterns[] = { "SAVOIR-PLUS 1=", "SAVOIR-PLUS 2=", "SAVOIR-PLUS 3=" }; hyperlinks.clear(); @@ -1992,8 +1992,8 @@ Common::String Versailles_Documentation::getRecordTitle(const Common::String &re } Common::String Versailles_Documentation::getRecordData(const Common::String &record, - Common::String &title, Common::String &subtitle, Common::String &caption, - Common::StringArray &hyperlinks) { + Common::String &title, Common::String &subtitle, Common::String &caption, + Common::StringArray &hyperlinks) { Common::HashMap::iterator it = _records.find(record); if (it == _records.end()) { warning("Can't find %s record data", record.c_str()); @@ -2041,7 +2041,7 @@ Common::String Versailles_Documentation::getRecordData(const Common::String &rec } void Versailles_Documentation::convertHyperlinks(const Common::StringArray &hyperlinks, - Common::Array &links) { + Common::Array &links) { for (Common::StringArray::const_iterator it = hyperlinks.begin(); it != hyperlinks.end(); it++) { LinkInfo link; link.record = *it; @@ -2069,7 +2069,7 @@ void Versailles_Documentation::loadLinksFile() { } void Versailles_Documentation::getLinks(const Common::String &record, - Common::Array &links) { + Common::Array &links) { loadLinksFile(); links.clear(); diff --git a/engines/cryomni3d/versailles/engine.cpp b/engines/cryomni3d/versailles/engine.cpp index 06496e1bab0..d644b89ab80 100644 --- a/engines/cryomni3d/versailles/engine.cpp +++ b/engines/cryomni3d/versailles/engine.cpp @@ -49,7 +49,7 @@ const FixedImageConfiguration CryOmni3DEngine_Versailles::kFixedImageConfigurati }; CryOmni3DEngine_Versailles::CryOmni3DEngine_Versailles(OSystem *syst, - const CryOmni3DGameDescription *gamedesc) : CryOmni3DEngine(syst, gamedesc), + const CryOmni3DGameDescription *gamedesc) : CryOmni3DEngine(syst, gamedesc), _mainPalette(nullptr), _cursorPalette(nullptr), _transparentPaletteMap(nullptr), _transparentSrcStart(uint(-1)), _transparentSrcStop(uint(-1)), _transparentDstStart(uint(-1)), _transparentDstStop(uint(-1)), _transparentNewStart(uint(-1)), _transparentNewStop(uint(-1)), @@ -257,7 +257,7 @@ bool CryOmni3DEngine_Versailles::shouldAbort() { } Common::String CryOmni3DEngine_Versailles::prepareFileName(const Common::String &baseName, - const char *const *extensions) const { + const char *const *extensions) const { Common::String baseName_(baseName); if (getPlatform() != Common::kPlatformMacintosh) { // Replace dashes by underscores for PC versions @@ -440,7 +440,7 @@ void CryOmni3DEngine_Versailles::loadCursorsPalette() { } void CryOmni3DEngine_Versailles::setupPalette(const byte *palette, uint start, uint num, - bool commit) { + bool commit) { memcpy(_mainPalette + 3 * start, palette, 3 * num); copySubPalette(_mainPalette, _cursorPalette, 240, 8); @@ -536,7 +536,7 @@ void CryOmni3DEngine_Versailles::calculateTransparentMapping() { } void CryOmni3DEngine_Versailles::makeTranslucent(Graphics::Surface &dst, - const Graphics::Surface &src) const { + const Graphics::Surface &src) const { assert(dst.w == src.w && dst.h == src.h); const byte *srcP = (const byte *) src.getPixels(); @@ -1120,7 +1120,7 @@ void CryOmni3DEngine_Versailles::fakeTransition(uint dstPlaceId) { } uint CryOmni3DEngine_Versailles::determineTransitionAnimation(uint srcPlaceId, - uint dstPlaceId, const Transition **transition_) { + uint dstPlaceId, const Transition **transition_) { const Place *srcPlace = _wam.findPlaceById(srcPlaceId); const Place *dstPlace = _wam.findPlaceById(dstPlaceId); const Transition *transition = srcPlace->findTransition(dstPlaceId); @@ -1270,7 +1270,7 @@ int CryOmni3DEngine_Versailles::handleWarp() { } bool CryOmni3DEngine_Versailles::handleWarpMouse(uint *actionId, - uint movingCursor) { + uint movingCursor) { fixActionId(actionId); if (getCurrentMouseButton() == 2 || @@ -1485,7 +1485,7 @@ void CryOmni3DEngine_Versailles::animateCursor(const Object *obj) { } void CryOmni3DEngine_Versailles::collectObject(Object *obj, const ZonFixedImage *fimg, - bool showObject) { + bool showObject) { _inventory.add(obj); Object::ViewCallback cb = obj->viewCallback(); if (showObject && cb) { @@ -1501,7 +1501,7 @@ void CryOmni3DEngine_Versailles::collectObject(Object *obj, const ZonFixedImage } void CryOmni3DEngine_Versailles::displayObject(const Common::String &imgName, - DisplayObjectHook hook) { + DisplayObjectHook hook) { Image::ImageDecoder *imageDecoder = loadHLZ(imgName); if (!imageDecoder) { error("Can't display object"); @@ -1624,7 +1624,7 @@ uint CryOmni3DEngine_Versailles::getFakeTransition(uint actionId) const { } void CryOmni3DEngine_Versailles::playInGameVideo(const Common::String &filename, - bool restoreCursorPalette) { + bool restoreCursorPalette) { if (!_isPlaying) { return; } @@ -1723,7 +1723,7 @@ void CryOmni3DEngine_Versailles::drawVideoSubtitles(uint frameNum) { } void CryOmni3DEngine_Versailles::loadBMPs(const char *pattern, Graphics::Surface *bmps, - uint count) { + uint count) { Image::BitmapDecoder bmpDecoder; Common::File file; diff --git a/engines/cryomni3d/versailles/logic.cpp b/engines/cryomni3d/versailles/logic.cpp index 3e583ea11ff..be9ed0c7334 100644 --- a/engines/cryomni3d/versailles/logic.cpp +++ b/engines/cryomni3d/versailles/logic.cpp @@ -67,9 +67,9 @@ void CryOmni3DEngine_Versailles::setupObjects() { _objects.reserve(51); #define SET_OBJECT(cursorId, nameId) _objects.push_back(Object(_sprites, cursorId, nameId)) #define SET_OBJECT_AND_CB(cursorId, nameId, cb) do { \ - _objects.push_back(Object(_sprites, cursorId, nameId)); \ - _objects.back().setViewCallback(new Common::Functor0Mem(this, &CryOmni3DEngine_Versailles::cb)); \ - } while (false) + _objects.push_back(Object(_sprites, cursorId, nameId)); \ + _objects.back().setViewCallback(new Common::Functor0Mem(this, &CryOmni3DEngine_Versailles::cb)); \ + } while (false) #define SET_OBJECT_GENERIC_CB(cursorId, nameId, imageId) SET_OBJECT_AND_CB(cursorId, nameId, genericDisplayObject) #define SET_OBJECT_CB(cursorId, nameId) SET_OBJECT_AND_CB(cursorId, nameId, obj_ ## nameId) SET_OBJECT(161, 93); // 0 @@ -478,12 +478,12 @@ void CryOmni3DEngine_Versailles::genericDumbImage(ZonFixedImage *fimg) { // Generic handler for interrogation mark action: display the painting title #define HANDLE_QUESTION(ID) \ - do { \ - if (fimg->_zoneQuestion) { \ - displayMessageBox(kFixedimageMsgBoxParameters, fimg->surface(), _paintingsTitles[ID], Common::Point(600, 400), \ - Common::Functor0Mem(fimg, &ZonFixedImage::manage)); \ - } \ - } while (false) + do { \ + if (fimg->_zoneQuestion) { \ + displayMessageBox(kFixedimageMsgBoxParameters, fimg->surface(), _paintingsTitles[ID], Common::Point(600, 400), \ + Common::Functor0Mem(fimg, &ZonFixedImage::manage)); \ + } \ + } while (false) // Generic handler for paintings fixed images template @@ -1286,7 +1286,7 @@ const uint16 CryOmni3DEngine_Versailles::kSafeDigitsX[] = { 267, 318, 370, 421 } const uint16 CryOmni3DEngine_Versailles::kSafeDigitsY[] = { 148, 230, 311 }; void CryOmni3DEngine_Versailles::drawSafeDigits(Graphics::ManagedSurface &surface, - const Graphics::Surface(&bmpDigits)[10], const unsigned char (&safeDigits)[kSafeDigitsCount]) { + const Graphics::Surface(&bmpDigits)[10], const unsigned char (&safeDigits)[kSafeDigitsCount]) { for (uint i = 0; i < ARRAYSIZE(safeDigits); i++) { const Graphics::Surface &digit = bmpDigits[safeDigits[i]]; Common::Point dst(kSafeDigitsX[i % 4], kSafeDigitsY[i / 4]); @@ -2444,7 +2444,7 @@ bool CryOmni3DEngine_Versailles::handleEpigraph(ZonFixedImage *fimg) { } void CryOmni3DEngine_Versailles::drawEpigraphLetters(Graphics::ManagedSurface &surface, - const Graphics::Surface(&bmpLetters)[28], const Common::String &letters) { + const Graphics::Surface(&bmpLetters)[28], const Common::String &letters) { for (uint i = 0; i < letters.size() && i < kEpigraphMaxLetters; i++) { uint letterId = 0; if (letters[i] >= 'A' && letters[i] <= 'Z') { @@ -3206,9 +3206,9 @@ const uint16 CryOmni3DEngine_Versailles::kBombLettersPos[2][kBombPasswordMaxLeng }; void CryOmni3DEngine_Versailles::drawBombLetters(Graphics::ManagedSurface &surface, - const Graphics::Surface(&bmpLetters)[28], const uint bombPasswordLength, - const uint32(&bombPossibilites)[kBombPasswordMaxLength][5], - const byte(&bombCurrentLetters)[kBombPasswordMaxLength]) { + const Graphics::Surface(&bmpLetters)[28], const uint bombPasswordLength, + const uint32(&bombPossibilites)[kBombPasswordMaxLength][5], + const byte(&bombCurrentLetters)[kBombPasswordMaxLength]) { uint table = bombPasswordLength <= kBombPasswordSmallLength ? 0 : 1; if (getLanguage() == Common::JA_JPN) { _fontManager.setCurrentFont(1); @@ -3369,13 +3369,13 @@ FILTER_EVENT(1, 3) { // Event 19 is not in this room: must be a leftover /* FILTER_EVENT(1, 7) { - if (*event == 19) { - // Too dark - displayMessageBoxWarp(7); - return false; - } + if (*event == 19) { + // Too dark + displayMessageBoxWarp(7); + return false; + } - return true; + return true; } */ diff --git a/engines/cryomni3d/versailles/menus.cpp b/engines/cryomni3d/versailles/menus.cpp index 6a4e7ca0845..1158c822e10 100644 --- a/engines/cryomni3d/versailles/menus.cpp +++ b/engines/cryomni3d/versailles/menus.cpp @@ -529,7 +529,7 @@ uint CryOmni3DEngine_Versailles::displayOptions() { } uint CryOmni3DEngine_Versailles::displayYesNoBox(Graphics::ManagedSurface &surface, - const Common::Rect &position, uint msg_id) { + const Common::Rect &position, uint msg_id) { uint confirmWidth = _fontManager.getStrWidth(_messages[53]); uint cancelWidth = _fontManager.getStrWidth(_messages[54]); uint oldFont = _fontManager.getCurrentFont(); @@ -604,7 +604,7 @@ uint CryOmni3DEngine_Versailles::displayYesNoBox(Graphics::ManagedSurface &surfa } uint CryOmni3DEngine_Versailles::displayFilePicker(const Graphics::Surface *bgFrame, - bool saveMode, Common::String &saveName) { + bool saveMode, Common::String &saveName) { bool autoName = (_messages.size() >= 148); Graphics::ManagedSurface surface(bgFrame->w, bgFrame->h, bgFrame->format); @@ -891,8 +891,8 @@ const MsgBoxParameters CryOmni3DEngine_Versailles::kFixedimageMsgBoxParameters = }; void CryOmni3DEngine_Versailles::displayMessageBox(const MsgBoxParameters ¶ms, - const Graphics::Surface *surface, const Common::String &msg, const Common::Point &position, - const Common::Functor0 &callback) { + const Graphics::Surface *surface, const Common::String &msg, const Common::Point &position, + const Common::Functor0 &callback) { Graphics::ManagedSurface dstSurface; dstSurface.create(surface->w, surface->h, surface->format); dstSurface.blitFrom(*surface); diff --git a/engines/cryomni3d/versailles/music.cpp b/engines/cryomni3d/versailles/music.cpp index 22d1dd8a594..d97a5338278 100644 --- a/engines/cryomni3d/versailles/music.cpp +++ b/engines/cryomni3d/versailles/music.cpp @@ -140,7 +140,7 @@ bool CryOmni3DEngine_Versailles::musicWouldChange(uint level, uint placeId) cons } uint CryOmni3DEngine_Versailles::getMusicId(uint level, - uint placeId) const { + uint placeId) const { // No need of place state switch (level) { case 1: diff --git a/engines/cryomni3d/versailles/saveload.cpp b/engines/cryomni3d/versailles/saveload.cpp index e28db7bc870..4a0fd4209fc 100644 --- a/engines/cryomni3d/versailles/saveload.cpp +++ b/engines/cryomni3d/versailles/saveload.cpp @@ -54,7 +54,7 @@ bool CryOmni3DEngine_Versailles::canVisit() const { } void CryOmni3DEngine_Versailles::getSavesList(bool visit, Common::StringArray &saveNames, - int &nextSaveNum) { + int &nextSaveNum) { nextSaveNum = 1; bool supportsAutoName = (_messages.size() >= 148); @@ -145,7 +145,7 @@ void CryOmni3DEngine_Versailles::getSavesList(bool visit, Common::StringArray &s } void CryOmni3DEngine_Versailles::saveGame(bool visit, uint saveNum, - const Common::String &saveName) { + const Common::String &saveName) { if (visit && saveNum == 1) { error("Can't erase bootstrap visit"); } diff --git a/engines/cryomni3d/versailles/toolbar.cpp b/engines/cryomni3d/versailles/toolbar.cpp index e4b1ce9bfde..c9633f35710 100644 --- a/engines/cryomni3d/versailles/toolbar.cpp +++ b/engines/cryomni3d/versailles/toolbar.cpp @@ -30,8 +30,8 @@ namespace CryOmni3D { namespace Versailles { void Toolbar::init(const Sprites *sprites, FontManager *fontManager, - const Common::Array *messages, Inventory *inventory, - CryOmni3DEngine *engine) { + const Common::Array *messages, Inventory *inventory, + CryOmni3DEngine *engine) { _sprites = sprites; _fontManager = fontManager; _messages = messages; @@ -82,7 +82,7 @@ void Toolbar::inventoryChanged(uint newPosition) { } void Toolbar::addZone(uint16 cursorMainId, uint16 cursorSecondaryId, Common::Point position, - ZoneCallback callback) { + ZoneCallback callback) { const Graphics::Cursor &cursorMain = _sprites->getCursor(cursorMainId); Common::Rect rct(cursorMain.getWidth(), cursorMain.getHeight()); rct.moveTo(position); diff --git a/engines/cryomni3d/video/hnm_decoder.cpp b/engines/cryomni3d/video/hnm_decoder.cpp index 43a75f9da25..5214cfd8e29 100644 --- a/engines/cryomni3d/video/hnm_decoder.cpp +++ b/engines/cryomni3d/video/hnm_decoder.cpp @@ -153,7 +153,7 @@ void HNMDecoder::readNextPacket() { } HNMDecoder::HNM4VideoTrack::HNM4VideoTrack(uint32 width, uint32 height, uint32 frameSize, - uint32 frameCount, uint32 regularFrameDelay, const byte *initialPalette) : + uint32 frameCount, uint32 regularFrameDelay, const byte *initialPalette) : _frameCount(frameCount), _regularFrameDelay(regularFrameDelay), _nextFrameStartTime(0) { restart(); @@ -350,7 +350,7 @@ void HNMDecoder::HNM4VideoTrack::decodeIntraframe(Common::SeekableReadStream *st } HNMDecoder::DPCMAudioTrack::DPCMAudioTrack(uint16 channels, uint16 bits, uint sampleRate, - Audio::Mixer::SoundType soundType) : AudioTrack(soundType), _audioStream(nullptr), + Audio::Mixer::SoundType soundType) : AudioTrack(soundType), _audioStream(nullptr), _gotLUT(false), _lastSample(0) { if (bits != 16) { error("Unsupported audio bits"); @@ -366,7 +366,7 @@ HNMDecoder::DPCMAudioTrack::~DPCMAudioTrack() { } Audio::Timestamp HNMDecoder::DPCMAudioTrack::decodeSound(Common::SeekableReadStream *stream, - uint32 size) { + uint32 size) { if (!_gotLUT) { if (size < 256 * sizeof(*_lut)) { error("Invalid first sound chunk"); diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp index 58181d45657..2bf058ca314 100644 --- a/engines/director/lingo/lingo-code.cpp +++ b/engines/director/lingo/lingo-code.cpp @@ -985,7 +985,7 @@ void LC::c_charOf() { Datum src = g_lingo->pop(false); Datum index = g_lingo->pop(); - if ((index.type != INT && index.type != FLOAT) + if ((index.type != INT && index.type != FLOAT) || (src.type != STRING && src.type != VAR && src.type != FIELDREF && src.type != CHUNKREF && src.type != CASTREF)) { g_lingo->lingoError("LC::c_charOf(): Called with wrong data types: %s and %s", index.type2str(), src.type2str()); g_lingo->push(Datum("")); diff --git a/engines/director/util.h b/engines/director/util.h index 009291e33d9..3918b3fb655 100644 --- a/engines/director/util.h +++ b/engines/director/util.h @@ -58,22 +58,22 @@ bool processQuitEvent(bool click = false); // events.cpp class RandomState { public: - uint32 _seed; - uint32 _mask; - uint32 _len; + uint32 _seed; + uint32 _mask; + uint32 _len; - RandomState() { - _seed = _mask = _len = 0; - } + RandomState() { + _seed = _mask = _len = 0; + } - void setSeed(int seed); - uint32 getSeed() { return _seed; } - int32 getRandom(int32 range); + void setSeed(int seed); + uint32 getSeed() { return _seed; } + int32 getRandom(int32 range); private: - void init(int len); - int32 genNextRandom(); - int32 perlin(int32 val); + void init(int len); + int32 genNextRandom(); + int32 perlin(int32 val); }; uint32 readVarInt(Common::SeekableReadStream &stream); diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index cdf92a884b1..813633c80c8 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -558,7 +558,7 @@ void DisplayMan::initConstants() { for(int c = 0; c < 6; ++c) _wallOrnamentCoordSets[a][b][c] = wallOrnamentCoordSets[a][b][c]; - for(int a = 0; a < 4; ++a) + for(int a = 0; a < 4; ++a) for(int b = 0; b < 3; ++b) for(int c = 0; c < 6; ++c) _doorOrnCoordSets[a][b][c] = doorOrnCoordSets[a][b][c]; @@ -703,8 +703,8 @@ void DisplayMan::initializeGraphicData() { _bitmapViewport = new byte[224 * 136](); if (!_derivedBitmapByteCount) { - _derivedBitmapByteCount = new uint16[k730_DerivedBitmapMaximumCount]; - } + _derivedBitmapByteCount = new uint16[k730_DerivedBitmapMaximumCount]; + } if (!_derivedBitmaps) { _derivedBitmaps = new byte *[k730_DerivedBitmapMaximumCount]; for (uint16 i = 0; i < k730_DerivedBitmapMaximumCount; ++i) diff --git a/engines/draci/metaengine.cpp b/engines/draci/metaengine.cpp index fa40d4f8178..f982e831a8c 100644 --- a/engines/draci/metaengine.cpp +++ b/engines/draci/metaengine.cpp @@ -34,7 +34,7 @@ public: return "draci"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; int getMaximumSaveSlot() const override { return 99; } SaveStateList listSaves(const char *target) const override; void removeSaveState(const char *target, int slot) const override; diff --git a/engines/draci/sprite.cpp b/engines/draci/sprite.cpp index 8b5e5a918a0..32e34db032d 100644 --- a/engines/draci/sprite.cpp +++ b/engines/draci/sprite.cpp @@ -55,7 +55,7 @@ static void transformToRows(byte *img, uint16 width, uint16 height) { * Constructor for loading sprites from a raw data buffer, one byte per pixel. */ Sprite::Sprite(uint16 width, uint16 height, byte *raw_data, int x, int y, bool columnwise) - : _ownsData(true), _data(raw_data), _mirror(false) { + : _ownsData(true), _data(raw_data), _mirror(false) { _width = width; _height = height; @@ -78,7 +78,7 @@ Sprite::Sprite(uint16 width, uint16 height, byte *raw_data, int x, int y, bool c * pixel. */ Sprite::Sprite(const byte *sprite_data, uint16 length, int x, int y, bool columnwise) - : _ownsData(false), _data(NULL), _mirror(false) { + : _ownsData(false), _data(NULL), _mirror(false) { Common::MemoryReadStream reader(sprite_data, length); _width = reader.readSint16LE(); @@ -250,7 +250,7 @@ Common::Rect Sprite::getRect(const Displacement &displacement) const { } Text::Text(const Common::String &str, const Font *font, byte fontColor, - int x, int y, uint spacing) { + int x, int y, uint spacing) { _x = x; _y = y; _delay = 0; diff --git a/engines/drascula/metaengine.cpp b/engines/drascula/metaengine.cpp index 4ae15bb9143..a1cd28b40d4 100644 --- a/engines/drascula/metaengine.cpp +++ b/engines/drascula/metaengine.cpp @@ -60,14 +60,14 @@ SaveStateDescriptor loadMetaData(Common::ReadStream *s, int slot, bool setPlayTi class DrasculaMetaEngine : public AdvancedMetaEngine { public: - const char *getName() const override { + const char *getName() const override { return "drascula"; } Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const override; bool hasFeature(MetaEngineFeature f) const override; - SaveStateList listSaves(const char *target) const override; + SaveStateList listSaves(const char *target) const override; int getMaximumSaveSlot() const override; void removeSaveState(const char *target, int slot) const override; SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override; diff --git a/engines/engine.cpp b/engines/engine.cpp index b926d475e3d..24056008386 100644 --- a/engines/engine.cpp +++ b/engines/engine.cpp @@ -472,7 +472,7 @@ void Engine::checkCD() { #endif #ifdef USE_FLAC if (Common::File::exists("track1.fla") || - Common::File::exists("track1.flac") || + Common::File::exists("track1.flac") || Common::File::exists("track01.fla") || Common::File::exists("track01.flac")) return; diff --git a/engines/engine.h b/engines/engine.h index 3d5963233a2..6ee760ca3ed 100644 --- a/engines/engine.h +++ b/engines/engine.h @@ -97,16 +97,16 @@ class PauseToken { public: PauseToken(); /** - * Construct a pause token. - */ + * Construct a pause token. + */ PauseToken(const PauseToken &); #if __cplusplus >= 201103L PauseToken(PauseToken &&); #endif ~PauseToken(); /** - * Assign the pause token. - */ + * Assign the pause token. + */ void operator=(const PauseToken &); #if __cplusplus >= 201103L void operator=(PauseToken &&); diff --git a/engines/glk/adrift/os_glk.cpp b/engines/glk/adrift/os_glk.cpp index b4b9e4c5e2e..1f94db46d62 100644 --- a/engines/glk/adrift/os_glk.cpp +++ b/engines/glk/adrift/os_glk.cpp @@ -83,12 +83,12 @@ sc_game gsc_game = nullptr; /* Special out-of-band os_confirm() options used locally with os_glk. */ static const sc_int GSC_CONF_SUBTLE_HINT = INTEGER_MAX, - GSC_CONF_UNSUBTLE_HINT = INTEGER_MAX - 1, - GSC_CONF_CONTINUE_HINTS = INTEGER_MAX - 2; + GSC_CONF_UNSUBTLE_HINT = INTEGER_MAX - 1, + GSC_CONF_CONTINUE_HINTS = INTEGER_MAX - 2; /* Forward declaration of event wait functions, and a short delay. */ static void gsc_event_wait_2(glui32 wait_type_1, - glui32 wait_type_2, event_t *event); + glui32 wait_type_2, event_t *event); static void gsc_event_wait(glui32 wait_type, event_t *event); static void gsc_short_delay(); @@ -467,7 +467,7 @@ static void glk_put_char_uni(glui32 ch) { } static void glk_request_line_event_uni(winid_t win, - glui32 *buf, glui32 maxlen, glui32 initlen) { + glui32 *buf, glui32 maxlen, glui32 initlen) { winid_t unused1; glui32 *unused2; glui32 unused3, unused4; @@ -486,7 +486,7 @@ static void glk_request_line_event_uni(winid_t win, * we also make an explicit range check against guaranteed to print chars. */ static const glui32 GSC_MIN_PRINTABLE = ' ', - GSC_MAX_PRINTABLE = '~'; + GSC_MAX_PRINTABLE = '~'; /* List of pointers to supported and available locales, nullptr terminated. */ @@ -1002,7 +1002,7 @@ static void gsc_status_redraw() { * been silenced as a result of already using a Glk command. */ static int gsc_help_requested = FALSE, - gsc_help_hints_silenced = FALSE; + gsc_help_hints_silenced = FALSE; /* Font descriptor type, encapsulating size and monospaced boolean. */ struct gsc_font_size_t { @@ -1015,14 +1015,14 @@ enum { GSC_MAX_STYLE_NESTING = 32 }; static gsc_font_size_t gsc_font_stack[GSC_MAX_STYLE_NESTING]; static glui32 gsc_font_index = 0; static glui32 gsc_attribute_bold = 0, - gsc_attribute_italic = 0, - gsc_attribute_underline = 0, - gsc_attribute_secondary_color = 0; + gsc_attribute_italic = 0, + gsc_attribute_underline = 0, + gsc_attribute_secondary_color = 0; /* Notional default font size, and limit font sizes. */ static const sc_int GSC_DEFAULT_FONT_SIZE = 12, - GSC_MEDIUM_FONT_SIZE = 14, - GSC_LARGE_FONT_SIZE = 16; + GSC_MEDIUM_FONT_SIZE = 14, + GSC_LARGE_FONT_SIZE = 16; /* Milliseconds per second and timeouts count for delay tags. */ static const glui32 GSC_MILLISECONDS_PER_SECOND = 1000; @@ -1033,7 +1033,7 @@ static const sc_int GSC_HINT_REFUSAL_LIMIT = 5; /* The keypresses used to cancel any early. */ static const glui32 GSC_CANCEL_WAIT_1 = ' ', - GSC_CANCEL_WAIT_2 = keycode_Return; + GSC_CANCEL_WAIT_2 = keycode_Return; /* @@ -3019,7 +3019,7 @@ static void gsc_main() { * we only get a call to main once. */ static int gsc_startup_called = FALSE, - gsc_main_called = FALSE; + gsc_main_called = FALSE; /* * adrift_main() diff --git a/engines/glk/adrift/scare.h b/engines/glk/adrift/scare.h index f3bdc5a5ecc..104a72fc87c 100644 --- a/engines/glk/adrift/scare.h +++ b/engines/glk/adrift/scare.h @@ -77,10 +77,10 @@ typedef void *sc_game; extern void os_print_string(const sc_char *string); extern void os_print_tag(sc_int tag, const sc_char *argument); extern void os_play_sound(const sc_char *filepath, - sc_int offset, sc_int length, sc_bool is_looping); + sc_int offset, sc_int length, sc_bool is_looping); extern void os_stop_sound(); extern void os_show_graphic(const sc_char *filepath, - sc_int offset, sc_int length); + sc_int offset, sc_int length); extern sc_bool os_read_line(sc_char *buffer, sc_int length); extern sc_bool os_confirm(sc_int type); extern void *os_open_file(sc_bool is_save); @@ -110,8 +110,8 @@ extern void sc_set_trace_flags(sc_uint trace_flags); extern sc_game sc_game_from_filename(const sc_char *filename); extern sc_game sc_game_from_stream(Common::SeekableReadStream *stream); extern sc_game sc_game_from_callback(sc_int(*callback) - (void *, sc_byte *, sc_int), - void *opaque); + (void *, sc_byte *, sc_int), + void *opaque); extern void sc_interpret_game(CONTEXT, sc_game game); extern void sc_restart_game(CONTEXT, sc_game game); extern sc_bool sc_save_game(sc_game game); @@ -121,16 +121,16 @@ extern void sc_quit_game(sc_game game); extern sc_bool sc_save_game_to_filename(sc_game game, const sc_char *filename); extern void sc_save_game_to_stream(sc_game game, Common::SeekableReadStream *stream); extern void sc_save_game_to_callback(sc_game game, - void (*callback) - (void *, const sc_byte *, sc_int), - void *opaque); + void (*callback) + (void *, const sc_byte *, sc_int), + void *opaque); extern sc_bool sc_load_game_from_filename(sc_game game, - const sc_char *filename); + const sc_char *filename); extern sc_bool sc_load_game_from_stream(sc_game game, Common::SeekableReadStream *stream); extern sc_bool sc_load_game_from_callback(sc_game game, - sc_int(*callback) - (void *, sc_byte *, sc_int), - void *opaque); + sc_int(*callback) + (void *, sc_byte *, sc_int), + void *opaque); extern void sc_free_game(sc_game game); extern sc_bool sc_is_game_running(sc_game game); extern const sc_char *sc_get_game_name(sc_game game); @@ -158,16 +158,16 @@ typedef void *sc_game_hint; extern sc_game_hint sc_get_first_game_hint(sc_game game); extern sc_game_hint sc_get_next_game_hint(sc_game game, sc_game_hint hint); extern const sc_char *sc_get_game_hint_question(sc_game game, - sc_game_hint hint); + sc_game_hint hint); extern const sc_char *sc_get_game_subtle_hint(sc_game game, - sc_game_hint hint); + sc_game_hint hint); extern const sc_char *sc_get_game_unsubtle_hint(sc_game game, - sc_game_hint hint); + sc_game_hint hint); extern void sc_set_game_debugger_enabled(sc_game game, sc_bool flag); extern sc_bool sc_get_game_debugger_enabled(sc_game game); extern sc_bool sc_run_game_debugger_command(sc_game game, - const sc_char *debug_command); + const sc_char *debug_command); extern void sc_set_portable_random(sc_bool flag); extern void sc_reseed_random_sequence(sc_uint new_seed); diff --git a/engines/glk/adrift/scgamest.cpp b/engines/glk/adrift/scgamest.cpp index 9ecc8806cf1..bc8d24ea1e5 100644 --- a/engines/glk/adrift/scgamest.cpp +++ b/engines/glk/adrift/scgamest.cpp @@ -449,7 +449,7 @@ sc_int gs_npc_walkstep_count(sc_gameref_t gs, sc_int npc) { } void gs_set_npc_walkstep(sc_gameref_t gs, - sc_int npc, sc_int walk, sc_int walkstep) { + sc_int npc, sc_int walk, sc_int walkstep) { assert(gs_is_game_valid(gs) && gs_in_range(npc, gs->npc_count) && gs_in_range(walk, gs->npcs[npc].walkstep_count)); gs->npcs[npc].walksteps[walk] = walkstep; diff --git a/engines/glk/adrift/scinterf.cpp b/engines/glk/adrift/scinterf.cpp index d6d63365dca..9ad3e09db1e 100644 --- a/engines/glk/adrift/scinterf.cpp +++ b/engines/glk/adrift/scinterf.cpp @@ -265,7 +265,7 @@ void if_update_sound(const sc_char *filename, sc_int sound_offset, sc_int sound_ } void if_update_graphic(const sc_char *filename, - sc_int graphic_offset, sc_int graphic_length) { + sc_int graphic_offset, sc_int graphic_length) { os_show_graphic(filename, graphic_offset, graphic_length); } diff --git a/engines/glk/adrift/sclibrar.cpp b/engines/glk/adrift/sclibrar.cpp index e3c13eae3af..3e18b122d84 100644 --- a/engines/glk/adrift/sclibrar.cpp +++ b/engines/glk/adrift/sclibrar.cpp @@ -7245,7 +7245,7 @@ static sc_bool lib_put_on_filter(sc_gameref_t game, sc_int object, sc_int unused static sc_bool lib_put_on_not_supporter_filter(sc_gameref_t game, - sc_int object, sc_int supporter) { + sc_int object, sc_int supporter) { return lib_put_on_filter(game, object, -1) && object != supporter; } @@ -9339,7 +9339,7 @@ sc_bool lib_cmd_wash_other(sc_gameref_t game) { * uninteresting responses. */ static sc_bool lib_dont_think_common(sc_gameref_t game, - const sc_char *verb, sc_bool is_object) { + const sc_char *verb, sc_bool is_object) { const sc_filterref_t filter = gs_get_filter(game); sc_int object; sc_bool is_ambiguous; diff --git a/engines/glk/adrift/scprintf.cpp b/engines/glk/adrift/scprintf.cpp index 73c14d2e4a4..fcbbc58767a 100644 --- a/engines/glk/adrift/scprintf.cpp +++ b/engines/glk/adrift/scprintf.cpp @@ -46,8 +46,8 @@ static const sc_char LESSTHAN = '<'; static const sc_char GREATERTHAN = '>'; static const sc_char PERCENT = '%'; static const sc_char *const ENTITY_LESSTHAN = "<", - *const ENTITY_GREATERTHAN = ">", - *const ENTITY_PERCENT = "+percent+"; + *const ENTITY_GREATERTHAN = ">", + *const ENTITY_PERCENT = "+percent+"; enum { ENTITY_LENGTH = 4, PERCENT_LENGTH = 9 diff --git a/engines/glk/adrift/scprotos.h b/engines/glk/adrift/scprotos.h index 0a742b921f6..bf9cc78c872 100644 --- a/engines/glk/adrift/scprotos.h +++ b/engines/glk/adrift/scprotos.h @@ -91,7 +91,7 @@ extern sc_bool sc_strempty(const sc_char *string); extern sc_char *sc_trim_string(sc_char *string); extern sc_char *sc_normalize_string(sc_char *string); extern sc_bool sc_compare_word(const sc_char *string, - const sc_char *Word, sc_int length); + const sc_char *Word, sc_int length); extern sc_uint sc_hash(const sc_char *string); /* TAF file reader/decompressor enumerations, opaque typedef and functions. */ @@ -108,7 +108,7 @@ typedef struct sc_taf_s *sc_tafref_t; extern void taf_destroy(sc_tafref_t taf); extern sc_tafref_t taf_create(sc_read_callbackref_t callback, void *opaque); extern sc_tafref_t taf_create_tas(sc_read_callbackref_t callback, - void *opaque); + void *opaque); extern void taf_first_line(sc_tafref_t taf); extern const sc_char *taf_next_line(sc_tafref_t taf); extern sc_bool taf_more_lines(sc_tafref_t taf); @@ -132,24 +132,24 @@ typedef struct sc_prop_set_s *sc_prop_setref_t; extern sc_prop_setref_t prop_create(const sc_tafref_t taf); extern void prop_destroy(sc_prop_setref_t bundle); extern void prop_put(sc_prop_setref_t bundle, - const sc_char *format, sc_vartype_t vt_value, - const sc_vartype_t vt_key[]); + const sc_char *format, sc_vartype_t vt_value, + const sc_vartype_t vt_key[]); extern sc_bool prop_get(sc_prop_setref_t bundle, - const sc_char *format, sc_vartype_t *vt_value, - const sc_vartype_t vt_key[]); + const sc_char *format, sc_vartype_t *vt_value, + const sc_vartype_t vt_key[]); extern void prop_solidify(sc_prop_setref_t bundle); extern sc_int prop_get_integer(sc_prop_setref_t bundle, - const sc_char *format, - const sc_vartype_t vt_key[]); + const sc_char *format, + const sc_vartype_t vt_key[]); extern sc_bool prop_get_boolean(sc_prop_setref_t bundle, - const sc_char *format, - const sc_vartype_t vt_key[]); + const sc_char *format, + const sc_vartype_t vt_key[]); extern const sc_char *prop_get_string(sc_prop_setref_t bundle, - const sc_char *format, - const sc_vartype_t vt_key[]); + const sc_char *format, + const sc_vartype_t vt_key[]); extern sc_int prop_get_child_count(sc_prop_setref_t bundle, - const sc_char *format, - const sc_vartype_t vt_key[]); + const sc_char *format, + const sc_vartype_t vt_key[]); extern void prop_adopt(sc_prop_setref_t bundle, void *addr); extern void prop_debug_trace(sc_bool flag); extern void prop_debug_dump(sc_prop_setref_t bundle); @@ -184,17 +184,17 @@ enum { typedef struct sc_var_set_s *sc_var_setref_t; extern void var_put(sc_var_setref_t vars, - const sc_char *name, sc_int _type, sc_vartype_t vt_value); + const sc_char *name, sc_int _type, sc_vartype_t vt_value); extern sc_bool var_get(sc_var_setref_t vars, - const sc_char *name, sc_int *_type, - sc_vartype_t *vt_rvalue); + const sc_char *name, sc_int *_type, + sc_vartype_t *vt_rvalue); extern void var_put_integer(sc_var_setref_t vars, - const sc_char *name, sc_int value); + const sc_char *name, sc_int value); extern sc_int var_get_integer(sc_var_setref_t vars, const sc_char *name); extern void var_put_string(sc_var_setref_t vars, - const sc_char *name, const sc_char *string); + const sc_char *name, const sc_char *string); extern const sc_char *var_get_string(sc_var_setref_t vars, - const sc_char *name); + const sc_char *name); extern sc_var_setref_t var_create(sc_prop_setref_t bundle); extern void var_destroy(sc_var_setref_t vars); extern void var_register_game(sc_var_setref_t vars, sc_gameref_t game); @@ -213,22 +213,22 @@ extern void var_debug_dump(sc_var_setref_t vars); /* Expression evaluation functions. */ extern sc_bool expr_eval_numeric_expression(const sc_char *expression, - sc_var_setref_t vars, - sc_int *rvalue); + sc_var_setref_t vars, + sc_int *rvalue); extern sc_bool expr_eval_string_expression(const sc_char *expression, - sc_var_setref_t vars, - sc_char **rvalue); + sc_var_setref_t vars, + sc_char **rvalue); /* Print filtering opaque typedef and functions. */ typedef struct sc_filter_s *sc_filterref_t; extern sc_filterref_t pf_create(void); extern void pf_destroy(sc_filterref_t filter); extern void pf_buffer_string(sc_filterref_t filter, - const sc_char *string); + const sc_char *string); extern void pf_buffer_character(sc_filterref_t filter, - sc_char character); + sc_char character); extern void pf_prepend_string(sc_filterref_t filter, - const sc_char *string); + const sc_char *string); extern void pf_new_sentence(sc_filterref_t filter); extern void pf_mute(sc_filterref_t filter); extern void pf_clear_mute(sc_filterref_t filter); @@ -236,19 +236,19 @@ extern void pf_buffer_tag(sc_filterref_t filter, sc_int tag); extern void pf_strip_tags(sc_char *string); extern void pf_strip_tags_for_hints(sc_char *string); extern sc_char *pf_filter(const sc_char *string, - sc_var_setref_t vars, sc_prop_setref_t bundle); + sc_var_setref_t vars, sc_prop_setref_t bundle); extern sc_char *pf_filter_for_info(const sc_char *string, - sc_var_setref_t vars); + sc_var_setref_t vars); extern void pf_flush(sc_filterref_t filter, - sc_var_setref_t vars, sc_prop_setref_t bundle); + sc_var_setref_t vars, sc_prop_setref_t bundle); extern void pf_checkpoint(sc_filterref_t filter, - sc_var_setref_t vars, sc_prop_setref_t bundle); + sc_var_setref_t vars, sc_prop_setref_t bundle); extern const sc_char *pf_get_buffer(sc_filterref_t filter); extern sc_char *pf_transfer_buffer(sc_filterref_t filter); extern void pf_empty(sc_filterref_t filter); extern sc_char *pf_escape(const sc_char *string); extern sc_char *pf_filter_input(const sc_char *string, - sc_prop_setref_t bundle); + sc_prop_setref_t bundle); extern void pf_debug_trace(sc_bool flag); /* Game memo opaque typedef and functions. */ @@ -260,22 +260,22 @@ extern sc_bool memo_load_game(sc_memo_setref_t memento, sc_gameref_t game); extern sc_bool memo_is_load_available(sc_memo_setref_t memento); extern void memo_clear_games(sc_memo_setref_t memento); extern void memo_save_command(sc_memo_setref_t memento, - const sc_char *command, sc_int timestamp, - sc_int turns); + const sc_char *command, sc_int timestamp, + sc_int turns); extern void memo_unsave_command(sc_memo_setref_t memento); extern sc_int memo_get_command_count(sc_memo_setref_t memento); extern void memo_first_command(sc_memo_setref_t memento); extern void memo_next_command(sc_memo_setref_t memento, - const sc_char **command, sc_int *sequence, - sc_int *timestamp, sc_int *turns); + const sc_char **command, sc_int *sequence, + sc_int *timestamp, sc_int *turns); extern sc_bool memo_more_commands(sc_memo_setref_t memento); extern const sc_char *memo_find_command(sc_memo_setref_t memento, - sc_int sequence); + sc_int sequence); extern void memo_clear_commands(sc_memo_setref_t memento); /* Game state functions. */ extern sc_gameref_t gs_create(sc_var_setref_t vars, sc_prop_setref_t bundle, - sc_filterref_t filter); + sc_filterref_t filter); extern sc_bool gs_is_game_valid(sc_gameref_t game); extern void gs_copy(sc_gameref_t to, sc_gameref_t from); extern void gs_destroy(sc_gameref_t game); @@ -309,13 +309,13 @@ extern sc_bool gs_task_done(sc_gameref_t gs, sc_int task); extern sc_bool gs_task_scored(sc_gameref_t gs, sc_int task); extern sc_int gs_object_count(sc_gameref_t gs); extern void gs_set_object_openness(sc_gameref_t gs, - sc_int object, sc_int openness); + sc_int object, sc_int openness); extern void gs_set_object_state(sc_gameref_t gs, sc_int object, sc_int state); extern void gs_set_object_seen(sc_gameref_t gs, sc_int object, sc_bool seen); extern void gs_set_object_unmoved(sc_gameref_t gs, - sc_int object, sc_bool unmoved); + sc_int object, sc_bool unmoved); extern void gs_set_object_static_unmoved(sc_gameref_t gs, - sc_int _object, sc_bool unmoved); + sc_int _object, sc_bool unmoved); extern sc_int gs_object_openness(sc_gameref_t gs, sc_int object); extern sc_int gs_object_state(sc_gameref_t gs, sc_int _object); extern sc_bool gs_object_seen(sc_gameref_t gs, sc_int _object); @@ -342,10 +342,10 @@ extern void gs_set_npc_seen(sc_gameref_t gs, sc_int npc, sc_bool seen); extern sc_bool gs_npc_seen(sc_gameref_t gs, sc_int npc); extern sc_int gs_npc_walkstep_count(sc_gameref_t gs, sc_int npc); extern void gs_set_npc_walkstep(sc_gameref_t gs, sc_int npc, - sc_int walk, sc_int walkstep); + sc_int walk, sc_int walkstep); extern sc_int gs_npc_walkstep(sc_gameref_t gs, sc_int npc, sc_int walk); extern void gs_decrement_npc_walkstep(sc_gameref_t gs, - sc_int npc, sc_int walkstep); + sc_int npc, sc_int walkstep); extern void gs_clear_npc_references(sc_gameref_t gs); extern void gs_clear_object_references(sc_gameref_t gs); extern void gs_set_multiple_references(sc_gameref_t gs); @@ -353,7 +353,7 @@ extern void gs_clear_multiple_references(sc_gameref_t gs); /* Pattern matching functions. */ extern sc_bool uip_match(const sc_char *pattern, - const sc_char *string, sc_gameref_t game); + const sc_char *string, sc_gameref_t game); extern sc_char *uip_replace_pronouns(sc_gameref_t game, const sc_char *string); extern void uip_assign_pronouns(sc_gameref_t game, const sc_char *string); extern void uip_debug_trace(sc_bool flag); @@ -615,10 +615,10 @@ extern sc_bool res_has_sound(sc_gameref_t game); extern sc_bool res_has_graphics(sc_gameref_t game); extern void res_clear_resource(sc_resourceref_t resource); extern sc_bool res_compare_resource(sc_resourceref_t from, - sc_resourceref_t with); + sc_resourceref_t with); extern void res_handle_resource(sc_gameref_t game, - const sc_char *partial_format, - const sc_vartype_t vt_partial[]); + const sc_char *partial_format, + const sc_vartype_t vt_partial[]); extern void res_sync_resources(sc_gameref_t game); extern void res_cancel_resources(sc_gameref_t game); @@ -638,26 +638,26 @@ extern sc_bool run_is_running(sc_gameref_t game); extern sc_bool run_has_completed(sc_gameref_t game); extern sc_bool run_is_undo_available(sc_gameref_t game); extern void run_get_attributes(sc_gameref_t game, - const sc_char **game_name, - const sc_char **game_author, - const sc_char **game_compile_date, - sc_int *turns, sc_int *score, - sc_int *max_score, - const sc_char **current_room_name, - const sc_char **status_line, - const sc_char **preferred_font, - sc_bool *bold_room_names, sc_bool *verbose, - sc_bool *notify_score_change); + const sc_char **game_name, + const sc_char **game_author, + const sc_char **game_compile_date, + sc_int *turns, sc_int *score, + sc_int *max_score, + const sc_char **current_room_name, + const sc_char **status_line, + const sc_char **preferred_font, + sc_bool *bold_room_names, sc_bool *verbose, + sc_bool *notify_score_change); extern void run_set_attributes(sc_gameref_t game, - sc_bool bold_room_names, sc_bool verbose, - sc_bool notify_score_change); + sc_bool bold_room_names, sc_bool verbose, + sc_bool notify_score_change); extern sc_hintref_t run_hint_iterate(sc_gameref_t game, sc_hintref_t hint); extern const sc_char *run_get_hint_question(sc_gameref_t game, - sc_hintref_t hint); + sc_hintref_t hint); extern const sc_char *run_get_subtle_hint(sc_gameref_t game, - sc_hintref_t hint); + sc_hintref_t hint); extern const sc_char *run_get_unsubtle_hint(sc_gameref_t game, - sc_hintref_t hint); + sc_hintref_t hint); /* Event functions. */ extern sc_bool evt_can_see_event(sc_gameref_t game, sc_int event); @@ -670,17 +670,17 @@ extern const sc_char *task_get_hint_question(sc_gameref_t game, sc_int task); extern const sc_char *task_get_hint_subtle(sc_gameref_t game, sc_int task); extern const sc_char *task_get_hint_unsubtle(sc_gameref_t game, sc_int task); extern sc_bool task_can_run_task_directional(sc_gameref_t game, - sc_int task, sc_bool forwards); + sc_int task, sc_bool forwards); extern sc_bool task_can_run_task(sc_gameref_t game, sc_int task); extern sc_bool task_run_task(sc_gameref_t game, sc_int task, sc_bool forwards); extern void task_debug_trace(sc_bool flag); /* Task restriction functions. */ extern sc_bool restr_pass_task_object_state(sc_gameref_t game, - sc_int var1, sc_int var2); + sc_int var1, sc_int var2); extern sc_bool restr_eval_task_restrictions(sc_gameref_t game, - sc_int task, sc_bool *pass, - const sc_char **fail_message); + sc_int task, sc_bool *pass, + const sc_char **fail_message); extern void restr_debug_trace(sc_bool flag); /* NPC gender enumeration and functions. */ @@ -712,10 +712,10 @@ extern sc_bool obj_is_surface(sc_gameref_t game, sc_int object); extern sc_int obj_container_object(sc_gameref_t game, sc_int n); extern sc_int obj_surface_object(sc_gameref_t game, sc_int n); extern sc_bool obj_indirectly_in_room(sc_gameref_t game, - sc_int _object, sc_int Room); + sc_int _object, sc_int Room); extern sc_bool obj_indirectly_held_by_player(sc_gameref_t game, sc_int object); extern sc_bool obj_directly_in_room(sc_gameref_t game, - sc_int _object, sc_int Room); + sc_int _object, sc_int Room); extern sc_int obj_stateful_object(sc_gameref_t game, sc_int n); extern sc_int obj_dynamic_object(sc_gameref_t game, sc_int n); extern sc_int obj_wearable_object(sc_gameref_t game, sc_int n); @@ -751,7 +751,7 @@ extern void loc_debug_dump(void); /* Debugger interface. */ typedef struct sc_debugger_s *sc_debuggerref_t; extern sc_bool debug_run_command(sc_gameref_t game, - const sc_char *debug_command); + const sc_char *debug_command); extern sc_bool debug_cmd_debugger(sc_gameref_t game); extern void debug_set_enabled(sc_gameref_t game, sc_bool enable); extern sc_bool debug_get_enabled(sc_gameref_t game); diff --git a/engines/glk/adrift/scresour.cpp b/engines/glk/adrift/scresour.cpp index c09a5c82abf..4406f432ad4 100644 --- a/engines/glk/adrift/scresour.cpp +++ b/engines/glk/adrift/scresour.cpp @@ -70,7 +70,7 @@ sc_bool res_has_graphics(sc_gameref_t game) { * Convenience functions to set, clear, and compare resource fields. */ static void res_set_resource(sc_resourceref_t resource, const sc_char *name, - sc_int offset, sc_int length) { + sc_int offset, sc_int length) { resource->name = name; resource->offset = offset; resource->length = length; diff --git a/engines/glk/adrift/sctaffil.cpp b/engines/glk/adrift/sctaffil.cpp index eea22445e9b..2365c1a093e 100644 --- a/engines/glk/adrift/sctaffil.cpp +++ b/engines/glk/adrift/sctaffil.cpp @@ -83,9 +83,9 @@ typedef sc_taf_s sc_taf_t; /* Microsoft Visual Basic PRNG magic numbers, initial and current state. */ static const sc_int PRNG_CST1 = 0x43fd43fd, - PRNG_CST2 = 0x00c39ec3, - PRNG_CST3 = 0x00ffffff, - PRNG_INITIAL_STATE = 0x00a09e86; + PRNG_CST2 = 0x00c39ec3, + PRNG_CST3 = 0x00ffffff, + PRNG_INITIAL_STATE = 0x00a09e86; static sc_int taf_random_state = 0x00a09e86; /* diff --git a/engines/glk/adrift/sxprotos.h b/engines/glk/adrift/sxprotos.h index 5ea39517750..8256203ebb2 100644 --- a/engines/glk/adrift/sxprotos.h +++ b/engines/glk/adrift/sxprotos.h @@ -68,13 +68,13 @@ extern void *sx_malloc(size_t size); extern void *sx_realloc(void *pointer, size_t size); extern void sx_free(void *pointer); extern Common::SeekableReadStream *sx_fopen(const sc_char *name, - const sc_char *extension, const sc_char *mode); + const sc_char *extension, const sc_char *mode); extern sc_char *sx_trim_string(sc_char *string); extern sc_char *sx_normalize_string(sc_char *string); /* Test controller function. */ extern sc_int test_run_game_tests(const sx_test_descriptor_t tests[], - sc_int count, sc_bool is_verbose); + sc_int count, sc_bool is_verbose); /* Globbing function. */ extern sc_bool glob_match(const sc_char *pattern, const sc_char *string); @@ -86,9 +86,9 @@ extern sc_bool glob_match(const sc_char *pattern, const sc_char *string); /* Serialization helper for script running and checking. */ extern void *file_open_file_callback(sc_bool is_save); extern sc_int file_read_file_callback(void *opaque, - sc_byte *buffer, sc_int length); + sc_byte *buffer, sc_int length); extern void file_write_file_callback(void *opaque, - const sc_byte *buffer, sc_int length); + const sc_byte *buffer, sc_int length); extern void file_close_file_callback(void *opaque); extern void file_cleanup(void); diff --git a/engines/glk/adrift/sxstubs.cpp b/engines/glk/adrift/sxstubs.cpp index 32d1fddd4e8..c1432e71c42 100644 --- a/engines/glk/adrift/sxstubs.cpp +++ b/engines/glk/adrift/sxstubs.cpp @@ -61,11 +61,11 @@ static sc_int stub_show_tags = 0; */ void stub_attach_handlers(sc_bool(*read_line)(sc_char *, sc_int), - void (*print_string)(const sc_char *), - void *(*open_file)(sc_bool), - sc_int(*read_file)(void *, sc_byte *, sc_int), - void (*write_file)(void *, const sc_byte *, sc_int), - void (*close_file)(void *)) { + void (*print_string)(const sc_char *), + void *(*open_file)(sc_bool), + sc_int(*read_file)(void *, sc_byte *, sc_int), + void (*write_file)(void *, const sc_byte *, sc_int), + void (*close_file)(void *)) { stub_read_line = read_line; stub_print_string = print_string; stub_open_file = open_file; @@ -183,7 +183,7 @@ os_print_string_debug(const sc_char *string) { void os_play_sound(const sc_char *filepath, - sc_int offset, sc_int length, sc_bool is_looping) { + sc_int offset, sc_int length, sc_bool is_looping) { if (stub_trace) sx_trace("os_play_sound (\"%s\", %ld, %ld, %s)\n", stub_notnull(filepath), offset, length, diff --git a/engines/glk/agt/agil.cpp b/engines/glk/agt/agil.cpp index 23bc2fb6527..981a017e09f 100644 --- a/engines/glk/agt/agil.cpp +++ b/engines/glk/agt/agil.cpp @@ -38,7 +38,7 @@ descr_ptr *err_ptr; /* [NUM_ERR];*/ descr_ptr *msg_ptr; /* [MAX_MSG];*/ descr_ptr *help_ptr, *room_ptr, *special_ptr; /*[ROOM] */ descr_ptr *noun_ptr, *text_ptr, *turn_ptr, /* [NOUN] */ - *push_ptr, *pull_ptr, *play_ptr; + *push_ptr, *pull_ptr, *play_ptr; descr_ptr *talk_ptr, *ask_ptr, *creat_ptr; /* [CREAT] */ descr_ptr *quest_ptr, *ans_ptr; /* [MAX_QUEST] */ @@ -54,12 +54,12 @@ long dp; /* Dictionary pointer: number of words in dict */ #define DICT_INIT 12*1024 /* Starting size of dictstr */ #define DICT_GRAN 1024 /* Granularity of dictstr size requests - must be at least 4. */ + must be at least 4. */ char *dictstr; /* Pointer to memory block containing dict words */ long dictstrptr, dictstrsize; /* dictstrptr points to the first unused byte in dictstr. dictstrsize points to the end of the space currently allocated for - dictstr. + dictstr. */ char *static_str; /*Static string space */ @@ -297,7 +297,7 @@ static void build_verbmenu(void) { void agil_option(int optnum, char *optstr[], rbool setflag, rbool lastpass) { if (opt("ibm_char")) fix_ascii_flag = !setflag; else if (!lastpass) return; /* On the first pass through the game specific - file, we ignore all but the above options */ + file, we ignore all but the above options */ else if (opt("tone")) PURE_TONE = setflag; else if (opt("input_bold")) PURE_INPUT = setflag; else if (opt("force_load")) FORCE_VERSION = setflag; @@ -329,7 +329,7 @@ static rbool check_dot(char *prevtext, int prevcnt, char *lookahead) int i, endword, restcnt; if (!PURE_DOT) return 1; /* No words with periods in them, so it must - be punctuation. */ + be punctuation. */ /* We just start scanning the dictionary to see if any of them are possible matches, looking ahead as neccessary. */ @@ -355,7 +355,7 @@ static rbool check_dot(char *prevtext, int prevcnt, char *lookahead) the fact that the trailing text could itself contain ambiguous '.'s */ restcnt -= prevcnt + 1; /* Number of characters in dict entry after '.' */ if (restcnt > endword) continue; /* Dictionary entry is longer than - following text */ + following text */ /* Check to see if the dictionary entry can be found in the lookahead buffer */ @@ -520,7 +520,7 @@ static void parse_loop(void) if (doing_restore) break; if (ip >= 0 && ip < MAXINPUT && input[ip] != -1) writeln(""); /* Insert blank lines between commands when dealing - with THEN lists */ + with THEN lists */ } } @@ -630,7 +630,7 @@ static int init(void) { pictable = (integer *)rmalloc(sizeof(int) * maxpict); for (i = 0; i < maxpict; i++) pictable[i] = i; init_state_sys(); /* Initialize the system for saving and restoring - game states */ + game states */ tmp1 = (uchar *)rmalloc(MEM_MARGIN); /* Preserve some work space */ tmp2 = getstate(NULL); /* Make sure we have space to save */ @@ -693,7 +693,7 @@ static void fix_dummy(void) { for (i = 0; i < dp && !PURE_DOT; i++) if (strchr(dict[i], '.') != NULL && /* i.e. dict[i] contains period */ i != ext_code[wp]) /* The period itself _is_ a dictionary word: - avoid this false match */ + avoid this false match */ PURE_DOT = 1; } } @@ -714,7 +714,7 @@ static void fix_prompt(void) { void close_game(void); /* Called by setup_game, and so needs - to be defined here. */ + to be defined here. */ static fc_type setup_game(fc_type fc) /* game_name is the common filename of the AGT game files */ @@ -766,7 +766,7 @@ static fc_type setup_game(fc_type fc) #endif if (have_opt) menu_mode = opt_data[5]; /* See agtread.c for discussion of OPT file - format */ + format */ text_file = 1; read_config(openfile(fc, fCFG, NULL, 0), 1); /*Game specific config file*/ text_file = 0; @@ -780,7 +780,7 @@ static fc_type setup_game(fc_type fc) ext_dict(); build_verbmenu(); fix_dummy(); /* Prevent player from calling dummy verbs or subroutines by - typing 'Subroutine n' on the command line */ + typing 'Subroutine n' on the command line */ can_save = init(); if (!agx_file) open_descr(fc); fix_prompt(); /* Kill off 'What Now?' prompt. */ @@ -872,7 +872,7 @@ void run_game(fc_type fc) { rm_trap = 1; rm_size = ralloc_cnt = rfree_cnt = 0; read_config(agt_globalfile(0), 1); /* Global configuration file: - get PATH information*/ + get PATH information*/ fix_file_context(fc, fDA1); do { if (doing_restore == 3) { diff --git a/engines/glk/agt/agility.h b/engines/glk/agt/agility.h index b92243086e8..89d562882c2 100644 --- a/engines/glk/agt/agility.h +++ b/engines/glk/agt/agility.h @@ -31,19 +31,19 @@ namespace AGT { /* This indicates the AGiliTy version code for the current version. */ /* 0=0.8.7 and the numbers are assigned sequentially from there. - 1=0.8.8 - 2=1.0 - (pre-0.8.7 versions of AGiliTy don't have version codes) */ + 1=0.8.8 + 2=1.0 + (pre-0.8.7 versions of AGiliTy don't have version codes) */ /* Don't touch this unless you know exactly what you're doing. */ #define AGIL_VERID 3 /* - This is the master header file for all of the AGT stuff. - It includes the global variables, the data types, etc. - (everything that is read in from the game file). - Variables not read in from the game file but used internally - by the AGiliTy interpreter are declared in interp.h. - Magx specific things are in comp.h. + This is the master header file for all of the AGT stuff. + It includes the global variables, the data types, etc. + (everything that is read in from the game file). + Variables not read in from the game file but used internally + by the AGiliTy interpreter are declared in interp.h. + Magx specific things are in comp.h. */ /* ------------------------------------------------------------------- */ @@ -83,22 +83,22 @@ typedef char tline[81]; /* Both of these must include terminating null */ typedef char words[WORD_LENG]; /* ...23 in classic, 16 in master's */ typedef short word; /* A pointer into the dictionary */ typedef short slist; /* Index into synlist marking beginning of this - synonym list. [SYNCNT] - list of word pointers -- eg synonyms */ + synonym list. [SYNCNT] + list of word pointers -- eg synonyms */ typedef char *descr_line; /* This is the type used to return descriptions. - They are actually returned as an array of - pointers to char, one for each line. - It is NULL terminated. */ + They are actually returned as an array of + pointers to char, one for each line. + It is NULL terminated. */ typedef char *filename; /* Datatype used for picture, sound, etc. names*/ typedef enum {fNONE, - fDA1, fDA2, fDA3, fDA4, fDA5, fDA6, fDSS, - fHNT, fOPT, fTTL, - fSAV, fSCR, fLOG, - fAGX, fINS, fVOC, fCFG, - fAGT, fDAT, fMSG, fCMD, fSTD, fAGT_STD - } filetype; + fDA1, fDA2, fDA3, fDA4, fDA5, fDA6, fDSS, + fHNT, fOPT, fTTL, + fSAV, fSCR, fLOG, + fAGX, fINS, fVOC, fCFG, + fAGT, fDAT, fMSG, fCMD, fSTD, fAGT_STD + } filetype; /* ------------------------------------------------------------------- */ @@ -112,11 +112,11 @@ typedef enum {fNONE, #define SS_GRAIN 1024 /* Granularity of size request for static string - array (to avoid calling rrealloc too often) */ + array (to avoid calling rrealloc too often) */ #define SYN_GRAIN 32 /* Granularity of requests for synonym array; this - is in units of sizeof(word) */ + is in units of sizeof(word) */ #define MAX_BADTOK 10 /* How many bad tokens to report before giving - up */ + up */ @@ -127,7 +127,7 @@ typedef enum {fNONE, #define def_interp_arg 1 /* Decipher arguments to opcodes? */ #define def_debug_da1 0 /* used to analyse .DA1 files */ #define def_RAW_CMD_OUT 0 /*Print CMDs out raw, undecoded; sometimes useful - when trying to understand new gamefile version */ + when trying to understand new gamefile version */ #define def_ERR_LEVEL 2 /* Level of error reporting. */ /* 0== almost none */ /* 1== Report possibly serious conditions */ @@ -144,10 +144,10 @@ typedef enum {fNONE, /* ------------------------------------------------------------------- */ #define FORMAT_CODE 0xFF /* Character used for special formatting codes: - --in 1.8x games, it designates bold - --in AGX+ games, it will prefix format codes - --otherwise it designates black (replacing - 0, which has obvious problems) */ + --in 1.8x games, it designates bold + --in AGX+ games, it will prefix format codes + --otherwise it designates black (replacing + 0, which has obvious problems) */ #define LAST_TEXTCODE 8 /* Last ascii code to be used for text attributes */ @@ -158,7 +158,7 @@ typedef enum {fNONE, #define OLD_VERB 59 /* Number of built in verbs in original interpreters-- - this number includes ANY, which is verb 0. */ + this number includes ANY, which is verb 0. */ #define DIR_ADDR_CODE (OLD_VERB+17) /* Verb ID used for direct address */ #define AUX_VERB 18 /* Additional verbs supported by the interpreter */ #define BASE_VERB (OLD_VERB+AUX_VERB) /* Total number of built-in verbs */ @@ -182,7 +182,7 @@ typedef enum {fNONE, */ #define MAX_TOKEN_ID 250 /* Upper limit on legal (raw) token values - read from AGT files. Doesn't need to be exact. */ + read from AGT files. Doesn't need to be exact. */ /* Number of built in properties and attributes. */ #define NUM_PROP 14 @@ -252,7 +252,7 @@ typedef struct { integer path[13]; integer key; integer contents; /* Used internally by the interpreter; not read in - from the game file */ + from the game file */ integer points; integer light; /* Object that lights room; 0=none needed, 1=any */ integer pict, initdesc; @@ -273,7 +273,7 @@ typedef struct { slist syns; /* List of synonyms */ word name, adj; word related_name; /* Word that should appear on menu when this noun - is in scope */ + is in scope */ word pos_prep, pos_name; /* Used internally by the interpreter */ /* pos_prep==-1 means use noun.position */ integer nearby_noun; /* Noun this noun is behind */ @@ -284,7 +284,7 @@ typedef struct { integer initdesc, pict; integer location; /* 1=carried, 1000=worn */ integer contents, next; /* Used internally by the interpreter; not read in - from the game file */ + from the game file */ integer oclass; integer flagnum; /* Number of associated flag + 1. 0=no flag. */ rbool scope; /* Used internally by the interpreter */ @@ -312,7 +312,7 @@ typedef struct { word adj; integer location; integer contents, next; /* Used internally by the interpreter; not read in - from the game file */ + from the game file */ integer weapon; /* Killed by this */ integer points; integer counter; /* How many times has player been nasty to it? */ @@ -329,7 +329,7 @@ typedef struct { rbool unused; /* True if this creature entry is unused */ rbool seen; /* True if this creature has been seen by the player */ rbool proper; /* True if this creature's name is to be treated as a proper - noun (i.e. not prepended with "the") */ + noun (i.e. not prepended with "the") */ } creat_rec; /* These records are used to hold reference information for @@ -365,20 +365,20 @@ typedef struct { } flagdef_rec; /* Metacommand headers and a pointer to the actual sequence of tokens - to execute if the metacommand is run. */ + to execute if the metacommand is run. */ typedef struct { integer actor; /* Contains the actor object number; - 1==self(no explicit actor) 2=anybody - It is multiplied by negative one for redirected - commands */ + 1==self(no explicit actor) 2=anybody + It is multiplied by negative one for redirected + commands */ /* 0 in any of the following word variables denotes ANY; -1 denotes <*none*> and will only occur in Magx-generated files. (verbcmd cannot be equal to -1). Support for -1 is still experimental */ word verbcmd, nouncmd, objcmd, prep; /* prep only in ME games */ word noun_adj, obj_adj; /* Adjectives for noun and obj; not - supported in original AGT games */ + supported in original AGT games */ integer noun_obj, obj_obj; /* Actual object numbers, - or 0 if none specified */ + or 0 if none specified */ integer *data; /* MaxSizeCommand */ integer cmdsize; /* Number of commands */ /* integer ptr; */ /* In ME games-- see below for replacement */ @@ -467,20 +467,20 @@ global int ERR_LEVEL; global rbool agx_file; /* Are we reading an AGX file? */ global rbool have_opt; /* Do we have an OPT file? */ global rbool skip_descr; /* Causes read_filerec() to skip over description - pointers without actually reading them in. - Used to support RESTORE for multi-part games - such as Klaustrophobia */ + pointers without actually reading them in. + Used to support RESTORE for multi-part games + such as Klaustrophobia */ global rbool no_auxsyn; /* Prevents building of auxsyn and preplist - synonym lists; used by agt2agx. */ + synonym lists; used by agt2agx. */ global rbool BATCH_MODE, make_test; /* These indicates we are in testing mode: - -- The random number generator should be set to a standard state. - -- Automatically send output to .scr - -- Automatically read/write input from .log - (depending on whether we are in BATCH_MODE or make_test mode, - respectivly). + -- The random number generator should be set to a standard state. + -- Automatically send output to .scr + -- Automatically read/write input from .log + (depending on whether we are in BATCH_MODE or make_test mode, + respectivly). */ @@ -494,15 +494,15 @@ global rbool intro_first; global rbool box_title; global rbool mars_fix; global rbool fix_ascii_flag; /* Translate IBM characters? - Defaults to fix_ascii #define'd above */ + Defaults to fix_ascii #define'd above */ global rbool dbg_nomsg; /* Causes printing of arguments by - debug disassembler to be supressed */ + debug disassembler to be supressed */ global rbool irun_mode; /* If true, all messages will be in 1st person */ global rbool verboseflag; global int font_status; /* 0=unknown; 1=force fixed font, - 2=allow proportional font. */ + 2=allow proportional font. */ /* The following are AGT 'purity' flags; they turn off features of */ @@ -549,7 +549,7 @@ global int num_auxcomb; global int num_comb; global integer exitmsg_base; /* Number added to messages used as - "illegal direction" messages */ + "illegal direction" messages */ /* ------------------------------------------------------------------- */ @@ -602,8 +602,8 @@ global short *verbptr, *verbend; /* [TOTAL_VERB] */ global slist *synlist; /* [MAX_VERBS+1];*/ global slist *comblist; /* Global combination list */ global word *old_agt_verb; /* List of non-canonical verb synonyms in the - original AGT; these are not allowed to be - expanded as dummy verbs. */ + original AGT; these are not allowed to be + expanded as dummy verbs. */ global slist *userprep; /* Array of user-defined prepostions */ @@ -613,8 +613,8 @@ global word pix_name[MAX_PIX]; global filename *pictlist, *pixlist, *fontlist, *songlist; global uchar opt_data[14]; /* Contents of OPT file. For the format of this - block, see the comments to read_opt() in - agtread.c */ + block, see the comments to read_opt() in + agtread.c */ /* These are built by reinit_dict */ @@ -622,7 +622,7 @@ global slist *auxsyn; /* [TOTAL_VERB] Built-in synonym list */ global slist *preplist; /* [TOTAL_VERB] */ global uchar *verbflag; /* [TOTAL_VERB] Verb flags; see below */ global slist *auxcomb; /* Built-in combination lists (for multi-word - verbs) */ + verbs) */ #ifdef PATH_SEP global char **gamepath; @@ -639,7 +639,7 @@ global descr_ptr *err_ptr; /* [NUM_ERR];*/ global descr_ptr *msg_ptr; /* [MAX_MSG];*/ global descr_ptr *help_ptr, *room_ptr, *special_ptr; /*[ROOM] */ global descr_ptr *noun_ptr, *text_ptr, *turn_ptr, /* [NOUN] */ - *push_ptr, *pull_ptr, *play_ptr; + *push_ptr, *pull_ptr, *play_ptr; global descr_ptr *talk_ptr, *ask_ptr, *creat_ptr; /* [CREAT] */ global descr_ptr *quest_ptr, *ans_ptr; /* [MAX_QUEST] */ @@ -655,12 +655,12 @@ global long dp; /* Dictionary pointer: number of words in dict */ #define DICT_INIT 12*1024 /* Starting size of dictstr */ #define DICT_GRAN 1024 /* Granularity of dictstr size requests - must be at least 4. */ + must be at least 4. */ global char *dictstr; /* Pointer to memory block containing dict words */ global long dictstrptr, dictstrsize; /* dictstrptr points to the first unused byte in dictstr. dictstrsize points to the end of the space currently allocated for - dictstr. + dictstr. */ global char *static_str; /*Static string space */ @@ -707,7 +707,7 @@ global rbool open_as_binary; /* Open text files as binary, anyhow. */ #define AGT12 3 /* SOS,... */ #define AGTCOS 4 /* COSMOS and SOGGY: enhanced versions of 1.3x */ #define AGT135 5 /* By far the most common version; includes practically - every version of Classic AGT from 1.19 to 1.7 */ + every version of Classic AGT from 1.19 to 1.7 */ #define AGT182 6 #define AGT183 7 #define AGT15 8 /* HOTEL */ @@ -778,9 +778,9 @@ global rbool open_as_binary; /* Open text files as binary, anyhow. */ #define AGT_GENPROP 149 /* ObjProp/Property */ /* certain restrictions. Used internally - by the compiler in the parsing - of "[obj].[prop].[prop].[flag]" - constructions. */ + by the compiler in the parsing + of "[obj].[prop].[prop].[flag]" + constructions. */ #define AGT_LVAL 150 /* Used by the compiler in certain psuedo-ops */ @@ -824,7 +824,7 @@ global rbool open_as_binary; /* Open text files as binary, anyhow. */ #define FT_TLINE 14 /* TextLine */ #define FT_CHAR 15 /* Characters. */ #define FT_CFG 16 /* Configuration byte; 0=false, 1=true, - 2=none (don't change) */ + 2=none (don't change) */ #define DT_DEFAULT 0 /* Default internal type for */ #define DT_LONG 1 @@ -865,8 +865,8 @@ void free_dict(void); word search_dict(const char *); word add_dict(const char *); const char *gdict(word w); /* Almost equivalent to dict[w], but with - some error checking and handling for - the w==-1 case. */ + some error checking and handling for + the w==-1 case. */ int verb_code(word); int verb_builtin(word); @@ -933,8 +933,8 @@ void close_descr(void); descr_line *agt_read_descr(long start, long len); rbool readagt(fc_type fc, rbool diag); void free_all_agtread(void); /* Cleans up everything allocated in agtread - should only be called at the very end of - the program */ + should only be called at the very end of + the program */ void free_ttl(descr_line *title); @@ -963,8 +963,8 @@ void read_config(genfile cfgfile, rbool lastpass); rbool parse_config_line(char *s, rbool lastpass); descr_line *read_ttl(fc_type fc); /* This returns the title. The return string - must be freed with free_ttl() and not - with free_descr */ + must be freed with free_ttl() and not + with free_descr */ void free_ttl(descr_line *title); void read_voc(fc_type fc); @@ -976,8 +976,8 @@ descr_line *read_ins(fc_type fc); void free_ins(descr_line *instr); rbool open_ins_file(fc_type fc, rbool report_error); char *read_ins_line(void); /* Reuses buffer, so return value should be copied - if it needs to be used past the next call to - read_ins_line or close_ins_file */ + if it needs to be used past the next call to + read_ins_line or close_ins_file */ void close_ins_file(void); void build_fixchar(void); @@ -1008,7 +1008,7 @@ void agil_option(int optnum, char *optstr[], rbool setflag, rbool lastpass); void close_interface(void); void print_tos(void); /* Called by the disassembler; in either TOKEN.C - or AGTOUT.C */ + or AGTOUT.C */ /* ------------------------------------------------------------------- */ @@ -1018,14 +1018,14 @@ void print_tos(void); /* Called by the disassembler; in either TOKEN.C /* ------------------------------------------------------------------- */ global uchar trans_ascii[256]; /* Table to translate ascii values read - in from file */ + in from file */ void build_trans_ascii(void); /* Set up the above table. */ void rprintf(const char *fmt, ...); /* General output routine, mainly used - for diagnostics. There can be a newline - at the end, but there shouldn't be - one in the middle of the string */ + for diagnostics. There can be a newline + at the end, but there shouldn't be + one in the middle of the string */ @@ -1086,7 +1086,7 @@ long fixsign32(uchar n1, uchar n2, uchar n3, uchar n4); #else #define fixsign16(u1,u2) ( (u1) | ((u2)<<8) ) #define fixsign32(u1,u2,u3,u4) ( ((long)u1) | (((long)u2)<<8) | \ - (((long)u3)<<16) | (((long)u4)<<24) ) + (((long)u3)<<16) | (((long)u4)<<24) ) #endif @@ -1115,7 +1115,7 @@ char *readln(genfile f, char *buff, int n); /* (None of the following routines are at all reentrant) */ long buffopen(fc_type fc, filetype ext, - long minbuffsize, const char *rectype, long recnum); + long minbuffsize, const char *rectype, long recnum); /* Open file for our buffered routines and make it our current file; returns the record size. Prints out error message on failure rectype="noun","room",etc.; recnum=expected # of objects in file */ @@ -1132,16 +1132,16 @@ void bw_abort(void); /* Close and delete buffered file */ extern const size_t ft_leng[FT_COUNT]; /* File lengths of the data types */ long compute_recsize(file_info *recinfo); void *read_recblock(void *base, int ftype, long numrec, long offset, - long blocksize); + long blocksize); /* Only works for FT_BYTE, FT_SLIST, FT_WORD, FT_DICTTEXT, FT_INT16 */ void *read_recarray(void *base, long eltsize, long numelts, - file_info *field_info, const char *rectype, - long file_offset, long file_blocksize); + file_info *field_info, const char *rectype, + long file_offset, long file_blocksize); void read_globalrec(file_info *global_info, const char *rectype, - long file_offset, long file_blocksize); + long file_offset, long file_blocksize); long write_recarray(void *base, long eltsize, long numelts, - file_info *field_info, long file_offset); + file_info *field_info, long file_offset); long write_globalrec(file_info *global_info, long file_offset); long write_recblock(void *base, int ftype, long numrec, long offset); @@ -1182,7 +1182,7 @@ fc_type init_file_context(const char *game_name, filetype ft); name and location-- everything but the global config file.) */ /* ft indicates the file type class. At the moment, it can be fAGX, fSAV, fSCR, fLOG - */ + */ void fix_file_context(fc_type fc, filetype ft); fc_type convert_file_context(fc_type fc, filetype ft, const char *name); void release_file_context(fc_type *pfc); @@ -1194,7 +1194,7 @@ rbool fileexist(fc_type fc, filetype ft); genfile readopen(fc_type fc, filetype ft, const char **errstr); genfile writeopen(fc_type fc, filetype ft, - file_id_type *pfileid, const char **errstr); + file_id_type *pfileid, const char **errstr); rbool filevalid(genfile f, filetype ft); void readclose(genfile f); void writeclose(genfile f, file_id_type fileid); @@ -1209,7 +1209,7 @@ long binsize(genfile f); /* Size of an open binary file */ rbool textrewind(genfile f); char *assemble_filename(const char *path, const char *root, - const char *ext); + const char *ext); #ifdef global_defined_agtread diff --git a/engines/glk/agt/agtread.cpp b/engines/glk/agt/agtread.cpp index 885e2305d48..e10ca680d47 100644 --- a/engines/glk/agt/agtread.cpp +++ b/engines/glk/agt/agtread.cpp @@ -33,7 +33,7 @@ static void fixcmd(integer *, int); /* This parses the block of integers of a command to standardize the command numbers */ static short *cmd_table; /* Holds the command translation table used - by fixcmd */ + by fixcmd */ int topcmd; /* The highest legal opcode in the current AGT version. */ @@ -169,7 +169,7 @@ void open_descr(fc_type fc) { break; } if (buff[0] > 0 && buff[1] != ' ' && buff[1] > 0) /* To avoid "banner" - lines */ + lines */ { for (i = 1; i <= buff[0]; i++) { if (buff[i] >= 'A' && buff[i] <= 'z') alpha++; @@ -249,7 +249,7 @@ descr_line *agt_read_descr(long start, long len) { #define seti(a) (room[i].a=buff[bp] | (buff[bp+1]<<8),bp+=2) #define set32(a) (room[i].a=buff[bp] | (buff[bp+1]<<8) | (buff[bp+2]<<16)|\ - (buff[bp+3]<<24), bp+=4) + (buff[bp+3]<<24), bp+=4) #define setb(a) (room[i].a=buff[bp],bp++) #define setstr(leng) (bp+=(leng),new_str((char*)buff+bp-(leng),(leng),1)) @@ -510,14 +510,14 @@ static int translate_vnum(int vnum) AGT version. ii)If this command is directed at an actor, then the creature number will be in this field instead of the verb number. - Commands directed to ANYBODY have one plus the maximum verb number + Commands directed to ANYBODY have one plus the maximum verb number in this field (a hassle since the maximum verb number depends on AGT version: Classic:106, Master's:123); EVERYONE is the next code after ANYBODY. What this routine does is rationalize the differences between AGT versions. --Verb values (ie. not referring to creatures) are converted to 1. --Redirections are marked by multiplying by negative one and setting - cmdsize to 0. + cmdsize to 0. --ANYBODY is set to 2 --EVERYBODY is set to 3 */ @@ -600,9 +600,9 @@ static void read_da5(fc_type fc) { /* Now to read in DA6 for versions that have it */ if (aver >= AGT15F) read_da6(fc); check_cmd_version(); /* This uses the opcodes to check gamefile - version information and change it if neccesary. */ + version information and change it if neccesary. */ build_cmd_table(); /* Create the command translation table for - this version of AGT. */ + this version of AGT. */ badtokcnt = 0; if (!RAW_CMD_OUT) @@ -631,8 +631,8 @@ static void read_da6(fc_type fc) long ip; /* Points to instruction in cmd.data[] that we are writing to */ long bp; /* Pointer into buffer */ long endp; /* Used to indicate end of current read loop - (with an infinite buffer, this would always be an adjusted - cmdend) */ + (with an infinite buffer, this would always be an adjusted + cmdend) */ long adj_cbuf_size; /* Stores number of bytes actually read in to cbuf */ fda6 = openbin(fc, fDA6, "Could not open code file '%s'.", 1); @@ -1181,8 +1181,8 @@ noun inside information; this is used by agtout */ reinit_dict(); /* The dictionary grows dynamically so we want to - allocate it AFTER we have allocated all the permenent - things */ + allocate it AFTER we have allocated all the permenent + things */ } @@ -1197,16 +1197,16 @@ static int try_read_da1(fc_type fc, genfile fda1, rbool diag) /* Returns new aver value to try, or 0 on success. */ /* diag determines if noun inside info will be read */ /* VER values: 1=Small - 2=Large - 3=Master's Edition - 4="Soggy Large", with a larger last_room + 2=Large + 3=Master's Edition + 4="Soggy Large", with a larger last_room */ /* AVER values: see agility.h for the current values */ /* NOTE: This routine is allowed to set *ver*, but is not allowed to change *aver*; should it be neccessary to change *aver*, then the routine should return the new *aver* value. (The only exception to this is in the very beginning-- and that may get - changed) + changed) [This is done to allow the user to force a version number] */ { @@ -1342,7 +1342,7 @@ static int try_read_da1(fc_type fc, genfile fda1, rbool diag) for (i = 52; i > 42; i--) /* i:=Remove to Brief (above List Exits) */ synlist[i] = synlist[i - 1]; synlist[41] = synptr; /* LIST_EXITS, which doesn't exist in 1.83 and so - can't have synonyms */ + can't have synonyms */ addsyn(-1); } @@ -1437,7 +1437,7 @@ static int try_read_da1(fc_type fc, genfile fda1, rbool diag) for (i = 0; i < MAX_USTR; i++) readtext(fda1, userstr[i]); /* This is just a guess-- should be - tested. */ + tested. */ } else { for (i = 0; i < maxpix; i++) pix_name[i] = 0; maxpict = maxpix = maxsong = maxfont = 0; @@ -1573,7 +1573,7 @@ static rbool read_da1(fc_type fc, rbool diag) ver = 0; } if (aver == 0) aver = AGTSTD; /* i.e. if we didn't notice any differences from - standard format, it must be a standard file. */ + standard format, it must be a standard file. */ readclose(fda1); return 1; /* Success */ } @@ -1587,7 +1587,7 @@ static rbool read_da1(fc_type fc, rbool diag) static void finish_read(rbool cleanup) /* cleanup=0 means it will leave cmd_ptr, 1=it cleans up cmd_ptr */ /* The only reason to set cleanup==0 is if we are writing a diagnostic - program of some sort */ + program of some sort */ { int i; @@ -1603,7 +1603,7 @@ static void finish_read(rbool cleanup) } min_ver = 0; /* All original AGT games will run with any version of - AGiliTy. */ + AGiliTy. */ if (aver >= AGTME10) PURE_ROOMTITLE = 0; diff --git a/engines/glk/agt/agxfile.cpp b/engines/glk/agt/agxfile.cpp index 5a93a2ecf15..1a70bf91941 100644 --- a/engines/glk/agt/agxfile.cpp +++ b/engines/glk/agt/agxfile.cpp @@ -27,29 +27,29 @@ namespace AGT { /* NOTES ON CHANGING THE AGX FILE FORMAT - First of all, don't. + First of all, don't. - One of the benefits of adventure creation systems like this is + One of the benefits of adventure creation systems like this is that the same game files can be played on a variety of different platforms without any extra effort on the part of the game author. If you change the file format, this is no longer true: games created under the new format won't run on the old interpreters. - Even if you distribute a new interpreter with your game, there are two + Even if you distribute a new interpreter with your game, there are two problems: - i) People on other platforms won't be able to play your game unless - and until your modified interpreter is ported to their machine. Since - I-F players as a group tend to use a wider range of different computers - and operating systems than the population at large, this is bad. + i) People on other platforms won't be able to play your game unless + and until your modified interpreter is ported to their machine. Since + I-F players as a group tend to use a wider range of different computers + and operating systems than the population at large, this is bad. - ii) Even for machines that you port your modified interpreter to, - people will now need to maintain two interpreters: the original one - (for most of the games) and your modified one (for your new game). - This is not only a nuisance but it wastes disk space. + ii) Even for machines that you port your modified interpreter to, + people will now need to maintain two interpreters: the original one + (for most of the games) and your modified one (for your new game). + This is not only a nuisance but it wastes disk space. - If you *do* decide to change the file format anyhow, please adhere to + If you *do* decide to change the file format anyhow, please adhere to the following guidelines, to minimize confusion. GUIDLINES FOR NEW FILE FORMAT VERSIONS @@ -118,11 +118,11 @@ records and it can define new blocks. id and number, but keep the version the same): --Adding a new field onto the end of the creature record, containing - the code for a sound file that should be played whenever - the creature is in the room. + the code for a sound file that should be played whenever + the creature is in the room. --Adding a new block to the file containing debugging information for - the new AGT compiler you've just written, numbered 35. + the new AGT compiler you've just written, numbered 35. Things that would *not* be extensions (create a new version id and @@ -179,30 +179,30 @@ error message. /* Changes is AGX File format versions: 0-0: Original format. 0-1: Add - PURE_TIME, PURE_OBJ_DESC, exitmsg_base - noun.related_name - command.noun_adj, command.obj_adj + PURE_TIME, PURE_OBJ_DESC, exitmsg_base + noun.related_name + command.noun_adj, command.obj_adj 1-0: Change index file format, fixing a bug 1-1: Add - Multi-word verb block(28) - Preposition block(29) - (room|noun|creature).oclass + Multi-word verb block(28) + Preposition block(29) + (room|noun|creature).oclass 1-2: Add (room|noun|creature).unused 1-3: Add PURE_GRAMMAR 1-4: Add (noun|creature).isglobal and (noun|creature).flagnum - Add TWO_CYCLE + Add TWO_CYCLE 1-5: Add min_ver - Add PURE_AFTER + Add PURE_AFTER 1-6: Add (noun|creature).seen 1-7: Add objflag and objprop blocks (with corrosponding - support data in the gameinfo block). + support data in the gameinfo block). 2-0: No change in file format; version upped to protect against - a bug in early versions of the AGX file code. + a bug in early versions of the AGX file code. 2-1: Added (noun|creature).proper 2-2: Added noun_obj and obj_obj to cmd header - Added objflag.ystr, objflag.nstr, objprop.str_cnt, objprop.str_list - Added propstr block. - Added fallback_ext to file header. + Added objflag.ystr, objflag.nstr, objprop.str_cnt, objprop.str_list + Added propstr block. + Added fallback_ext to file header. */ #define AGX_NUMBLOCK 37 @@ -231,21 +231,21 @@ Mandatory blocks are marked with astericks. byte Extension 0 char[2]: '\n\r' -- to catch download errors byte Extension fallback. For non-'R' extensions, this gives the - 'R' extension to fall back to. + 'R' extension to fall back to. char[5] Reserved for future use (should be 0 right now) *0-File index: For each block (including itself): [16 bytes] - uint32 starting offset - uint32 block size - uint32 number of records - uint32 size of a record (recsize*numrec == blocksize) + uint32 starting offset + uint32 block size + uint32 number of records + uint32 size of a record (recsize*numrec == blocksize) 11-Description strings (block of tline) 12-Command text (block of int16) *1-Game header uint16 AGT_version_code; +1 for "big/soggy" games uint32 game_sig (game signature, used to check save files and debug info) rbool debug_mode, freeze_mode, milltime_mode, bold_mode, - have_meta, mars_fix, intro_first, TWO_CYCLE; + have_meta, mars_fix, intro_first, TWO_CYCLE; uchar score_mode, statusmode; uint16 max_lives uint32 max_score; @@ -276,7 +276,7 @@ Mandatory blocks are marked with astericks. 4-Creature data (creat_rec format) include creature, talk, ask ptrs 5-Command headers (cmd_rec format), pointers into command text - must be in increasing order. + must be in increasing order. 6-Standard error message ptrs (array of descptr 7-Message ptrs (array of descptr) 8-Question pointers (array of descptr) @@ -310,23 +310,23 @@ Mandatory blocks are marked with astericks. */ /* AGT Version IDs; +1 for LARGE/SOGGY - 00000=v1.0 - 01800=v1.18 - 01900=v1.19 - 02000=v1.20 ("Early Classic") - 03200=v1.32/COS - 03500=v1.35 ("Classic") - 05000=v1.5/H - 05050=v1.5/F (MDT) - 05070=v1.6 (PORK) - 08200=v1.82 - 08300=v1.83 - 10000=ME/1.0 - 15000=ME/1.5 - 15500=ME/1.55 - 16000=ME/1.6 - 20000=Magx/0.0 - etc. + 00000=v1.0 + 01800=v1.18 + 01900=v1.19 + 02000=v1.20 ("Early Classic") + 03200=v1.32/COS + 03500=v1.35 ("Classic") + 05000=v1.5/H + 05050=v1.5/F (MDT) + 05070=v1.6 (PORK) + 08200=v1.82 + 08300=v1.83 + 10000=ME/1.0 + 15000=ME/1.5 + 15500=ME/1.55 + 16000=ME/1.6 + 20000=Magx/0.0 + etc. */ @@ -762,7 +762,7 @@ struct file_head_rec { uchar ext_own; uchar extnum; uchar fallback_ext; /* For non-'R' extensions, this is the 'R' extension - to fall back to. */ + to fall back to. */ }; static file_info fi_header[] = { @@ -996,7 +996,7 @@ int read_agx(fc_type fc, rbool diag) { } maxpix = index[16].numrec; for (i = 0; i < MAX_PIX; i++) pix_name[i] = 0; /* In case there are less than - MAX_PIX names */ + MAX_PIX names */ read_recblock(pix_name, FT_WORD, index[16].numrec, index[16].file_offset, index[16].blocksize); @@ -1180,7 +1180,7 @@ void write_header(void) { filehead.version = 2; filehead.extnum = 2; filehead.fallback_ext = 2; /* 'R' extension to fall back to; - only meaningful if ext_own is *not* 'R' */ + only meaningful if ext_own is *not* 'R' */ filehead.eol_chk1 = '\n'; filehead.eol_chk2 = '\r'; filehead.res1 = 0; @@ -1243,8 +1243,8 @@ void agx_create(fc_type fc) { write_recarray(NULL, sizeof(index_rec), AGX_NUMBLOCK, fi_index, 16); old_base_verb = BASE_VERB; /* This will be constant for any given version - of the interpreter, but may change across - versions of the interpreter */ + of the interpreter, but may change across + versions of the interpreter */ /* Set record sizes */ gindex[0].recsize = compute_recsize(fi_index); gindex[1].recsize = compute_recsize(fi_gameinfo); @@ -1328,7 +1328,7 @@ static void agx_finish_index(void) { gindex[18].numrec = MAX_FLAG_NOUN; agx_compute_index(); /* This time it will be complete except for - the VOC-TTL-INS blocks at the end */ + the VOC-TTL-INS blocks at the end */ } diff --git a/engines/glk/agt/auxfile.cpp b/engines/glk/agt/auxfile.cpp index bfc97282e3a..58f45202c18 100644 --- a/engines/glk/agt/auxfile.cpp +++ b/engines/glk/agt/auxfile.cpp @@ -43,103 +43,103 @@ namespace AGT { rbool PURE_ANSWER = 0; /* For ME questions, requires that AND-separated - answers be in the same order in the player's - answer as they are in the game file. According - to the AGT documentation, AND should ignore - the order, but the original AGT interpreters - (at least the one I've tested) don't conform - to this. */ + answers be in the same order in the player's + answer as they are in the game file. According + to the AGT documentation, AND should ignore + the order, but the original AGT interpreters + (at least the one I've tested) don't conform + to this. */ rbool PURE_TIME = 1; /* Set to 0 causes time to always be increased - by delta_time rather than by a random amount - between 0 and delta_time. Only really of any use - to a game author who wanted to write a game - explicitly for AGiliTy. */ + by delta_time rather than by a random amount + between 0 and delta_time. Only really of any use + to a game author who wanted to write a game + explicitly for AGiliTy. */ /* rbool PURE_BOLD=1; Set to 0 causes the backslash to toggle bold on and - off for all versions of AGT, not just 1.8x. - I can think of no reason to do this unless - you are an AGT author who wants to use the 1.8x - bold feature with the Master's Edition compiler. */ + off for all versions of AGT, not just 1.8x. + I can think of no reason to do this unless + you are an AGT author who wants to use the 1.8x + bold feature with the Master's Edition compiler. */ rbool PURE_AND = 1; /* increment the turn counter for each noun in a - chain of AND AND ... If 0, the turn - counter will only be incremented by one in such a case. - (need to do something about metacommands, as well...) */ + chain of AND AND ... If 0, the turn + counter will only be incremented by one in such a case. + (need to do something about metacommands, as well...) */ rbool PURE_METAVERB = 1; /* If set, ANY and AFTER commands are run even - if you type in a metaverb (SAVE, RESTORE,... - that is, any verb that doesn't cause time to - pass). Verb specific metacommands are _always_ - run. */ + if you type in a metaverb (SAVE, RESTORE,... + that is, any verb that doesn't cause time to + pass). Verb specific metacommands are _always_ + run. */ rbool PURE_ROOMTITLE = 1; /* If 0, the interpreter will print out room - names before room descriptions even for - pre-ME games */ + names before room descriptions even for + pre-ME games */ rbool PURE_SYN = 0; /* Treats synonyms as nouns when parsing: that is, they - must show up only as the last word and they have the - same priority as noun matches during disambiguation. - If this is 0, then synonyms can appear anywhere in - the name the player types in but are still - disambiguated as nouns. */ + must show up only as the last word and they have the + same priority as noun matches during disambiguation. + If this is 0, then synonyms can appear anywhere in + the name the player types in but are still + disambiguated as nouns. */ rbool PURE_NOUN = 0; /* _Requires_ a noun to end a word. This is only - imperfectly supported: if there are no other - possible matches the parser will take the adjective- - only one anyhow. Frankly, I can't think of any reason - to set this to 1, but it's included for completeness - sake (and for any AGT Purists out there :-) ) */ + imperfectly supported: if there are no other + possible matches the parser will take the adjective- + only one anyhow. Frankly, I can't think of any reason + to set this to 1, but it's included for completeness + sake (and for any AGT Purists out there :-) ) */ rbool PURE_ADJ = 1; /* Picks noun/syn-matches over pure adj matches - when disambiguating. This is redundant if PURE_NOUN=1 - since in that case pure adjective matches will - be rejected anyhow. */ + when disambiguating. This is redundant if PURE_NOUN=1 + since in that case pure adjective matches will + be rejected anyhow. */ rbool PURE_DUMMY = 0; /* If set, the player can running dummy verbs - in the game by typing 'dummy_verb3'; otherwise, - this will produce an error message */ + in the game by typing 'dummy_verb3'; otherwise, + this will produce an error message */ rbool PURE_SUBNAME = 0; /* If set, the player can run subroutines from - the parse line by typing (e.g.) 'subroutine4' - (yes, the original AGT interpreters actually - allow this). If cleared, this cheat isn't - available */ + the parse line by typing (e.g.) 'subroutine4' + (yes, the original AGT interpreters actually + allow this). If cleared, this cheat isn't + available */ rbool PURE_PROSUB = 0; /* If clear, then $you$ substitutions are done - everywhere $$ substitutions are, even in - messages written by the game author. - If set, these substitutions are only made - in internal game messages */ + everywhere $$ substitutions are, even in + messages written by the game author. + If set, these substitutions are only made + in internal game messages */ rbool PURE_HOSTILE = 1; /* =0 Will allow you to leave a room with a hostile - creature if you go back the way you came */ + creature if you go back the way you came */ rbool PURE_ALL = 1; /* =0 will cause the parser to expand ALL */ rbool PURE_DISAMBIG = 1; /* =0 will cause intelligent disambiguation */ rbool PURE_GETHOSTILE = 1; /* =0 will prevent the player from picking things - up in a room with a hostile creature */ + up in a room with a hostile creature */ rbool PURE_OBJ_DESC = 1; /* =0 prevents [providing light] messages - from being shown */ + from being shown */ rbool PURE_ERROR = 0; /* =1 means no GAME ERROR messages will be printed - out */ + out */ rbool PURE_SIZE = 1; /* =0 eliminates size/weight limits on how many - things the player can wear or carry. (But it's - still impossible to pick things up that are - in themselves larger than the player's capacity) */ + things the player can wear or carry. (But it's + still impossible to pick things up that are + in themselves larger than the player's capacity) */ rbool PURE_GRAMMAR = 1; /* =0 prints error messages if the player uses a - built in verb with an extra object. - (e.g. YELL CHAIR). Otherwise, the extra object - will just be ignored. */ + built in verb with an extra object. + (e.g. YELL CHAIR). Otherwise, the extra object + will just be ignored. */ rbool PURE_SYSMSG = 1; /* =0 causes AGiliTy to always use the default - messages even if the game file has its own - standard error messages. */ + messages even if the game file has its own + standard error messages. */ rbool PURE_AFTER = 1; /* =0 causes LOOK and other end-of-turn events - to happen *before* AFTER commands run. */ + to happen *before* AFTER commands run. */ rbool PURE_PROPER = 1; /* Don't automatically treat creatures as proper nouns */ @@ -154,14 +154,14 @@ rbool FORCE_VERSION = 0; /* Load even if the version is wrong. */ /* The main interpreter handles configuration in this order: 1) Global configuration file 2) First pass through game specific CFG to get the settings for - SLASH_BOLD and IBM_CHAR which we need to know _before_ reading - in the game. + SLASH_BOLD and IBM_CHAR which we need to know _before_ reading + in the game. 3) Read in the game. 4) Main pass through game specific CFG. Doing it here ensures that - its settings will override those in the gamefile. + its settings will override those in the gamefile. Secondary programs (such as agt2agx) usually only call this once, for the game specific configuration file. - */ + */ #define opt(s) (strcasecmp(optstr[0],s)==0) @@ -284,8 +284,8 @@ void read_config(genfile cfgfile, rbool lastpass) { 8 Height of menus (3, 4, 5, 6, 7, or 8) 9 Unknown, always seems to be 0 10-13 Color scheme: output/status/input/menu, specified in DOS attribute - format (Bbbbffff, B=blink, b=backround, f=foreground, - MSB of foreground specifies intensity ("bold") ). */ + format (Bbbbffff, B=blink, b=backround, f=foreground, + MSB of foreground specifies intensity ("bold") ). */ /* The interpreter ignores almost all of this. */ void read_opt(fc_type fc) { @@ -456,7 +456,7 @@ void init_verbrec(void) vm_size = 0; newindex = 0; if (freeze_mode) newindex = 1; /* Don't include MENU option if we can't - use it. */ + use it. */ } void finish_verbrec(void) { diff --git a/engines/glk/agt/config.h b/engines/glk/agt/config.h index 14e4c6e96b0..7a519ba6180 100644 --- a/engines/glk/agt/config.h +++ b/engines/glk/agt/config.h @@ -31,18 +31,18 @@ namespace AGT { /* This file contains most of the configuration information - including the platform-dependent #define statements + including the platform-dependent #define statements It's in three major sections: - --Platform specific defines for various platforms, each - surrounded by "#ifdef " and "#endif" - --Various defaults - --Filename extensions + --Platform specific defines for various platforms, each + surrounded by "#ifdef " and "#endif" + --Various defaults + --Filename extensions Ideally, a port to a new platform should only need to modify this - file, the makefile, os_.c, and possibly filename.c. (In - practice, you may also need to tweak the the high-level I/O code - in interface.c or the memory-allocation code in util.c. If you - find yourself needing to do more than that, get in touch with me.) */ + file, the makefile, os_.c, and possibly filename.c. (In + practice, you may also need to tweak the the high-level I/O code + in interface.c or the memory-allocation code in util.c. If you + find yourself needing to do more than that, get in touch with me.) */ #undef _WIN32 /* GARGLK */ @@ -71,51 +71,51 @@ namespace AGT { /* REPLACE_MAIN: define if you replace the default main(). */ /* (replacements should be defined in the relevant os_.c file) */ /* DA1,DA2,...DA6,DSS,pTTL: file name extensions for the various AGT - files */ + files */ /* HAVE_SLEEP if your platform has the sleep() function */ /* BUFF_SIZE is the maximum size of the buffer to use when reading - in files. Regardless, it will be made no bigger than the file - being read in and no smaller than the record size; thus setting - it to 0 will cause the smallest buffer to always be used and - setting this to 1MB will in practice always use a buffer the - sizs of the file. It defaults to 32K */ + in files. Regardless, it will be made no bigger than the file + being read in and no smaller than the record size; thus setting + it to 0 will cause the smallest buffer to always be used and + setting this to 1MB will in practice always use a buffer the + sizs of the file. It defaults to 32K */ /* CBUF_SIZE is the maximum size of the buffer used for reading in - the Master's Edition DA6 files; the size of the buffer in bytes - is twice this value (since an individual token is two bytes long). */ + the Master's Edition DA6 files; the size of the buffer in bytes + is twice this value (since an individual token is two bytes long). */ /* DESCR_BUFFSIZE is the maximum size of the description text block before - the interpreter will read it from disk rather than storing it in - memory during play. At the moment this only affects AGX games; - original AGT games always use the disk. */ + the interpreter will read it from disk rather than storing it in + memory during play. At the moment this only affects AGX games; + original AGT games always use the disk. */ /* DOHASH to use a hash table for dictionary searches; the only - reason not to have this would be memory */ + reason not to have this would be memory */ /* HASHBITS determines the size of the hash table: (2^HASHBITS)*sizeof(word); - the hash table must be at least as large as the dictionary. - In practice this means HASHBITS should be at least 12; - this is the current default. */ + the hash table must be at least as large as the dictionary. + In practice this means HASHBITS should be at least 12; + this is the current default. */ /* MAXSTRUC The maximum size (in chars) which a single data structure can - be on this platform. This defaults to 1MB (i.e. no limit for - practical purposes). In practice I know of no game files that - require any structures bigger than about 30K. */ + be on this platform. This defaults to 1MB (i.e. no limit for + practical purposes). In practice I know of no game files that + require any structures bigger than about 30K. */ /* LOWMEM Define this if you are low on memory. At the moment this - only saves a few K.*/ + only saves a few K.*/ /* PORTSTR Is the string describing this particular port. - e.g. #define PORTSTR "OrfDOS Port by R.J. Wright" */ + e.g. #define PORTSTR "OrfDOS Port by R.J. Wright" */ /* UNIX_IO if you have Unix-like low level file I/O functions. - (MS-DOS, for example, does). This speeds up the reading - of the large game data files on some platforms. If this is - defined, READFLAG, WRITEFLAG, and FILE_PERM also need to - be defined. (Giving the flags needed for opening a file for - reading or writing, and the file permissions to be given to newly - created files. */ + (MS-DOS, for example, does). This speeds up the reading + of the large game data files on some platforms. If this is + defined, READFLAG, WRITEFLAG, and FILE_PERM also need to + be defined. (Giving the flags needed for opening a file for + reading or writing, and the file permissions to be given to newly + created files. */ /* OPEN_AS_TEXT Define to cause text files to be opened as text files. */ /* PREFIX_EXT Add filename extensions at the beginning of the name, - rather than at the end. */ + rather than at the end. */ /* PATH_SEP, if defined, is a string containing all characters which - can be used to separate the path from the filename. */ + can be used to separate the path from the filename. */ /* pathtest(s) is a macro that should check whether the given string - is an absolute path. If this is left undefined, then _all_ - paths will be treated as absolute. You don't need to define - this if you are replacing filename.c. */ + is an absolute path. If this is left undefined, then _all_ + paths will be treated as absolute. You don't need to define + this if you are replacing filename.c. */ /* ------------------------------------------------------------------- */ /* force16 is used purely for debugging purposes, to make sure that @@ -140,7 +140,7 @@ namespace AGT { #define INBUFF_SIZE (1024) /* Inherited from PLAIN. */ #define fix_ascii 0 /* os_glk.c does translations. */ #define MAXSTRUC (1024L*1024L) /* 32Kb from PLAIN is too small for - several games (including Soggy). */ + several games (including Soggy). */ #define PORTSTR "Glk version" /* Identify ourselves discreetly. */ #define REPLACE_GETFILE /* Override get_user_file. */ #define REPLACE_MAIN /* Override main. */ @@ -158,7 +158,7 @@ namespace AGT { #define CBUF_SIZE (5000L) #define INBUFF_SIZE (1024) /* Used by Magx */ #define MAXSTRUC (32L*1024L) /* IIRC, 32K is the minimum required by - the ANSI standard */ + the ANSI standard */ #define PORTSTR "Pure ANSI C version" #endif diff --git a/engines/glk/agt/debugcmd.cpp b/engines/glk/agt/debugcmd.cpp index 17fad335ece..c5b9106881a 100644 --- a/engines/glk/agt/debugcmd.cpp +++ b/engines/glk/agt/debugcmd.cpp @@ -86,7 +86,7 @@ static void d_listroom() { } #define SEPLENG 27 /* Width between beginning of object column and - location column */ + location column */ static void d_listnoun() { int i; diff --git a/engines/glk/agt/exec.cpp b/engines/glk/agt/exec.cpp index 6513cfdaa1e..8073128c984 100644 --- a/engines/glk/agt/exec.cpp +++ b/engines/glk/agt/exec.cpp @@ -125,15 +125,15 @@ void set_statline() { It advances *pstr to point after the number and after the terminating character, if relevant. is the terminating character; if this is 0, then - the calling routine will worry about the terminating character. + the calling routine will worry about the terminating character. of 0 indicates no upper bound */ static int extract_number(const char **pstr, int maxval, - char term_char) { + char term_char) { const char *s; long n; /* n holds the value to be returned; i holds - the number of characters parsed. */ + the number of characters parsed. */ n = 0; s = *pstr; while (*s == ' ' || *s == '\t') s++; @@ -155,8 +155,8 @@ static int extract_number(const char **pstr, int maxval, /* This is used by #PROP[obj].[prop]# and $ATTR[obj].[attr]$, etc. */ /* isprop: Are we looking for a property (as opposed to an attribute)? */ static void extract_prop_val(const char **pstr, - int *id, int *val, - rbool isprop, const char term_char) { + int *id, int *val, + rbool isprop, const char term_char) { const char *s; int v; /* object number / final value */ int i; /* Attribute id */ @@ -256,7 +256,7 @@ static void num_name_func(parse_rec *obj_rec, char *fill_buff, word prev_adj) } if (w == prev_adj) /* ... and prev_adj!=0 but we don't need to explicity - test that since w!=0 */ + test that since w!=0 */ fill_buff[0] = 0; /* i.e. an empty string */ else { rstrncpy(fill_buff, dict[w], FILL_SIZE); @@ -288,20 +288,20 @@ static word get_adj(parse_rec *obj_rec, char *buff) { return 1;} word just_seen_adj; /* This determines if we just saw $adjective$; if so, - this is set to it, otherwise it is zero. See - num_name_func above. */ + this is set to it, otherwise it is zero. See + num_name_func above. */ static int wordcode_match(const char **pvarname, char *fill_buff, - int context, const char *pword) + int context, const char *pword) /* Check <*p*pvarname> for a match; put subs text in fill_buf indicates who called us; this determines - what substitutions are valid. See interp.h for possible - values. Move *p*pvarname after whatever is matched. + what substitutions are valid. See interp.h for possible + values. Move *p*pvarname after whatever is matched. contains the parse word when context is MSG_PARSE. */ /* $ forms: $verb$, $noun$, $adjective$, $prep$, $object$, $name$, $n_pro$, $o_pro$, $n_indir$, $o_indir$, - $name_pro$, $name_indir$ + $name_pro$, $name_indir$ $n_is$, $o_is$, $name_is$ $c_name$ $n_was$, $o_was$, $name_was$ @@ -471,7 +471,7 @@ static int capstate(const char *varname) { static char fill_buff[FILL_SIZE]; /* Buffer to hold returned string */ static char *wordvar_match(const char **pvarname, char match_type, - int context, const char *pword) + int context, const char *pword) /* Match_type=='#' for variables, '$' for parsed words */ /* Possible # forms: #VARn#, #CNTn# */ /* See above for $ forms */ @@ -528,7 +528,7 @@ static char *format_line(const char *s, int context, const char *pword) const char *p, *oldp; /* Pointer to the original string */ int i; char *fill_word, *q; /* Word used to fill in the blanks, and a pointer - used to iterate through it*/ + used to iterate through it*/ char fill_type; /* '#'=#variable#, '$'=$word$ */ /* Need to do subsitutions and also correct for tabs */ @@ -550,7 +550,7 @@ static char *format_line(const char *s, int context, const char *pword) /* Read in $word$ or #var# and do substitution */ fill_type = *p; oldp = p++; /* Save old value in case we are wrong and then - increment p */ + increment p */ fill_word = wordvar_match(&p, fill_type, context, pword); if (fill_word == NULL) { /*i.e. no match-- so just copy it verbatim */ @@ -603,7 +603,7 @@ static void lineout(const char *s, rbool nl, int context, const char *pword) { } static void gen_print_descr(descr_ptr dp_, rbool nl, - int context, const char *pword) { + int context, const char *pword) { int j; descr_line *txt; @@ -788,7 +788,7 @@ static rbool check_answer(char *ans, long start, long size) descr_line *astr; /* Holds the answer string */ int i; /* Index to line of astr we're on. */ char *p, *q, *r; /* Used to break astr up into pieces and - loop over them */ + loop over them */ astr = read_descr(start, size); if (astr == NULL) { @@ -900,7 +900,7 @@ long read_number(void) { void runptr(int i, descr_ptr dp_[], const char *msg, int msgid, - parse_rec *nounrec, parse_rec *objrec) + parse_rec *nounrec, parse_rec *objrec) /* Prints out description unless it doesn't exist, in which case it prints out either system message #msgid or the message contained in msg. */ @@ -912,17 +912,17 @@ void runptr(int i, descr_ptr dp_[], const char *msg, int msgid, /* Score modes: - S:Score, R:Room +=list '(out of..'), -=don't list at all. - 0-- S+ R+ - 1-- S+ R - 2-- S R+ - 3-- S R - 4-- S+ R- - 5-- S R- - 6-- S- R+ - 7-- S- R - 8-- S- R- and disable SCORE. - */ + S:Score, R:Room +=list '(out of..'), -=don't list at all. + 0-- S+ R+ + 1-- S+ R + 2-- S R+ + 3-- S R + 4-- S+ R- + 5-- S R- + 6-- S- R+ + 7-- S- R + 8-- S- R- and disable SCORE. + */ void print_score(void) { @@ -1239,7 +1239,7 @@ static void set_pronoun(int item) { if (it_plur(item)) last_they = item; last_it = item; /* Change: last_it will be set even if the - noun is plural */ + noun is plural */ break; case 1: last_she = item; @@ -1265,7 +1265,7 @@ static rbool lastnoun(parse_rec *list) { static void runverbs(parse_rec *actor0, int vnum, - parse_rec *lnoun, word prep0, parse_rec *iobj0) + parse_rec *lnoun, word prep0, parse_rec *iobj0) /* The zeros are postpended simply to avoid a name conflict */ { parse_rec *currnoun; @@ -1336,7 +1336,7 @@ parse_rec *save_lnoun = NULL; void exec(parse_rec *actor_, int vnum, - parse_rec *lnoun, word prep_, parse_rec *iobj_) { + parse_rec *lnoun, word prep_, parse_rec *iobj_) { cmd_saveable = 0; pronoun_mode = !PURE_PROSUB; diff --git a/engines/glk/agt/exec.h b/engines/glk/agt/exec.h index d82ccf0504e..bca391647a0 100644 --- a/engines/glk/agt/exec.h +++ b/engines/glk/agt/exec.h @@ -51,15 +51,15 @@ struct op_rec { /* The following determines if we are doing disambiguation or actually executing a verb */ global uchar do_disambig; /* 0= execution - 1= disambiguating noun - 2= disambiguating object */ + 1= disambiguating noun + 2= disambiguating object */ /* Flags used during turn execution */ global rbool beforecmd; /* Only used by 1.8x games */ global rbool supress_debug; /* Causes debugging info to _not_ be printed - even if debugging is on; used by disambiguator - and to supress ANY commands */ + even if debugging is on; used by disambiguator + and to supress ANY commands */ global rbool was_metaverb; /* Was the verb that just executed a metaverb? */ /* Metaverbs are commands that should not take game time to execute: SAVE, RESTORE, RESTART, QUIT, SCRIPT, UNSCRIPT, @@ -80,7 +80,7 @@ global integer *creat_fix; /* Defined in EXEC.C */ /* -------------------------------------------------------------------- */ extern void raw_lineout(const char *s, rbool do_repl, - int context, const char *pword); + int context, const char *pword); extern void msgout(int msgnum, rbool add_nl); extern void sysmsg(int msgid, const char *s); extern void alt_sysmsg(int msgid, const char *s, parse_rec *new_dobjrec, @@ -95,7 +95,7 @@ extern rbool match_answer(char *ans, int anum); extern void look_room(void); extern void runptr(int i, descr_ptr dp[], const char *msg, int msgid, - parse_rec *nounrec, parse_rec *objrec); + parse_rec *nounrec, parse_rec *objrec); extern int normalize_time(int tnum); /* Convert hhmm so mm<60 */ extern void add_time(int dt); @@ -172,8 +172,8 @@ extern void exec_verb(void); /* The main routine to search the metacommand list and run the appropriate meta-commands */ extern int scan_metacommand(integer m_actor, int vcode, - integer m_dobj, word m_prep, integer m_iobj, - int *redir_flag); + integer m_dobj, word m_prep, integer m_iobj, + int *redir_flag); /* The type checking routine */ rbool argvalid(int argtype, int arg); @@ -196,20 +196,20 @@ extern void get_debugcmd(void); /* Get and execute debugging commands */ /* -------------------------------------------------------------------- */ /* A note on object codes: - <0 obj is a 'virtual' object, existing only as the word - dict[-obj], e.g. DOOR, flag nouns, global nouns - 0 No object (or any object) - 1 Self(i.e. the player) + <0 obj is a 'virtual' object, existing only as the word + dict[-obj], e.g. DOOR, flag nouns, global nouns + 0 No object (or any object) + 1 Self(i.e. the player) first_room..last_room Rooms first_noun..last_noun Nouns first_creat..last_creat Creatures - 1000 Being worn by the player */ + 1000 Being worn by the player */ /* The following macro loops over the contents of an object */ #define contloop(i,obj) for(i=it_contents(obj);i!=0;i=it_next(i)) #define safecontloop(i,j,obj) for(i=it_contents(obj),j=it_next(i); \ - i!=0;i=j,j=it_next(i)) + i!=0;i=j,j=it_next(i)) #define cnt_val(c) ((c)==-1 ? 0 : (c)) @@ -240,7 +240,7 @@ extern void get_debugcmd(void); /* Get and execute debugging commands */ #define it_name(item) objattr2(item,name,(item<0) ? -item : 0) #define it_open(item) nounattr2(item,open, tcreat(item) || \ - (tdoor(item) && !room[loc].locked_door)) + (tdoor(item) && !room[loc].locked_door)) /* This checks to make sure the object isn't unmovable. */ /* (As such, all non-nouns automatically pass) */ @@ -249,13 +249,13 @@ extern void get_debugcmd(void); /* Get and execute debugging commands */ #ifdef IT_MACRO #define it_contents(item) objattr2(item,contents,\ - roomattr2(item,contents,\ - (item==1) ? player_contents : \ - (item==1000) ? player_worn : 0)) + roomattr2(item,contents,\ + (item==1) ? player_contents : \ + (item==1000) ? player_worn : 0)) #define it_lockable(item) nounattr2(item,lockable, (tdoor(item) ? 1 : 0) ) #define it_locked(item,name) nounattr2(item,locked,\ - (tdoor(item) && room[loc].locked_door ? \ - 1 : 0)) + (tdoor(item) && room[loc].locked_door ? \ + 1 : 0)) #else extern int it_contents(integer obj); extern rbool it_lockable(integer obj, word noun); diff --git a/engines/glk/agt/filename.cpp b/engines/glk/agt/filename.cpp index fba5c4f41c4..3d48872c864 100644 --- a/engines/glk/agt/filename.cpp +++ b/engines/glk/agt/filename.cpp @@ -100,7 +100,7 @@ static rbool compat_ext(filetype ft, filetype ft_base) { /*----------------------------------------------------------------------*/ char *assemble_filename(const char *path, const char *root, - const char *ext) { + const char *ext) { int len1, len2, len3; char *name; @@ -157,7 +157,7 @@ static int find_path_sep(const char *name) { has an extension. Returns the length of the extensions and writes the extension type in pft */ static int search_for_ext(const char *name, filetype base_ft, - filetype *pft) { + filetype *pft) { filetype t; int xlen, len; @@ -191,7 +191,7 @@ static char *extract_piece(const char *name, int extlen, rbool isext) { char *root; int len, xlen; rbool first; /* If true, extract from beginning; if false, extract - from end */ + from end */ len = strlen(name) - extlen; xlen = extlen; @@ -275,13 +275,13 @@ static void fix_path(file_context_rec *fc) { /* This creates a new file context based on gamename. */ /* ft indicates the rough use it will be put towards: - ft=fNONE indicates it's the first pass read, before PATH has been - read in, and so the fc shouldn't be filled out until - fix_file_context() is called. - ft=pDA1 indicates that name refers to the game files. - ft=pAGX indicates the name of the AGX file to be written to. - ft=pSAV,pLOG,pSCR all indicate that name corresponds to the - related type of file. */ + ft=fNONE indicates it's the first pass read, before PATH has been + read in, and so the fc shouldn't be filled out until + fix_file_context() is called. + ft=pDA1 indicates that name refers to the game files. + ft=pAGX indicates the name of the AGX file to be written to. + ft=pSAV,pLOG,pSCR all indicate that name corresponds to the + related type of file. */ fc_type init_file_context(const char *name, filetype ft) { file_context_rec *fc; int p, x; /* Path and extension markers */ @@ -325,7 +325,7 @@ void fix_file_context(fc_type fc, filetype ft) { fc_type convert_file_context(fc_type fc, filetype ft, const char *name) { file_context_rec *nfc; rbool local_ftype; /* Indicates file should be in working directory, - not game directory. */ + not game directory. */ local_ftype = (ft == fSAV || ft == fSCR || ft == fLOG); if (BATCH_MODE || make_test) local_ftype = 0; @@ -374,8 +374,8 @@ void release_file_context(fc_type *pfc) { /*----------------------------------------------------------------------*/ static genfile try_open_file(const char *path, const char *root, - const char *ext, const char *how, - rbool nofix) { + const char *ext, const char *how, + rbool nofix) { char *name = assemble_filename(path, root, ext); genfile f = fopen(name, how); rfree(name); @@ -430,7 +430,7 @@ rbool fileexist(fc_type fc, filetype ft) { genfile writeopen(fc_type fc, filetype ft, - file_id_type *pfileid, const char **errstr) { + file_id_type *pfileid, const char **errstr) { char *name; genfile f; diff --git a/engines/glk/agt/gamedata.cpp b/engines/glk/agt/gamedata.cpp index e33b5940183..8601ab84b98 100644 --- a/engines/glk/agt/gamedata.cpp +++ b/engines/glk/agt/gamedata.cpp @@ -44,14 +44,14 @@ namespace AGT { /* ------------------------------------------------------------ */ const char trans_ibm[] = - "CueaaaaceeeiiiAA" /* 80 */ - "E@@ooouuyOUc$$pf" /* 90 */ - "aiounNao?....!<>" /* A0 */ - "###|++|+++|\\/++\\" /* B0 */ - "\\+++-+||\\/+++=+=" /* C0 */ - "+=+++++++//@@@@@" /* D0 */ - "abGpSsmtFTOd.fe^" /* E0 */ - "=+>" /* A0 */ + "###|++|+++|\\/++\\" /* B0 */ + "\\+++-+||\\/+++=+=" /* C0 */ + "+=+++++++//@@@@@" /* D0 */ + "abGpSsmtFTOd.fe^" /* E0 */ + "=+> n-55 105,122 - Dummy_verb1...Dummy_Verb50 */ + Dummy_verb1...Dummy_Verb50 */ /* Possible extension to verb definitons (not implemented): If it _requires_ a prep, use : ? @@ -859,7 +859,7 @@ void reinit_dict(void) as loading the initial vocabulary into the dictionary. */ { char buff[16]; /* Needs to be big enough to hold dummy_verbNNN\0 - or subroutineNNN\0 */ + or subroutineNNN\0 */ int i; no_syn = no_auxsyn; @@ -1128,7 +1128,7 @@ static int cmp_cmd(const void *cmd1, const void *cmd2) { /* actor will equal the index of the header in the original list. */ /* (or negative the header if the command is a redirection) */ /* For redirected commands, we steal the data pointer since it shouldn't - be being used anyhow. */ + be being used anyhow. */ /* In a field pointed to by data we store the verb word */ /* NOTE: this routine requires that the data type of *data (namely integer) is big enough to hold a value of type word. */ @@ -1225,7 +1225,7 @@ void sort_cmd(void) { all_word = search_dict("all"); if (all_word == 0) all_word = -1; /* This means none of the metacommands - used ALL, so prevent ANY matches */ + used ALL, so prevent ANY matches */ global_word = search_dict("global_scope"); if (global_word == 0) global_word = -1; /* Ditto */ diff --git a/engines/glk/agt/interface.cpp b/engines/glk/agt/interface.cpp index 818b43c5fbb..9eb3e4e218e 100644 --- a/engines/glk/agt/interface.cpp +++ b/engines/glk/agt/interface.cpp @@ -218,7 +218,7 @@ static char *get_log(void) writeln(""); writeln("ERROR: Unexpected end of log file."); agt_quit(); /* This doesn't actually quit; it just sets things - up so we *will* quit. */ + up so we *will* quit. */ dead_log = 0; } else { logflag &= ~2; @@ -506,7 +506,7 @@ void print_statline(void) s[j++] = ' '; i -= 2; } /* If statline is wide enough, put a - space on each side */ + space on each side */ if ((int)strlen(l_stat) < status_width) /* Copy left side of status line into s*/ for (t = l_stat; *t != 0; t++) s[j++] = fixstatchar(*t); @@ -563,7 +563,7 @@ void textbox(char *(txt[]), int len, unsigned long flags) agt_makebox(width, len, flags & ~(TB_BOLD | TB_CENTER)); quotemode = 1; /* So newlines will cause truncation rather than a - real newline */ + real newline */ for (i = 0; i < len; i++) { padwidth = width - linewidth[i]; /* Amount of padding we need */ if (flags & TB_CENTER) { diff --git a/engines/glk/agt/interp.h b/engines/glk/agt/interp.h index 3794a09794e..dd140732341 100644 --- a/engines/glk/agt/interp.h +++ b/engines/glk/agt/interp.h @@ -29,9 +29,9 @@ namespace Glk { namespace AGT { /* This file contains variables and data structures used - by the interpreter but not read in from the gamefile. + by the interpreter but not read in from the gamefile. For the rest of the data structures, see agility.h and - agtdata.c */ + agtdata.c */ #ifndef global #define uagt_defined_global @@ -52,23 +52,23 @@ global rbool stable_random; global rbool DEBUG_MEM; /* prints out information on memory allocation */ global rbool debug_parse; /* Prints out long parse diagnostic information - after the sentence has been parse but before - disambiguation */ + after the sentence has been parse but before + disambiguation */ global rbool DEBUG_EXEC_VERB; /* This prints out a line indicating each command - that exec_verb() is asked to run */ + that exec_verb() is asked to run */ global rbool DEBUG_DISAMBIG; /* Print out dismabiguation debugging info */ global rbool DEBUG_SMSG; /* Print out STANDARD message info */ #define DEBUG_AGT_CMD flag[0] /* This sends metacommand execution information - to either the screen or debugfile, depending on - whether DEBUG_OUT is true or false. */ + to either the screen or debugfile, depending on + whether DEBUG_OUT is true or false. */ global rbool debug_disambig, debug_any; /* These determine if metacommands are traced during disambiguation or during the scanning of ANY commands */ global rbool DEBUG_OUT; /* True if debugging output is redirected somewhere - other than the screen */ + other than the screen */ global Common::DumpFile *debugfile; /* Where debugging output should be sent */ #define def_DEBUG_MEM 1 /* parser.c */ @@ -85,28 +85,28 @@ global Common::DumpFile *debugfile; /* Where debugging output should be sent */ extern rbool PURE_INPUT, PURE_TONE; #define PURE_WEAR 1 /* If this is cleared, then things taken off - still stay in the player's inventory. - The support for this isn't quite complete yet - (there are one or two checks that need to be done - but aren't) and so right now this should be 1. */ + still stay in the player's inventory. + The support for this isn't quite complete yet + (there are one or two checks that need to be done + but aren't) and so right now this should be 1. */ global rbool PURE_DOT; /* Treats period as a letter-character and not - as punctuation. This should be set automatically - during initialization based on whether any words - in the dictionary have dots. */ + as punctuation. This should be set automatically + during initialization based on whether any words + in the dictionary have dots. */ #define FORCE_PURE_DOT 0 /* This forces the period to be treated as a letter - even if there are no words in the dictionary - containing periods. The only reason to set - this was if you were concerned that knowledge - about the presence or absence of periods in the - dictionary would give puzzles away. */ + even if there are no words in the dictionary + containing periods. The only reason to set + this was if you were concerned that knowledge + about the presence or absence of periods in the + dictionary would give puzzles away. */ #define MEM_MARGIN (16*1024) /* 16K should be enough (SOGGY, the largest AGT - game, uses around 12K) */ + game, uses around 12K) */ #define PICT_SUPPORT 0 /* Graphics not supported */ #define TAB_SIZE 3 /* Number of spaces in a tab */ @@ -120,16 +120,16 @@ global rbool PURE_DOT; /* Treats period as a letter-character and not global rbool notify_flag, listexit_flag, menu_mode; global rbool cmd_saveable; /* set indicates that this command can be repeated - with AGAIN. */ + with AGAIN. */ global rbool can_undo; /* Can we UNDO the last turn? */ global uchar *restart_state, *undo_state; /* Store old game states for - RESTART and UNDO */ + RESTART and UNDO */ global char doing_restore; /* Have we been asked to RESTORE? */ global rbool do_look; /* True if we should print a room description */ global rbool do_autoverb; /* True if we should run the autoexec verb - for the current room */ + for the current room */ /* The following are used for scripting and logging */ global rbool script_on; @@ -141,13 +141,13 @@ global genfile log_in, log_out; global rbool fast_replay; /* If true, don't print MORE prompts. */ global rbool sound_on; /* Manipulated by music_cmd; can be used by interface - to determine if a tone should be made */ + to determine if a tone should be made */ global integer *pictable; /* Used to decode picture numbers */ global fc_type hold_fc; /* Needed to print instructions on demand */ global unsigned short compass_rose; /* Used to pass compass info to - the os layer */ + the os layer */ /* -------------------------------------------------------------------- */ @@ -158,13 +158,13 @@ global rbool quitflag, deadflag, winflag, endflag; global rbool first_visit_flag, newlife_flag, room_firstdesc; global rbool start_of_turn; /* True if running the command on the first - noun in the list */ + noun in the list */ global rbool end_of_turn; /* True if running command on last noun in - the list. */ + the list. */ global rbool actor_in_scope; /* Used to determine if the actor was in - scope when the command was originally - given */ + scope when the command was originally + given */ global integer loc; /* Player's location */ global integer player_contents, player_worn; /* Worn and carried objects*/ @@ -175,11 +175,11 @@ global integer curr_lives; /* Number of lives left. */ global long tscore, old_score; /* Total score */ global long objscore; /* Portion of tscore that comes from the POINTS - field of nouns and creatures. */ + field of nouns and creatures. */ global integer turncnt; /* Number of turns that have passed */ global integer curr_time; /* The time in the game; in the format - 1243==12:43 */ + 1243==12:43 */ global rbool *flag; /* AGT Flags */ global short *agt_counter; /* AGT counters */ @@ -191,22 +191,22 @@ global long *agt_var; global long agt_number; /* The number entered by the player */ global rbool agt_answer; /* Did the player get the answer to the last question - right? */ + right? */ global tline l_stat, r_stat; /* Left and right parts of status line */ /* If r_stat is the empty string, l_stat should be centered to create a Trinity-like status line */ global rbool nomatch_aware; /* Does the game use the nomatch extension - to the metacommand format? - (which allow and ANY to be - distingused) */ + to the metacommand format? + (which allow and ANY to be + distingused) */ global rbool smart_look; /* If true, then LOOK will be converted - to EXAMINE. This is set automatically in agil.c, - based on whether the game file uses - LOOK in any of the metacommands; if it - does, then smart_look is set to 0. */ + to EXAMINE. This is set automatically in agil.c, + based on whether the game file uses + LOOK in any of the metacommands; if it + does, then smart_look is set to 0. */ /* -------------------------------------------------------------------- */ /* Menu data structures */ @@ -241,7 +241,7 @@ struct parse_rec { /* In an ideal world, the following would all be local variables. */ /* Unfortunately, they're used in too many different places for this - to be practical */ + to be practical */ global int vb; global integer actor, dobj, iobj; @@ -254,7 +254,7 @@ used to fill in $c_name$ messages */ global int disambig_score; /* Used to rank objects during disambiguation */ #define DISAMBIG_SUCC 1000 /* Score given to an object that triggers a - built-in verb or an action token */ + built-in verb or an action token */ #define MAXINPUT 200 /* Max number of words input */ @@ -265,25 +265,25 @@ global words in_text[MAXINPUT]; global short ip, ep; /* input pointer and error pointer */ global short ap, vp, np, pp, op; /* Points to first word in actor, verb, noun, - and object resp. */ + and object resp. */ /* The following needs to be kept consistant with ext_voc[] in agil.c */ typedef enum {wthe, wmy, wa, wan, wthen, wp, wsc, wand, wc, wits, wall, wundo, wlook, wg, - wpick, wgo, wexits, wtalk, wtake, wdoor, wagain, wbut, wexcept, - wscene, weverything, wlistexit, wlistexits, wclose, - wdverb, wdnoun, wdadjective, wdprep, wdobject, wdname, - wstep, w_any, weither, wboth, weveryone, weverybody, - whe, wshe, wit, wthey, whim, wher, wthem, wis, ware, woops, - wwas, wwere, - win, wout, winto, wat, wto, wacross, winside, wwith, wnear, wfor, - wof, wbehind, wbeside, won, woff, wunder, wfrom, wthrough, - wtoward, wtowards, wbetween, waround, wupon, wthru, - wby, wover, wup, wdown, - wabout - } wtype; + wpick, wgo, wexits, wtalk, wtake, wdoor, wagain, wbut, wexcept, + wscene, weverything, wlistexit, wlistexits, wclose, + wdverb, wdnoun, wdadjective, wdprep, wdobject, wdname, + wstep, w_any, weither, wboth, weveryone, weverybody, + whe, wshe, wit, wthey, whim, wher, wthem, wis, ware, woops, + wwas, wwere, + win, wout, winto, wat, wto, wacross, winside, wwith, wnear, wfor, + wof, wbehind, wbeside, won, woff, wunder, wfrom, wthrough, + wtoward, wtowards, wbetween, waround, wupon, wthru, + wby, wover, wup, wdown, + wabout + } wtype; global word ext_code[wabout + 1]; /* Codes for the above */ global short last_he, last_she, last_it, last_they; /* Used for pronoun support */ @@ -314,7 +314,7 @@ global short last_he, last_she, last_it, last_they; #define D_EITHER 10 /* EITHER or ANY, used only to resolve disambiguation */ #define D_MARK 0x80 /* Used as a temporary marker, usually to indicate - this noun is being considered for elimination */ + this noun is being considered for elimination */ @@ -357,7 +357,7 @@ extern void gen_sysmsg(int msgid, const char *s, int context, const char *pword) gives the $pword$ substitution for MSG_PARSE messages */ extern void exec(parse_rec *actor, int vnum, parse_rec *lnoun, - word prep, parse_rec *iobj); + word prep, parse_rec *iobj); extern void set_statline(void); extern void newroom(void); extern void print_descr(descr_ptr dp, rbool nl); @@ -397,32 +397,32 @@ extern void free_creat_fix(void); creatattr(item,attr) -- returns 0 if not creature objattr(item,attr) -- Returns attribute for noun or creature, 0 otherwise anyattr(item,attr) -- Returns attribute for noun, creature, or room, - 0 otherwise. + 0 otherwise. */ #define creatattr2(item,attr,op3) (tcreat(item)? \ - creature[(item)-first_creat].attr:\ - (op3)) + creature[(item)-first_creat].attr:\ + (op3)) #define creatattr(item,attr) creatattr2(item,attr,0) #define nounattr2(item,attr,alt) (tnoun(item)? \ - noun[(item)-first_noun].attr:(alt)) + noun[(item)-first_noun].attr:(alt)) #define nounattr(item,attr) nounattr2(item,attr,0) #define objattr(item,attr) nounattr2(item,attr,creatattr(item,attr)) #define objattr2(item,attr,op3) nounattr2(item,attr,creatattr2(item,attr,op3)) #define roomattr2(item,attr,op3) (troom(item)?\ - room[(item)-first_room].attr:(op3)) + room[(item)-first_room].attr:(op3)) #define anyattr(item,attr) roomattr2(item,attr,objattr(item,attr)) #define it_scratch(item) objattr(item,scratch) #define it_loc(item) objattr2(item,location,\ - (tdoor(item)) ? loc+first_room : 0) + (tdoor(item)) ? loc+first_room : 0) /* -------------------------------------------------------------------- */ /* In RUNVERB.C */ /* -------------------------------------------------------------------- */ extern int check_obj(parse_rec *act, int verbid, - parse_rec *donum, word prep, parse_rec *ionum); + parse_rec *donum, word prep, parse_rec *ionum); /* -------------------------------------------------------------------- */ @@ -442,7 +442,7 @@ extern uchar *getstate(uchar *gs); /* Returns malloc'd block containing game state. */ extern void putstate(uchar *gs); /* Restores games state. */ extern void init_vals(void); /* Compute dependent variables - such as totwt, totsize, etc. */ + such as totwt, totsize, etc. */ extern void restart_game(void); @@ -473,7 +473,7 @@ extern genfile agt_globalfile(int fid); /* When fid=0, return global config file extern rbool agt_option(int optnum, char *optstr[], rbool setflag); /* These have stubs defined in interface.c that would ened to be - commented out if you actually wanted to support these */ + commented out if you actually wanted to support these */ extern void fontcmd(int cmd, int font); /* fontlist[font] */ extern void pictcmd(int cmd, int pict); /* pictlist[pict] or pixlist[pict] */ extern int musiccmd(int cmd, int song); /* songlist[song] */ @@ -522,7 +522,7 @@ extern void agt_newgame(fc_type fc); /* Object manipulation macros */ /* -------------------------------------------------------------------- */ #define objloop(i) for(i=first_noun; i<=maxnoun || i<=maxcreat; \ - (i<=maxnoun || i>=first_creat) ? (i++) : (i=first_creat) ) + (i<=maxnoun || i>=first_creat) ? (i++) : (i=first_creat) ) #define nounloop(i) for(i=0;i<=maxnoun-first_noun;i++) #define creatloop(i) for(i=0;i<=maxcreat-first_creat;i++) diff --git a/engines/glk/agt/metacommand.cpp b/engines/glk/agt/metacommand.cpp index 52b3b9564a4..f4756d91ac1 100644 --- a/engines/glk/agt/metacommand.cpp +++ b/engines/glk/agt/metacommand.cpp @@ -36,12 +36,12 @@ namespace AGT { #define DEBUG_SCAN 1 #define MAX_REDIR 50000L /* Maximum number of redirects, to catch - infinite loops. If this is 0, allow infinitely - many */ + infinite loops. If this is 0, allow infinitely + many */ #define MAX_SUBCALL 2047 /* Maximum number of subroutine calls. - If this is 0, no limit (except for the - program's stack size). */ + If this is 0, no limit (except for the + program's stack size). */ /* @@ -53,13 +53,13 @@ scan_metacommand 2=end of turn (disambig: nothing happened) run_metacommand - 0 to go on to next metacommand, - 1 to stop running metacommands, and - 2 to end the turn. - 3 indicates that redirection has just occured - 4 indicates a subcall has just occured. - 5 to go on to next metacommand after a return has occured. - -2 means we're doing disambiguation and just hit an action token. + 0 to go on to next metacommand, + 1 to stop running metacommands, and + 2 to end the turn. + 3 indicates that redirection has just occured + 4 indicates a subcall has just occured. + 5 to go on to next metacommand after a return has occured. + -2 means we're doing disambiguation and just hit an action token. */ @@ -197,7 +197,7 @@ static rbool argfix(int argtype, int *arg, int optype, rbool *special) { /* is true if "bad" argument is NOUN/OBJECT/etc. and is 0. */ static int argok(const opdef *opdata, int *arg1, int *arg2, int optype, - rbool *grammer_arg) { + rbool *grammer_arg) { if ((opdata->argnum) > 1 && !argfix(opdata->arg2, arg2, optype % 4, grammer_arg)) return 0; if ((opdata->argnum) > 0 && !argfix(opdata->arg1, arg1, optype / 4, grammer_arg)) @@ -284,8 +284,8 @@ static int decode_instr(op_rec *oprec, const integer *data, int maxleng) { case 1159: oprec->endor = 0; break; /* Operations that only affect the stack don't - stop disambiguation, either. They also - don't mark the end of an OR block */ + stop disambiguation, either. They also + don't mark the end of an OR block */ default: /* Aside from the above exceptions, all actions will stop @@ -378,24 +378,24 @@ static rbool decode_args(int ip_, op_rec *oprec) { for maintaining the subcall stack-- scan_metacommand treats a subroutine call just like RedirecTo) */ /* The progression for subroutine calls goes like this: - run_metacommand hits a DoSubroutine token; - the subroutine id is saved in subcall_arg by exec_token. - run_metacommand does push_subcall, saving cnum and ip, - and then returns 4 to scan_metacommand. - scan_metacommand saves grammar state to the new stack entry - with push_subcall and then starts scanning SUBROUTINEnn + run_metacommand hits a DoSubroutine token; + the subroutine id is saved in subcall_arg by exec_token. + run_metacommand does push_subcall, saving cnum and ip, + and then returns 4 to scan_metacommand. + scan_metacommand saves grammar state to the new stack entry + with push_subcall and then starts scanning SUBROUTINEnn - Many tokens are executed. + Many tokens are executed. - run_metacommand hits Return. It sets restart_state and - returns 5 to its parent. - scan_metacommand then runs pop_subcall_grammar and restores - the original scanning grammer. It subtracts one from cnum - so the original cnum will be rerun. - run_metacommand sees that restart_state is set and pops the - rest of the information (cnum and ip) off of the stack. - Things continue as usual. - */ + run_metacommand hits Return. It sets restart_state and + returns 5 to its parent. + scan_metacommand then runs pop_subcall_grammar and restores + the original scanning grammer. It subtracts one from cnum + so the original cnum will be rerun. + run_metacommand sees that restart_state is set and pops the + rest of the information (cnum and ip) off of the stack. + Things continue as usual. + */ @@ -451,7 +451,7 @@ static void pop_subcall(int *rcnum, int *rip, int *rfailaddr) { /* This is called after push_subcall */ static void push_subcall_grammar(int m_actor, int vcode, int m_dobj, word m_prep, - int m_iobj, int cnum) { + int m_iobj, int cnum) { /* run_metacommand should already have pushed cnum on the stack */ substack[subcnt - 1].vb = vb; substack[subcnt - 1].prep = prep; @@ -465,8 +465,8 @@ static void push_subcall_grammar(int m_actor, int vcode, int m_dobj, word m_prep /* Return false if something goes wrong-- such as stack underflow. */ /* This is called *before* pop_subcall */ static rbool pop_subcall_grammar(integer *m_actor, int *vcode, - integer *m_dobj, word *m_prep, integer *m_iobj, - int *cnum) { + integer *m_dobj, word *m_prep, integer *m_iobj, + int *cnum) { if (subcnt == 0) return 0; vb = substack[subcnt - 1].vb; prep = substack[subcnt - 1].prep; @@ -490,23 +490,23 @@ static int run_metacommand(int cnum, int *redir_offset) /* cnum=command number to run. */ /* *redir_offset=offset of redirect header, if we exit with redirection. */ /* Return - 0 to go on to next metacommand, - 1 to stop running metacommands, and - 2 to end the turn. - 3 indicates that redirection has just occured - 4 indicates a subcall has just occured. - 5 Is used to go on to the next metacommand after a Return. - -2 means we're doing disambiguation and just hit an action token. */ + 0 to go on to next metacommand, + 1 to stop running metacommands, and + 2 to end the turn. + 3 indicates that redirection has just occured + 4 indicates a subcall has just occured. + 5 Is used to go on to the next metacommand after a Return. + -2 means we're doing disambiguation and just hit an action token. */ { int ip_, oip; /* ip_=Instruction pointer, oip=Old instruction pointer */ int r; /* Used to hold return value from token execution */ int fail_addr; /* What address to jump to on failure */ rbool fail; /* Last token was a conditional token that failed */ rbool ortrue, blocktrue, orflag; /* OR stuff - orflag: Are we in an OR group? - ortrue: Is current OR group true? - blocktrue: Is current block w/in OR true? - */ + orflag: Are we in an OR group? + ortrue: Is current OR group true? + blocktrue: Is current block w/in OR true? + */ static rbool restart = 0; /* Restarting after subroutine? */ op_rec currop; /* Information on the current token and its args */ @@ -515,7 +515,7 @@ static int run_metacommand(int cnum, int *redir_offset) ip_ = 0; orflag = blocktrue = ortrue = 0; *redir_offset = 1; /* Default: This is what RedirectTo does. - Only XRedirect can send a different value */ + Only XRedirect can send a different value */ if (restart) /* finish up Return from subroutine */ @@ -576,7 +576,7 @@ static int run_metacommand(int cnum, int *redir_offset) ip_ = fail_addr; fail_addr = 32000; /* Reset fail_addr */ continue; /* Usually fail_addr will fall off the end, causing this to - return 0 */ + return 0 */ } /* - Finish decoding arguments and print out debugging message - */ @@ -734,8 +734,8 @@ static int extract_obj(word name, word adj) { the header */ static void fix_objnum(integer *objnum, word match, - int real_obj, - int actor_, int dobj_, int iobj_) { + int real_obj, + int actor_, int dobj_, int iobj_) { if (real_obj) *objnum = real_obj; else if (match == ext_code[wdobject]) *objnum = iobj_; else if (match == ext_code[wdnoun]) *objnum = dobj_; @@ -745,9 +745,9 @@ static void fix_objnum(integer *objnum, word match, /* Returns TRUE if we changed *objrec, FALSE otherwise */ /* (This is needed for memory allocation purposes) */ static rbool fix_objrec(parse_rec **objrec, word match, - int real_obj, - parse_rec *actrec, parse_rec *dobjrec, - parse_rec *iobjrec) { + int real_obj, + parse_rec *actrec, parse_rec *dobjrec, + parse_rec *iobjrec) { if (real_obj) *objrec = make_parserec(real_obj, NULL); else if (match == ext_code[wdobject]) *objrec = copy_parserec(iobjrec); else if (match == ext_code[wdnoun]) *objrec = copy_parserec(dobjrec); @@ -806,7 +806,7 @@ static void objcode_fix(cmd_rec *cmd) /* NOUN or OBJECT */ void redirect_exec(cmd_rec *cmd, word *m_actor, int *vcode, - word *m_dobj, word *m_prep, word *m_iobj) { + word *m_dobj, word *m_prep, word *m_iobj) { *m_actor = extract_actor(cmd->actor); vb = *vcode = verb_code(it_name(expand_redirect(cmd->verbcmd))); *m_dobj = extract_obj(cmd->nouncmd, cmd->noun_adj); @@ -860,7 +860,7 @@ static rbool cm_x_obj(int x_obj, int real_obj) { /* Does [obj] match [x_obj]? */ /* --[obj] must match up with */ /* --If x_obj(the explicit object) is defined, it must match with - the "real" object-- that is, the global dobj or iobj value. */ + the "real" object-- that is, the global dobj or iobj value. */ static rbool cm_obj(word name, word adj, int x_obj, int obj, int real_obj) { if (name == -1) return (obj == 0); /* */ @@ -917,7 +917,7 @@ static rbool redir_narrows_grammar(cmd_rec *cmd1, cmd_rec *cmd2) { } } if (nomatch_aware) return 0; /* If we are using nomatch, don't need - to go through the rest of this nonsense. */ + to go through the rest of this nonsense. */ if (not_any(cmd2->objcmd, cmd2->obj_adj)) return 0; if (not_any(cmd1->objcmd, cmd1->obj_adj)) return 1; @@ -934,8 +934,8 @@ static rbool redir_narrows_grammar(cmd_rec *cmd1, cmd_rec *cmd2) { static rbool cm_command(cmd_rec *cmd, - integer m_actor, int m_verb, - integer m_dobj, word m_prep, integer m_iobj) { + integer m_actor, int m_verb, + integer m_dobj, word m_prep, integer m_iobj) { if (cmd->verbcmd == 0) { /* ANY */ if (cmd->actor == 0 && aver >= AGX00) return (m_verb == 0); /* ANY command: rest of line ignored */ @@ -983,8 +983,8 @@ static void scan_for_actor(integer m_actor, int *start, int *end) { connection to dobj, iobj, etc. */ int scan_metacommand(integer m_actor, int vcode, - integer m_dobj, word m_prep, integer m_iobj, - int *redir_flag) + integer m_dobj, word m_prep, integer m_iobj, + int *redir_flag) /* Return codes: 0=end of this cycle, 1=end of all commands 2=end of turn */ /* If doing disambiguation, then -2=end of cycle, something happened; @@ -997,16 +997,16 @@ int scan_metacommand(integer m_actor, int vcode, word m_verb; int scanend; int redir_offset; /* Used for multiple redirects in the same - metacommand (which can occur in AGATE-style - commands)-- this is used to hold the offset - of the given redirect. */ + metacommand (which can occur in AGATE-style + commands)-- this is used to hold the offset + of the given redirect. */ long redirect_count; /* This is a safety measure: this keeps track of how - many redirections have occured on a single turn, and - if there are "too many" it will issue an error message - and stop. This is to prevent the system from getting - into a redirection loop. The number should be set - high enough not to prevent deliberate loops, - however. */ + many redirections have occured on a single turn, and + if there are "too many" it will issue an error message + and stop. This is to prevent the system from getting + into a redirection loop. The number should be set + high enough not to prevent deliberate loops, + however. */ rfree(substack); subcnt = 0; @@ -1095,7 +1095,7 @@ int scan_metacommand(integer m_actor, int vcode, scanend = verbend[vcode]; } i--; /* Back up one so that the following i++ we'll - be at the right location */ + be at the right location */ } /* So when i is incremented, we start back at the correct start: i.e. @@ -1109,7 +1109,7 @@ int scan_metacommand(integer m_actor, int vcode, /* -------- SUBROUTINE CALL ------------ */ case 4: /* Subroutine Call -- same idea as RedirectTo, - but less complicated */ + but less complicated */ push_subcall_grammar(m_actor, vcode, m_dobj, m_prep, m_iobj, i); vcode = verb_code(sub_name[subcall_arg - 1]); m_actor = m_dobj = m_iobj = 0; @@ -1138,8 +1138,8 @@ int scan_metacommand(integer m_actor, int vcode, m_verb = syntbl[auxsyn[vcode]]; i--; /* Cause the last command to restart, - at which point run_command will pop the rest of the - stack. */ + at which point run_command will pop the rest of the + stack. */ break; } diff --git a/engines/glk/agt/object.cpp b/engines/glk/agt/object.cpp index 7095e1a54cb..ee26258264d 100644 --- a/engines/glk/agt/object.cpp +++ b/engines/glk/agt/object.cpp @@ -268,7 +268,7 @@ void it_reposition(int item, int newloc, rbool save_pos) { winflag = 1; } if (it_loc(item) == 1) /* only things you are carrying directly count vs. - size limit. */ + size limit. */ totsize += noun[item - first_noun].size; } else if (tcreat(item)) { if (newloc == 0) { @@ -832,7 +832,7 @@ static int print_obj(int obj, int ind_lev) /* Return 1 if we actually printed something, 0 if obj is invisible */ { int sdesc_flag; /* True if should print out as sdesc rather than - as adjective-noun */ + as adjective-noun */ int i, retval, parent; const char *s; char *t, *s0, *posstr; @@ -843,8 +843,8 @@ static int print_obj(int obj, int ind_lev) s0 = NULL; sdesc_flag = !player_has(obj); /* This should be tested. */ sdesc_flag = sdesc_flag || (ind_lev > 1); /* It seems that AGT uses the - sdesc for describing items - contained in other items */ + sdesc for describing items + contained in other items */ /* Some code below relies on this, as well */ if (sdesc_flag) diff --git a/engines/glk/agt/os_glk.cpp b/engines/glk/agt/os_glk.cpp index 57e9b114511..157a7ba378e 100644 --- a/engines/glk/agt/os_glk.cpp +++ b/engines/glk/agt/os_glk.cpp @@ -72,8 +72,8 @@ static const glui32 GAGT_PORT_VERSION = 0x00010701; /* Forward declaration of event wait functions. */ static void gagt_event_wait(glui32 wait_type, event_t *event); static void gagt_event_wait_2(glui32 wait_type_1, - glui32 wait_type_2, - event_t *event); + glui32 wait_type_2, + event_t *event); /* * Forward declaration of the g_vm->glk_exit() wrapper. Normal functions in this @@ -661,7 +661,7 @@ static void gagt_iso_to_cp(const unsigned char *from_string, unsigned char *to_s * status buffer printed for non-windowing Glk libraries, for comparison. */ static char *gagt_status_buffer = NULL, - *gagt_status_buffer_printed = NULL; + *gagt_status_buffer_printed = NULL; /* * Indication that we are in mid-delay. The delay is silent, and can look @@ -978,8 +978,8 @@ struct gagt_attrset_t { * correspond to AGT_NORMAL. */ static gagt_attrset_t gagt_current_attribute_set = { AGT_WHITE, FALSE, - FALSE, FALSE - }; + FALSE, FALSE + }; /* * An extra flag to indicate if we have coerced fixed font override. On @@ -996,9 +996,9 @@ static int gagt_coerced_fixed = FALSE; * attributes. */ static const unsigned char GAGT_COLOR_MASK = 0x0f, - GAGT_BLINK_MASK = 1 << 4, - GAGT_FIXED_MASK = 1 << 5, - GAGT_EMPHASIS_MASK = 1 << 6; + GAGT_BLINK_MASK = 1 << 4, + GAGT_FIXED_MASK = 1 << 5, + GAGT_EMPHASIS_MASK = 1 << 6; /* Forward declaration of message function. */ static void gagt_standout_string(const char *message); @@ -1438,7 +1438,7 @@ struct gagt_line_s { * lines, with a tail pointer to facilitate adding entries at the end. */ static gagt_lineref_t gagt_page_head = NULL, - gagt_page_tail = NULL; + gagt_page_tail = NULL; /* * Definition of the current output line; this one is appended to on @@ -1454,7 +1454,7 @@ static gagt_string_t gagt_current_buffer = { NULL, NULL, 0, 0 }; * String append, move, and allocation free for string_t buffers. */ static void gagt_string_append(gagt_stringref_t buffer, const char *string, - unsigned char packed_attributes) { + unsigned char packed_attributes) { int length, bytes; /* @@ -1741,7 +1741,7 @@ struct gagt_paragraph_s { * adding entries at the end. */ static gagt_paragraphref_t gagt_paragraphs_head = NULL, - gagt_paragraphs_tail = NULL; + gagt_paragraphs_tail = NULL; /* * gagt_paragraphs_delete() @@ -2090,7 +2090,7 @@ static int gagt_get_paragraph_line_count(const gagt_paragraphref_t paragraph) { * characters that appear together multiple times in non-table text). */ static const int GAGT_THRESHOLD = 4, - GAGT_COMMON_THRESHOLD = 8; + GAGT_COMMON_THRESHOLD = 8; static const char *const GAGT_COMMON_PUNCTUATION = ".!?"; @@ -2733,7 +2733,7 @@ static int gagt_compare_special_line(const char *compare, const gagt_lineref_t l } static int gagt_compare_special_paragraph(const gagt_specialref_t special, - const gagt_paragraphref_t paragraph) { + const gagt_paragraphref_t paragraph) { /* If the line counts match, compare line by line. */ if (special->line_count == gagt_get_paragraph_line_count(paragraph)) { gagt_lineref_t line; @@ -2903,7 +2903,7 @@ static glui32 gagt_display_special(const gagt_specialref_t special, glui32 curre * been silenced as a result of already using a Glk command. */ static int gagt_help_requested = FALSE, - gagt_help_hints_silenced = FALSE; + gagt_help_hints_silenced = FALSE; /* * gagt_display_register_help_request() @@ -2945,7 +2945,7 @@ static glui32 gagt_display_provide_help_hint(glui32 current_style) { * The function handles a flag to coerce fixed width font. */ static glui32 gagt_display_text_element(const char *string, const unsigned char *attributes, - int length, glui32 current_style, int fixed_width) { + int length, glui32 current_style, int fixed_width) { int marker, index; glui32 set_style; assert(g_vm->glk_stream_get_current()); @@ -3004,8 +3004,8 @@ static glui32 gagt_display_text_element(const char *string, const unsigned char * trailing whitespace). */ static glui32 gagt_display_line(const gagt_lineref_t line, glui32 current_style, - int fixed_width, int skip_indent, int skip_outdent, - int trim_hyphen) { + int fixed_width, int skip_indent, int skip_outdent, + int trim_hyphen) { int start, length; glui32 set_style; @@ -3044,7 +3044,7 @@ static glui32 gagt_display_line(const gagt_lineref_t line, glui32 current_style, * from the line, and receives the font hint of the prior line. */ static glui32 gagt_display_hinted_line(const gagt_lineref_t line, glui32 current_style, - gagt_font_hint_t prior_hint) { + gagt_font_hint_t prior_hint) { glui32 style; style = current_style; @@ -3513,9 +3513,9 @@ static void gagt_delay_resume() { /* Saved details of any current box dimensions and flags. */ static unsigned long gagt_box_flags = 0; static int gagt_box_busy = FALSE, - gagt_box_width = 0, - gagt_box_height = 0, - gagt_box_startx = 0; + gagt_box_width = 0, + gagt_box_height = 0, + gagt_box_startx = 0; /* @@ -5000,8 +5000,8 @@ static int gagt_event_in_glk_select() { * use with Glk libraries that don't support separate windows. */ static const int GAGT_DEFAULT_SCREEN_WIDTH = 80, - GAGT_DEFAULT_SCREEN_HEIGHT = 25, - GAGT_DEFAULT_STATUS_WIDTH = 76; + GAGT_DEFAULT_SCREEN_HEIGHT = 25, + GAGT_DEFAULT_STATUS_WIDTH = 76; /* @@ -5597,7 +5597,7 @@ static void gagt_main() { * we only get a call to main once. */ static int gagt_startup_called = FALSE, - gagt_main_called = FALSE; + gagt_main_called = FALSE; /* * We try to catch calls to exit() from the interpreter, and redirect them diff --git a/engines/glk/agt/parser.cpp b/engines/glk/agt/parser.cpp index 72bb9eaa7b5..cb873660044 100644 --- a/engines/glk/agt/parser.cpp +++ b/engines/glk/agt/parser.cpp @@ -67,9 +67,9 @@ disambiguation info?) 1=ambig actor, 2=ambig noun, /* Empty ALL error messages, for those verbs that have their own */ int all_err_msg[] = {73, 83, 113, 103, /* open, close, lock, unlock: 15 - 18 */ - 239, 239, 239, 239, /* 19 - 22 */ - 123, 125 - }; /* eat, drink: 23 - 24 */ + 239, 239, 239, 239, /* 19 - 22 */ + 123, 125 + }; /* eat, drink: 23 - 24 */ @@ -133,7 +133,7 @@ static void print_nlist(parse_rec *n) { /* Output the parser's analysis of the current input line; used for debugging */ static int parse_out(parse_rec *lactor_, int vb_, parse_rec *lnoun_, int prep_, - parse_rec *lobj_) { + parse_rec *lobj_) { writeln("ANALYSIS:"); writestr("Actor: "); print_nlist(lactor_); @@ -181,7 +181,7 @@ static void restore_input(void) { #define w_and(w) (w==ext_code[wand] || w==ext_code[wc]) #define w_but(w) (w==ext_code[wbut] || w==ext_code[wexcept]) #define w_isterm(w) (w==ext_code[wp] || w==ext_code[wthen] || \ - w==ext_code[wsc] || w_and(w) || w==-1) + w==ext_code[wsc] || w_and(w) || w==-1) @@ -248,14 +248,14 @@ static rbool orig_agt_verb(word w) { /* A few comments on id_verb: The sequence is as follows: - i) Convert built-in synonyms to the base form (TAKE-->GET, for example) - _unless_ there is an author-defined synonym. (The original AGT - didn't have this 'unless'.) - ii) Check room-synonyms - iii) ID the verb based first on game-specific synonyms and then - falling back to the built-in ones. - (AGT gave the built-in ones higher priority than the game-specific - ones, but this causes problems and is generally a bad idea.) + i) Convert built-in synonyms to the base form (TAKE-->GET, for example) + _unless_ there is an author-defined synonym. (The original AGT + didn't have this 'unless'.) + ii) Check room-synonyms + iii) ID the verb based first on game-specific synonyms and then + falling back to the built-in ones. + (AGT gave the built-in ones higher priority than the game-specific + ones, but this causes problems and is generally a bad idea.) */ static int id_verb(void) @@ -371,7 +371,7 @@ static parse_rec *new_list(void) { } static parse_rec *add_w_rec(parse_rec *pold, int obj0, long num0, int info0, - word adj0, word noun0) { + word adj0, word noun0) { parse_rec *pnew; int n; @@ -391,7 +391,7 @@ static parse_rec *add_rec(parse_rec *old, int obj0, long num0, int info0) { word w; if (obj0 < 0) w = -obj0; /* The NOUN field of literal words will just be - that word */ + that word */ else w = 0; return add_w_rec(old, obj0, num0, info0, 0, w); } @@ -606,7 +606,7 @@ static parse_rec *convert_to_all(parse_rec *list, int *ofsref) { static parse_rec *add_disambig_info(parse_rec *ilist, int ofs, - parse_rec *truenoun) + parse_rec *truenoun) /* Basically, try to find interesection of tmp and truenoun, or failing that, between ilist and truenoun */ /* truenoun is what the player just typed in to resolve @@ -714,11 +714,11 @@ static parse_rec *expand_all(parse_rec *lnoun_) { /* disambig check checks for the various things that can eliminate a noun - from the list. The higher dlev is, the more things that are bad */ + from the list. The higher dlev is, the more things that are bad */ /* Returns 1 if we should keep it, 0 if we should kill it */ /* The elimination order is based on AGT: 0-Eliminate adjective matches if PURE_NOUN is set and - out-of-scope adjectives that are not at the head of the list. + out-of-scope adjectives that are not at the head of the list. 1-Eliminate adj matches if the adjective is out-of-scope. 2-eliminate SCENE and DOOR (D_INTERN) 3-eliminate out-of-scope nouns that are not at the head of the list @@ -741,7 +741,7 @@ static parse_rec *expand_all(parse_rec *lnoun_) { are visible, we don't want to ask disambiguation questions) */ static rbool disambig_check(parse_rec *rec, int dsch, int dlev, - int ambig_type, rbool pick_one) { + int ambig_type, rbool pick_one) { switch (dsch) { case 0: switch (dlev) { /* Syntactic checks: pre-scope */ @@ -751,7 +751,7 @@ static rbool disambig_check(parse_rec *rec, int dsch, int dlev, return (rec->info != D_INTERN); /* Elim SCENE and DOOR */ case 2: return (rec->info != D_NUM || rec->obj != 0); /* Eliminate numbers w/o - corrosponding word matches */ + corrosponding word matches */ default: return 0; } @@ -807,20 +807,20 @@ static parse_rec *disambig_a_noun(parse_rec *list, int ofs, int ambig_type) { int i, cnt; /* cnt keeps track of how many nouns we've let through */ int dsch; /* Dismabiguation scheme; we run through these in turn, - pushing dlev as high as possible for each scheme */ + pushing dlev as high as possible for each scheme */ int dlev; /* Disambiguation level: how picky do we want to be? - We keep raising this until we get a unique choice - or until we reach MAX_DLEV and have to give up */ + We keep raising this until we get a unique choice + or until we reach MAX_DLEV and have to give up */ rbool one_in_scope; /* True if at least one noun is visible; if no nouns - are visible then we never ask for disambiguation - from the player (to avoid giving things away) but - just take the first one. */ + are visible then we never ask for disambiguation + from the player (to avoid giving things away) but + just take the first one. */ cnt = 2; /* Arbitrary number > 1 */ one_in_scope = 0; max_disambig_score = -1000; /* Nothing built in returns anything lower than 0, - but some game author might come up with a - clever application of negative scores */ + but some game author might come up with a + clever application of negative scores */ for (dsch = 0; dsch <= MAX_DSCHEME; dsch++) for (dlev = 0; dlev <= MAX_DLEV; dlev++) { if (DEBUG_DISAMBIG) @@ -876,7 +876,7 @@ static parse_rec *disambig_a_noun(parse_rec *list, int ofs, int ambig_type) static int disambig_phrase(parse_rec **ilist, parse_rec *truenoun, int tn_ofs, - int ambig_type) + int ambig_type) /* Note that ilist is double dereferenced: this is so we can realloc it */ /* ambig_type=1 for actor, 2 for noun, 3 for object */ /* We can assume that the earlier bits have already been disambiguated */ @@ -972,10 +972,10 @@ static parse_rec *disambig(int ambig_set, parse_rec *list, parse_rec *truenoun) /* Leave ip pointing _after_ last word we get. */ /* Return list of all possible objects */ /* Go to some difficullty to make sure "all the kings men" will - not be accidentally parsed as "all" + "the kings men" */ + not be accidentally parsed as "all" + "the kings men" */ /* (Yes, yes, I know -- you can't have an AGT object with a name as - complex as 'all the king's men'-- but you could try to simulate it using - synonyms) */ + complex as 'all the king's men'-- but you could try to simulate it using + synonyms) */ /* May also want to use more intellegence along the adj--noun distinction */ /* all_ok indicates whether ALL is acceptable */ @@ -1132,7 +1132,7 @@ resolving disambiguation) */ if (lnoun_[0].info == D_ALL && w_but(input[ip])) /* ALL EXCEPT ... */ all_except = 1; /* This will cause us to skip over EXCEPT and - start creating an AND list */ + start creating an AND list */ /* Now, itereate over AND AND ... */ while ((all_except || w_and(input[ip])) && @@ -1182,9 +1182,9 @@ static int parse_cmd(void) /* Needs to leave ip pointing at beginning of next statement */ { rbool new_actor; /* This is used for some error checking; it is set - if we just found an actor on this command - (as opposed to inheriting one from a previous - command in a multiple statement) */ + if we just found an actor on this command + (as opposed to inheriting one from a previous + command in a multiple statement) */ parse_rec *tmp; int tp; @@ -1202,7 +1202,7 @@ static int parse_cmd(void) if (input[ip] == ext_code[wc]) /* ie there is a comma */ return parseerr(229, "Who is this '$word$' you are addressing?", ap); else ip = ap; /* Otherwise, assume we shouldn't have parsed it as - an actor-- it may be a verb. */ + an actor-- it may be a verb. */ } } if (lactor[0].info != D_END && input[ip] == ext_code[wc]) @@ -1225,7 +1225,7 @@ static int parse_cmd(void) } TELLHack: /* This is used to restart the noun/prep/object scan - if we find a TELL TO ... command */ + if we find a TELL TO ... command */ if (vnum == 0) return parseerr(230, "I don't understand '$word$' as a verb.", ip); @@ -1256,7 +1256,7 @@ TELLHack: /* This is used to restart the noun/prep/object scan vp = ip; /* Replace TELL with new verb */ vnum = id_verb(); /* May increment ip (ip points att last word in verb) */ goto TELLHack; /* Go back up and reparse the sentence from - the new start point. */ + the new start point. */ } /* Convert TURN ON to TURN ON */ diff --git a/engines/glk/agt/runverb.cpp b/engines/glk/agt/runverb.cpp index b5e1afcc81a..e043a40f382 100644 --- a/engines/glk/agt/runverb.cpp +++ b/engines/glk/agt/runverb.cpp @@ -31,7 +31,7 @@ namespace AGT { This file contains several things: i) The code for each of the built-in verbs, all prefixed with 'v_' - (so, for example, the code for DROP is in v_drop()). + (so, for example, the code for DROP is in v_drop()). ii) The main routine for checking and running player commands. iii) The main routine for doing intelligent disambiguation. @@ -398,8 +398,8 @@ static int v_remove(parse_rec *objrec) { parse_rec tmp; if (PURE_WEAR) drop_obj(i); else it_move(i, 1); /* Really need to check to make sure - we haven't exceeded weight requirement - here */ + we haven't exceeded weight requirement + here */ make_parserec(i, &tmp); sysmsgd(9, "$You$ take off $the_n$$noun$.", &tmp); } @@ -796,7 +796,7 @@ static void v_attack(uchar missile, parse_rec *targrec, parse_rec *weprec) { /* child_proc is true if v_put is being called by v_put, and so shouldn't print success messages */ static rbool v_put(parse_rec *nounrec, word prep_, - parse_rec *objrec, rbool child_proc) { + parse_rec *objrec, rbool child_proc) { rbool in_prep; int dobj_, iobj_; @@ -976,9 +976,9 @@ static void v_quit(void) { } const char dirname[12][10] = {"north", "south", "east", "west", - "northeast", "northwest", "southeast", "southwest", - "up", "down", "in", "out" - }; + "northeast", "northwest", "southeast", "southwest", + "up", "down", "in", "out" + }; void v_listexit(void) { int i, j, k; @@ -1069,7 +1069,7 @@ static int checkgram(int vb_, int dobj_, word prep_, int iobj_, rbool redir_flag /* This checks to make sure that all of the objects are present */ static rbool verify_scope(int vb_, parse_rec *nounrec, - word prep_, parse_rec *objrec) { + word prep_, parse_rec *objrec) { int msgnum; int dobj_, iobj_; dobj_ = nounrec->obj; @@ -1522,15 +1522,15 @@ void exec_verb(void) { /* If obj==0, then we are doing a noun search, otherwise we are doing an object search */ /* Return the disambiguation score; - 0 if the object doesn't trigger anything - 1000 if it runs an action token or built in verb. - Other values may be returned if an ErrMessage token is encountered. - 500 is the cutoff for ALL expansion. + 0 if the object doesn't trigger anything + 1000 if it runs an action token or built in verb. + Other values may be returned if an ErrMessage token is encountered. + 500 is the cutoff for ALL expansion. */ int objcheck_cycle(rbool *success, parse_rec *act, int verbid, - parse_rec *dorec, word prep_, parse_rec *iorec) { + parse_rec *dorec, word prep_, parse_rec *iorec) { int result; actor = act->obj; @@ -1570,7 +1570,7 @@ int objcheck_cycle(rbool *success, parse_rec *act, int verbid, case 0: case 1: break; /* Nothing matched, but we still need to check - built-in verbs */ + built-in verbs */ case 2: free_all_parserec(); return disambig_score; /* End of turn, no match */ @@ -1585,7 +1585,7 @@ int objcheck_cycle(rbool *success, parse_rec *act, int verbid, int check_obj(parse_rec *act, int verbid, - parse_rec *dorec, word prep_, parse_rec *iorec) { + parse_rec *dorec, word prep_, parse_rec *iorec) { int result; rbool success; diff --git a/engines/glk/agt/savegame.cpp b/engines/glk/agt/savegame.cpp index 65c4ed9c956..062706444cf 100644 --- a/engines/glk/agt/savegame.cpp +++ b/engines/glk/agt/savegame.cpp @@ -182,7 +182,7 @@ uchar *getstate(uchar *gs) gs[5] = (game_sig >> 8) & 0xFF; tscore -= objscore; /* Only include "permanent" part of score; - objscore we can recompute on RESTORE */ + objscore we can recompute on RESTORE */ /* Need to setup here */ set_internal_buffer(gs); @@ -237,7 +237,7 @@ void putstate(uchar *gs) { /* Restores games state. */ " Klaustrophobia"); if (yesno("?")) skip_descr = 1; /* We don't want to overwrite the descriptions - with the pointers from the save file. */ + with the pointers from the save file. */ else { writestr("Do you want to try using it anyhow (WARNING: This could" " crash the interpreter)"); diff --git a/engines/glk/agt/token.cpp b/engines/glk/agt/token.cpp index db5b9ba75d9..84619fc3305 100644 --- a/engines/glk/agt/token.cpp +++ b/engines/glk/agt/token.cpp @@ -249,13 +249,13 @@ void print_tos(void) { #define cretn(i,f) cret(tnoun(i) && noun[i-first_noun].f) #define cretc(i,f) cret(tcreat(i) && creature[i-first_creat].f) #define icretc(f) cret(do_disambig==1 || \ - (tcreat(iobj) && creature[iobj-first_creat].f)) + (tcreat(iobj) && creature[iobj-first_creat].f)) static int obj_cond(int op_, int obj, int arg) { switch (op_) { case 0: cret(in_scope(obj)); /* Present-- - Do we want to use visible here?? */ + Do we want to use visible here?? */ case 1: cret(is_within(obj, 1000, 1)); /* IsWearing */ case 2: diff --git a/engines/glk/agt/util.cpp b/engines/glk/agt/util.cpp index 892a3085bee..7ab7ac95bb0 100644 --- a/engines/glk/agt/util.cpp +++ b/engines/glk/agt/util.cpp @@ -28,13 +28,13 @@ namespace Glk { namespace AGT { /* This includes wrappers for malloc, realloc, strdup, and free - that exit gracefully if we run out of memory. */ + that exit gracefully if we run out of memory. */ /* There are also various utilities: - concdup: Creates a new string that is concatation of two others. - strcasecmp: case insensitive comparison of strings - strncasecmp: case insensitive compare of first n characters of strings - fixsign16, fixsign32: routines to assemble signed ints out of - individual bytes in an endian-free way. */ + concdup: Creates a new string that is concatation of two others. + strcasecmp: case insensitive comparison of strings + strncasecmp: case insensitive compare of first n characters of strings + fixsign16, fixsign32: routines to assemble signed ints out of + individual bytes in an endian-free way. */ /* Also buffered file i/o routines and some misc. file utilites. */ #ifdef force16 @@ -422,8 +422,8 @@ genfile openbin(fc_type fc, filetype ext, const char *err, rbool ferr) It should work with files that have \n, \r, or \r\n termined lines. */ #define READLN_GRAIN 64 /* Granularity of readln() rrealloc requests - this needs to be at least the size of a tab - character */ + this needs to be at least the size of a tab + character */ #define DOS_EOF 26 /* Ctrl-Z is the DOS end-of-file marker */ char *readln(genfile f, char *buff, int n) @@ -512,9 +512,9 @@ static long real_buff_fcnt; /* Number of records actually held in buffer */ static long buff_rsize; /* Minimum amount that must be read. */ static long block_size; /* Size of the current block - (for non-AGX files, this is just the filesize) */ + (for non-AGX files, this is just the filesize) */ static long block_offset; /* Offset of current block in file (this should - be zero for non-AGX files) */ + be zero for non-AGX files) */ static void buff_setrecsize(long recsize) { @@ -552,7 +552,7 @@ buffreopen will be called before any major file activity const char *errstr; assert(buffer == NULL); /* If not, it means these routines have been - called by someone else who isn't done yet */ + called by someone else who isn't done yet */ bfile = readopen(fc, ext, &errstr); if (errstr != NULL) { @@ -616,7 +616,7 @@ uchar *buffread(long index) { else { binseek(bfile, block_offset + index * record_size); real_buff_fcnt = block_size / record_size - index; /* How many records - could we read in? */ + could we read in? */ if (real_buff_fcnt > buff_fcnt) real_buff_fcnt = buff_fcnt; /* Don't overflow buffer */ if (!binread(bfile, buffer, record_size, real_buff_fcnt, &errstr)) @@ -639,7 +639,7 @@ void buffclose(void) { file so we can read files that consist of multiple sections with different structures */ static void buffreopen(long f_ofs, long file_recsize, long recnum, - long bl_size, const char *rectype) { + long bl_size, const char *rectype) { char ebuff[200]; long recsize; @@ -687,9 +687,9 @@ static void buffreopen(long f_ofs, long file_recsize, long recnum, /* #define DEBUG_SEEK*/ /* Debug seek beyond EOF problem */ static long bw_first, bw_last; /* First and last record in buffer written to. - This is relative to the beginning of the - buffer bw_last points just beyond the last - one written to */ + This is relative to the beginning of the + buffer bw_last points just beyond the last + one written to */ #ifdef DEBUG_SEEK static long bw_fileleng; /* Current file length */ #endif /* DEBUG_SEEK */ @@ -849,14 +849,14 @@ static void bw_blockwrite(void *buff, long size, long offset) { /* Length of file datatypes */ const size_t ft_leng[FT_COUNT] = {0, 2, 2, /* END, int16, and uint16 */ - 4, 4, /* int32 and uint32 */ - 1, 2, 0, /* byte, version, rbool */ - 8, 4, /* descptr, ss_ptr */ - 2, 26, /* slist, path[13] */ - 4, 4, /* cmdptr, dictptr */ - 81, /* tline */ - 1, 1 - }; /* char, cfg */ + 4, 4, /* int32 and uint32 */ + 1, 2, 0, /* byte, version, rbool */ + 8, 4, /* descptr, ss_ptr */ + 2, 26, /* slist, path[13] */ + 4, 4, /* cmdptr, dictptr */ + 81, /* tline */ + 1, 1 + }; /* char, cfg */ long compute_recsize(file_info *recinfo) { @@ -874,8 +874,8 @@ long compute_recsize(file_info *recinfo) { } static const int agx_version[] = {0, 0000, 1800, 2000, 3200, 3500, 8200, 8300, - 5000, 5050, 5070, 10000, 10050, 15000, 15500, 16000, 20000 - }; + 5000, 5050, 5070, 10000, 10050, 15000, 15500, 16000, 20000 + }; static int agx_decode_version(int vercode) { if (vercode & 1) /* Large/Soggy */ @@ -935,17 +935,17 @@ static int agx_decode_version(int vercode) { /* This is as large as the largest data structure we could run into */ static const uchar zero_block[81] = {0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0 - }; + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0 + }; static void read_filerec(file_info *rec_desc, const uchar *filedata) { uchar mask; @@ -1184,8 +1184,8 @@ static void write_filerec(file_info *rec_desc, uchar *filedata) { file_offset = the offset of the beginning of the array into the file */ void *read_recarray(void *base, long eltsize, long numelts, - file_info *field_info, const char *rectype, - long file_offset, long file_blocksize) { + file_info *field_info, const char *rectype, + long file_offset, long file_blocksize) { long i; file_info *curr; uchar *file_data; @@ -1228,7 +1228,7 @@ void *read_recarray(void *base, long eltsize, long numelts, a placeholder for systems that can't seek beyond the end-of-file */ long write_recarray(void *base, long eltsize, long numelts, - file_info *field_info, long file_offset) { + file_info *field_info, long file_offset) { long i; file_info *curr; uchar *file_data; @@ -1266,7 +1266,7 @@ long write_recarray(void *base, long eltsize, long numelts, void read_globalrec(file_info *global_info, const char *rectype, - long file_offset, long file_blocksize) { + long file_offset, long file_blocksize) { uchar *file_data; if (int_buff) { @@ -1305,7 +1305,7 @@ static file_info fi_temp[] = { /* This routine reads in an array of simple data */ void *read_recblock(void *base, int ftype, long numrec, - long offset, long bl_size) { + long offset, long bl_size) { int dsize; switch (ftype) { @@ -1336,7 +1336,7 @@ void *read_recblock(void *base, int ftype, long numrec, default: fatal("Invalid argument to read_recblock."); dsize = 0; /* Silence compiler warnings; this will never actually - be reached. */ + be reached. */ } fi_temp[0].ftype = ftype; @@ -1374,7 +1374,7 @@ long write_recblock(void *base, int ftype, long numrec, long offset) { default: fatal("Invalid argument to write_recblock."); dsize = 0; /* Silence compiler warnings; this will never actually - be reached. */ + be reached. */ } fi_temp[0].ftype = ftype; diff --git a/engines/glk/alan2/debug.cpp b/engines/glk/alan2/debug.cpp index b819eba54fb..e8cf1fa5de1 100644 --- a/engines/glk/alan2/debug.cpp +++ b/engines/glk/alan2/debug.cpp @@ -302,16 +302,16 @@ void debug() { case '?': output(alan.longHeader); output("$nABUG Commands:\ - $iO [n] -- show object[s]\ - $iA [n] -- show actor[s]\ - $iL [n] -- show location[s]\ - $iC [n] -- show container[s]\ - $iE -- show events\ - $iG -- go on\ - $iT -- toggle trace mode\ - $iS -- toggle step mode\ - $iX -- exit debug mode\ - $iQ -- quit game"); + $iO [n] -- show object[s]\ + $iA [n] -- show actor[s]\ + $iL [n] -- show location[s]\ + $iC [n] -- show container[s]\ + $iE -- show events\ + $iG -- go on\ + $iT -- toggle trace mode\ + $iS -- toggle step mode\ + $iX -- exit debug mode\ + $iQ -- quit game"); break; case 'Q': { Context ctx; diff --git a/engines/glk/alan2/exe.cpp b/engines/glk/alan2/exe.cpp index 284556c279e..0053f68a4c4 100644 --- a/engines/glk/alan2/exe.cpp +++ b/engines/glk/alan2/exe.cpp @@ -248,8 +248,8 @@ void schedule(Aword evt, Aword whr, Aword aft) { */ static Aptr getatr( - Aaddr atradr, /* IN - ACODE address to attribute table */ - Aaddr atr /* IN - The attribute to read */ + Aaddr atradr, /* IN - ACODE address to attribute table */ + Aaddr atr /* IN - The attribute to read */ ) { AtrElem *at; @@ -366,9 +366,9 @@ void setstr(Aword id, Aword atr, Aword str) { */ static void incratr( - Aaddr atradr, /* IN - ACODE address to attribute table */ - Aword atr, /* IN - attribute code */ - Aword step /* IN - step to increment by */ + Aaddr atradr, /* IN - ACODE address to attribute table */ + Aword atr, /* IN - attribute code */ + Aword step /* IN - step to increment by */ ) { AtrElem *at; diff --git a/engines/glk/alan2/main.cpp b/engines/glk/alan2/main.cpp index 6f3eda07fc5..bae21c07904 100644 --- a/engines/glk/alan2/main.cpp +++ b/engines/glk/alan2/main.cpp @@ -349,7 +349,7 @@ static void sayparam(int p) { $ = no space needed after this */ static void prsym( - char *str /* IN - The string starting with '$' */ + char *str /* IN - The string starting with '$' */ ) { switch (toLower(str[1])) { case 'n': @@ -558,8 +558,8 @@ static int count(int cnt /* IN - the container to count */) { */ static int sumatr( - Aword atr, /* IN - the attribute to sum over */ - Aword cnt /* IN - the container to sum */ + Aword atr, /* IN - the attribute to sum over */ + Aword cnt /* IN - the container to sum */ ) { uint i; int sum = 0; @@ -581,8 +581,8 @@ static int sumatr( */ Boolean checklim( - Aword cnt, /* IN - Container code */ - Aword obj /* IN - The object to add */ + Aword cnt, /* IN - Container code */ + Aword obj /* IN - The object to add */ ) { LimElem *lim; Aword props; @@ -633,8 +633,8 @@ Boolean checklim( */ static Boolean trycheck( - Aaddr adr, /* IN - ACODE address to check table */ - Boolean act /* IN - Act if it fails ? */ + Aaddr adr, /* IN - ACODE address to check table */ + Boolean act /* IN - Act if it fails ? */ ) { ChkElem *chk; @@ -723,8 +723,8 @@ void go(CONTEXT, int dir) { */ static AltElem *findalt( - Aword vrbsadr, /* IN - Address to start of list */ - Aword param /* IN - Which parameter to match */ + Aword vrbsadr, /* IN - Address to start of list */ + Aword param /* IN - Which parameter to match */ ) { VrbElem *vrb; AltElem *alt; diff --git a/engines/glk/alan2/sysdep.cpp b/engines/glk/alan2/sysdep.cpp index ba8cc5eb4d7..f9f92171fdd 100644 --- a/engines/glk/alan2/sysdep.cpp +++ b/engines/glk/alan2/sysdep.cpp @@ -210,8 +210,8 @@ char *stringUpper(char str[]) { /* INOUT - ISO string to convert */ */ void toIso(char copy[], /* OUT - Mapped string */ - char original[], /* IN - string to convert */ - int charset) { /* IN - the current character set */ + char original[], /* IN - string to convert */ + int charset) { /* IN - the current character set */ static unsigned char macMap[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0A, 0x0E, 0x0F, @@ -284,7 +284,7 @@ void toIso(char copy[], /* OUT - Mapped string */ */ void fromIso(char copy[], /* OUT - Mapped string */ - char original[]) { /* IN - string to convert */ + char original[]) { /* IN - string to convert */ if (copy != original) (void)strcpy(copy, original); } @@ -299,8 +299,8 @@ void fromIso(char copy[], /* OUT - Mapped string */ */ void toNative(char copy[], /* OUT - Mapped string */ - char original[], /* IN - string to convert */ - int charset) { /* IN - the current character set */ + char original[], /* IN - string to convert */ + int charset) { /* IN - the current character set */ toIso(copy, original, charset); if (NATIVECHARSET != 0) fromIso(copy, copy); diff --git a/engines/glk/alan2/sysdep.h b/engines/glk/alan2/sysdep.h index 24c0aefe727..113e1e941aa 100644 --- a/engines/glk/alan2/sysdep.h +++ b/engines/glk/alan2/sysdep.h @@ -73,15 +73,15 @@ extern char *stringUpper(char str[]); /* INOUT - ISO string to convert */ /* ISO string conversion functions */ extern void toIso(char copy[], /* OUT - Mapped string */ - char original[], /* IN - string to convert */ - int charset); /* IN - The current character set */ + char original[], /* IN - string to convert */ + int charset); /* IN - The current character set */ extern void fromIso(char copy[], /* OUT - Mapped string */ - char original[]); /* IN - string to convert */ + char original[]); /* IN - string to convert */ extern void toNative(char copy[], /* OUT - Mapped string */ - char original[], /* IN - string to convert */ - int charset); /* IN - current character set */ + char original[], /* IN - string to convert */ + int charset); /* IN - current character set */ } // End of namespace Alan2 } // End of namespace Glk diff --git a/engines/glk/alan3/acode.h b/engines/glk/alan3/acode.h index 6e663fabd08..83d6cdc2f6d 100644 --- a/engines/glk/alan3/acode.h +++ b/engines/glk/alan3/acode.h @@ -203,18 +203,18 @@ enum InstClass { I_UNION, /* Add a set from the top of stack to a */ /* set valued attribute */ I_GETSTR, /* Get a string contents from text - file, create a copy and push it - on top of stack */ + file, create a copy and push it + on top of stack */ I_INCR, /* Increase an attribute */ I_DECR, /* Decrease a numeric attribute */ I_INCLUDE, /* Include a value in the set on stack top */ I_EXCLUDE, /* Remove a value from the set on stack top */ I_SETSIZE, /* Push number of members in a set */ I_SETMEMB, /* Push the member with index -1 - from set */ + from set */ I_CONTSIZE, /* Push number of members in a container */ I_CONTMEMB, /* Push the member with index -1 - from container */ + from container */ I_USE, I_STOP, I_AT, @@ -368,8 +368,8 @@ struct InstanceEntry { /* INSTANCE TABLE */ struct AttributeEntry { /* ATTRIBUTE LIST */ Aint code; /* Its code */ Aptr value; /* Its value, a string has a dynamic - string pointer, a set has a pointer - to a dynamically allocated set */ + string pointer, a set has a pointer + to a dynamically allocated set */ Aaddr id; /* Address to the name */ /** @@ -381,8 +381,8 @@ struct AttributeEntry { /* ATTRIBUTE LIST */ struct AttributeHeaderEntry { /* ATTRIBUTE LIST in header */ Aint code; /* Its code */ Aword value; /* Its value, a string has a dynamic - string pointer, a set has a pointer - to a dynamically allocated set */ + string pointer, a set has a pointer + to a dynamically allocated set */ Aaddr id; /* Address to the name */ } PACKED_STRUCT; diff --git a/engines/glk/alan3/alt_info.h b/engines/glk/alan3/alt_info.h index 75a097f9c9b..c0cef562a65 100644 --- a/engines/glk/alan3/alt_info.h +++ b/engines/glk/alan3/alt_info.h @@ -58,7 +58,7 @@ struct AltInfo { Aint level; /* 0 - Global, 1 - location, 2 - parameter */ Aid _class; /* In which class, only used for tracing */ Aid instance; /* In which instance the Alternative was found, - used to set current.instance and tracing */ + used to set current.instance and tracing */ Aid parameter; /* In which parameter, only used for tracing */ }; diff --git a/engines/glk/alan3/container.cpp b/engines/glk/alan3/container.cpp index 0ce44b06c2c..53202d2a47a 100644 --- a/engines/glk/alan3/container.cpp +++ b/engines/glk/alan3/container.cpp @@ -51,8 +51,8 @@ static int countInContainer(int containerIndex) { /* IN - the container to count /*----------------------------------------------------------------------*/ static int sumAttributeInContainer( - Aint containerIndex, /* IN - the container to sum */ - Aint attributeIndex /* IN - the attribute to sum over */ + Aint containerIndex, /* IN - the container to sum */ + Aint attributeIndex /* IN - the attribute to sum over */ ) { uint instanceIndex; int sum = 0; diff --git a/engines/glk/alan3/output.cpp b/engines/glk/alan3/output.cpp index 816474f3b60..773d916b401 100644 --- a/engines/glk/alan3/output.cpp +++ b/engines/glk/alan3/output.cpp @@ -404,7 +404,7 @@ void output(const char *original) { *symptr = '\0'; if (strlen(str) > 0) { skipSpace = FALSE; /* Only let skipSpace through if it is - last in the string */ + last in the string */ if (lastCharOf(str) == ' ') { str[strlen(str) - 1] = '\0'; /* Truncate space character */ justify(str); /* Output part before '$' */ diff --git a/engines/glk/alan3/parse.cpp b/engines/glk/alan3/parse.cpp index 9ddd454bfb2..e6e3aa24791 100644 --- a/engines/glk/alan3/parse.cpp +++ b/engines/glk/alan3/parse.cpp @@ -273,7 +273,7 @@ static int getPronounInstances(int word, Parameter instanceParameters[]) { if (pronouns[p].instance != 0 && dictionary[word].code == (Aword)pronouns[p].pronoun) { instanceParameters[instanceCount].instance = pronouns[p].instance; instanceParameters[instanceCount].useWords = FALSE; /* Can't use words since they are gone, pronouns - refer to parameters in previous command */ + refer to parameters in previous command */ setEndOfArray(&instanceParameters[++instanceCount]); } return instanceCount; diff --git a/engines/glk/alan3/set.h b/engines/glk/alan3/set.h index 60b992a903b..3edfa4b2745 100644 --- a/engines/glk/alan3/set.h +++ b/engines/glk/alan3/set.h @@ -25,12 +25,12 @@ /* Abstract datatype Set for Alan interpreter - A set is implemented as a struct holding a size and a - dynamically allocated array of members. Members can be - integers or instance numbers. Attributes of Set type is - allocated and the pointer to it is used as the attribute - value. As members are only references, clearing a set can - simply be done by setting the size to zero. + A set is implemented as a struct holding a size and a + dynamically allocated array of members. Members can be + integers or instance numbers. Attributes of Set type is + allocated and the pointer to it is used as the attribute + value. As members are only references, clearing a set can + simply be done by setting the size to zero. */ #include "glk/alan3/acode.h" diff --git a/engines/glk/alan3/sysdep.cpp b/engines/glk/alan3/sysdep.cpp index 8285f41068b..268ea9cead1 100644 --- a/engines/glk/alan3/sysdep.cpp +++ b/engines/glk/alan3/sysdep.cpp @@ -219,8 +219,8 @@ int compareStrings(char *str1, char *str2) { */ void toIso(char copy[], /* OUT - Mapped string */ - char original[], /* IN - string to convert */ - int charset) { /* IN - the current character set */ + char original[], /* IN - string to convert */ + int charset) { /* IN - the current character set */ static const unsigned char macMap[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0A, 0x0E, 0x0F, diff --git a/engines/glk/alan3/sysdep.h b/engines/glk/alan3/sysdep.h index 7f6f756e83c..ab52e7a8ec5 100644 --- a/engines/glk/alan3/sysdep.h +++ b/engines/glk/alan3/sysdep.h @@ -102,15 +102,15 @@ extern int compareStrings(char str1[], char str2[]); /* Case-insensitive compare /* ISO string conversion functions */ extern void toIso(char copy[], /* OUT - Mapped string */ - char original[], /* IN - string to convert */ - int charset); /* IN - The current character set */ + char original[], /* IN - string to convert */ + int charset); /* IN - The current character set */ extern void fromIso(char copy[], /* OUT - Mapped string */ - char original[]); /* IN - string to convert */ + char original[]); /* IN - string to convert */ extern void toNative(char copy[], /* OUT - Mapped string */ - char original[], /* IN - string to convert */ - int charset); /* IN - current character set */ + char original[], /* IN - string to convert */ + int charset); /* IN - current character set */ extern char *baseNameStart(char *fullPathName); diff --git a/engines/glk/archetype/interpreter.cpp b/engines/glk/archetype/interpreter.cpp index 485a408555a..39fa14bfc93 100644 --- a/engines/glk/archetype/interpreter.cpp +++ b/engines/glk/archetype/interpreter.cpp @@ -58,7 +58,7 @@ bool convert_to(AclType target_type, ResultType &the_scalar) { int the_number = -1; String s1; void *p; - bool boolval = false; + bool boolval = false; if (target_type == the_scalar._kind) return true; @@ -74,8 +74,8 @@ bool convert_to(AclType target_type, ResultType &the_scalar) { } switch (the_scalar._kind) { - case NUMERIC: - dir_from = 'N'; + case NUMERIC: + dir_from = 'N'; the_number = the_scalar._data._numeric.acl_int; break; @@ -87,21 +87,21 @@ bool convert_to(AclType target_type, ResultType &the_scalar) { case TEXT_LIT: case QUOTE_LIT: - dir_from = 'S'; + dir_from = 'S'; if (index_xarray(g_vm->Literals, the_scalar._data._msgTextQuote.index, p)) s1 = *(StringPtr)p; break; case STR_PTR: // string memory will be disposed ONLY if successful convert - dir_from = 'S'; + dir_from = 'S'; s1 = *the_scalar._data._str.acl_str; break; case IDENT: //with the_scalar do begin - dir_from = 'S'; - + dir_from = 'S'; + switch (the_scalar._data._ident.ident_kind) { case ENUMERATE_ID: dir_from = 'N'; @@ -207,7 +207,7 @@ bool convert_to(AclType target_type, ResultType &the_scalar) { } return true; - + default: break; } diff --git a/engines/glk/archetype/semantic.cpp b/engines/glk/archetype/semantic.cpp index c13b770e808..6092988fb24 100644 --- a/engines/glk/archetype/semantic.cpp +++ b/engines/glk/archetype/semantic.cpp @@ -32,7 +32,7 @@ typedef int *IntegerPtr; int classify_as(progfile &f, int id_number, ClassifyType interpretation, void *ptr_to_data) { IdRecPtr the_id_ptr; - String error_string; + String error_string; int result = 0; if (!index_ident(id_number, the_id_ptr)) { diff --git a/engines/glk/archetype/sys_object.cpp b/engines/glk/archetype/sys_object.cpp index ec98038be3e..68df573cda1 100644 --- a/engines/glk/archetype/sys_object.cpp +++ b/engines/glk/archetype/sys_object.cpp @@ -70,7 +70,7 @@ void send_to_system(int transport, String &strmsg, ResultType &result, ContextTy int the_caller; int obj_index; String nomatch; - NodePtr np; + NodePtr np; void *p; if (g_vm->shouldQuit()) diff --git a/engines/glk/comprehend/debugger_dumper.cpp b/engines/glk/comprehend/debugger_dumper.cpp index 96d3942bf26..e5fe988c39b 100644 --- a/engines/glk/comprehend/debugger_dumper.cpp +++ b/engines/glk/comprehend/debugger_dumper.cpp @@ -123,7 +123,7 @@ DebuggerDumper::DebuggerDumper() : _game(nullptr) { } Common::String DebuggerDumper::dumpInstruction(ComprehendGame *game, - const FunctionState *func_state, const Instruction *instr) { + const FunctionState *func_state, const Instruction *instr) { uint i; int str_index, str_table; ScriptOpcode opcode = _game->getScriptOpcode(instr); diff --git a/engines/glk/comprehend/dictionary.cpp b/engines/glk/comprehend/dictionary.cpp index 10ebd977ba7..1dcd8a86e01 100644 --- a/engines/glk/comprehend/dictionary.cpp +++ b/engines/glk/comprehend/dictionary.cpp @@ -37,7 +37,7 @@ static bool word_match(Word *word, const char *string) { } Word *dict_find_word_by_string(ComprehendGame *game, - const char *string) { + const char *string) { uint i; if (!string) @@ -51,7 +51,7 @@ Word *dict_find_word_by_string(ComprehendGame *game, } Word *dict_find_word_by_index_type(ComprehendGame *game, - uint8 index, uint8 type) { + uint8 index, uint8 type) { uint i; for (i = 0; i < game->_words.size(); i++) { @@ -64,7 +64,7 @@ Word *dict_find_word_by_index_type(ComprehendGame *game, } Word *find_dict_word_by_index(ComprehendGame *game, - uint8 index, uint8 type_mask) { + uint8 index, uint8 type_mask) { uint i; for (i = 0; i < game->_words.size(); i++) { @@ -77,7 +77,7 @@ Word *find_dict_word_by_index(ComprehendGame *game, } bool dict_match_index_type(ComprehendGame *game, const char *word, - uint8 index, uint8 type_mask) { + uint8 index, uint8 type_mask) { uint i; for (i = 0; i < game->_words.size(); i++) diff --git a/engines/glk/comprehend/dictionary.h b/engines/glk/comprehend/dictionary.h index b01860d5df7..12fa1bc770b 100644 --- a/engines/glk/comprehend/dictionary.h +++ b/engines/glk/comprehend/dictionary.h @@ -30,13 +30,13 @@ class ComprehendGame; struct Word; Word *find_dict_word_by_index(ComprehendGame *game, - uint8 index, uint8 type_mask); + uint8 index, uint8 type_mask); Word *dict_find_word_by_index_type(ComprehendGame *game, - uint8 index, uint8 type); + uint8 index, uint8 type); Word *dict_find_word_by_string(ComprehendGame *game, - const char *string); + const char *string); bool dict_match_index_type(ComprehendGame *game, const char *word, - uint8 index, uint8 type_mask); + uint8 index, uint8 type_mask); } // namespace Comprehend } // namespace Glk diff --git a/engines/glk/comprehend/game_data.cpp b/engines/glk/comprehend/game_data.cpp index f702f8ca4ec..de84f56db31 100644 --- a/engines/glk/comprehend/game_data.cpp +++ b/engines/glk/comprehend/game_data.cpp @@ -192,7 +192,7 @@ void GameData::parse_header_le16(FileBuffer *fb, uint16 *val) { } uint8 GameData::parse_vm_instruction(FileBuffer *fb, - Instruction *instr) { + Instruction *instr) { uint i; /* Get the opcode */ @@ -481,7 +481,7 @@ done: } void GameData::parse_string_table(FileBuffer *fb, unsigned start_addr, - uint32 end_addr, StringTable *table) { + uint32 end_addr, StringTable *table) { if (start_addr < end_addr) { fb->seek(start_addr); while (1) { diff --git a/engines/glk/comprehend/game_data.h b/engines/glk/comprehend/game_data.h index 8b9fe3725e6..37312b45cb2 100644 --- a/engines/glk/comprehend/game_data.h +++ b/engines/glk/comprehend/game_data.h @@ -195,7 +195,7 @@ enum ItemFlag { #define WORD_TYPE_NOUN 0x40 #define WORD_TYPE_NOUN_PLURAL 0x80 #define WORD_TYPE_NOUN_MASK (WORD_TYPE_FEMALE | WORD_TYPE_MALE | \ - WORD_TYPE_NOUN | WORD_TYPE_NOUN_PLURAL) + WORD_TYPE_NOUN | WORD_TYPE_NOUN_PLURAL) struct FunctionState { bool _testResult; diff --git a/engines/glk/comprehend/game_tr1.cpp b/engines/glk/comprehend/game_tr1.cpp index 34752461dc7..c94ca5baf3a 100644 --- a/engines/glk/comprehend/game_tr1.cpp +++ b/engines/glk/comprehend/game_tr1.cpp @@ -132,7 +132,7 @@ bool TransylvaniaGame1::isMonsterInRoom(const TransylvaniaMonster *monsterInfo) } int TransylvaniaGame1::roomIsSpecial(unsigned room_index, - unsigned *roomDescString) { + unsigned *roomDescString) { Room *room = &_rooms[room_index]; if (room_index == 0x28) { diff --git a/engines/glk/comprehend/game_tr2.cpp b/engines/glk/comprehend/game_tr2.cpp index 44c30faf3fe..2c197e67c73 100644 --- a/engines/glk/comprehend/game_tr2.cpp +++ b/engines/glk/comprehend/game_tr2.cpp @@ -125,7 +125,7 @@ bool TransylvaniaGame2::isMonsterInRoom(const TransylvaniaMonster *monsterInfo) } int TransylvaniaGame2::roomIsSpecial(unsigned room_index, - unsigned *roomDescString) { + unsigned *roomDescString) { Room *room = &_rooms[room_index]; if (room_index == 0x28) { diff --git a/engines/glk/comprehend/pics.cpp b/engines/glk/comprehend/pics.cpp index 638c3bf9ed7..949fca4509d 100644 --- a/engines/glk/comprehend/pics.cpp +++ b/engines/glk/comprehend/pics.cpp @@ -333,8 +333,8 @@ void Pics::clear() { } void Pics::load(const Common::StringArray &roomFiles, - const Common::StringArray &itemFiles, - const Common::String &titleFile) { + const Common::StringArray &itemFiles, + const Common::String &titleFile) { clear(); for (uint idx = 0; idx < roomFiles.size(); ++idx) diff --git a/engines/glk/glk_api.cpp b/engines/glk/glk_api.cpp index 5398d1c8efd..591df4e39dc 100644 --- a/engines/glk/glk_api.cpp +++ b/engines/glk/glk_api.cpp @@ -198,7 +198,7 @@ void GlkAPI::glk_window_set_arrangement(winid_t win, uint method, uint size, win } void GlkAPI::glk_window_get_arrangement(winid_t win, uint *method, - uint *size, winid_t *keyWin) { + uint *size, winid_t *keyWin) { if (win) { win->getArrangement(method, size, keyWin); } else { @@ -782,7 +782,7 @@ uint GlkAPI::glk_buffer_to_upper_case_uni(uint32 *buf, uint len, uint numchars) } uint GlkAPI::glk_buffer_to_title_case_uni(uint32 *buf, uint len, - uint numchars, uint lowerrest) { + uint numchars, uint lowerrest) { return bufferChangeCase(buf, len, numchars, CASE_TITLE, COND_LINESTART, lowerrest); } @@ -898,7 +898,7 @@ bool GlkAPI::glk_image_draw(winid_t win, uint image, int val1, int val2) { } bool GlkAPI::glk_image_draw_scaled(winid_t win, uint image, int val1, int val2, - uint width, uint height) { + uint width, uint height) { return glk_image_draw_scaled(win, Common::String::format("%d", image), val1, val2, width, height); } @@ -1011,7 +1011,7 @@ void GlkAPI::glk_window_erase_rect(winid_t win, int left, int top, uint width, u } void GlkAPI::glk_window_fill_rect(winid_t win, uint color, int left, int top, - uint width, uint height) { + uint width, uint height) { if (!win) { warning("window_fill_rect: invalid ref"); } else { @@ -1097,7 +1097,7 @@ schanid_t GlkAPI::glk_schannel_create_ext(uint rock, uint volume) { } uint GlkAPI::glk_schannel_play_multi(schanid_t *chanarray, uint chancount, - uint *sndarray, uint soundcount, uint notify) { + uint *sndarray, uint soundcount, uint notify) { // No implementation return 0; } @@ -1119,7 +1119,7 @@ void GlkAPI::glk_schannel_unpause(schanid_t chan) { } void GlkAPI::glk_schannel_set_volume_ext(schanid_t chan, uint vol, - uint duration, uint notify) { + uint duration, uint notify) { if (chan) { chan->setVolume(vol, duration, notify); } else { diff --git a/engines/glk/glk_dispa.cpp b/engines/glk/glk_dispa.cpp index 32bbefe1b56..2fb8b87b873 100644 --- a/engines/glk/glk_dispa.cpp +++ b/engines/glk/glk_dispa.cpp @@ -26,159 +26,159 @@ namespace Glk { #define NUMCLASSES \ - (sizeof(class_table) / sizeof(gidispatch_intconst_t)) + (sizeof(class_table) / sizeof(gidispatch_intconst_t)) #define NUMINTCONSTANTS \ - (sizeof(intconstant_table) / sizeof(gidispatch_intconst_t)) + (sizeof(intconstant_table) / sizeof(gidispatch_intconst_t)) /** * The constants in this table must be ordered alphabetically. */ static const gidispatch_intconst_t class_table[] = { - { "fileref", (2) }, /* "Qc" */ - { "schannel", (3) }, /* "Qd" */ - { "stream", (1) }, /* "Qb" */ - { "window", (0) }, /* "Qa" */ + { "fileref", (2) }, /* "Qc" */ + { "schannel", (3) }, /* "Qd" */ + { "stream", (1) }, /* "Qb" */ + { "window", (0) }, /* "Qa" */ }; /** * The constants in this table must be ordered alphabetically. */ static const gidispatch_intconst_t intconstant_table[] = { - { "evtype_Arrange", (5) }, - { "evtype_CharInput", (2) }, - { "evtype_Hyperlink", (8) }, - { "evtype_LineInput", (3) }, - { "evtype_MouseInput", (4) }, - { "evtype_None", (0) }, - { "evtype_Redraw", (6) }, - { "evtype_SoundNotify", (7) }, - { "evtype_Timer", (1) }, - { "evtype_VolumeNotify", (9) }, + { "evtype_Arrange", (5) }, + { "evtype_CharInput", (2) }, + { "evtype_Hyperlink", (8) }, + { "evtype_LineInput", (3) }, + { "evtype_MouseInput", (4) }, + { "evtype_None", (0) }, + { "evtype_Redraw", (6) }, + { "evtype_SoundNotify", (7) }, + { "evtype_Timer", (1) }, + { "evtype_VolumeNotify", (9) }, - { "filemode_Read", (0x02) }, - { "filemode_ReadWrite", (0x03) }, - { "filemode_Write", (0x01) }, - { "filemode_WriteAppend", (0x05) }, + { "filemode_Read", (0x02) }, + { "filemode_ReadWrite", (0x03) }, + { "filemode_Write", (0x01) }, + { "filemode_WriteAppend", (0x05) }, - { "fileusage_BinaryMode", (0x000) }, - { "fileusage_Data", (0x00) }, - { "fileusage_InputRecord", (0x03) }, - { "fileusage_SavedGame", (0x01) }, - { "fileusage_TextMode", (0x100) }, - { "fileusage_Transcript", (0x02) }, - { "fileusage_TypeMask", (0x0f) }, + { "fileusage_BinaryMode", (0x000) }, + { "fileusage_Data", (0x00) }, + { "fileusage_InputRecord", (0x03) }, + { "fileusage_SavedGame", (0x01) }, + { "fileusage_TextMode", (0x100) }, + { "fileusage_Transcript", (0x02) }, + { "fileusage_TypeMask", (0x0f) }, - { "gestalt_CharInput", (1) }, - { "gestalt_CharOutput", (3) }, - { "gestalt_CharOutput_ApproxPrint", (1) }, - { "gestalt_CharOutput_CannotPrint", (0) }, - { "gestalt_CharOutput_ExactPrint", (2) }, - { "gestalt_DateTime", (20) }, - { "gestalt_DrawImage", (7) }, - { "gestalt_GarglkText", (0x1100) }, - { "gestalt_Graphics", (6) }, - { "gestalt_GraphicsTransparency", (14) }, - { "gestalt_HyperlinkInput", (12) }, - { "gestalt_Hyperlinks", (11) }, - { "gestalt_LineInput", (2) }, - { "gestalt_LineInputEcho", (17) }, - { "gestalt_LineTerminatorKey", (19) }, - { "gestalt_LineTerminators", (18) }, - { "gestalt_MouseInput", (4) }, - { "gestalt_Sound", (8) }, - { "gestalt_Sound2", (21) }, - { "gestalt_SoundMusic", (13) }, - { "gestalt_SoundNotify", (10) }, - { "gestalt_SoundVolume", (9) }, - { "gestalt_Timer", (5) }, - { "gestalt_Unicode", (15) }, - { "gestalt_UnicodeNorm", (16) }, - { "gestalt_Version", (0) }, + { "gestalt_CharInput", (1) }, + { "gestalt_CharOutput", (3) }, + { "gestalt_CharOutput_ApproxPrint", (1) }, + { "gestalt_CharOutput_CannotPrint", (0) }, + { "gestalt_CharOutput_ExactPrint", (2) }, + { "gestalt_DateTime", (20) }, + { "gestalt_DrawImage", (7) }, + { "gestalt_GarglkText", (0x1100) }, + { "gestalt_Graphics", (6) }, + { "gestalt_GraphicsTransparency", (14) }, + { "gestalt_HyperlinkInput", (12) }, + { "gestalt_Hyperlinks", (11) }, + { "gestalt_LineInput", (2) }, + { "gestalt_LineInputEcho", (17) }, + { "gestalt_LineTerminatorKey", (19) }, + { "gestalt_LineTerminators", (18) }, + { "gestalt_MouseInput", (4) }, + { "gestalt_Sound", (8) }, + { "gestalt_Sound2", (21) }, + { "gestalt_SoundMusic", (13) }, + { "gestalt_SoundNotify", (10) }, + { "gestalt_SoundVolume", (9) }, + { "gestalt_Timer", (5) }, + { "gestalt_Unicode", (15) }, + { "gestalt_UnicodeNorm", (16) }, + { "gestalt_Version", (0) }, - { "imagealign_InlineCenter", (0x03) }, - { "imagealign_InlineDown", (0x02) }, - { "imagealign_MarginLeft", (0x04) }, - { "imagealign_MarginRight", (0x05) }, - { "imagealign_InlineUp", (0x01) }, + { "imagealign_InlineCenter", (0x03) }, + { "imagealign_InlineDown", (0x02) }, + { "imagealign_MarginLeft", (0x04) }, + { "imagealign_MarginRight", (0x05) }, + { "imagealign_InlineUp", (0x01) }, - { "keycode_Delete", (0xfffffff9) }, - { "keycode_Down", (0xfffffffb) }, - { "keycode_End", (0xfffffff3) }, - { "keycode_Escape", (0xfffffff8) }, - { "keycode_Func1", (0xffffffef) }, - { "keycode_Func10", (0xffffffe6) }, - { "keycode_Func11", (0xffffffe5) }, - { "keycode_Func12", (0xffffffe4) }, - { "keycode_Func2", (0xffffffee) }, - { "keycode_Func3", (0xffffffed) }, - { "keycode_Func4", (0xffffffec) }, - { "keycode_Func5", (0xffffffeb) }, - { "keycode_Func6", (0xffffffea) }, - { "keycode_Func7", (0xffffffe9) }, - { "keycode_Func8", (0xffffffe8) }, - { "keycode_Func9", (0xffffffe7) }, - { "keycode_Home", (0xfffffff4) }, - { "keycode_Left", (0xfffffffe) }, - { "keycode_MAXVAL", (28) }, - { "keycode_PageDown", (0xfffffff5) }, - { "keycode_PageUp", (0xfffffff6) }, - { "keycode_Return", (0xfffffffa) }, - { "keycode_Right", (0xfffffffd) }, - { "keycode_Tab", (0xfffffff7) }, - { "keycode_Unknown", (0xffffffff) }, - { "keycode_Up", (0xfffffffc) }, + { "keycode_Delete", (0xfffffff9) }, + { "keycode_Down", (0xfffffffb) }, + { "keycode_End", (0xfffffff3) }, + { "keycode_Escape", (0xfffffff8) }, + { "keycode_Func1", (0xffffffef) }, + { "keycode_Func10", (0xffffffe6) }, + { "keycode_Func11", (0xffffffe5) }, + { "keycode_Func12", (0xffffffe4) }, + { "keycode_Func2", (0xffffffee) }, + { "keycode_Func3", (0xffffffed) }, + { "keycode_Func4", (0xffffffec) }, + { "keycode_Func5", (0xffffffeb) }, + { "keycode_Func6", (0xffffffea) }, + { "keycode_Func7", (0xffffffe9) }, + { "keycode_Func8", (0xffffffe8) }, + { "keycode_Func9", (0xffffffe7) }, + { "keycode_Home", (0xfffffff4) }, + { "keycode_Left", (0xfffffffe) }, + { "keycode_MAXVAL", (28) }, + { "keycode_PageDown", (0xfffffff5) }, + { "keycode_PageUp", (0xfffffff6) }, + { "keycode_Return", (0xfffffffa) }, + { "keycode_Right", (0xfffffffd) }, + { "keycode_Tab", (0xfffffff7) }, + { "keycode_Unknown", (0xffffffff) }, + { "keycode_Up", (0xfffffffc) }, - { "seekmode_Current", (1) }, - { "seekmode_End", (2) }, - { "seekmode_Start", (0) }, + { "seekmode_Current", (1) }, + { "seekmode_End", (2) }, + { "seekmode_Start", (0) }, - { "style_Alert", (5) }, - { "style_BlockQuote", (7) }, - { "style_Emphasized", (1) }, - { "style_Header", (3) }, - { "style_Input", (8) }, - { "style_NUMSTYLES", (11) }, - { "style_Normal", (0) }, - { "style_Note", (6) }, - { "style_Preformatted", (2) }, - { "style_Subheader", (4) }, - { "style_User1", (9) }, - { "style_User2", (10) }, - { "stylehint_BackColor", (8) }, - { "stylehint_Indentation", (0) }, - { "stylehint_Justification", (2) }, - { "stylehint_NUMHINTS", (10) }, - { "stylehint_Oblique", (5) }, - { "stylehint_ParaIndentation", (1) }, - { "stylehint_Proportional", (6) }, - { "stylehint_ReverseColor", (9) }, - { "stylehint_Size", (3) }, - { "stylehint_TextColor", (7) }, - { "stylehint_Weight", (4) }, - { "stylehint_just_Centered", (2) }, - { "stylehint_just_LeftFlush", (0) }, - { "stylehint_just_LeftRight", (1) }, - { "stylehint_just_RightFlush", (3) }, + { "style_Alert", (5) }, + { "style_BlockQuote", (7) }, + { "style_Emphasized", (1) }, + { "style_Header", (3) }, + { "style_Input", (8) }, + { "style_NUMSTYLES", (11) }, + { "style_Normal", (0) }, + { "style_Note", (6) }, + { "style_Preformatted", (2) }, + { "style_Subheader", (4) }, + { "style_User1", (9) }, + { "style_User2", (10) }, + { "stylehint_BackColor", (8) }, + { "stylehint_Indentation", (0) }, + { "stylehint_Justification", (2) }, + { "stylehint_NUMHINTS", (10) }, + { "stylehint_Oblique", (5) }, + { "stylehint_ParaIndentation", (1) }, + { "stylehint_Proportional", (6) }, + { "stylehint_ReverseColor", (9) }, + { "stylehint_Size", (3) }, + { "stylehint_TextColor", (7) }, + { "stylehint_Weight", (4) }, + { "stylehint_just_Centered", (2) }, + { "stylehint_just_LeftFlush", (0) }, + { "stylehint_just_LeftRight", (1) }, + { "stylehint_just_RightFlush", (3) }, - { "winmethod_Above", (0x02) }, - { "winmethod_Below", (0x03) }, - { "winmethod_Border", (0x000) }, - { "winmethod_BorderMask", (0x100) }, - { "winmethod_DirMask", (0x0f) }, - { "winmethod_DivisionMask", (0xf0) }, - { "winmethod_Fixed", (0x10) }, - { "winmethod_Left", (0x00) }, - { "winmethod_NoBorder", (0x100) }, - { "winmethod_Proportional", (0x20) }, - { "winmethod_Right", (0x01) }, + { "winmethod_Above", (0x02) }, + { "winmethod_Below", (0x03) }, + { "winmethod_Border", (0x000) }, + { "winmethod_BorderMask", (0x100) }, + { "winmethod_DirMask", (0x0f) }, + { "winmethod_DivisionMask", (0xf0) }, + { "winmethod_Fixed", (0x10) }, + { "winmethod_Left", (0x00) }, + { "winmethod_NoBorder", (0x100) }, + { "winmethod_Proportional", (0x20) }, + { "winmethod_Right", (0x01) }, - { "wintype_AllTypes", (0) }, - { "wintype_Blank", (2) }, - { "wintype_Graphics", (5) }, - { "wintype_Pair", (1) }, - { "wintype_TextBuffer", (3) }, - { "wintype_TextGrid", (4) }, + { "wintype_AllTypes", (0) }, + { "wintype_Blank", (2) }, + { "wintype_Graphics", (5) }, + { "wintype_Pair", (1) }, + { "wintype_TextBuffer", (3) }, + { "wintype_TextGrid", (4) }, }; void GlkAPI::gidispatch_set_object_registry(gidispatch_rock_t(*regi)(void *obj, uint objclass), @@ -222,1123 +222,1123 @@ void GlkAPI::gidispatch_set_retained_registry(gidispatch_rock_t(*regi)(void *arr } uint32 GlkAPI::gidispatch_count_classes() const { - return NUMCLASSES; + return NUMCLASSES; } const gidispatch_intconst_t *GlkAPI::gidispatch_get_class(uint32 index) const { - if (index >= NUMCLASSES) - return nullptr; - return &(class_table[index]); + if (index >= NUMCLASSES) + return nullptr; + return &(class_table[index]); } uint32 GlkAPI::gidispatch_count_intconst() const { - return NUMINTCONSTANTS; + return NUMINTCONSTANTS; } const gidispatch_intconst_t *GlkAPI::gidispatch_get_intconst(uint32 index) const { - if (index >= NUMINTCONSTANTS) - return nullptr; - return &(intconstant_table[index]); + if (index >= NUMINTCONSTANTS) + return nullptr; + return &(intconstant_table[index]); } const char *GlkAPI::gidispatch_prototype(uint32 funcnum) const { - switch (funcnum) { - case 0x0001: /* exit */ - return "0:"; - case 0x0002: /* set_interrupt_handler */ - /* cannot be invoked through dispatch layer */ - return nullptr; - case 0x0003: /* tick */ - return "0:"; - case 0x0004: /* gestalt */ - return "3IuIu:Iu"; - case 0x0005: /* gestalt_ext */ - return "4IuIu&#Iu:Iu"; - case 0x0020: /* window_iterate */ - return "3Qa+#Cn:"; - case 0x0085: /* put_buffer_stream */ - return "2Qb>+#Cn:"; - case 0x0086: /* set_style */ - return "1Iu:"; - case 0x0087: /* set_style_stream */ - return "2QbIu:"; - case 0x0090: /* get_char_stream */ - return "2Qb:Is"; - case 0x0091: /* get_line_stream */ - return "3Qb<+#Cn:Iu"; - case 0x0092: /* get_buffer_stream */ - return "3Qb<+#Cn:Iu"; - case 0x00A0: /* char_to_lower */ - return "2Cu:Cu"; - case 0x00A1: /* char_to_upper */ - return "2Cu:Cu"; - case 0x00B0: /* stylehint_set */ - return "4IuIuIuIs:"; - case 0x00B1: /* stylehint_clear */ - return "3IuIuIu:"; - case 0x00B2: /* style_distinguish */ - return "4QaIuIu:Iu"; - case 0x00B3: /* style_measure */ - return "5QaIuIu+#Cn:"; + case 0x0085: /* put_buffer_stream */ + return "2Qb>+#Cn:"; + case 0x0086: /* set_style */ + return "1Iu:"; + case 0x0087: /* set_style_stream */ + return "2QbIu:"; + case 0x0090: /* get_char_stream */ + return "2Qb:Is"; + case 0x0091: /* get_line_stream */ + return "3Qb<+#Cn:Iu"; + case 0x0092: /* get_buffer_stream */ + return "3Qb<+#Cn:Iu"; + case 0x00A0: /* char_to_lower */ + return "2Cu:Cu"; + case 0x00A1: /* char_to_upper */ + return "2Cu:Cu"; + case 0x00B0: /* stylehint_set */ + return "4IuIuIuIs:"; + case 0x00B1: /* stylehint_clear */ + return "3IuIuIu:"; + case 0x00B2: /* style_distinguish */ + return "4QaIuIu:Iu"; + case 0x00B3: /* style_measure */ + return "5QaIuIu+#Qd>+#IuIu:Iu"; - case 0x00FD: /* schannel_set_volume_ext */ - return "4QdIuIuIu:"; - case 0x00FE: /* schannel_pause */ - return "1Qd:"; - case 0x00FF: /* schannel_unpause */ - return "1Qd:"; + case 0x00F4: /* schannel_create_ext */ + return "3IuIu:Qd"; + case 0x00F7: /* schannel_play_multi */ + return "4>+#Qd>+#IuIu:Iu"; + case 0x00FD: /* schannel_set_volume_ext */ + return "4QdIuIuIu:"; + case 0x00FE: /* schannel_pause */ + return "1Qd:"; + case 0x00FF: /* schannel_unpause */ + return "1Qd:"; #endif /* GLK_MODULE_SOUND2 */ #endif /* GLK_MODULE_SOUND */ #ifdef GLK_MODULE_HYPERLINKS - case 0x0100: /* set_hyperlink */ - return "1Iu:"; - case 0x0101: /* set_hyperlink_stream */ - return "2QbIu:"; - case 0x0102: /* request_hyperlink_event */ - return "1Qa:"; - case 0x0103: /* cancel_hyperlink_event */ - return "1Qa:"; + case 0x0100: /* set_hyperlink */ + return "1Iu:"; + case 0x0101: /* set_hyperlink_stream */ + return "2QbIu:"; + case 0x0102: /* request_hyperlink_event */ + return "1Qa:"; + case 0x0103: /* cancel_hyperlink_event */ + return "1Qa:"; #endif /* GLK_MODULE_HYPERLINKS */ #ifdef GLK_MODULE_UNICODE - case 0x0120: /* buffer_to_lower_case_uni */ - return "3&+#IuIu:Iu"; - case 0x0121: /* buffer_to_upper_case_uni */ - return "3&+#IuIu:Iu"; - case 0x0122: /* buffer_to_title_case_uni */ - return "4&+#IuIuIu:Iu"; - case 0x0128: /* put_char_uni */ - return "1Iu:"; - case 0x0129: /* put_string_uni */ - return "1U:"; - case 0x012A: /* put_buffer_uni */ - return "1>+#Iu:"; - case 0x012B: /* put_char_stream_uni */ - return "2QbIu:"; - case 0x012C: /* put_string_stream_uni */ - return "2QbU:"; - case 0x012D: /* put_buffer_stream_uni */ - return "2Qb>+#Iu:"; - case 0x0130: /* get_char_stream_uni */ - return "2Qb:Is"; - case 0x0131: /* get_buffer_stream_uni */ - return "3Qb<+#Iu:Iu"; - case 0x0132: /* get_line_stream_uni */ - return "3Qb<+#Iu:Iu"; - case 0x0138: /* stream_open_file_uni */ - return "4QcIuIu:Qb"; - case 0x0139: /* stream_open_memory_uni */ - return "4&#!IuIuIu:Qb"; - case 0x0140: /* request_char_event_uni */ - return "1Qa:"; - case 0x0141: /* request_line_event_uni */ - return "3Qa&+#!IuIu:"; + case 0x0120: /* buffer_to_lower_case_uni */ + return "3&+#IuIu:Iu"; + case 0x0121: /* buffer_to_upper_case_uni */ + return "3&+#IuIu:Iu"; + case 0x0122: /* buffer_to_title_case_uni */ + return "4&+#IuIuIu:Iu"; + case 0x0128: /* put_char_uni */ + return "1Iu:"; + case 0x0129: /* put_string_uni */ + return "1U:"; + case 0x012A: /* put_buffer_uni */ + return "1>+#Iu:"; + case 0x012B: /* put_char_stream_uni */ + return "2QbIu:"; + case 0x012C: /* put_string_stream_uni */ + return "2QbU:"; + case 0x012D: /* put_buffer_stream_uni */ + return "2Qb>+#Iu:"; + case 0x0130: /* get_char_stream_uni */ + return "2Qb:Is"; + case 0x0131: /* get_buffer_stream_uni */ + return "3Qb<+#Iu:Iu"; + case 0x0132: /* get_line_stream_uni */ + return "3Qb<+#Iu:Iu"; + case 0x0138: /* stream_open_file_uni */ + return "4QcIuIu:Qb"; + case 0x0139: /* stream_open_memory_uni */ + return "4&#!IuIuIu:Qb"; + case 0x0140: /* request_char_event_uni */ + return "1Qa:"; + case 0x0141: /* request_line_event_uni */ + return "3Qa&+#!IuIu:"; #endif /* GLK_MODULE_UNICODE */ #ifdef GLK_MODULE_UNICODE_NORM - case 0x0123: /* buffer_canon_decompose_uni */ - return "3&+#IuIu:Iu"; - case 0x0124: /* buffer_canon_normalize_uni */ - return "3&+#IuIu:Iu"; + case 0x0123: /* buffer_canon_decompose_uni */ + return "3&+#IuIu:Iu"; + case 0x0124: /* buffer_canon_normalize_uni */ + return "3&+#IuIu:Iu"; #endif /* GLK_MODULE_UNICODE_NORM */ #ifdef GLK_MODULE_LINE_ECHO - case 0x0150: /* set_echo_line_event */ - return "2QaIu:"; + case 0x0150: /* set_echo_line_event */ + return "2QaIu:"; #endif /* GLK_MODULE_LINE_ECHO */ #ifdef GLK_MODULE_LINE_TERMINATORS - case 0x0151: /* set_terminators_line_event */ - return "2Qa>#Iu:"; + case 0x0151: /* set_terminators_line_event */ + return "2Qa>#Iu:"; #endif /* GLK_MODULE_LINE_TERMINATORS */ #ifdef GLK_MODULE_DATETIME - case 0x0160: /* current_time */ - return "1<+[3IsIuIs]:"; - case 0x0161: /* current_simple_time */ - return "2Iu:Is"; - case 0x0168: /* time_to_date_utc */ - return "2>+[3IsIuIs]<+[8IsIsIsIsIsIsIsIs]:"; - case 0x0169: /* time_to_date_local */ - return "2>+[3IsIuIs]<+[8IsIsIsIsIsIsIsIs]:"; - case 0x016A: /* simple_time_to_date_utc */ - return "3IsIu<+[8IsIsIsIsIsIsIsIs]:"; - case 0x016B: /* simple_time_to_date_local */ - return "3IsIu<+[8IsIsIsIsIsIsIsIs]:"; - case 0x016C: /* date_to_time_utc */ - return "2>+[8IsIsIsIsIsIsIsIs]<+[3IsIuIs]:"; - case 0x016D: /* date_to_time_local */ - return "2>+[8IsIsIsIsIsIsIsIs]<+[3IsIuIs]:"; - case 0x016E: /* date_to_simple_time_utc */ - return "3>+[8IsIsIsIsIsIsIsIs]Iu:Is"; - case 0x016F: /* date_to_simple_time_local */ - return "3>+[8IsIsIsIsIsIsIsIs]Iu:Is"; + case 0x0160: /* current_time */ + return "1<+[3IsIuIs]:"; + case 0x0161: /* current_simple_time */ + return "2Iu:Is"; + case 0x0168: /* time_to_date_utc */ + return "2>+[3IsIuIs]<+[8IsIsIsIsIsIsIsIs]:"; + case 0x0169: /* time_to_date_local */ + return "2>+[3IsIuIs]<+[8IsIsIsIsIsIsIsIs]:"; + case 0x016A: /* simple_time_to_date_utc */ + return "3IsIu<+[8IsIsIsIsIsIsIsIs]:"; + case 0x016B: /* simple_time_to_date_local */ + return "3IsIu<+[8IsIsIsIsIsIsIsIs]:"; + case 0x016C: /* date_to_time_utc */ + return "2>+[8IsIsIsIsIsIsIsIs]<+[3IsIuIs]:"; + case 0x016D: /* date_to_time_local */ + return "2>+[8IsIsIsIsIsIsIsIs]<+[3IsIuIs]:"; + case 0x016E: /* date_to_simple_time_utc */ + return "3>+[8IsIsIsIsIsIsIsIs]Iu:Is"; + case 0x016F: /* date_to_simple_time_local */ + return "3>+[8IsIsIsIsIsIsIsIs]Iu:Is"; #endif /* GLK_MODULE_DATETIME */ #ifdef GLK_MODULE_GARGLKTEXT - case 0x1100: /* garglk_set_zcolors */ - return "2IuIu:"; - case 0x1101: /* garglk_set_zcolors_stream */ - return "3QbIuIu:"; - case 0x1102: /* garglk_set_reversevideo */ - return "1Iu:"; - case 0x1103: /* garglk_set_reversevideo_stream */ - return "2QbIu:"; + case 0x1100: /* garglk_set_zcolors */ + return "2IuIu:"; + case 0x1101: /* garglk_set_zcolors_stream */ + return "3QbIuIu:"; + case 0x1102: /* garglk_set_reversevideo */ + return "1Iu:"; + case 0x1103: /* garglk_set_reversevideo_stream */ + return "2QbIu:"; #endif /* GLK_MODULE_GARGLKTEXT */ - default: - return nullptr; - } + default: + return nullptr; + } } void GlkAPI::gidispatch_call(uint32 funcnum, uint32 numargs, gluniversal_t *arglist) { - switch (funcnum) { - case 0x0001: /* exit */ - glk_exit(); - break; - case 0x0002: /* set_interrupt_handler */ - /* cannot be invoked through dispatch layer */ - break; - case 0x0003: /* tick */ - glk_tick(); - break; - case 0x0004: /* gestalt */ - arglist[3]._uint = glk_gestalt(arglist[0]._uint, arglist[1]._uint); - break; - case 0x0005: /* gestalt_ext */ - if (arglist[2]._ptrflag) { - arglist[6]._uint = glk_gestalt_ext(arglist[0]._uint, arglist[1]._uint, - (uint *)arglist[3]._array, arglist[4]._uint); - } else { - arglist[4]._uint = glk_gestalt_ext(arglist[0]._uint, arglist[1]._uint, - nullptr, 0); - } - break; - case 0x0020: /* window_iterate */ - if (arglist[1]._ptrflag) - arglist[4]._opaqueref = glk_window_iterate((Window *)arglist[0]._opaqueref, &arglist[2]._uint); - else - arglist[3]._opaqueref = glk_window_iterate((Window *)arglist[0]._opaqueref, nullptr); - break; - case 0x0021: /* window_get_rock */ - arglist[2]._uint = glk_window_get_rock((Window *)arglist[0]._opaqueref); - break; - case 0x0022: /* window_get_root */ - arglist[1]._opaqueref = glk_window_get_root(); - break; - case 0x0023: /* window_open */ - arglist[6]._opaqueref = glk_window_open((Window *)arglist[0]._opaqueref, arglist[1]._uint, - arglist[2]._uint, arglist[3]._uint, arglist[4]._uint); - break; - case 0x0024: /* window_close */ - if (arglist[1]._ptrflag) { - stream_result_t dat; - glk_window_close((Window *)arglist[0]._opaqueref, &dat); - arglist[2]._uint = dat._readCount; - arglist[3]._uint = dat._writeCount; - } else { - glk_window_close((Window *)arglist[0]._opaqueref, nullptr); - } - break; - case 0x0025: /* window_get_size */ - { - int ix = 1; - uint *ptr1, *ptr2; - if (!arglist[ix]._ptrflag) { - ptr1 = nullptr; - } else { - ix++; - ptr1 = &(arglist[ix]._uint); - } - ix++; - if (!arglist[ix]._ptrflag) { - ptr2 = nullptr; - } else { - ix++; - ptr2 = &(arglist[ix]._uint); - } - ix++; - glk_window_get_size((Window *)arglist[0]._opaqueref, ptr1, ptr2); + switch (funcnum) { + case 0x0001: /* exit */ + glk_exit(); + break; + case 0x0002: /* set_interrupt_handler */ + /* cannot be invoked through dispatch layer */ + break; + case 0x0003: /* tick */ + glk_tick(); + break; + case 0x0004: /* gestalt */ + arglist[3]._uint = glk_gestalt(arglist[0]._uint, arglist[1]._uint); + break; + case 0x0005: /* gestalt_ext */ + if (arglist[2]._ptrflag) { + arglist[6]._uint = glk_gestalt_ext(arglist[0]._uint, arglist[1]._uint, + (uint *)arglist[3]._array, arglist[4]._uint); + } else { + arglist[4]._uint = glk_gestalt_ext(arglist[0]._uint, arglist[1]._uint, + nullptr, 0); + } + break; + case 0x0020: /* window_iterate */ + if (arglist[1]._ptrflag) + arglist[4]._opaqueref = glk_window_iterate((Window *)arglist[0]._opaqueref, &arglist[2]._uint); + else + arglist[3]._opaqueref = glk_window_iterate((Window *)arglist[0]._opaqueref, nullptr); + break; + case 0x0021: /* window_get_rock */ + arglist[2]._uint = glk_window_get_rock((Window *)arglist[0]._opaqueref); + break; + case 0x0022: /* window_get_root */ + arglist[1]._opaqueref = glk_window_get_root(); + break; + case 0x0023: /* window_open */ + arglist[6]._opaqueref = glk_window_open((Window *)arglist[0]._opaqueref, arglist[1]._uint, + arglist[2]._uint, arglist[3]._uint, arglist[4]._uint); + break; + case 0x0024: /* window_close */ + if (arglist[1]._ptrflag) { + stream_result_t dat; + glk_window_close((Window *)arglist[0]._opaqueref, &dat); + arglist[2]._uint = dat._readCount; + arglist[3]._uint = dat._writeCount; + } else { + glk_window_close((Window *)arglist[0]._opaqueref, nullptr); + } + break; + case 0x0025: /* window_get_size */ + { + int ix = 1; + uint *ptr1, *ptr2; + if (!arglist[ix]._ptrflag) { + ptr1 = nullptr; + } else { + ix++; + ptr1 = &(arglist[ix]._uint); + } + ix++; + if (!arglist[ix]._ptrflag) { + ptr2 = nullptr; + } else { + ix++; + ptr2 = &(arglist[ix]._uint); + } + ix++; + glk_window_get_size((Window *)arglist[0]._opaqueref, ptr1, ptr2); break; - } - case 0x0026: /* window_set_arrangement */ - glk_window_set_arrangement((Window *)arglist[0]._opaqueref, arglist[1]._uint, - arglist[2]._uint, (Window *)arglist[3]._opaqueref); - break; - case 0x0027: /* window_get_arrangement */ - { - int ix = 1; - uint *ptr1, *ptr2; - winid_t *ptr3; - if (!arglist[ix]._ptrflag) { - ptr1 = nullptr; - } else { - ix++; - ptr1 = &(arglist[ix]._uint); - } - ix++; - if (!arglist[ix]._ptrflag) { - ptr2 = nullptr; - } else { - ix++; - ptr2 = &(arglist[ix]._uint); - } - ix++; - if (!arglist[ix]._ptrflag) { - ptr3 = nullptr; - } else { - ix++; - ptr3 = (winid_t *)(&(arglist[ix]._opaqueref)); - } - ix++; - glk_window_get_arrangement((Window *)arglist[0]._opaqueref, ptr1, ptr2, ptr3); - } - break; - case 0x0028: /* window_get_type */ - arglist[2]._uint = glk_window_get_type((Window *)arglist[0]._opaqueref); - break; - case 0x0029: /* window_get_parent */ - arglist[2]._opaqueref = glk_window_get_parent((Window *)arglist[0]._opaqueref); - break; - case 0x002A: /* window_clear */ - glk_window_clear((Window *)arglist[0]._opaqueref); - break; - case 0x002B: /* window_move_cursor */ - glk_window_move_cursor((Window *)arglist[0]._opaqueref, arglist[1]._uint, - arglist[2]._uint); - break; - case 0x002C: /* window_get_stream */ - arglist[2]._opaqueref = glk_window_get_stream((Window *)arglist[0]._opaqueref); - break; - case 0x002D: /* window_set_echo_stream */ - glk_window_set_echo_stream((Window *)arglist[0]._opaqueref, (Stream *)arglist[1]._opaqueref); - break; - case 0x002E: /* window_get_echo_stream */ - arglist[2]._opaqueref = glk_window_get_echo_stream((Window *)arglist[0]._opaqueref); - break; - case 0x002F: /* set_window */ - glk_set_window((Window *)arglist[0]._opaqueref); - break; - case 0x0030: /* window_get_sibling */ - arglist[2]._opaqueref = glk_window_get_sibling((Window *)arglist[0]._opaqueref); - break; - case 0x0040: /* stream_iterate */ - if (arglist[1]._ptrflag) - arglist[4]._opaqueref = glk_stream_iterate((Stream *)arglist[0]._opaqueref, &arglist[2]._uint); - else - arglist[3]._opaqueref = glk_stream_iterate((Stream *)arglist[0]._opaqueref, nullptr); - break; - case 0x0041: /* stream_get_rock */ - arglist[2]._uint = glk_stream_get_rock((Stream *)arglist[0]._opaqueref); - break; - case 0x0042: /* stream_open_file */ - arglist[4]._opaqueref = glk_stream_open_file((frefid_t)arglist[0]._opaqueref, (FileMode)arglist[1]._uint, - arglist[2]._uint); - break; - case 0x0043: /* stream_open_memory */ - if (arglist[0]._ptrflag) - arglist[6]._opaqueref = glk_stream_open_memory((char *)arglist[1]._array, - arglist[2]._uint, (FileMode)arglist[3]._uint, arglist[4]._uint); - else - arglist[4]._opaqueref = glk_stream_open_memory(nullptr, 0, (FileMode)arglist[1]._uint, arglist[2]._uint); - break; - case 0x0044: /* stream_close */ - if (arglist[1]._ptrflag) { - stream_result_t dat; - glk_stream_close((Stream *)arglist[0]._opaqueref, &dat); - arglist[2]._uint = dat._readCount; - arglist[3]._uint = dat._writeCount; - } else { - glk_stream_close((Stream *)arglist[0]._opaqueref, nullptr); - } - break; - case 0x0045: /* stream_set_position */ - glk_stream_set_position((Stream *)arglist[0]._opaqueref, arglist[1]._sint, - arglist[2]._uint); - break; - case 0x0046: /* stream_get_position */ - arglist[2]._uint = glk_stream_get_position((Stream *)arglist[0]._opaqueref); - break; - case 0x0047: /* stream_set_current */ - glk_stream_set_current((Stream *)arglist[0]._opaqueref); - break; - case 0x0048: /* stream_get_current */ - arglist[1]._opaqueref = glk_stream_get_current(); - break; - case 0x0060: /* fileref_create_temp */ - arglist[3]._opaqueref = glk_fileref_create_temp(arglist[0]._uint, - arglist[1]._uint); - break; - case 0x0061: /* fileref_create_by_name */ - arglist[4]._opaqueref = glk_fileref_create_by_name(arglist[0]._uint, - arglist[1]._charstr, arglist[2]._uint); - break; - case 0x0062: /* fileref_create_by_prompt */ - arglist[4]._opaqueref = glk_fileref_create_by_prompt(arglist[0]._uint, (FileMode)arglist[1]._uint, arglist[2]._uint); - break; - case 0x0063: /* fileref_destroy */ - glk_fileref_destroy((frefid_t)arglist[0]._opaqueref); - break; - case 0x0064: /* fileref_iterate */ - if (arglist[1]._ptrflag) - arglist[4]._opaqueref = glk_fileref_iterate((frefid_t)arglist[0]._opaqueref, &arglist[2]._uint); - else - arglist[3]._opaqueref = glk_fileref_iterate((frefid_t)arglist[0]._opaqueref, nullptr); - break; - case 0x0065: /* fileref_get_rock */ - arglist[2]._uint = glk_fileref_get_rock((frefid_t)arglist[0]._opaqueref); - break; - case 0x0066: /* fileref_delete_file */ - glk_fileref_delete_file((frefid_t)arglist[0]._opaqueref); - break; - case 0x0067: /* fileref_does_file_exist */ - arglist[2]._uint = glk_fileref_does_file_exist((frefid_t)arglist[0]._opaqueref); - break; - case 0x0068: /* fileref_create_from_fileref */ - arglist[4]._opaqueref = glk_fileref_create_from_fileref(arglist[0]._uint, (frefid_t)arglist[1]._opaqueref, arglist[2]._uint); - break; - case 0x0080: /* put_char */ - glk_put_char(arglist[0]._uch); - break; - case 0x0081: /* put_char_stream */ - glk_put_char_stream((Stream *)arglist[0]._opaqueref, arglist[1]._uch); - break; - case 0x0082: /* put_string */ - glk_put_string(arglist[0]._charstr); - break; - case 0x0083: /* put_string_stream */ - glk_put_string_stream((Stream *)arglist[0]._opaqueref, arglist[1]._charstr); - break; - case 0x0084: /* put_buffer */ - if (arglist[0]._ptrflag) - glk_put_buffer((const char *)arglist[1]._array, arglist[2]._uint); - else - glk_put_buffer(nullptr, 0); - break; - case 0x0085: /* put_buffer_stream */ - if (arglist[1]._ptrflag) - glk_put_buffer_stream((Stream *)arglist[0]._opaqueref, (const char *)arglist[2]._array, arglist[3]._uint); - else - glk_put_buffer_stream((Stream *)arglist[0]._opaqueref, - nullptr, 0); - break; - case 0x0086: /* set_style */ - glk_set_style(arglist[0]._uint); - break; - case 0x0087: /* set_style_stream */ - glk_set_style_stream((Stream *)arglist[0]._opaqueref, arglist[1]._uint); - break; - case 0x0090: /* get_char_stream */ - arglist[2]._sint = glk_get_char_stream((Stream *)arglist[0]._opaqueref); - break; - case 0x0091: /* get_line_stream */ - if (arglist[1]._ptrflag) - arglist[5]._uint = glk_get_line_stream((Stream *)arglist[0]._opaqueref, (char *)arglist[2]._array, arglist[3]._uint); - else - arglist[3]._uint = glk_get_line_stream((Stream *)arglist[0]._opaqueref, - nullptr, 0); - break; - case 0x0092: /* get_buffer_stream */ - if (arglist[1]._ptrflag) - arglist[5]._uint = glk_get_buffer_stream((Stream *)arglist[0]._opaqueref, (char *)arglist[2]._array, arglist[3]._uint); - else - arglist[3]._uint = glk_get_buffer_stream((Stream *)arglist[0]._opaqueref, - nullptr, 0); - break; - case 0x00A0: /* char_to_lower */ - arglist[2]._uch = glk_char_to_lower(arglist[0]._uch); - break; - case 0x00A1: /* char_to_upper */ - arglist[2]._uch = glk_char_to_upper(arglist[0]._uch); - break; - case 0x00B0: /* stylehint_set */ - glk_stylehint_set(arglist[0]._uint, arglist[1]._uint, - arglist[2]._uint, arglist[3]._sint); - break; - case 0x00B1: /* stylehint_clear */ - glk_stylehint_clear(arglist[0]._uint, arglist[1]._uint, - arglist[2]._uint); - break; - case 0x00B2: /* style_distinguish */ - arglist[4]._uint = glk_style_distinguish((Window *)arglist[0]._opaqueref, arglist[1]._uint, - arglist[2]._uint); - break; - case 0x00B3: /* style_measure */ - if (arglist[3]._ptrflag) - arglist[6]._uint = glk_style_measure((Window *)arglist[0]._opaqueref, arglist[1]._uint, - arglist[2]._uint, &(arglist[4]._uint)); - else - arglist[5]._uint = glk_style_measure((Window *)arglist[0]._opaqueref, arglist[1]._uint, - arglist[2]._uint, nullptr); - break; - case 0x00C0: /* select */ - if (arglist[0]._ptrflag) { - event_t dat; - glk_select(&dat); - arglist[1]._uint = dat.type; - arglist[2]._opaqueref = dat.window; - arglist[3]._uint = dat.val1; - arglist[4]._uint = dat.val2; - } else { - glk_select(nullptr); - } - break; - case 0x00C1: /* select_poll */ - if (arglist[0]._ptrflag) { - event_t dat; - glk_select_poll(&dat); - arglist[1]._uint = dat.type; - arglist[2]._opaqueref = dat.window; - arglist[3]._uint = dat.val1; - arglist[4]._uint = dat.val2; - } else { - glk_select_poll(nullptr); - } - break; - case 0x00D0: /* request_line_event */ - if (arglist[1]._ptrflag) - glk_request_line_event((Window *)arglist[0]._opaqueref, (char *)arglist[2]._array, - arglist[3]._uint, arglist[4]._uint); - else - glk_request_line_event((Window *)arglist[0]._opaqueref, nullptr, - 0, arglist[2]._uint); - break; - case 0x00D1: /* cancel_line_event */ - if (arglist[1]._ptrflag) { - event_t dat; - glk_cancel_line_event((Window *)arglist[0]._opaqueref, &dat); - arglist[2]._uint = dat.type; - arglist[3]._opaqueref = dat.window; - arglist[4]._uint = dat.val1; - arglist[5]._uint = dat.val2; - } else { - glk_cancel_line_event((Window *)arglist[0]._opaqueref, nullptr); - } - break; - case 0x00D2: /* request_char_event */ - glk_request_char_event((Window *)arglist[0]._opaqueref); - break; - case 0x00D3: /* cancel_char_event */ - glk_cancel_char_event((Window *)arglist[0]._opaqueref); - break; - case 0x00D4: /* request_mouse_event */ - glk_request_mouse_event((Window *)arglist[0]._opaqueref); - break; - case 0x00D5: /* cancel_mouse_event */ - glk_cancel_mouse_event((Window *)arglist[0]._opaqueref); - break; - case 0x00D6: /* request_timer_events */ - glk_request_timer_events(arglist[0]._uint); - break; + } + case 0x0026: /* window_set_arrangement */ + glk_window_set_arrangement((Window *)arglist[0]._opaqueref, arglist[1]._uint, + arglist[2]._uint, (Window *)arglist[3]._opaqueref); + break; + case 0x0027: /* window_get_arrangement */ + { + int ix = 1; + uint *ptr1, *ptr2; + winid_t *ptr3; + if (!arglist[ix]._ptrflag) { + ptr1 = nullptr; + } else { + ix++; + ptr1 = &(arglist[ix]._uint); + } + ix++; + if (!arglist[ix]._ptrflag) { + ptr2 = nullptr; + } else { + ix++; + ptr2 = &(arglist[ix]._uint); + } + ix++; + if (!arglist[ix]._ptrflag) { + ptr3 = nullptr; + } else { + ix++; + ptr3 = (winid_t *)(&(arglist[ix]._opaqueref)); + } + ix++; + glk_window_get_arrangement((Window *)arglist[0]._opaqueref, ptr1, ptr2, ptr3); + } + break; + case 0x0028: /* window_get_type */ + arglist[2]._uint = glk_window_get_type((Window *)arglist[0]._opaqueref); + break; + case 0x0029: /* window_get_parent */ + arglist[2]._opaqueref = glk_window_get_parent((Window *)arglist[0]._opaqueref); + break; + case 0x002A: /* window_clear */ + glk_window_clear((Window *)arglist[0]._opaqueref); + break; + case 0x002B: /* window_move_cursor */ + glk_window_move_cursor((Window *)arglist[0]._opaqueref, arglist[1]._uint, + arglist[2]._uint); + break; + case 0x002C: /* window_get_stream */ + arglist[2]._opaqueref = glk_window_get_stream((Window *)arglist[0]._opaqueref); + break; + case 0x002D: /* window_set_echo_stream */ + glk_window_set_echo_stream((Window *)arglist[0]._opaqueref, (Stream *)arglist[1]._opaqueref); + break; + case 0x002E: /* window_get_echo_stream */ + arglist[2]._opaqueref = glk_window_get_echo_stream((Window *)arglist[0]._opaqueref); + break; + case 0x002F: /* set_window */ + glk_set_window((Window *)arglist[0]._opaqueref); + break; + case 0x0030: /* window_get_sibling */ + arglist[2]._opaqueref = glk_window_get_sibling((Window *)arglist[0]._opaqueref); + break; + case 0x0040: /* stream_iterate */ + if (arglist[1]._ptrflag) + arglist[4]._opaqueref = glk_stream_iterate((Stream *)arglist[0]._opaqueref, &arglist[2]._uint); + else + arglist[3]._opaqueref = glk_stream_iterate((Stream *)arglist[0]._opaqueref, nullptr); + break; + case 0x0041: /* stream_get_rock */ + arglist[2]._uint = glk_stream_get_rock((Stream *)arglist[0]._opaqueref); + break; + case 0x0042: /* stream_open_file */ + arglist[4]._opaqueref = glk_stream_open_file((frefid_t)arglist[0]._opaqueref, (FileMode)arglist[1]._uint, + arglist[2]._uint); + break; + case 0x0043: /* stream_open_memory */ + if (arglist[0]._ptrflag) + arglist[6]._opaqueref = glk_stream_open_memory((char *)arglist[1]._array, + arglist[2]._uint, (FileMode)arglist[3]._uint, arglist[4]._uint); + else + arglist[4]._opaqueref = glk_stream_open_memory(nullptr, 0, (FileMode)arglist[1]._uint, arglist[2]._uint); + break; + case 0x0044: /* stream_close */ + if (arglist[1]._ptrflag) { + stream_result_t dat; + glk_stream_close((Stream *)arglist[0]._opaqueref, &dat); + arglist[2]._uint = dat._readCount; + arglist[3]._uint = dat._writeCount; + } else { + glk_stream_close((Stream *)arglist[0]._opaqueref, nullptr); + } + break; + case 0x0045: /* stream_set_position */ + glk_stream_set_position((Stream *)arglist[0]._opaqueref, arglist[1]._sint, + arglist[2]._uint); + break; + case 0x0046: /* stream_get_position */ + arglist[2]._uint = glk_stream_get_position((Stream *)arglist[0]._opaqueref); + break; + case 0x0047: /* stream_set_current */ + glk_stream_set_current((Stream *)arglist[0]._opaqueref); + break; + case 0x0048: /* stream_get_current */ + arglist[1]._opaqueref = glk_stream_get_current(); + break; + case 0x0060: /* fileref_create_temp */ + arglist[3]._opaqueref = glk_fileref_create_temp(arglist[0]._uint, + arglist[1]._uint); + break; + case 0x0061: /* fileref_create_by_name */ + arglist[4]._opaqueref = glk_fileref_create_by_name(arglist[0]._uint, + arglist[1]._charstr, arglist[2]._uint); + break; + case 0x0062: /* fileref_create_by_prompt */ + arglist[4]._opaqueref = glk_fileref_create_by_prompt(arglist[0]._uint, (FileMode)arglist[1]._uint, arglist[2]._uint); + break; + case 0x0063: /* fileref_destroy */ + glk_fileref_destroy((frefid_t)arglist[0]._opaqueref); + break; + case 0x0064: /* fileref_iterate */ + if (arglist[1]._ptrflag) + arglist[4]._opaqueref = glk_fileref_iterate((frefid_t)arglist[0]._opaqueref, &arglist[2]._uint); + else + arglist[3]._opaqueref = glk_fileref_iterate((frefid_t)arglist[0]._opaqueref, nullptr); + break; + case 0x0065: /* fileref_get_rock */ + arglist[2]._uint = glk_fileref_get_rock((frefid_t)arglist[0]._opaqueref); + break; + case 0x0066: /* fileref_delete_file */ + glk_fileref_delete_file((frefid_t)arglist[0]._opaqueref); + break; + case 0x0067: /* fileref_does_file_exist */ + arglist[2]._uint = glk_fileref_does_file_exist((frefid_t)arglist[0]._opaqueref); + break; + case 0x0068: /* fileref_create_from_fileref */ + arglist[4]._opaqueref = glk_fileref_create_from_fileref(arglist[0]._uint, (frefid_t)arglist[1]._opaqueref, arglist[2]._uint); + break; + case 0x0080: /* put_char */ + glk_put_char(arglist[0]._uch); + break; + case 0x0081: /* put_char_stream */ + glk_put_char_stream((Stream *)arglist[0]._opaqueref, arglist[1]._uch); + break; + case 0x0082: /* put_string */ + glk_put_string(arglist[0]._charstr); + break; + case 0x0083: /* put_string_stream */ + glk_put_string_stream((Stream *)arglist[0]._opaqueref, arglist[1]._charstr); + break; + case 0x0084: /* put_buffer */ + if (arglist[0]._ptrflag) + glk_put_buffer((const char *)arglist[1]._array, arglist[2]._uint); + else + glk_put_buffer(nullptr, 0); + break; + case 0x0085: /* put_buffer_stream */ + if (arglist[1]._ptrflag) + glk_put_buffer_stream((Stream *)arglist[0]._opaqueref, (const char *)arglist[2]._array, arglist[3]._uint); + else + glk_put_buffer_stream((Stream *)arglist[0]._opaqueref, + nullptr, 0); + break; + case 0x0086: /* set_style */ + glk_set_style(arglist[0]._uint); + break; + case 0x0087: /* set_style_stream */ + glk_set_style_stream((Stream *)arglist[0]._opaqueref, arglist[1]._uint); + break; + case 0x0090: /* get_char_stream */ + arglist[2]._sint = glk_get_char_stream((Stream *)arglist[0]._opaqueref); + break; + case 0x0091: /* get_line_stream */ + if (arglist[1]._ptrflag) + arglist[5]._uint = glk_get_line_stream((Stream *)arglist[0]._opaqueref, (char *)arglist[2]._array, arglist[3]._uint); + else + arglist[3]._uint = glk_get_line_stream((Stream *)arglist[0]._opaqueref, + nullptr, 0); + break; + case 0x0092: /* get_buffer_stream */ + if (arglist[1]._ptrflag) + arglist[5]._uint = glk_get_buffer_stream((Stream *)arglist[0]._opaqueref, (char *)arglist[2]._array, arglist[3]._uint); + else + arglist[3]._uint = glk_get_buffer_stream((Stream *)arglist[0]._opaqueref, + nullptr, 0); + break; + case 0x00A0: /* char_to_lower */ + arglist[2]._uch = glk_char_to_lower(arglist[0]._uch); + break; + case 0x00A1: /* char_to_upper */ + arglist[2]._uch = glk_char_to_upper(arglist[0]._uch); + break; + case 0x00B0: /* stylehint_set */ + glk_stylehint_set(arglist[0]._uint, arglist[1]._uint, + arglist[2]._uint, arglist[3]._sint); + break; + case 0x00B1: /* stylehint_clear */ + glk_stylehint_clear(arglist[0]._uint, arglist[1]._uint, + arglist[2]._uint); + break; + case 0x00B2: /* style_distinguish */ + arglist[4]._uint = glk_style_distinguish((Window *)arglist[0]._opaqueref, arglist[1]._uint, + arglist[2]._uint); + break; + case 0x00B3: /* style_measure */ + if (arglist[3]._ptrflag) + arglist[6]._uint = glk_style_measure((Window *)arglist[0]._opaqueref, arglist[1]._uint, + arglist[2]._uint, &(arglist[4]._uint)); + else + arglist[5]._uint = glk_style_measure((Window *)arglist[0]._opaqueref, arglist[1]._uint, + arglist[2]._uint, nullptr); + break; + case 0x00C0: /* select */ + if (arglist[0]._ptrflag) { + event_t dat; + glk_select(&dat); + arglist[1]._uint = dat.type; + arglist[2]._opaqueref = dat.window; + arglist[3]._uint = dat.val1; + arglist[4]._uint = dat.val2; + } else { + glk_select(nullptr); + } + break; + case 0x00C1: /* select_poll */ + if (arglist[0]._ptrflag) { + event_t dat; + glk_select_poll(&dat); + arglist[1]._uint = dat.type; + arglist[2]._opaqueref = dat.window; + arglist[3]._uint = dat.val1; + arglist[4]._uint = dat.val2; + } else { + glk_select_poll(nullptr); + } + break; + case 0x00D0: /* request_line_event */ + if (arglist[1]._ptrflag) + glk_request_line_event((Window *)arglist[0]._opaqueref, (char *)arglist[2]._array, + arglist[3]._uint, arglist[4]._uint); + else + glk_request_line_event((Window *)arglist[0]._opaqueref, nullptr, + 0, arglist[2]._uint); + break; + case 0x00D1: /* cancel_line_event */ + if (arglist[1]._ptrflag) { + event_t dat; + glk_cancel_line_event((Window *)arglist[0]._opaqueref, &dat); + arglist[2]._uint = dat.type; + arglist[3]._opaqueref = dat.window; + arglist[4]._uint = dat.val1; + arglist[5]._uint = dat.val2; + } else { + glk_cancel_line_event((Window *)arglist[0]._opaqueref, nullptr); + } + break; + case 0x00D2: /* request_char_event */ + glk_request_char_event((Window *)arglist[0]._opaqueref); + break; + case 0x00D3: /* cancel_char_event */ + glk_cancel_char_event((Window *)arglist[0]._opaqueref); + break; + case 0x00D4: /* request_mouse_event */ + glk_request_mouse_event((Window *)arglist[0]._opaqueref); + break; + case 0x00D5: /* cancel_mouse_event */ + glk_cancel_mouse_event((Window *)arglist[0]._opaqueref); + break; + case 0x00D6: /* request_timer_events */ + glk_request_timer_events(arglist[0]._uint); + break; #ifdef GLK_MODULE_IMAGE - case 0x00E0: /* image_get_info */ - { - int ix = 1; - uint *ptr1, *ptr2; - if (!arglist[ix]._ptrflag) { - ptr1 = nullptr; - } else { - ix++; - ptr1 = &(arglist[ix]._uint); - } - ix++; - if (!arglist[ix]._ptrflag) { - ptr2 = nullptr; - } else { - ix++; - ptr2 = &(arglist[ix]._uint); - } - ix++; - ix++; - arglist[ix]._uint = glk_image_get_info(arglist[0]._uint, ptr1, ptr2); - } - break; - case 0x00E1: /* image_draw */ - arglist[5]._uint = glk_image_draw((Window *)arglist[0]._opaqueref, - arglist[1]._uint, - arglist[2]._sint, arglist[3]._sint); - break; - case 0x00E2: /* image_draw_scaled */ - arglist[7]._uint = glk_image_draw_scaled((Window *)arglist[0]._opaqueref, - arglist[1]._uint, - arglist[2]._sint, arglist[3]._sint, - arglist[4]._uint, arglist[5]._uint); - break; - case 0x00E8: /* window_flow_break */ - glk_window_flow_break((Window *)arglist[0]._opaqueref); - break; - case 0x00E9: /* window_erase_rect */ - glk_window_erase_rect((Window *)arglist[0]._opaqueref, - arglist[1]._sint, arglist[2]._sint, - arglist[3]._uint, arglist[4]._uint); - break; - case 0x00EA: /* window_fill_rect */ - glk_window_fill_rect((Window *)arglist[0]._opaqueref, arglist[1]._uint, - arglist[2]._sint, arglist[3]._sint, - arglist[4]._uint, arglist[5]._uint); - break; - case 0x00EB: /* window_set_background_color */ - glk_window_set_background_color((Window *)arglist[0]._opaqueref, arglist[1]._uint); - break; + case 0x00E0: /* image_get_info */ + { + int ix = 1; + uint *ptr1, *ptr2; + if (!arglist[ix]._ptrflag) { + ptr1 = nullptr; + } else { + ix++; + ptr1 = &(arglist[ix]._uint); + } + ix++; + if (!arglist[ix]._ptrflag) { + ptr2 = nullptr; + } else { + ix++; + ptr2 = &(arglist[ix]._uint); + } + ix++; + ix++; + arglist[ix]._uint = glk_image_get_info(arglist[0]._uint, ptr1, ptr2); + } + break; + case 0x00E1: /* image_draw */ + arglist[5]._uint = glk_image_draw((Window *)arglist[0]._opaqueref, + arglist[1]._uint, + arglist[2]._sint, arglist[3]._sint); + break; + case 0x00E2: /* image_draw_scaled */ + arglist[7]._uint = glk_image_draw_scaled((Window *)arglist[0]._opaqueref, + arglist[1]._uint, + arglist[2]._sint, arglist[3]._sint, + arglist[4]._uint, arglist[5]._uint); + break; + case 0x00E8: /* window_flow_break */ + glk_window_flow_break((Window *)arglist[0]._opaqueref); + break; + case 0x00E9: /* window_erase_rect */ + glk_window_erase_rect((Window *)arglist[0]._opaqueref, + arglist[1]._sint, arglist[2]._sint, + arglist[3]._uint, arglist[4]._uint); + break; + case 0x00EA: /* window_fill_rect */ + glk_window_fill_rect((Window *)arglist[0]._opaqueref, arglist[1]._uint, + arglist[2]._sint, arglist[3]._sint, + arglist[4]._uint, arglist[5]._uint); + break; + case 0x00EB: /* window_set_background_color */ + glk_window_set_background_color((Window *)arglist[0]._opaqueref, arglist[1]._uint); + break; #endif /* GLK_MODULE_IMAGE */ #ifdef GLK_MODULE_SOUND - case 0x00F0: /* schannel_iterate */ - if (arglist[1]._ptrflag) - arglist[4]._opaqueref = glk_schannel_iterate((schanid_t)arglist[0]._opaqueref, &arglist[2]._uint); - else - arglist[3]._opaqueref = glk_schannel_iterate((schanid_t)arglist[0]._opaqueref, nullptr); - break; - case 0x00F1: /* schannel_get_rock */ - arglist[2]._uint = glk_schannel_get_rock((schanid_t)arglist[0]._opaqueref); - break; - case 0x00F2: /* schannel_create */ - arglist[2]._opaqueref = glk_schannel_create(arglist[0]._uint); - break; - case 0x00F3: /* schannel_destroy */ - glk_schannel_destroy((schanid_t)arglist[0]._opaqueref); - break; - case 0x00F8: /* schannel_play */ - arglist[3]._uint = glk_schannel_play((schanid_t)arglist[0]._opaqueref, arglist[1]._uint); - break; - case 0x00F9: /* schannel_play_ext */ - arglist[5]._uint = glk_schannel_play_ext((schanid_t)arglist[0]._opaqueref, - arglist[1]._uint, arglist[2]._uint, arglist[3]._uint); - break; - case 0x00FA: /* schannel_stop */ - glk_schannel_stop((schanid_t)arglist[0]._opaqueref); - break; - case 0x00FB: /* schannel_set_volume */ - glk_schannel_set_volume((schanid_t)arglist[0]._opaqueref, arglist[1]._uint); - break; - case 0x00FC: /* sound_load_hint */ - glk_sound_load_hint(arglist[0]._uint, arglist[1]._uint); - break; + case 0x00F0: /* schannel_iterate */ + if (arglist[1]._ptrflag) + arglist[4]._opaqueref = glk_schannel_iterate((schanid_t)arglist[0]._opaqueref, &arglist[2]._uint); + else + arglist[3]._opaqueref = glk_schannel_iterate((schanid_t)arglist[0]._opaqueref, nullptr); + break; + case 0x00F1: /* schannel_get_rock */ + arglist[2]._uint = glk_schannel_get_rock((schanid_t)arglist[0]._opaqueref); + break; + case 0x00F2: /* schannel_create */ + arglist[2]._opaqueref = glk_schannel_create(arglist[0]._uint); + break; + case 0x00F3: /* schannel_destroy */ + glk_schannel_destroy((schanid_t)arglist[0]._opaqueref); + break; + case 0x00F8: /* schannel_play */ + arglist[3]._uint = glk_schannel_play((schanid_t)arglist[0]._opaqueref, arglist[1]._uint); + break; + case 0x00F9: /* schannel_play_ext */ + arglist[5]._uint = glk_schannel_play_ext((schanid_t)arglist[0]._opaqueref, + arglist[1]._uint, arglist[2]._uint, arglist[3]._uint); + break; + case 0x00FA: /* schannel_stop */ + glk_schannel_stop((schanid_t)arglist[0]._opaqueref); + break; + case 0x00FB: /* schannel_set_volume */ + glk_schannel_set_volume((schanid_t)arglist[0]._opaqueref, arglist[1]._uint); + break; + case 0x00FC: /* sound_load_hint */ + glk_sound_load_hint(arglist[0]._uint, arglist[1]._uint); + break; #ifdef GLK_MODULE_SOUND2 - case 0x00F4: /* schannel_create_ext */ - arglist[3]._opaqueref = glk_schannel_create_ext(arglist[0]._uint, arglist[1]._uint); - break; - case 0x00F7: /* schannel_play_multi */ - if (arglist[0]._ptrflag && arglist[3]._ptrflag) - arglist[8]._uint = glk_schannel_play_multi((schanid_t *)arglist[1]._array, arglist[2]._uint, (uint *)arglist[4]._array, arglist[5]._uint, arglist[6]._uint); - else if (arglist[0]._ptrflag) - arglist[6]._uint = glk_schannel_play_multi((schanid_t *)arglist[1]._array, arglist[2]._uint, nullptr, 0, arglist[4]._uint); - else if (arglist[1]._ptrflag) - arglist[6]._uint = glk_schannel_play_multi(nullptr, 0, (uint *)arglist[2]._array, arglist[3]._uint, arglist[4]._uint); - else - arglist[4]._uint = glk_schannel_play_multi(nullptr, 0, nullptr, 0, arglist[2]._uint); - break; - case 0x00FD: /* schannel_set_volume_ext */ - glk_schannel_set_volume_ext((schanid_t)arglist[0]._opaqueref, arglist[1]._uint, arglist[2]._uint, arglist[3]._uint); - break; - case 0x00FE: /* schannel_pause */ - glk_schannel_pause((schanid_t)arglist[0]._opaqueref); - break; - case 0x00FF: /* schannel_unpause */ - glk_schannel_unpause((schanid_t)arglist[0]._opaqueref); - break; + case 0x00F4: /* schannel_create_ext */ + arglist[3]._opaqueref = glk_schannel_create_ext(arglist[0]._uint, arglist[1]._uint); + break; + case 0x00F7: /* schannel_play_multi */ + if (arglist[0]._ptrflag && arglist[3]._ptrflag) + arglist[8]._uint = glk_schannel_play_multi((schanid_t *)arglist[1]._array, arglist[2]._uint, (uint *)arglist[4]._array, arglist[5]._uint, arglist[6]._uint); + else if (arglist[0]._ptrflag) + arglist[6]._uint = glk_schannel_play_multi((schanid_t *)arglist[1]._array, arglist[2]._uint, nullptr, 0, arglist[4]._uint); + else if (arglist[1]._ptrflag) + arglist[6]._uint = glk_schannel_play_multi(nullptr, 0, (uint *)arglist[2]._array, arglist[3]._uint, arglist[4]._uint); + else + arglist[4]._uint = glk_schannel_play_multi(nullptr, 0, nullptr, 0, arglist[2]._uint); + break; + case 0x00FD: /* schannel_set_volume_ext */ + glk_schannel_set_volume_ext((schanid_t)arglist[0]._opaqueref, arglist[1]._uint, arglist[2]._uint, arglist[3]._uint); + break; + case 0x00FE: /* schannel_pause */ + glk_schannel_pause((schanid_t)arglist[0]._opaqueref); + break; + case 0x00FF: /* schannel_unpause */ + glk_schannel_unpause((schanid_t)arglist[0]._opaqueref); + break; #endif /* GLK_MODULE_SOUND2 */ #endif /* GLK_MODULE_SOUND */ #ifdef GLK_MODULE_HYPERLINKS - case 0x0100: /* set_hyperlink */ - glk_set_hyperlink(arglist[0]._uint); - break; - case 0x0101: /* set_hyperlink_stream */ - glk_set_hyperlink_stream((strid_t)arglist[0]._opaqueref, arglist[1]._uint); - break; - case 0x0102: /* request_hyperlink_event */ - glk_request_hyperlink_event((Window *)arglist[0]._opaqueref); - break; - case 0x0103: /* cancel_hyperlink_event */ - glk_cancel_hyperlink_event((Window *)arglist[0]._opaqueref); - break; + case 0x0100: /* set_hyperlink */ + glk_set_hyperlink(arglist[0]._uint); + break; + case 0x0101: /* set_hyperlink_stream */ + glk_set_hyperlink_stream((strid_t)arglist[0]._opaqueref, arglist[1]._uint); + break; + case 0x0102: /* request_hyperlink_event */ + glk_request_hyperlink_event((Window *)arglist[0]._opaqueref); + break; + case 0x0103: /* cancel_hyperlink_event */ + glk_cancel_hyperlink_event((Window *)arglist[0]._opaqueref); + break; #endif /* GLK_MODULE_HYPERLINKS */ #ifdef GLK_MODULE_UNICODE - case 0x0120: /* buffer_to_lower_case_uni */ - if (arglist[0]._ptrflag) - arglist[5]._uint = glk_buffer_to_lower_case_uni((uint32 *)arglist[1]._array, arglist[2]._uint, arglist[3]._uint); - else - arglist[3]._uint = glk_buffer_to_lower_case_uni(nullptr, 0, arglist[1]._uint); - break; - case 0x0121: /* buffer_to_upper_case_uni */ - if (arglist[0]._ptrflag) - arglist[5]._uint = glk_buffer_to_upper_case_uni((uint32 *)arglist[1]._array, arglist[2]._uint, arglist[3]._uint); - else - arglist[3]._uint = glk_buffer_to_upper_case_uni(nullptr, 0, arglist[1]._uint); - break; - case 0x0122: /* buffer_to_title_case_uni */ - if (arglist[0]._ptrflag) - arglist[6]._uint = glk_buffer_to_title_case_uni((uint32 *)arglist[1]._array, arglist[2]._uint, arglist[3]._uint, arglist[4]._uint); - else - arglist[4]._uint = glk_buffer_to_title_case_uni(nullptr, 0, arglist[1]._uint, arglist[2]._uint); - break; - case 0x0128: /* put_char_uni */ - glk_put_char_uni(arglist[0]._uint); - break; - case 0x0129: /* put_string_uni */ - glk_put_string_uni(arglist[0]._unicharstr); - break; - case 0x012A: /* put_buffer_uni */ - if (arglist[0]._ptrflag) - glk_put_buffer_uni((const uint32 *)arglist[1]._array, arglist[2]._uint); - else - glk_put_buffer_uni(nullptr, 0); - break; - case 0x012B: /* put_char_stream_uni */ - glk_put_char_stream_uni((strid_t)arglist[0]._opaqueref, arglist[1]._uint); - break; - case 0x012C: /* put_string_stream_uni */ - glk_put_string_stream_uni((strid_t)arglist[0]._opaqueref, arglist[1]._unicharstr); - break; - case 0x012D: /* put_buffer_stream_uni */ - if (arglist[1]._ptrflag) - glk_put_buffer_stream_uni((strid_t)arglist[0]._opaqueref, (const uint32 *)arglist[2]._array, arglist[3]._uint); - else - glk_put_buffer_stream_uni((strid_t)arglist[0]._opaqueref, nullptr, 0); - break; - case 0x0130: /* get_char_stream_uni */ - arglist[2]._sint = glk_get_char_stream_uni((strid_t)arglist[0]._opaqueref); - break; - case 0x0131: /* get_buffer_stream_uni */ - if (arglist[1]._ptrflag) - arglist[5]._uint = glk_get_buffer_stream_uni((strid_t)arglist[0]._opaqueref, - (uint32 *)arglist[2]._array, arglist[3]._uint); - else - arglist[3]._uint = glk_get_buffer_stream_uni((strid_t)arglist[0]._opaqueref, nullptr, 0); - break; - case 0x0132: /* get_line_stream_uni */ - if (arglist[1]._ptrflag) - arglist[5]._uint = glk_get_line_stream_uni((strid_t)arglist[0]._opaqueref, - (uint32 *)arglist[2]._array, arglist[3]._uint); - else - arglist[3]._uint = glk_get_line_stream_uni((strid_t)arglist[0]._opaqueref, nullptr, 0); - break; - case 0x0138: /* stream_open_file_uni */ - arglist[4]._opaqueref = glk_stream_open_file_uni((frefid_t)arglist[0]._opaqueref, (FileMode)arglist[1]._uint, - arglist[2]._uint); - break; - case 0x0139: /* stream_open_memory_uni */ - if (arglist[0]._ptrflag) - arglist[6]._opaqueref = glk_stream_open_memory_uni((uint32 *)arglist[1]._array, - arglist[2]._uint, (FileMode)arglist[3]._uint, arglist[4]._uint); - else - arglist[4]._opaqueref = glk_stream_open_memory_uni(nullptr, 0, (FileMode)arglist[1]._uint, arglist[2]._uint); - break; - case 0x0140: /* request_char_event_uni */ - glk_request_char_event_uni((Window *)arglist[0]._opaqueref); - break; - case 0x0141: /* request_line_event_uni */ - if (arglist[1]._ptrflag) - glk_request_line_event_uni((Window *)arglist[0]._opaqueref, (uint32 *)arglist[2]._array, - arglist[3]._uint, arglist[4]._uint); - else - glk_request_line_event_uni((Window *)arglist[0]._opaqueref, nullptr, - 0, arglist[2]._uint); - break; + case 0x0120: /* buffer_to_lower_case_uni */ + if (arglist[0]._ptrflag) + arglist[5]._uint = glk_buffer_to_lower_case_uni((uint32 *)arglist[1]._array, arglist[2]._uint, arglist[3]._uint); + else + arglist[3]._uint = glk_buffer_to_lower_case_uni(nullptr, 0, arglist[1]._uint); + break; + case 0x0121: /* buffer_to_upper_case_uni */ + if (arglist[0]._ptrflag) + arglist[5]._uint = glk_buffer_to_upper_case_uni((uint32 *)arglist[1]._array, arglist[2]._uint, arglist[3]._uint); + else + arglist[3]._uint = glk_buffer_to_upper_case_uni(nullptr, 0, arglist[1]._uint); + break; + case 0x0122: /* buffer_to_title_case_uni */ + if (arglist[0]._ptrflag) + arglist[6]._uint = glk_buffer_to_title_case_uni((uint32 *)arglist[1]._array, arglist[2]._uint, arglist[3]._uint, arglist[4]._uint); + else + arglist[4]._uint = glk_buffer_to_title_case_uni(nullptr, 0, arglist[1]._uint, arglist[2]._uint); + break; + case 0x0128: /* put_char_uni */ + glk_put_char_uni(arglist[0]._uint); + break; + case 0x0129: /* put_string_uni */ + glk_put_string_uni(arglist[0]._unicharstr); + break; + case 0x012A: /* put_buffer_uni */ + if (arglist[0]._ptrflag) + glk_put_buffer_uni((const uint32 *)arglist[1]._array, arglist[2]._uint); + else + glk_put_buffer_uni(nullptr, 0); + break; + case 0x012B: /* put_char_stream_uni */ + glk_put_char_stream_uni((strid_t)arglist[0]._opaqueref, arglist[1]._uint); + break; + case 0x012C: /* put_string_stream_uni */ + glk_put_string_stream_uni((strid_t)arglist[0]._opaqueref, arglist[1]._unicharstr); + break; + case 0x012D: /* put_buffer_stream_uni */ + if (arglist[1]._ptrflag) + glk_put_buffer_stream_uni((strid_t)arglist[0]._opaqueref, (const uint32 *)arglist[2]._array, arglist[3]._uint); + else + glk_put_buffer_stream_uni((strid_t)arglist[0]._opaqueref, nullptr, 0); + break; + case 0x0130: /* get_char_stream_uni */ + arglist[2]._sint = glk_get_char_stream_uni((strid_t)arglist[0]._opaqueref); + break; + case 0x0131: /* get_buffer_stream_uni */ + if (arglist[1]._ptrflag) + arglist[5]._uint = glk_get_buffer_stream_uni((strid_t)arglist[0]._opaqueref, + (uint32 *)arglist[2]._array, arglist[3]._uint); + else + arglist[3]._uint = glk_get_buffer_stream_uni((strid_t)arglist[0]._opaqueref, nullptr, 0); + break; + case 0x0132: /* get_line_stream_uni */ + if (arglist[1]._ptrflag) + arglist[5]._uint = glk_get_line_stream_uni((strid_t)arglist[0]._opaqueref, + (uint32 *)arglist[2]._array, arglist[3]._uint); + else + arglist[3]._uint = glk_get_line_stream_uni((strid_t)arglist[0]._opaqueref, nullptr, 0); + break; + case 0x0138: /* stream_open_file_uni */ + arglist[4]._opaqueref = glk_stream_open_file_uni((frefid_t)arglist[0]._opaqueref, (FileMode)arglist[1]._uint, + arglist[2]._uint); + break; + case 0x0139: /* stream_open_memory_uni */ + if (arglist[0]._ptrflag) + arglist[6]._opaqueref = glk_stream_open_memory_uni((uint32 *)arglist[1]._array, + arglist[2]._uint, (FileMode)arglist[3]._uint, arglist[4]._uint); + else + arglist[4]._opaqueref = glk_stream_open_memory_uni(nullptr, 0, (FileMode)arglist[1]._uint, arglist[2]._uint); + break; + case 0x0140: /* request_char_event_uni */ + glk_request_char_event_uni((Window *)arglist[0]._opaqueref); + break; + case 0x0141: /* request_line_event_uni */ + if (arglist[1]._ptrflag) + glk_request_line_event_uni((Window *)arglist[0]._opaqueref, (uint32 *)arglist[2]._array, + arglist[3]._uint, arglist[4]._uint); + else + glk_request_line_event_uni((Window *)arglist[0]._opaqueref, nullptr, + 0, arglist[2]._uint); + break; #endif /* GLK_MODULE_UNICODE */ #ifdef GLK_MODULE_UNICODE_NORM - case 0x0123: /* buffer_canon_decompose_uni */ - if (arglist[0]._ptrflag) - arglist[5]._uint = glk_buffer_canon_decompose_uni((uint32 *)arglist[1]._array, arglist[2]._uint, arglist[3]._uint); - else - arglist[3]._uint = glk_buffer_canon_decompose_uni(nullptr, 0, arglist[1]._uint); - break; - case 0x0124: /* buffer_canon_normalize_uni */ - if (arglist[0]._ptrflag) - arglist[5]._uint = glk_buffer_canon_normalize_uni((uint32 *)arglist[1]._array, arglist[2]._uint, arglist[3]._uint); - else - arglist[3]._uint = glk_buffer_canon_normalize_uni(nullptr, 0, arglist[1]._uint); - break; + case 0x0123: /* buffer_canon_decompose_uni */ + if (arglist[0]._ptrflag) + arglist[5]._uint = glk_buffer_canon_decompose_uni((uint32 *)arglist[1]._array, arglist[2]._uint, arglist[3]._uint); + else + arglist[3]._uint = glk_buffer_canon_decompose_uni(nullptr, 0, arglist[1]._uint); + break; + case 0x0124: /* buffer_canon_normalize_uni */ + if (arglist[0]._ptrflag) + arglist[5]._uint = glk_buffer_canon_normalize_uni((uint32 *)arglist[1]._array, arglist[2]._uint, arglist[3]._uint); + else + arglist[3]._uint = glk_buffer_canon_normalize_uni(nullptr, 0, arglist[1]._uint); + break; #endif /* GLK_MODULE_UNICODE_NORM */ #ifdef GLK_MODULE_LINE_ECHO - case 0x0150: /* set_echo_line_event */ - glk_set_echo_line_event((Window *)arglist[0]._opaqueref, arglist[1]._uint); - break; + case 0x0150: /* set_echo_line_event */ + glk_set_echo_line_event((Window *)arglist[0]._opaqueref, arglist[1]._uint); + break; #endif /* GLK_MODULE_LINE_ECHO */ #ifdef GLK_MODULE_LINE_TERMINATORS - case 0x0151: /* set_terminators_line_event */ - if (arglist[1]._ptrflag) - glk_set_terminators_line_event((Window *)arglist[0]._opaqueref, (const uint32 *)arglist[2]._array, arglist[3]._uint); - else - glk_set_terminators_line_event((Window *)arglist[0]._opaqueref, - nullptr, 0); - break; + case 0x0151: /* set_terminators_line_event */ + if (arglist[1]._ptrflag) + glk_set_terminators_line_event((Window *)arglist[0]._opaqueref, (const uint32 *)arglist[2]._array, arglist[3]._uint); + else + glk_set_terminators_line_event((Window *)arglist[0]._opaqueref, + nullptr, 0); + break; #endif /* GLK_MODULE_LINE_TERMINATORS */ #ifdef GLK_MODULE_DATETIME - case 0x0160: /* current_time */ - if (arglist[0]._ptrflag) { - glktimeval_t dat; - glk_current_time(&dat); - arglist[1]._sint = dat.high_sec; - arglist[2]._uint = dat.low_sec; - arglist[3]._sint = dat.microsec; - } else { - glk_current_time(nullptr); - } - break; - case 0x0161: /* current_simple_time */ - arglist[2]._sint = glk_current_simple_time(arglist[0]._uint); - break; - case 0x0168: /* time_to_date_utc */ { - glktimeval_t timeval; - glktimeval_t *timeptr = nullptr; - glkdate_t date; - glkdate_t *dateptr = nullptr; - int ix = 0; - if (arglist[ix++]._ptrflag) { - timeptr = &timeval; - timeval.high_sec = arglist[ix++]._sint; - timeval.low_sec = arglist[ix++]._uint; - timeval.microsec = arglist[ix++]._sint; - } - if (arglist[ix++]._ptrflag) { - dateptr = &date; - } - glk_time_to_date_utc(timeptr, dateptr); - if (dateptr) { - arglist[ix++]._sint = date.year; - arglist[ix++]._sint = date.month; - arglist[ix++]._sint = date.day; - arglist[ix++]._sint = date.weekday; - arglist[ix++]._sint = date.hour; - arglist[ix++]._sint = date.minute; - arglist[ix++]._sint = date.second; - arglist[ix++]._sint = date.microsec; - } - } - break; - case 0x0169: /* time_to_date_local */ { - glktimeval_t timeval; - glktimeval_t *timeptr = nullptr; - glkdate_t date; - glkdate_t *dateptr = nullptr; - int ix = 0; - if (arglist[ix++]._ptrflag) { - timeptr = &timeval; - timeval.high_sec = arglist[ix++]._sint; - timeval.low_sec = arglist[ix++]._uint; - timeval.microsec = arglist[ix++]._sint; - } - if (arglist[ix++]._ptrflag) { - dateptr = &date; - } - glk_time_to_date_local(timeptr, dateptr); - if (dateptr) { - arglist[ix++]._sint = date.year; - arglist[ix++]._sint = date.month; - arglist[ix++]._sint = date.day; - arglist[ix++]._sint = date.weekday; - arglist[ix++]._sint = date.hour; - arglist[ix++]._sint = date.minute; - arglist[ix++]._sint = date.second; - arglist[ix++]._sint = date.microsec; - } - } - break; - case 0x016A: /* simple_time_to_date_utc */ { - glkdate_t date; - glkdate_t *dateptr = nullptr; - int ix = 2; - if (arglist[ix++]._ptrflag) { - dateptr = &date; - } - glk_simple_time_to_date_utc(arglist[0]._sint, arglist[1]._uint, dateptr); - if (dateptr) { - arglist[ix++]._sint = date.year; - arglist[ix++]._sint = date.month; - arglist[ix++]._sint = date.day; - arglist[ix++]._sint = date.weekday; - arglist[ix++]._sint = date.hour; - arglist[ix++]._sint = date.minute; - arglist[ix++]._sint = date.second; - arglist[ix++]._sint = date.microsec; - } - } - break; - case 0x016B: /* simple_time_to_date_local */ { - glkdate_t date; - glkdate_t *dateptr = nullptr; - int ix = 2; - if (arglist[ix++]._ptrflag) { - dateptr = &date; - } - glk_simple_time_to_date_local(arglist[0]._sint, arglist[1]._uint, dateptr); - if (dateptr) { - arglist[ix++]._sint = date.year; - arglist[ix++]._sint = date.month; - arglist[ix++]._sint = date.day; - arglist[ix++]._sint = date.weekday; - arglist[ix++]._sint = date.hour; - arglist[ix++]._sint = date.minute; - arglist[ix++]._sint = date.second; - arglist[ix++]._sint = date.microsec; - } - } - break; - case 0x016C: /* date_to_time_utc */ { - glkdate_t date; - glkdate_t *dateptr = nullptr; - glktimeval_t timeval; - glktimeval_t *timeptr = nullptr; + case 0x0160: /* current_time */ + if (arglist[0]._ptrflag) { + glktimeval_t dat; + glk_current_time(&dat); + arglist[1]._sint = dat.high_sec; + arglist[2]._uint = dat.low_sec; + arglist[3]._sint = dat.microsec; + } else { + glk_current_time(nullptr); + } + break; + case 0x0161: /* current_simple_time */ + arglist[2]._sint = glk_current_simple_time(arglist[0]._uint); + break; + case 0x0168: /* time_to_date_utc */ { + glktimeval_t timeval; + glktimeval_t *timeptr = nullptr; + glkdate_t date; + glkdate_t *dateptr = nullptr; + int ix = 0; + if (arglist[ix++]._ptrflag) { + timeptr = &timeval; + timeval.high_sec = arglist[ix++]._sint; + timeval.low_sec = arglist[ix++]._uint; + timeval.microsec = arglist[ix++]._sint; + } + if (arglist[ix++]._ptrflag) { + dateptr = &date; + } + glk_time_to_date_utc(timeptr, dateptr); + if (dateptr) { + arglist[ix++]._sint = date.year; + arglist[ix++]._sint = date.month; + arglist[ix++]._sint = date.day; + arglist[ix++]._sint = date.weekday; + arglist[ix++]._sint = date.hour; + arglist[ix++]._sint = date.minute; + arglist[ix++]._sint = date.second; + arglist[ix++]._sint = date.microsec; + } + } + break; + case 0x0169: /* time_to_date_local */ { + glktimeval_t timeval; + glktimeval_t *timeptr = nullptr; + glkdate_t date; + glkdate_t *dateptr = nullptr; + int ix = 0; + if (arglist[ix++]._ptrflag) { + timeptr = &timeval; + timeval.high_sec = arglist[ix++]._sint; + timeval.low_sec = arglist[ix++]._uint; + timeval.microsec = arglist[ix++]._sint; + } + if (arglist[ix++]._ptrflag) { + dateptr = &date; + } + glk_time_to_date_local(timeptr, dateptr); + if (dateptr) { + arglist[ix++]._sint = date.year; + arglist[ix++]._sint = date.month; + arglist[ix++]._sint = date.day; + arglist[ix++]._sint = date.weekday; + arglist[ix++]._sint = date.hour; + arglist[ix++]._sint = date.minute; + arglist[ix++]._sint = date.second; + arglist[ix++]._sint = date.microsec; + } + } + break; + case 0x016A: /* simple_time_to_date_utc */ { + glkdate_t date; + glkdate_t *dateptr = nullptr; + int ix = 2; + if (arglist[ix++]._ptrflag) { + dateptr = &date; + } + glk_simple_time_to_date_utc(arglist[0]._sint, arglist[1]._uint, dateptr); + if (dateptr) { + arglist[ix++]._sint = date.year; + arglist[ix++]._sint = date.month; + arglist[ix++]._sint = date.day; + arglist[ix++]._sint = date.weekday; + arglist[ix++]._sint = date.hour; + arglist[ix++]._sint = date.minute; + arglist[ix++]._sint = date.second; + arglist[ix++]._sint = date.microsec; + } + } + break; + case 0x016B: /* simple_time_to_date_local */ { + glkdate_t date; + glkdate_t *dateptr = nullptr; + int ix = 2; + if (arglist[ix++]._ptrflag) { + dateptr = &date; + } + glk_simple_time_to_date_local(arglist[0]._sint, arglist[1]._uint, dateptr); + if (dateptr) { + arglist[ix++]._sint = date.year; + arglist[ix++]._sint = date.month; + arglist[ix++]._sint = date.day; + arglist[ix++]._sint = date.weekday; + arglist[ix++]._sint = date.hour; + arglist[ix++]._sint = date.minute; + arglist[ix++]._sint = date.second; + arglist[ix++]._sint = date.microsec; + } + } + break; + case 0x016C: /* date_to_time_utc */ { + glkdate_t date; + glkdate_t *dateptr = nullptr; + glktimeval_t timeval; + glktimeval_t *timeptr = nullptr; timeval.high_sec = timeval.low_sec = timeval.microsec = 0; int ix = 0; - if (arglist[ix++]._ptrflag) { - dateptr = &date; - date.year = arglist[ix++]._sint; - date.month = arglist[ix++]._sint; - date.day = arglist[ix++]._sint; - date.weekday = arglist[ix++]._sint; - date.hour = arglist[ix++]._sint; - date.minute = arglist[ix++]._sint; - date.second = arglist[ix++]._sint; - date.microsec = arglist[ix++]._sint; - } - if (arglist[ix++]._ptrflag) { - timeptr = &timeval; - } - glk_date_to_time_utc(dateptr, timeptr); - if (timeptr) { - arglist[ix++]._sint = timeval.high_sec; - arglist[ix++]._uint = timeval.low_sec; - arglist[ix++]._sint = timeval.microsec; - } - } - break; - case 0x016D: /* date_to_time_local */ { - glkdate_t date; - glkdate_t *dateptr = nullptr; - glktimeval_t timeval; - glktimeval_t *timeptr = nullptr; + if (arglist[ix++]._ptrflag) { + dateptr = &date; + date.year = arglist[ix++]._sint; + date.month = arglist[ix++]._sint; + date.day = arglist[ix++]._sint; + date.weekday = arglist[ix++]._sint; + date.hour = arglist[ix++]._sint; + date.minute = arglist[ix++]._sint; + date.second = arglist[ix++]._sint; + date.microsec = arglist[ix++]._sint; + } + if (arglist[ix++]._ptrflag) { + timeptr = &timeval; + } + glk_date_to_time_utc(dateptr, timeptr); + if (timeptr) { + arglist[ix++]._sint = timeval.high_sec; + arglist[ix++]._uint = timeval.low_sec; + arglist[ix++]._sint = timeval.microsec; + } + } + break; + case 0x016D: /* date_to_time_local */ { + glkdate_t date; + glkdate_t *dateptr = nullptr; + glktimeval_t timeval; + glktimeval_t *timeptr = nullptr; timeval.high_sec = timeval.low_sec = timeval.microsec = 0; - int ix = 0; - if (arglist[ix++]._ptrflag) { - dateptr = &date; - date.year = arglist[ix++]._sint; - date.month = arglist[ix++]._sint; - date.day = arglist[ix++]._sint; - date.weekday = arglist[ix++]._sint; - date.hour = arglist[ix++]._sint; - date.minute = arglist[ix++]._sint; - date.second = arglist[ix++]._sint; - date.microsec = arglist[ix++]._sint; - } - if (arglist[ix++]._ptrflag) { - timeptr = &timeval; - } - glk_date_to_time_local(dateptr, timeptr); - if (timeptr) { - arglist[ix++]._sint = timeval.high_sec; - arglist[ix++]._uint = timeval.low_sec; - arglist[ix++]._sint = timeval.microsec; - } - } - break; - case 0x016E: /* date_to_simple_time_utc */ { - glkdate_t date; - glkdate_t *dateptr = nullptr; - int ix = 0; - if (arglist[ix++]._ptrflag) { - dateptr = &date; - date.year = arglist[ix++]._sint; - date.month = arglist[ix++]._sint; - date.day = arglist[ix++]._sint; - date.weekday = arglist[ix++]._sint; - date.hour = arglist[ix++]._sint; - date.minute = arglist[ix++]._sint; - date.second = arglist[ix++]._sint; - date.microsec = arglist[ix++]._sint; - } - arglist[ix+2]._sint = glk_date_to_simple_time_utc(dateptr, arglist[ix]._uint); - } - break; - case 0x016F: /* date_to_simple_time_local */ { - glkdate_t date; - glkdate_t *dateptr = nullptr; - int ix = 0; - if (arglist[ix++]._ptrflag) { - dateptr = &date; - date.year = arglist[ix++]._sint; - date.month = arglist[ix++]._sint; - date.day = arglist[ix++]._sint; - date.weekday = arglist[ix++]._sint; - date.hour = arglist[ix++]._sint; - date.minute = arglist[ix++]._sint; - date.second = arglist[ix++]._sint; - date.microsec = arglist[ix++]._sint; - } - arglist[ix+2]._sint = glk_date_to_simple_time_local(dateptr, arglist[ix]._uint); - } - break; + int ix = 0; + if (arglist[ix++]._ptrflag) { + dateptr = &date; + date.year = arglist[ix++]._sint; + date.month = arglist[ix++]._sint; + date.day = arglist[ix++]._sint; + date.weekday = arglist[ix++]._sint; + date.hour = arglist[ix++]._sint; + date.minute = arglist[ix++]._sint; + date.second = arglist[ix++]._sint; + date.microsec = arglist[ix++]._sint; + } + if (arglist[ix++]._ptrflag) { + timeptr = &timeval; + } + glk_date_to_time_local(dateptr, timeptr); + if (timeptr) { + arglist[ix++]._sint = timeval.high_sec; + arglist[ix++]._uint = timeval.low_sec; + arglist[ix++]._sint = timeval.microsec; + } + } + break; + case 0x016E: /* date_to_simple_time_utc */ { + glkdate_t date; + glkdate_t *dateptr = nullptr; + int ix = 0; + if (arglist[ix++]._ptrflag) { + dateptr = &date; + date.year = arglist[ix++]._sint; + date.month = arglist[ix++]._sint; + date.day = arglist[ix++]._sint; + date.weekday = arglist[ix++]._sint; + date.hour = arglist[ix++]._sint; + date.minute = arglist[ix++]._sint; + date.second = arglist[ix++]._sint; + date.microsec = arglist[ix++]._sint; + } + arglist[ix+2]._sint = glk_date_to_simple_time_utc(dateptr, arglist[ix]._uint); + } + break; + case 0x016F: /* date_to_simple_time_local */ { + glkdate_t date; + glkdate_t *dateptr = nullptr; + int ix = 0; + if (arglist[ix++]._ptrflag) { + dateptr = &date; + date.year = arglist[ix++]._sint; + date.month = arglist[ix++]._sint; + date.day = arglist[ix++]._sint; + date.weekday = arglist[ix++]._sint; + date.hour = arglist[ix++]._sint; + date.minute = arglist[ix++]._sint; + date.second = arglist[ix++]._sint; + date.microsec = arglist[ix++]._sint; + } + arglist[ix+2]._sint = glk_date_to_simple_time_local(dateptr, arglist[ix]._uint); + } + break; #endif /* GLK_MODULE_DATETIME */ #ifdef GLK_MODULE_GARGLKTEXT - case 0x1100: /* garglk_set_zcolors */ - garglk_set_zcolors( arglist[0]._uint, arglist[1]._uint ); - break; - case 0x1101: /* garglk_set_zcolors_stream */ - garglk_set_zcolors_stream((strid_t)arglist[0]._opaqueref, arglist[1]._uint, arglist[2]._uint ); - break; - case 0x1102: /* garglk_set_reversevideo */ - garglk_set_reversevideo( arglist[0]._uint ); - break; - case 0x1103: /* garglk_set_reversevideo_stream */ - garglk_set_reversevideo_stream((strid_t)arglist[0]._opaqueref, arglist[1]._uint ); - break; + case 0x1100: /* garglk_set_zcolors */ + garglk_set_zcolors( arglist[0]._uint, arglist[1]._uint ); + break; + case 0x1101: /* garglk_set_zcolors_stream */ + garglk_set_zcolors_stream((strid_t)arglist[0]._opaqueref, arglist[1]._uint, arglist[2]._uint ); + break; + case 0x1102: /* garglk_set_reversevideo */ + garglk_set_reversevideo( arglist[0]._uint ); + break; + case 0x1103: /* garglk_set_reversevideo_stream */ + garglk_set_reversevideo_stream((strid_t)arglist[0]._opaqueref, arglist[1]._uint ); + break; #endif /* GLK_MODULE_GARGLKTEXT */ - default: - /* do nothing */ - break; - } + default: + /* do nothing */ + break; + } } gidispatch_rock_t GlkAPI::gidispatch_get_objrock(void *obj, uint objclass) { diff --git a/engines/glk/glulx/glkop.cpp b/engines/glk/glulx/glkop.cpp index a7dfb36d4b9..82593128a4a 100644 --- a/engines/glk/glulx/glkop.cpp +++ b/engines/glk/glulx/glkop.cpp @@ -31,38 +31,38 @@ namespace Glulx { To be precise, we make the following assumptions: - An argument list is an array of 32-bit values, which can represent - either integers or addresses. + either integers or addresses. - We can read or write to a 32-bit integer in VM memory using the macros - ReadMemory(addr) and WriteMemory(addr), where addr is an address - taken from the argument list. + ReadMemory(addr) and WriteMemory(addr), where addr is an address + taken from the argument list. - A character array is a sequence of bytes somewhere in VM memory. - The array can be turned into a C char array by the macro - CaptureCArray(addr, len), and released by ReleaseCArray(). - The passin, passout hints may be used to avoid unnecessary copying. + The array can be turned into a C char array by the macro + CaptureCArray(addr, len), and released by ReleaseCArray(). + The passin, passout hints may be used to avoid unnecessary copying. - An integer array is a sequence of integers somewhere in VM memory. - The array can be turned into a C integer array by the macro - CaptureIArray(addr, len), and released by ReleaseIArray(). - These macros are responsible for fixing byte-order and alignment - (if the C ABI does not match the VM's). The passin, passout hints - may be used to avoid unnecessary copying. + The array can be turned into a C integer array by the macro + CaptureIArray(addr, len), and released by ReleaseIArray(). + These macros are responsible for fixing byte-order and alignment + (if the C ABI does not match the VM's). The passin, passout hints + may be used to avoid unnecessary copying. - A Glk object array is a sequence of integers in VM memory. It is - turned into a C pointer array (remember that C pointers may be more - than 4 bytes!) The pointer array is allocated by - CapturePtrArray(addr, len, objclass) and released by ReleasePtrArray(). - Again, the macros handle the conversion. + turned into a C pointer array (remember that C pointers may be more + than 4 bytes!) The pointer array is allocated by + CapturePtrArray(addr, len, objclass) and released by ReleasePtrArray(). + Again, the macros handle the conversion. - A Glk structure (such as event_t) is a set of integers somewhere - in VM memory, which can be read and written with the macros - ReadStructField(addr, fieldnum) and WriteStructField(addr, fieldnum). - The fieldnum is an integer (from 0 to 3, for event_t.) + in VM memory, which can be read and written with the macros + ReadStructField(addr, fieldnum) and WriteStructField(addr, fieldnum). + The fieldnum is an integer (from 0 to 3, for event_t.) - A VM string can be turned into a C-style string with the macro - ptr = DecodeVMString(addr). After the string is used, this code - calls ReleaseVMString(ptr), which should free any memory that - DecodeVMString allocates. + ptr = DecodeVMString(addr). After the string is used, this code + calls ReleaseVMString(ptr), which should free any memory that + DecodeVMString allocates. - A VM Unicode string can be turned into a zero-terminated array - of 32-bit integers, in the same way, with DecodeVMUstring - and ReleaseVMUstring. + of 32-bit integers, in the same way, with DecodeVMUstring + and ReleaseVMUstring. - To work this code over for a new VM, just diddle the macros. + To work this code over for a new VM, just diddle the macros. */ static gidispatch_rock_t classtable_register(void *obj, uint objclass) { @@ -238,7 +238,7 @@ FullDispatcher: } const char *Glulx::read_prefix(const char *cx, int *isref, int *isarray, int *passin, int *passout, - int *nullok, int *isretained, int *isreturn) { + int *nullok, int *isretained, int *isreturn) { *isref = false; *passin = false; *passout = false; @@ -326,7 +326,7 @@ void Glulx::prepare_glk_args(const char *proto, dispatch_splot_t *splot) { cx++; } maxargs += nwx; /* This is *only* correct because all structs contain - plain values. */ + plain values. */ refdepth = 1; while (refdepth > 0) { if (*cx == '[') @@ -365,7 +365,7 @@ void Glulx::prepare_glk_args(const char *proto, dispatch_splot_t *splot) { } void Glulx::parse_glk_args(dispatch_splot_t *splot, const char **proto, int depth, int *argnumptr, - uint subaddress, int subpassin) { + uint subaddress, int subpassin) { const char *cx; int ix, argx; int gargnum, numwanted; @@ -580,7 +580,7 @@ void Glulx::parse_glk_args(dispatch_splot_t *splot, const char **proto, int dept } void Glulx::unparse_glk_args(dispatch_splot_t *splot, const char **proto, int depth, - int *argnumptr, uint subaddress, int subpassout) { + int *argnumptr, uint subaddress, int subpassout) { const char *cx; int ix, argx; int gargnum, numwanted; @@ -924,7 +924,7 @@ gidispatch_rock_t Glulx::glulxe_classtable_register(void *obj, uint objclass) { } void Glulx::glulxe_classtable_unregister(void *obj, uint objclass, - gidispatch_rock_t objrock) { + gidispatch_rock_t objrock) { classes_remove(objclass, obj); } diff --git a/engines/glk/glulx/search.cpp b/engines/glk/glulx/search.cpp index a62cccb7240..46edd9113f2 100644 --- a/engines/glk/glulx/search.cpp +++ b/engines/glk/glulx/search.cpp @@ -32,7 +32,7 @@ enum serop { }; uint Glulx::linear_search(uint key, uint keysize, uint start, uint structsize, uint numstructs, - uint keyoffset, uint options) { + uint keyoffset, uint options) { unsigned char keybuf[4]; uint count; uint ix; @@ -82,7 +82,7 @@ uint Glulx::linear_search(uint key, uint keysize, uint start, uint structsize, uint Glulx::binary_search(uint key, uint keysize, uint start, uint structsize, uint numstructs, - uint keyoffset, uint options) { + uint keyoffset, uint options) { byte keybuf[4]; byte byte1, byte2; uint top, bot, val, addr; diff --git a/engines/glk/hugo/heexpr.cpp b/engines/glk/hugo/heexpr.cpp index 246273ca260..06e8d82c0d2 100644 --- a/engines/glk/hugo/heexpr.cpp +++ b/engines/glk/hugo/heexpr.cpp @@ -318,7 +318,7 @@ int Hugo::GetVal() { break; } #endif - val = CallRoutine(routineaddr); + val = CallRoutine(routineaddr); break; } diff --git a/engines/glk/hugo/hemisc.cpp b/engines/glk/hugo/hemisc.cpp index 50ff4f78915..47cd6c46350 100644 --- a/engines/glk/hugo/hemisc.cpp +++ b/engines/glk/hugo/hemisc.cpp @@ -690,7 +690,7 @@ void Hugo::FatalError(int n) { #if defined (DEBUGGER) if (routines > 0) - { + { SwitchtoDebugger(); if (n==MEMORY_E) DebuggerFatal(D_MEMORY_ERROR); @@ -1331,7 +1331,7 @@ void ParseCommandLine(int argc, char *argv[]) char* game_file_arg = nullptr; #if defined(GCC_UNIX) && defined(DO_COLOR) - int ch; + int ch; /* Parse comand line options (colour switches) */ while ((ch = getopt(argc, argv, "f:b:F:B:?h")) != -1) { switch (ch) { @@ -2353,10 +2353,10 @@ static int rand_index1, rand_index2; int random() { - rand_index1 = (rand_index1 + 1) % 55; - rand_index2 = (rand_index2 + 1) % 55; - rand_table[rand_index1] = rand_table[rand_index1] - rand_table[rand_index2]; - return rand_table[rand_index1]; + rand_index1 = (rand_index1 + 1) % 55; + rand_index2 = (rand_index2 + 1) % 55; + rand_table[rand_index1] = rand_table[rand_index1] - rand_table[rand_index2]; + return rand_table[rand_index1]; } void srandom(int seed) diff --git a/engines/glk/hugo/heobject.cpp b/engines/glk/hugo/heobject.cpp index 931f9a3abd3..2de4bbb459c 100644 --- a/engines/glk/hugo/heobject.cpp +++ b/engines/glk/hugo/heobject.cpp @@ -75,7 +75,7 @@ int Hugo::Elder(int obj) { p = Parent(obj); cp = Child(p); - if (p==0 || cp==obj) + if (p==0 || cp==obj) return 0; lastobj = cp; @@ -204,7 +204,7 @@ int Hugo::GetProp(int obj, int p, int n, char s) { if (getaddress && MEM(codeptr)!=DECIMAL_T) getpropaddress = true; - tempself = var[self]; + tempself = var[self]; if (!s) var[self] = obj; temp_stack_depth = stack_depth; @@ -408,7 +408,7 @@ GetNextProp: and have therefore removed it. */ if (!flag || (objonly && !g) || ((game_version<22) && PeekWord(inprop-2)==(unsigned int)parseaddr)) - inprop = (long)PeekWord(inprop+1)*address_scale; + inprop = (long)PeekWord(inprop+1)*address_scale; else break; } } diff --git a/engines/glk/hugo/heset.cpp b/engines/glk/hugo/heset.cpp index b7e40e07cdf..09dbea70525 100644 --- a/engines/glk/hugo/heset.cpp +++ b/engines/glk/hugo/heset.cpp @@ -557,7 +557,7 @@ int Hugo::SetCompound(int t) { if (Peek(codeptr+1)==NOT_T) { codeptr += 2; - set_value = GetValue(); /* the attr. # */ + set_value = GetValue(); /* the attr. # */ inobj = 0; return 3; } diff --git a/engines/glk/jacl/csv.h b/engines/glk/jacl/csv.h index 80fe402d88d..8aaa186ebb1 100644 --- a/engines/glk/jacl/csv.h +++ b/engines/glk/jacl/csv.h @@ -44,8 +44,8 @@ namespace JACL { #define CSV_STRICT 1 /* enable strict mode */ #define CSV_REPALL_NL 2 /* report all unquoted carriage returns and linefeeds */ #define CSV_STRICT_FINI 4 /* causes csv_fini to return CSV_EPARSE if last - field is quoted and doesn't containg ending - quote */ + field is quoted and doesn't containg ending + quote */ #define CSV_APPEND_NULL 8 /* Ensure that all fields are null-ternimated */ diff --git a/engines/glk/jacl/jacl_main.cpp b/engines/glk/jacl/jacl_main.cpp index ee42aa82523..05a4c91311e 100644 --- a/engines/glk/jacl/jacl_main.cpp +++ b/engines/glk/jacl/jacl_main.cpp @@ -35,8 +35,8 @@ int convert_to_utf32(unsigned char *text); uint status_width, status_height; schanid_t sound_channel[8] = { NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL - }; + NULL, NULL, NULL, NULL + }; event_t *cancelled_event; @@ -124,7 +124,7 @@ int player_backup = 0; int variable_contents; int oec; int *object_element_address, - *object_backup_address; + *object_backup_address; short int spaced = TRUE; diff --git a/engines/glk/jacl/jpp.cpp b/engines/glk/jacl/jpp.cpp index a8db6a01a54..3e7f44a4d7a 100644 --- a/engines/glk/jacl/jpp.cpp +++ b/engines/glk/jacl/jpp.cpp @@ -1,19 +1,19 @@ /* jpp.c --- The JACL Preprocessor (C) 2001 Andreas Matthias - 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 1, or (at your option) - any later version. + 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 1, 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. + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "glk/jacl/jacl.h" diff --git a/engines/glk/jacl/libcsv.cpp b/engines/glk/jacl/libcsv.cpp index 9e006b07137..21dbc5380f3 100644 --- a/engines/glk/jacl/libcsv.cpp +++ b/engines/glk/jacl/libcsv.cpp @@ -43,8 +43,8 @@ namespace JACL { FIELD_NOT_BEGUN There have been fields but we are currently not in one FIELD_BEGUN We are in a field FIELD_MIGHT_HAVE_ENDED - We encountered a double quote inside a quoted field, the - field is either ended or the quote is literal + We encountered a double quote inside a quoted field, the + field is either ended or the quote is literal */ #define MEM_BLK_SIZE 128 @@ -72,11 +72,11 @@ namespace JACL { #define SUBMIT_CHAR(p, c) ((p)->entry_buf[entry_pos++] = (c)) static const char *csv_errors[] = {"success", - "error parsing data while strict checking enabled", - "memory exhausted while increasing buffer size", - "data size too large", - "invalid status code" - }; + "error parsing data while strict checking enabled", + "memory exhausted while increasing buffer size", + "data size too large", + "invalid status code" + }; int csv_error(struct csv_parser *p) { /* Return the current status of the parser */ @@ -273,7 +273,7 @@ static int csv_increase_buffer(struct csv_parser *p) { } size_t csv_parse(struct csv_parser *p, const void *s, size_t len, void (*cb1)(void *, size_t, void *), - void (*cb2)(int c, void *), void *data) { + void (*cb2)(int c, void *), void *data) { unsigned const char *us = (unsigned const char *)s; /* Access input data as array of unsigned char */ unsigned char c; /* The character we are currently processing */ size_t pos = 0; /* The number of characters we have processed in this call */ diff --git a/engines/glk/jacl/loader.cpp b/engines/glk/jacl/loader.cpp index 78c2b5ecd26..6af3b76c795 100644 --- a/engines/glk/jacl/loader.cpp +++ b/engines/glk/jacl/loader.cpp @@ -664,7 +664,7 @@ void read_gamefile() { if (word[0] == NULL); else if (text_buffer[0] == '{') { word[wp]++; /* MOVE THE START OF THE FIRST WORD ONLY - * TO PAST THE '{'. */ + * TO PAST THE '{'. */ if (word[wp][0] == 0) { nofnamerr(line); errors++; diff --git a/engines/glk/jacl/parser.cpp b/engines/glk/jacl/parser.cpp index 4aa5ed33f47..d924a803651 100644 --- a/engines/glk/jacl/parser.cpp +++ b/engines/glk/jacl/parser.cpp @@ -1435,12 +1435,12 @@ int noun_resolve(struct word_type *scope_word, int finding_from, int noun_number object_expected = TRUE; wp = backup_pointer; /* BACK UP THE CURRENT WORD POINTER. - * SO THE PARSER CAN INVESTIAGE THE - * POSIBILITY THAT THIS ISN'T A - * REFERENCE TO AN OBJECT AT ALL */ + * SO THE PARSER CAN INVESTIAGE THE + * POSIBILITY THAT THIS ISN'T A + * REFERENCE TO AN OBJECT AT ALL */ return (FALSE); /* RETURN TO PARSER WITH NO MATCHING - * OBJECT HAVING BEEN FOUND. */ + * OBJECT HAVING BEEN FOUND. */ } //printf("--- starting with %d matches\n", matches); diff --git a/engines/glk/level9/bitmap.cpp b/engines/glk/level9/bitmap.cpp index 976c8a1a8e3..50b808c4108 100644 --- a/engines/glk/level9/bitmap.cpp +++ b/engines/glk/level9/bitmap.cpp @@ -60,12 +60,12 @@ Bitmap *bitmap_alloc(int x, int y) { } /* - A PC or ST palette colour is a sixteen bit value in which the low three nybbles - hold the rgb colour values. The lowest nybble holds the blue value, the - second nybble the blue value and the third nybble the red value. (The high - nybble is ignored). Within each nybble, only the low three bits are used - IE the value can only be 0-7 not the full possible 0-15 and so the MSbit in - each nybble is always 0. + A PC or ST palette colour is a sixteen bit value in which the low three nybbles + hold the rgb colour values. The lowest nybble holds the blue value, the + second nybble the blue value and the third nybble the red value. (The high + nybble is ignored). Within each nybble, only the low three bits are used + IE the value can only be 0-7 not the full possible 0-15 and so the MSbit in + each nybble is always 0. */ Colour bitmap_pcst_colour(int big, int small) { Colour col; @@ -87,26 +87,26 @@ Colour bitmap_pcst_colour(int big, int small) { } /* - ST Bitmaps + ST Bitmaps - On the ST different graphics file formats were used for the early V4 - games (Knight Orc, Gnome Ranger) and the later V4 games (Lancelot, - Ingrid's Back, Time & Magik and Scapeghost). + On the ST different graphics file formats were used for the early V4 + games (Knight Orc, Gnome Ranger) and the later V4 games (Lancelot, + Ingrid's Back, Time & Magik and Scapeghost). */ /* - Extracts the number of pixels requested from an eight-byte data block (4 bit- - planes) passed to it. + Extracts the number of pixels requested from an eight-byte data block (4 bit- + planes) passed to it. - Note: On entry each one of four pointers is set to point to the start of each - bit-plane in the block. The function then indexes through each byte in - each bit plane. and uses shift and mask operations to extract each four - bit pixel into an L9PIXEL. + Note: On entry each one of four pointers is set to point to the start of each + bit-plane in the block. The function then indexes through each byte in + each bit plane. and uses shift and mask operations to extract each four + bit pixel into an L9PIXEL. - The bit belonging to the pixel in the current byte of the current bit- - plane is moved to its position in an eight-bit pixel. The byte is then - masked by a value to select only that bit and added to the final pixel - value. + The bit belonging to the pixel in the current byte of the current bit- + plane is moved to its position in an eight-bit pixel. The byte is then + masked by a value to select only that bit and added to the final pixel + value. */ L9UINT32 bitmap_st1_decode_pixels(L9BYTE *pic, L9BYTE *data, L9UINT32 count, L9UINT32 pixels) { L9UINT32 bitplane_length = count / 4; /* length of each bitplane */ @@ -188,73 +188,73 @@ L9UINT32 bitmap_st1_decode_pixels(L9BYTE *pic, L9BYTE *data, L9UINT32 count, L9U } /* - The ST image file has the following format. It consists of a 44 byte header - followed by the image data. + The ST image file has the following format. It consists of a 44 byte header + followed by the image data. - The header has the following format: - Bytes 0-31: sixteen entry ST palette - Bytes 32-33: padding - Bytes 34-35: big-endian word holding number of bitplanes needed to make - up a row of pixels* - Bytes 36-37: padding - Bytes 38-39: big-endian word holding number of rows in the image* - Bytes 40-41: padding** - Bytes 42-43: mask for pixels to show in last 16 pixel block. Again, this - is big endian + The header has the following format: + Bytes 0-31: sixteen entry ST palette + Bytes 32-33: padding + Bytes 34-35: big-endian word holding number of bitplanes needed to make + up a row of pixels* + Bytes 36-37: padding + Bytes 38-39: big-endian word holding number of rows in the image* + Bytes 40-41: padding** + Bytes 42-43: mask for pixels to show in last 16 pixel block. Again, this + is big endian - [*] these are probably big-endian unsigned longs but I have designated - the upper two bytes as padding because (a) Level 9 does not need - them as longs and (b) using unsigned shorts reduces byte sex induced - byte order juggling. - [**] not certain what this is for but I suspect that, like bytes 42-43 - it is a mask to indicate which pixels to show, in this case in the - first 16 pixel block + [*] these are probably big-endian unsigned longs but I have designated + the upper two bytes as padding because (a) Level 9 does not need + them as longs and (b) using unsigned shorts reduces byte sex induced + byte order juggling. + [**] not certain what this is for but I suspect that, like bytes 42-43 + it is a mask to indicate which pixels to show, in this case in the + first 16 pixel block - The image data is essentially a memory dump of the video RAM representing - the image in lo-res mode. In lo-res mode each row is 320 pixels wide - and each pixel can be any one of sixteen colours - needs 4 bits to store. + The image data is essentially a memory dump of the video RAM representing + the image in lo-res mode. In lo-res mode each row is 320 pixels wide + and each pixel can be any one of sixteen colours - needs 4 bits to store. - In the ST video memory (in lo-res mode which we are dealing with here) - is organised as follows. The lowest point in memory in the frame buffer - represents the top-left of the screen, the highest the bottom-right. - Each row of pixels is stored in sequence. + In the ST video memory (in lo-res mode which we are dealing with here) + is organised as follows. The lowest point in memory in the frame buffer + represents the top-left of the screen, the highest the bottom-right. + Each row of pixels is stored in sequence. - Within each pixel row the pixels are stored as follows. Each row is - divided into groups of 16 pixels. Each sixteen pixel group is stored - in 8 bytes, logically four groups of two. Each two byte pair - is a bit-plane for that sixteen pixel group - that is it stores the - same bit of each pixel in that group. The first two bytes store the - lowest bit, the second pair the second bit &c. + Within each pixel row the pixels are stored as follows. Each row is + divided into groups of 16 pixels. Each sixteen pixel group is stored + in 8 bytes, logically four groups of two. Each two byte pair + is a bit-plane for that sixteen pixel group - that is it stores the + same bit of each pixel in that group. The first two bytes store the + lowest bit, the second pair the second bit &c. - The word at bytes 34-35 of the header stores the number of bitplanes - that make up each pixel row in the image. Multplying this number by - four gives the number of pixels in the row***. For title and frame - images that will be 320, for sub-images it will be less. + The word at bytes 34-35 of the header stores the number of bitplanes + that make up each pixel row in the image. Multplying this number by + four gives the number of pixels in the row***. For title and frame + images that will be 320, for sub-images it will be less. - [***] Not always exactly. For GnomeRanger sub-images this value is 60 - - implying there are 240 pixels per row. In fact there are only - 225 pixels in each row. To identify this situation look at the - big-endian word in bytes 42-43 of the header. This is a mask - telling you the pixels to use. Each bit represents one pixel in - the block, with the MSBit representing the first pixel and the - LSbit the last. + [***] Not always exactly. For GnomeRanger sub-images this value is 60 + - implying there are 240 pixels per row. In fact there are only + 225 pixels in each row. To identify this situation look at the + big-endian word in bytes 42-43 of the header. This is a mask + telling you the pixels to use. Each bit represents one pixel in + the block, with the MSBit representing the first pixel and the + LSbit the last. - In this situation, the file does contain the entire sixteen - pixel block (it has to with the bitplane arrangement) but - the pixels which are not part of the image are just noise. When - decoding the image, the L9BITMAP produced has the actual pixel - dimensions - the surplus pixels are discarded. + In this situation, the file does contain the entire sixteen + pixel block (it has to with the bitplane arrangement) but + the pixels which are not part of the image are just noise. When + decoding the image, the L9BITMAP produced has the actual pixel + dimensions - the surplus pixels are discarded. - I suspect, though I have not found an instance, that in theory - the same situation could apply at the start of a pixel row and that - in this case the big-endian word at bytes 40-41 is the mask. + I suspect, though I have not found an instance, that in theory + the same situation could apply at the start of a pixel row and that + in this case the big-endian word at bytes 40-41 is the mask. - Having obtained the pixel dimensions of the image the function uses - them to allocate memory for the bitmap and then extracts the pixel - information from the bitmap row by row. For each row eight byte blocks - are read from the image data and passed to UnpackSTv1Pixels along with - the number of pixels to extract (usually 16, possibly less for the last - block in a row.) + Having obtained the pixel dimensions of the image the function uses + them to allocate memory for the bitmap and then extracts the pixel + information from the bitmap row by row. For each row eight byte blocks + are read from the image data and passed to UnpackSTv1Pixels along with + the number of pixels to extract (usually 16, possibly less for the last + block in a row.) */ L9BOOL bitmap_st1_decode(char *file, int x, int y) { L9BYTE *data = NULL; @@ -333,14 +333,14 @@ void bitmap_st2_name(int num, char *dir, char *out) { } /* - PC Bitmaps + PC Bitmaps - On the PC different graphics file formats were used for the early V4 - games (Knight Orc, Gnome Ranger) and the later V4 games (Lancelot, - Ingrid's Back, Time & Magik and Scapeghost). + On the PC different graphics file formats were used for the early V4 + games (Knight Orc, Gnome Ranger) and the later V4 games (Lancelot, + Ingrid's Back, Time & Magik and Scapeghost). - The ST and the PC both use the same image file format for the later - V4 games (Lancelot, Ingrid's Back, Time & Magik and Scapeghost.) + The ST and the PC both use the same image file format for the later + V4 games (Lancelot, Ingrid's Back, Time & Magik and Scapeghost.) */ void bitmap_pc_name(int num, char *dir, char *out) { @@ -351,18 +351,18 @@ void bitmap_pc_name(int num, char *dir, char *out) { } /* - The EGA standard for the IBM PCs and compatibles defines 64 colors, any - 16 of which can be mapped to the usable palette at any given time. If - you display these 64 colors in numerical order, 16 at a time, you get a - hodgepodge of colors in no logical order. The 64 EGA color numbers are - assigned in a way that the numbers can easily be converted to a relative - intensity of each of the three phosphor colors R,G,B. If the number is - converted to six bit binary, the most significant three bits represent - the 25% level of R,G,B in that order and the least significant three - bits represent the 75% level of R,G,B in that order. Take EGA color 53 - for example. In binary, 53 is 110101. Since both R bits are on, R = 1.0. - Of the G bits only the 25% bit is on so G = 0.25. Of the B bits only the - 75% bit is on so B = 0.75. + The EGA standard for the IBM PCs and compatibles defines 64 colors, any + 16 of which can be mapped to the usable palette at any given time. If + you display these 64 colors in numerical order, 16 at a time, you get a + hodgepodge of colors in no logical order. The 64 EGA color numbers are + assigned in a way that the numbers can easily be converted to a relative + intensity of each of the three phosphor colors R,G,B. If the number is + converted to six bit binary, the most significant three bits represent + the 25% level of R,G,B in that order and the least significant three + bits represent the 75% level of R,G,B in that order. Take EGA color 53 + for example. In binary, 53 is 110101. Since both R bits are on, R = 1.0. + Of the G bits only the 25% bit is on so G = 0.25. Of the B bits only the + 75% bit is on so B = 0.75. */ Colour bitmap_pc1_colour(int i) { Colour col; @@ -373,20 +373,20 @@ Colour bitmap_pc1_colour(int i) { } /* - The PC (v1) image file has the following format. It consists of a 22 - byte header organised like this: + The PC (v1) image file has the following format. It consists of a 22 + byte header organised like this: - Byte 0: probably a file type flag - Byte 1: the MSB of the file's length as a word - Bytes 2-3: little-endian word with picture width in pixels - Bytes 4-5: little-endian word with picture height in pixel rows - Bytes 6-21: the image colour table. One EGA colour in each byte + Byte 0: probably a file type flag + Byte 1: the MSB of the file's length as a word + Bytes 2-3: little-endian word with picture width in pixels + Bytes 4-5: little-endian word with picture height in pixel rows + Bytes 6-21: the image colour table. One EGA colour in each byte - The image data is extremely simple. The entire block is packed array - of 4-bit pixels - IE each byte holds two pixels - the first in the high - nybble, the second in the low. The pixel value is an index into the - image colour table. The pixels are organised with the top left first and - bottom left last, each row in turn. + The image data is extremely simple. The entire block is packed array + of 4-bit pixels - IE each byte holds two pixels - the first in the high + nybble, the second in the low. The pixel value is an index into the + image colour table. The pixels are organised with the top left first and + bottom left last, each row in turn. */ L9BOOL bitmap_pc1_decode(char *file, int x, int y) { L9BYTE *data = NULL; @@ -435,153 +435,153 @@ L9BOOL bitmap_pc1_decode(char *file, int x, int y) { } /* - The PC (v2) image file has the following format. It consists of a 44 - byte header followed by the image data. + The PC (v2) image file has the following format. It consists of a 44 + byte header followed by the image data. - The header has the following format: - Bytes 0-1: "datalen": length of file -1 as a big-endian word* - Bytes 2-3: "flagbyte1 & flagbyte2": unknown, possibly type identifiers. - Usually 0xFF or 0xFE followed by 0x84, 0x72, 0xFF, 0xFE or - some other (of a fairly small range of possibles) byte. - Bytes 4-35: "colour_index[]": sixteen entry palette. Basically an ST - palette (even if in a PC image file. Each entry is a sixteen - bit value in which the low three nybbles hold the rgb colour - values. The lowest nybble holds the blue value, the second - nybble the blue value and the third nybble the red value. (The - high nybble is ignored). Within each nybble, only the low - three bits are used IE the value can only be 0-7 not the full - possible 0-15 and so the MSbit in each nybble is always 0.**, - Bytes 36-37: "width": image width in pixels as a big-endian word - Bytes 38-39: "numrows": image height in pixel rows as a big-endian word - Byte 40: "seedByte": seed byte to start picture decoding. - Byte 41: "padByte": unknown. Possibly padding to word align the next - element? - Bytes 42-297: "pixelTable": an array of 0x100 bytes used as a lookup table - for pixel values - Bytes 298-313: "bitStripTable": an array of 0x10 bytes used as a lookup table - for the number of bytes to strip from the bit stream for the pixel being - decoded - Bytes 314-569: "indexByteTable": an array of 0x100 bytes used as a lookup - table to index into bitStripTable and pixelTable**** + The header has the following format: + Bytes 0-1: "datalen": length of file -1 as a big-endian word* + Bytes 2-3: "flagbyte1 & flagbyte2": unknown, possibly type identifiers. + Usually 0xFF or 0xFE followed by 0x84, 0x72, 0xFF, 0xFE or + some other (of a fairly small range of possibles) byte. + Bytes 4-35: "colour_index[]": sixteen entry palette. Basically an ST + palette (even if in a PC image file. Each entry is a sixteen + bit value in which the low three nybbles hold the rgb colour + values. The lowest nybble holds the blue value, the second + nybble the blue value and the third nybble the red value. (The + high nybble is ignored). Within each nybble, only the low + three bits are used IE the value can only be 0-7 not the full + possible 0-15 and so the MSbit in each nybble is always 0.**, + Bytes 36-37: "width": image width in pixels as a big-endian word + Bytes 38-39: "numrows": image height in pixel rows as a big-endian word + Byte 40: "seedByte": seed byte to start picture decoding. + Byte 41: "padByte": unknown. Possibly padding to word align the next + element? + Bytes 42-297: "pixelTable": an array of 0x100 bytes used as a lookup table + for pixel values + Bytes 298-313: "bitStripTable": an array of 0x10 bytes used as a lookup table + for the number of bytes to strip from the bit stream for the pixel being + decoded + Bytes 314-569: "indexByteTable": an array of 0x100 bytes used as a lookup + table to index into bitStripTable and pixelTable**** - The encoded image data then follows ending in a 0x00 at the file length stored - in the first two bytes of the file. there is then one extra byte holding a - checksum produced by the addition of all the bytes in the file (except the first - two and itself)* + The encoded image data then follows ending in a 0x00 at the file length stored + in the first two bytes of the file. there is then one extra byte holding a + checksum produced by the addition of all the bytes in the file (except the first + two and itself)* - [*] in some PC games the file is padded out beyond this length to the - nearest 0x80/0x00 boundary with the byte 0x1A. The valid data in the - file still finishes where this word says with the checkbyte following it. - [**] I imagine when a game was running on a PC this standard palette - was algorithimcally changed to suit the graphics mode being used - (Hercules, MDA, CGA, EGA, MCGA, VGA &c.) - [***] Note also, in image 1 of PC Time & Magik I think one palette entry - is bad as what should be white in the image is actually set to - a very pale yellow. This is corrected with the display of the next - sub-picture and I am pretty sure it is note a decoding problem - here as when run on the PC the same image has the same pale yellow - cast. - [****] for detail of how all this works see below + [*] in some PC games the file is padded out beyond this length to the + nearest 0x80/0x00 boundary with the byte 0x1A. The valid data in the + file still finishes where this word says with the checkbyte following it. + [**] I imagine when a game was running on a PC this standard palette + was algorithimcally changed to suit the graphics mode being used + (Hercules, MDA, CGA, EGA, MCGA, VGA &c.) + [***] Note also, in image 1 of PC Time & Magik I think one palette entry + is bad as what should be white in the image is actually set to + a very pale yellow. This is corrected with the display of the next + sub-picture and I am pretty sure it is note a decoding problem + here as when run on the PC the same image has the same pale yellow + cast. + [****] for detail of how all this works see below - As this file format is intended for two very different platforms the decoded - imaged data is in a neutral, intermediate form. Each pixel is extracted as a - byte with only the low four bits significant. The pixel value is an index into - the sixteen entry palette. + As this file format is intended for two very different platforms the decoded + imaged data is in a neutral, intermediate form. Each pixel is extracted as a + byte with only the low four bits significant. The pixel value is an index into + the sixteen entry palette. - The pixel data is compressed, presumably to allow a greater number of images - to be distributed on the (rather small) default ST & PC floppy disks (in both - cases about 370 Kbytes.)***** + The pixel data is compressed, presumably to allow a greater number of images + to be distributed on the (rather small) default ST & PC floppy disks (in both + cases about 370 Kbytes.)***** - Here's how to decode the data. The image data is actually a contiguous bit - stream with the byte structure on disk having almost no relevance to the - encoding. We access the bit stream via a two-byte buffer arranged as a word. + Here's how to decode the data. The image data is actually a contiguous bit + stream with the byte structure on disk having almost no relevance to the + encoding. We access the bit stream via a two-byte buffer arranged as a word. - Preparation: + Preparation: - Initially, move the first byte from the image data into the low byte of - theBitStreamBuffer and move the second byte of the image data into the - high byte of theBitStreamBuffer. + Initially, move the first byte from the image data into the low byte of + theBitStreamBuffer and move the second byte of the image data into the + high byte of theBitStreamBuffer. - Set a counter (theBufferBitCounter) to 8 which you will use to keep track - of when it is necesary to refill the buffer. + Set a counter (theBufferBitCounter) to 8 which you will use to keep track + of when it is necesary to refill the buffer. - Set a L9BYTE variable (theNewPixel) to byte 40 (seedByte) of the header. - We need to do this because as part of identifying the pixel being - extracted we need to know the value of the previous pixel extracted. Since - none exists at this point we must prime this variable with the correct - value. + Set a L9BYTE variable (theNewPixel) to byte 40 (seedByte) of the header. + We need to do this because as part of identifying the pixel being + extracted we need to know the value of the previous pixel extracted. Since + none exists at this point we must prime this variable with the correct + value. - Extraction: + Extraction: - Set up a loop which you will execute once for each pixel to be extracted - and within that loop do as follows. + Set up a loop which you will execute once for each pixel to be extracted + and within that loop do as follows. - Copy the low byte of theBitStreamBuffer to an L9BYTE - (theNewPixelIndexSelector). Examine theNewPixelIndexSelector. If this - is 0xFF this flags that the index to the new pixel is present as a - literal in the bit stream; if it is NOT 0xFF then the new pixel index - value has to be decoded. + Copy the low byte of theBitStreamBuffer to an L9BYTE + (theNewPixelIndexSelector). Examine theNewPixelIndexSelector. If this + is 0xFF this flags that the index to the new pixel is present as a + literal in the bit stream; if it is NOT 0xFF then the new pixel index + value has to be decoded. - If theNewPixelIndexSelector is NOT 0xFF do as follows: + If theNewPixelIndexSelector is NOT 0xFF do as follows: - Set the variable theNewPixelIndex to the byte in the - indexByteTable array of the header indexed by - theNewPixelIndexSelector. + Set the variable theNewPixelIndex to the byte in the + indexByteTable array of the header indexed by + theNewPixelIndexSelector. - Set the variable theBufferBitStripCount to the value in the - bitStripTable array of the header indexed by theNewPixelIndex. + Set the variable theBufferBitStripCount to the value in the + bitStripTable array of the header indexed by theNewPixelIndex. - One-by-one use right bit shift (>>) to remove - theBufferBitStripCount bits from theBitStreamBuffer. After each - shift decrement theBufferBitCounter and check whether it has - reached 0. If it has, get the next byte from the image data and - insert it in the high byte of theBitStreamBuffer and reset - theBufferBitCounter to 8. What is happening here is as we remove - each bit from the bottom of the bit stream buffer we check to see - if there are any bits left in the high byte of the buffer. As soon - as we know there are none, we refill it with the next eight bits - from the image data. + One-by-one use right bit shift (>>) to remove + theBufferBitStripCount bits from theBitStreamBuffer. After each + shift decrement theBufferBitCounter and check whether it has + reached 0. If it has, get the next byte from the image data and + insert it in the high byte of theBitStreamBuffer and reset + theBufferBitCounter to 8. What is happening here is as we remove + each bit from the bottom of the bit stream buffer we check to see + if there are any bits left in the high byte of the buffer. As soon + as we know there are none, we refill it with the next eight bits + from the image data. - When this 'bit-stripping' is finished, other than actually identifying - the new pixel we are nearly done. I will leave that for the moment and - look at what happens if the low byte of theBitStreamBuffer we put in - theNewPixelIndexSelector was actually 0xFF: + When this 'bit-stripping' is finished, other than actually identifying + the new pixel we are nearly done. I will leave that for the moment and + look at what happens if the low byte of theBitStreamBuffer we put in + theNewPixelIndexSelector was actually 0xFF: - In this case, instead of the above routine we begin by removing - the low eight bits from the theBitStreamBuffer. We use the same - ono-by-one bit shift right process described above to do this, - again checking after each shift if it is necesary to refill the - buffer's high byte. + In this case, instead of the above routine we begin by removing + the low eight bits from the theBitStreamBuffer. We use the same + ono-by-one bit shift right process described above to do this, + again checking after each shift if it is necesary to refill the + buffer's high byte. - When the eight bits have been removed we set theNewPixelIndex to - the value of the low four bits of theBitStreamBuffer. Having done - that we again one-by-one strip off those low four bits from the - theBitStreamBuffer, again checking if we need to refill the buffer - high byte. + When the eight bits have been removed we set theNewPixelIndex to + the value of the low four bits of theBitStreamBuffer. Having done + that we again one-by-one strip off those low four bits from the + theBitStreamBuffer, again checking if we need to refill the buffer + high byte. - Irrespective of whether we initially had 0xFF in - theNewPixelIndexSelector we now have a new value in theNewPixelIndex. - This value is used as follows to obtain the new pixel value. + Irrespective of whether we initially had 0xFF in + theNewPixelIndexSelector we now have a new value in theNewPixelIndex. + This value is used as follows to obtain the new pixel value. - The variable theNewPixel contains either the seedByte or the value of - the previously extracted pixel. In either case this is a 4-bit value - in the lower 4 bits. Use the left bit shift operator (or multiply by - 16) to shift those four bits into the high four bits of theNewPixel. + The variable theNewPixel contains either the seedByte or the value of + the previously extracted pixel. In either case this is a 4-bit value + in the lower 4 bits. Use the left bit shift operator (or multiply by + 16) to shift those four bits into the high four bits of theNewPixel. - Add the value in theNewPixelIndex (it is a 4-bit value) to - theNewPixel. The resulting value is used as an index into the - pixelTable array of the header to get the actual new pixel value so - theNewPixel = header.pixelTable[theNewPixel] gets us our new pixel and - primes theNewPixel for the same process next time around the loop. + Add the value in theNewPixelIndex (it is a 4-bit value) to + theNewPixel. The resulting value is used as an index into the + pixelTable array of the header to get the actual new pixel value so + theNewPixel = header.pixelTable[theNewPixel] gets us our new pixel and + primes theNewPixel for the same process next time around the loop. - Having got our new pixel it is stored in the next empty space in the - bitmap and we loop back and start again. + Having got our new pixel it is stored in the next empty space in the + bitmap and we loop back and start again. - [*****] I am not sure how the compression was done - someone with a better - understanding of this area may be able to work out the method from the above. - I worked out how to decode it by spending many, many hours tracing through the - code in a debugger - thanks to the now defunct HiSoft for their DevPac ST and - Gerin Philippe for NoSTalgia . + [*****] I am not sure how the compression was done - someone with a better + understanding of this area may be able to work out the method from the above. + I worked out how to decode it by spending many, many hours tracing through the + code in a debugger - thanks to the now defunct HiSoft for their DevPac ST and + Gerin Philippe for NoSTalgia . */ L9BOOL bitmap_pc2_decode(char *file, int x, int y) { L9BYTE *data = NULL; @@ -733,7 +733,7 @@ BitmapType bitmap_pc_type(char *file) { } /* - Amiga Bitmaps + Amiga Bitmaps */ void bitmap_noext_name(int num, char *dir, char *out) { @@ -753,9 +753,9 @@ int bitmap_amiga_intensity(int col) { } /* - Amiga palette colours are word length structures with the red, green and blue - values stored in the second, third and lowest nybles respectively. The high - nybble is always zero. + Amiga palette colours are word length structures with the red, green and blue + values stored in the second, third and lowest nybles respectively. The high + nybble is always zero. */ Colour bitmap_amiga_colour(int i1, int i2) { Colour col; @@ -766,30 +766,30 @@ Colour bitmap_amiga_colour(int i1, int i2) { } /* - The Amiga image file has the following format. It consists of a 44 byte - header followed by the image data. + The Amiga image file has the following format. It consists of a 44 byte + header followed by the image data. - The header has the following format: - Bytes 0-63: thirty-two entry Amiga palette - Bytes 64-65: padding - Bytes 66-67: big-endian word holding picture width in pixels* - Bytes 68-69: padding - Bytes 70-71: big-endian word holding number of pixel rows in the image* + The header has the following format: + Bytes 0-63: thirty-two entry Amiga palette + Bytes 64-65: padding + Bytes 66-67: big-endian word holding picture width in pixels* + Bytes 68-69: padding + Bytes 70-71: big-endian word holding number of pixel rows in the image* - [*] these are probably big-endian unsigned longs but I have designated - the upper two bytes as padding because (a) Level 9 does not need - them as longs and (b) using unsigned shorts reduces byte sex induced - byte order juggling. + [*] these are probably big-endian unsigned longs but I have designated + the upper two bytes as padding because (a) Level 9 does not need + them as longs and (b) using unsigned shorts reduces byte sex induced + byte order juggling. - The images are designed for an Amiga low-res mode screen - that is they - assume a 320*256 (or 320 * 200 if NSTC display) screen with a palette of - 32 colours from the possible 4096. + The images are designed for an Amiga low-res mode screen - that is they + assume a 320*256 (or 320 * 200 if NSTC display) screen with a palette of + 32 colours from the possible 4096. - The image data is organised the same way that Amiga video memory is. The - entire data block is divided into five equal length bit planes with the - first bit plane holding the low bit of each 5-bit pixel, the second bitplane - the second bit of the pixel and so on up to the fifth bit plane holding the - high bit of the f5-bit pixel. + The image data is organised the same way that Amiga video memory is. The + entire data block is divided into five equal length bit planes with the + first bit plane holding the low bit of each 5-bit pixel, the second bitplane + the second bit of the pixel and so on up to the fifth bit plane holding the + high bit of the f5-bit pixel. */ L9BOOL bitmap_amiga_decode(char *file, int x, int y) { L9BYTE *data = NULL; @@ -892,26 +892,26 @@ BitmapType bitmap_noext_type(char *file) { } /* - Macintosh Bitmaps + Macintosh Bitmaps */ /* - The Mac image file format is very simple. The header is ten bytes - with the width of the image in pixels in the first long and the - height (in pixel rows) in the second long - both are big-endian. - (In both cases I treat these as unsigned shorts to minimise byte - twiddling when working around byte sex issues). There follow two - unidentified bytes - possibly image type identifiers or maybe - valid pixel masks for the beginning and end of pixel rows in - sub-images. + The Mac image file format is very simple. The header is ten bytes + with the width of the image in pixels in the first long and the + height (in pixel rows) in the second long - both are big-endian. + (In both cases I treat these as unsigned shorts to minimise byte + twiddling when working around byte sex issues). There follow two + unidentified bytes - possibly image type identifiers or maybe + valid pixel masks for the beginning and end of pixel rows in + sub-images. - The image data is extremely simple. The entire block is a packed array - of 1-bit pixels - I.E. each byte holds eight pixels - with 1 representing - white and 0 representing black. The pixels are organised with the top - left first and bottom left last, each row in turn. + The image data is extremely simple. The entire block is a packed array + of 1-bit pixels - I.E. each byte holds eight pixels - with 1 representing + white and 0 representing black. The pixels are organised with the top + left first and bottom left last, each row in turn. - The image sizes are 512 * 216 pixels for main images and 360 * 186 pixels - for sub-images. + The image sizes are 512 * 216 pixels for main images and 360 * 186 pixels + for sub-images. */ L9BOOL bitmap_mac_decode(char *file, int x, int y) { L9BYTE *data = NULL; @@ -967,7 +967,7 @@ L9BOOL bitmap_mac_decode(char *file, int x, int y) { } /* - C64 Bitmaps, also related formats (BBC B, Amstrad CPC and Spectrum +3) + C64 Bitmaps, also related formats (BBC B, Amstrad CPC and Spectrum +3) */ /* Commodore 64 palette from Vice */ @@ -1051,42 +1051,42 @@ BitmapType bitmap_c64_type(char *file) { } /* - The C64 graphics file format is (loosely) based on the layout of - C64 graphics memory. There are in fact two formats (i) the - standard game images and (ii) title pictures. For both formats - the file begins within the 2-byte pair 0x00 and 0x20. + The C64 graphics file format is (loosely) based on the layout of + C64 graphics memory. There are in fact two formats (i) the + standard game images and (ii) title pictures. For both formats + the file begins within the 2-byte pair 0x00 and 0x20. - The images are "multi-color bitmap mode" images which means they - have rows of 160 double width pixels and can be up to 200 rows - long. (The title images are 200 lines long, the game images are - 136 lines long.) Unlike Amiga, Mac, ST and PC graphics there are - no "main" and "sub" images. All game graphics have the same - dimensions and each completely replaces its predecessor. + The images are "multi-color bitmap mode" images which means they + have rows of 160 double width pixels and can be up to 200 rows + long. (The title images are 200 lines long, the game images are + 136 lines long.) Unlike Amiga, Mac, ST and PC graphics there are + no "main" and "sub" images. All game graphics have the same + dimensions and each completely replaces its predecessor. - The graphics files used on the Amstrad CPC and Spectrum +3 are also - virtually identical to C64 graphics files. This choice was presumably - made because although the CPC screen was more capable than the c64 it - was (in low resolution) the same size (160*200) and presumably - algorothmic conversion conversion of the colours was trivial for - the interpreter. In addition (a) the artwork already existed so no - extra expense would be incurred and (b) by accepting the C64's - limitation of only four colours in each 4*8 pixel block (but still - with sixteen colours on screen) they got a compressed file format - allowing more pictures on each disk. + The graphics files used on the Amstrad CPC and Spectrum +3 are also + virtually identical to C64 graphics files. This choice was presumably + made because although the CPC screen was more capable than the c64 it + was (in low resolution) the same size (160*200) and presumably + algorothmic conversion conversion of the colours was trivial for + the interpreter. In addition (a) the artwork already existed so no + extra expense would be incurred and (b) by accepting the C64's + limitation of only four colours in each 4*8 pixel block (but still + with sixteen colours on screen) they got a compressed file format + allowing more pictures on each disk. - The file organisation is rather different though. Only picture - one and the title picture are separate files. All the other - pictures (2-29) are stored in one large file "allpics.pic". + The file organisation is rather different though. Only picture + one and the title picture are separate files. All the other + pictures (2-29) are stored in one large file "allpics.pic". - On these platforms the picture 1 file and title picture file have - an AMSDOS header (a 128 byte block of metadata) which contains a - checksum of the first 66 bytes of the header in a little-endian - word at bytes 67 & 68. On the original C64 platform there was a - simple two byte header. Following the header the data is organised - exactly as in the C64 game and title image files. The - 'allpics.pic" file has no header and consists of 0x139E blocks - each forming a picture, in the C64 game file format (minus the two - byte header). + On these platforms the picture 1 file and title picture file have + an AMSDOS header (a 128 byte block of metadata) which contains a + checksum of the first 66 bytes of the header in a little-endian + word at bytes 67 & 68. On the original C64 platform there was a + simple two byte header. Following the header the data is organised + exactly as in the C64 game and title image files. The + 'allpics.pic" file has no header and consists of 0x139E blocks + each forming a picture, in the C64 game file format (minus the two + byte header). */ L9BOOL bitmap_c64_decode(char *file, BitmapType type, int num) { L9BYTE *data = NULL; @@ -1231,78 +1231,78 @@ L9BOOL bitmap_c64_decode(char *file, BitmapType type, int num) { } /* - The graphics files used by the BBC B are virtually identical - to C64 graphics files. I assume that (as with the CPC and - Spectrum+3) this choice was made because the BBC mode 2 screen, - was nearly the same size (160*256) and had roughly the same capability - as the C64 screen (displays 16 colours, although eight of those ar - just the first eight flashing). + The graphics files used by the BBC B are virtually identical + to C64 graphics files. I assume that (as with the CPC and + Spectrum+3) this choice was made because the BBC mode 2 screen, + was nearly the same size (160*256) and had roughly the same capability + as the C64 screen (displays 16 colours, although eight of those ar + just the first eight flashing). - In addition (a) the artwork already existed so no extra expense would - be incurred and (b) by accepting the C64's limitation of only four - colours in each 4*8 pixel block (but still with sixteen colours on - screen) they got a compressed file format allowing more pictures - on each disk. + In addition (a) the artwork already existed so no extra expense would + be incurred and (b) by accepting the C64's limitation of only four + colours in each 4*8 pixel block (but still with sixteen colours on + screen) they got a compressed file format allowing more pictures + on each disk. - The file organisation is very close to the C64. The naming system - can be the same eg "PIC12", but another form is also used : - "P.Pic12". Unlike the C64 the BBC has well defined title images, - called "TITLE" or P.Title. All pictures are in separate files. + The file organisation is very close to the C64. The naming system + can be the same eg "PIC12", but another form is also used : + "P.Pic12". Unlike the C64 the BBC has well defined title images, + called "TITLE" or P.Title. All pictures are in separate files. - The only difference seems to be: + The only difference seems to be: - * There is either *no* header before the image data or a simple - 10 byte header which I think *may* be a file system header - left in place by the extractor system. + * There is either *no* header before the image data or a simple + 10 byte header which I think *may* be a file system header + left in place by the extractor system. - * There is an extra 32 bytes following the data at the end of - each file. These bytes encode a table to convert between the 16 - C64 colours and 16, four-pixel pix-patterns used to let the BBC - (with only 8 colours) represent the sixteen possible C64 colours. + * There is an extra 32 bytes following the data at the end of + each file. These bytes encode a table to convert between the 16 + C64 colours and 16, four-pixel pix-patterns used to let the BBC + (with only 8 colours) represent the sixteen possible C64 colours. - A pix-pattern looks like this: + A pix-pattern looks like this: - | Even | Odd | - | Column | Column | - ----------------------------- - Even Row |Pixel 1 | Pixel 2 | - ---------|--------|---------| - Odd Row |Pixel 3 | Pixel 4 | - ----------------------------- + | Even | Odd | + | Column | Column | + ----------------------------- + Even Row |Pixel 1 | Pixel 2 | + ---------|--------|---------| + Odd Row |Pixel 3 | Pixel 4 | + ----------------------------- - Each of the four pixel *can* be any of the eight BBC Mode 2 - steady colours. In practice they seem either to be all the - same or a simple check of two colours - the pixels in the - odd row being in the reverse order to those in the even row. + Each of the four pixel *can* be any of the eight BBC Mode 2 + steady colours. In practice they seem either to be all the + same or a simple check of two colours - the pixels in the + odd row being in the reverse order to those in the even row. - When converting a C64 pixel to a BBC pixel the game uses the - value of the C64 pixel as an index into the array of sixteen - BBC pix-patterns. The game looks at the selected pattern and - chooses the BBC pixel colour thus: if the pixel is in an even - numbered row and an even numbered column, it uses Pixel 1 from - the pattern, if in an even row but an odd column, it uses Pixel 3 - and so on. + When converting a C64 pixel to a BBC pixel the game uses the + value of the C64 pixel as an index into the array of sixteen + BBC pix-patterns. The game looks at the selected pattern and + chooses the BBC pixel colour thus: if the pixel is in an even + numbered row and an even numbered column, it uses Pixel 1 from + the pattern, if in an even row but an odd column, it uses Pixel 3 + and so on. - The pix-pattern data is encoded thus: the first sixteen bytes - encode the even row pixels for the patterns, one byte per - pattern, and in the same way the second sixteen bytes encode - the odd row pixels for each pattern. For example for the - pattern representing C64 colour 0 the even row pixels are encoded - in the first byte and the odd row pixels in the sixteenth byte. + The pix-pattern data is encoded thus: the first sixteen bytes + encode the even row pixels for the patterns, one byte per + pattern, and in the same way the second sixteen bytes encode + the odd row pixels for each pattern. For example for the + pattern representing C64 colour 0 the even row pixels are encoded + in the first byte and the odd row pixels in the sixteenth byte. - Within each byte the pixels are encoded in this way: + Within each byte the pixels are encoded in this way: - Bit 7 6 5 4 3 2 1 0 - ------------------------------------- - 0 0 1 0 0 1 1 1 - | | | | | | | | - +---|---+---|---+---|---+---|----- Even Pixel 0101 (5) - | | | | - +-------+-------+-------+----- Odd Pixel 0011 (3) + Bit 7 6 5 4 3 2 1 0 + ------------------------------------- + 0 0 1 0 0 1 1 1 + | | | | | | | | + +---|---+---|---+---|---+---|----- Even Pixel 0101 (5) + | | | | + +-------+-------+-------+----- Odd Pixel 0011 (3) - This function calls the C64 decoding routines to do the actual - loading. See the comments to that function for details of how the - image is encoded and stored. + This function calls the C64 decoding routines to do the actual + loading. See the comments to that function for details of how the + image is encoded and stored. */ L9BOOL bitmap_bbc_decode(char *file, BitmapType type, int num) { unsigned char patRowData[32]; diff --git a/engines/glk/level9/level9_main.cpp b/engines/glk/level9/level9_main.cpp index fc9549f610b..c3f64b8f33e 100644 --- a/engines/glk/level9/level9_main.cpp +++ b/engines/glk/level9/level9_main.cpp @@ -66,12 +66,12 @@ struct SaveStruct { enum L9MsgTypes { MSGT_V1, MSGT_V2 }; /* - Graphics type Resolution Scale stack reset - ------------------------------------------------- - GFX_V2 160 x 128 yes - GFX_V3A 160 x 96 yes - GFX_V3B 160 x 96 no - GFX_V3C 320 x 96 no + Graphics type Resolution Scale stack reset + ------------------------------------------------- + GFX_V2 160 x 128 yes + GFX_V3A 160 x 96 yes + GFX_V3B 160 x 96 no + GFX_V3C 320 x 96 no */ enum L9GfxTypes { GFX_V2, GFX_V3A, GFX_V3B, GFX_V3C }; @@ -2220,11 +2220,11 @@ void newxy(int x, int y) { } /* sdraw instruction plus arguments are stored in an 8 bit word. - 76543210 - iixxxyyy + 76543210 + iixxxyyy where i is instruction code - x is x argument, high bit is sign - y is y argument, high bit is sign + x is x argument, high bit is sign + y is y argument, high bit is sign */ void sdraw(int d7) { int x, y, x1, y1; @@ -2257,11 +2257,11 @@ void sdraw(int d7) { } /* smove instruction plus arguments are stored in an 8 bit word. - 76543210 - iixxxyyy + 76543210 + iixxxyyy where i is instruction code - x is x argument, high bit is sign - y is y argument, high bit is sign + x is x argument, high bit is sign + y is y argument, high bit is sign */ void smove(int d7) { int x, y; @@ -2290,11 +2290,11 @@ void sgosub(int d7, L9BYTE **a5) { } /* draw instruction plus arguments are stored in a 16 bit word. - FEDCBA9876543210 - iiiiixxxxxxyyyyy + FEDCBA9876543210 + iiiiixxxxxxyyyyy where i is instruction code - x is x argument, high bit is sign - y is y argument, high bit is sign + x is x argument, high bit is sign + y is y argument, high bit is sign */ void draw(int d7, L9BYTE **a5) { int xy, x, y, x1, y1; @@ -2328,11 +2328,11 @@ void draw(int d7, L9BYTE **a5) { } /* move instruction plus arguments are stored in a 16 bit word. - FEDCBA9876543210 - iiiiixxxxxxyyyyy + FEDCBA9876543210 + iiiiixxxxxxyyyyy where i is instruction code - x is x argument, high bit is sign - y is y argument, high bit is sign + x is x argument, high bit is sign + y is y argument, high bit is sign */ void _move(int d7, L9BYTE **a5) { int xy, x, y; diff --git a/engines/glk/level9/os_glk.cpp b/engines/glk/level9/os_glk.cpp index c94216ad962..0454f3cb393 100644 --- a/engines/glk/level9/os_glk.cpp +++ b/engines/glk/level9/os_glk.cpp @@ -87,7 +87,7 @@ extern gln_uint32 FileSize; /* Forward declarations of event wait and other miscellaneous functions. */ static void gln_event_wait(glui32 wait_type, event_t *event); static void gln_event_wait_2(glui32 wait_type_1, - glui32 wait_type_2, event_t *event); + glui32 wait_type_2, event_t *event); static void gln_watchdog_tick(); static void gln_standout_string(const char *message); @@ -342,7 +342,7 @@ static const glui32 GLN_GRAPHICS_PROPORTION = 50; * timeouts to wait on after fully rendering the title picture (~2 seconds). */ static const int GLN_GRAPHICS_TITLE_PICTURE = 0, - GLN_GRAPHICS_TITLE_WAIT = 40; + GLN_GRAPHICS_TITLE_WAIT = 40; /* * Border and shading control. For cases where we can't detect the back- @@ -351,10 +351,10 @@ static const int GLN_GRAPHICS_TITLE_PICTURE = 0, * of shading fade. */ static const glui32 GLN_GRAPHICS_DEFAULT_BACKGROUND = 0x00ffffff, - GLN_GRAPHICS_BORDER_COLOR = 0x00000000; + GLN_GRAPHICS_BORDER_COLOR = 0x00000000; static const int GLN_GRAPHICS_BORDER = 1, - GLN_GRAPHICS_SHADING = 2, - GLN_GRAPHICS_SHADE_STEPS = 8; + GLN_GRAPHICS_SHADING = 2, + GLN_GRAPHICS_SHADE_STEPS = 8; /* * Guaranteed unused pixel value. This value is used to fill the on-screen @@ -669,7 +669,7 @@ static void gln_graphics_convert_palette(Colour ln_palette[], glui32 glk_palette * this picture in the current graphics window. */ static void gln_graphics_position_picture(winid_t glk_window, int pixel_size, - gln_uint16 width, gln_uint16 height, int *x_offset, int *y_offset) { + gln_uint16 width, gln_uint16 height, int *x_offset, int *y_offset) { uint window_width, window_height; assert(glk_window && x_offset && y_offset); @@ -765,7 +765,7 @@ static int gln_graphics_is_vertex(gln_byte off_screen[], gln_uint16 width, gln_u } static int gln_graphics_compare_layering_inverted(const void *void_first, - const void *void_second) { + const void *void_second) { const gln_layering_t *first = (const gln_layering_t *)void_first; const gln_layering_t *second = (const gln_layering_t *)void_second; @@ -1632,7 +1632,7 @@ struct gln_linegraphics_segment_t { static gln_linegraphics_segment_t *gln_linegraphics_fill_segments = nullptr; static int gln_linegraphics_fill_segments_allocation = 0, - gln_linegraphics_fill_segments_length = 0; + gln_linegraphics_fill_segments_length = 0; /* @@ -2178,7 +2178,7 @@ static double gln_watchdog_timeout_secs = 0.0; * than we're polled. Here's the control for that. */ static int gln_watchdog_check_period = 0, - gln_watchdog_check_counter = 0; + gln_watchdog_check_counter = 0; /* @@ -2422,7 +2422,7 @@ static void gln_status_redraw() { * been silenced as a result of already using a Glk command. */ static int gln_help_requested = FALSE, - gln_help_hints_silenced = FALSE; + gln_help_hints_silenced = FALSE; /* * Output buffer. We receive characters one at a time, and it's a bit @@ -2431,7 +2431,7 @@ static int gln_help_requested = FALSE, */ static char *gln_output_buffer = nullptr; static int gln_output_allocation = 0, - gln_output_length = 0; + gln_output_length = 0; /* * Output activity flag. Set when os_printchar() is called, and queried @@ -3684,7 +3684,7 @@ static int gln_command_intercept(char *string) { /* Ctrl-C and Ctrl-U character constants. */ static const char GLN_CONTROL_C = '\003', - GLN_CONTROL_U = '\025'; + GLN_CONTROL_U = '\025'; /* * os_readchar() call count limit, after which we really read a character. @@ -3692,7 +3692,7 @@ static const char GLN_CONTROL_C = '\003', * character press to stop the listing, and a stoplist poll timeout. */ static const int GLN_READCHAR_LIMIT = 1024, - GLN_STOPLIST_LIMIT = 10; + GLN_STOPLIST_LIMIT = 10; static const glui32 GLN_STOPLIST_TIMEOUT = 50; /* Quote used to suppress abbreviation expansion and local commands. */ @@ -4478,7 +4478,7 @@ int __wrap_tolower(int ch) { * it every 10,240 opcodes. */ static const int GLN_WATCHDOG_TIMEOUT = 5, - GLN_WATCHDOG_PERIOD = 10240; + GLN_WATCHDOG_PERIOD = 10240; /* * gln_establish_picture_filename() diff --git a/engines/glk/magnetic/glk.cpp b/engines/glk/magnetic/glk.cpp index fd7d06f55d1..713fa6e44ef 100644 --- a/engines/glk/magnetic/glk.cpp +++ b/engines/glk/magnetic/glk.cpp @@ -476,7 +476,7 @@ int Magnetic::gms_graphics_color_luminance(gms_rgbref_t rgb_color) { } int Magnetic::gms_graphics_compare_luminance(const void *void_first, - const void *void_second) { + const void *void_second) { long first = *(const long *)void_first; long second = *(const long *)void_second; @@ -484,12 +484,12 @@ int Magnetic::gms_graphics_compare_luminance(const void *void_first, } long Magnetic::gms_graphics_contrast_variance(type16 palette[], - long color_usage[], gms_gammaref_t gamma) { + long color_usage[], gms_gammaref_t gamma) { int index, count, has_black, mean; long sum; int contrast[GMS_PALETTE_SIZE]; int luminance[GMS_PALETTE_SIZE + 1]; /* Luminance for each color, - plus one extra for black */ + plus one extra for black */ /* Calculate the luminance energy of each palette color at this gamma. */ has_black = false; @@ -571,7 +571,7 @@ gms_gammaref_t Magnetic::gms_graphics_equal_contrast_gamma(type16 palette[], lon } gms_gammaref_t Magnetic::gms_graphics_select_gamma(type8 bitmap[], - type16 width, type16 height, type16 palette[]) { + type16 width, type16 height, type16 palette[]) { long color_usage[GMS_PALETTE_SIZE]; int color_count; gms_gammaref_t contrast_gamma; @@ -611,7 +611,7 @@ gms_gammaref_t Magnetic::gms_graphics_select_gamma(type8 bitmap[], } void Magnetic::gms_graphics_clear_and_border(winid_t glk_window, - int x_offset, int y_offset, int pixel_size, type16 width, type16 height) { + int x_offset, int y_offset, int pixel_size, type16 width, type16 height) { uint background; glui32 fade_color, shading_color; gms_rgb_t rgb_background, rgb_border, rgb_fade; @@ -714,7 +714,7 @@ void Magnetic::gms_graphics_clear_and_border(winid_t glk_window, } void Magnetic::gms_graphics_convert_palette(type16 ms_palette[], gms_gammaref_t gamma, - glui32 glk_palette[]) { + glui32 glk_palette[]) { int index; assert(ms_palette && gamma && glk_palette); @@ -731,7 +731,7 @@ void Magnetic::gms_graphics_convert_palette(type16 ms_palette[], gms_gammaref_t } void Magnetic::gms_graphics_position_picture(winid_t glk_window, - int pixel_size, type16 width, type16 height, int *x_offset, int *y_offset) { + int pixel_size, type16 width, type16 height, int *x_offset, int *y_offset) { uint window_width, window_height; assert(glk_window && x_offset && y_offset); @@ -747,8 +747,8 @@ void Magnetic::gms_graphics_position_picture(winid_t glk_window, } void Magnetic::gms_graphics_apply_animation_frame(type8 bitmap[], - type16 frame_width, type16 frame_height, type8 mask[], int frame_x, int frame_y, - type8 off_screen[], type16 width, type16 height) { + type16 frame_width, type16 frame_height, type8 mask[], int frame_x, int frame_y, + type8 off_screen[], type16 width, type16 height) { int mask_width, x, y; type8 mask_hibit; long frame_row, buffer_row, mask_row; @@ -894,7 +894,7 @@ int Magnetic::gms_graphics_is_vertex(type8 off_screen[], type16 width, type16 he } int Magnetic::gms_graphics_compare_layering_inverted(const void *void_first, - const void *void_second) { + const void *void_second) { gms_layering_t *first = (gms_layering_t *) void_first; gms_layering_t *second = (gms_layering_t *) void_second; @@ -913,8 +913,8 @@ int Magnetic::gms_graphics_compare_layering_inverted(const void *void_first, } void Magnetic::gms_graphics_assign_layers(type8 off_screen[], type8 on_screen[], - type16 width, type16 height, - int layers[], long layer_usage[]) { + type16 width, type16 height, + int layers[], long layer_usage[]) { int index, x, y; long index_row; gms_layering_t layering[GMS_PALETTE_SIZE]; @@ -968,9 +968,9 @@ void Magnetic::gms_graphics_assign_layers(type8 off_screen[], type8 on_screen[], } void Magnetic::gms_graphics_paint_region(winid_t glk_window, glui32 palette[], int layers[], - type8 off_screen[], type8 on_screen[], - int x, int y, int x_offset, int y_offset, - int pixel_size, type16 width, type16 height) { + type8 off_screen[], type8 on_screen[], + int x, int y, int x_offset, int y_offset, + int pixel_size, type16 width, type16 height) { type8 pixel; int layer, x_min, x_max, y_min, y_max, x_index, y_index; long index_row; @@ -1074,8 +1074,8 @@ break_y_max: #endif void Magnetic::gms_graphics_paint_everything(winid_t glk_window, - glui32 palette[], type8 off_screen[], int x_offset, int y_offset, - type16 width, type16 height) { + glui32 palette[], type8 off_screen[], int x_offset, int y_offset, + type16 width, type16 height) { type16 x, y; glui32 pixel; diff --git a/engines/glk/magnetic/magnetic_defs.h b/engines/glk/magnetic/magnetic_defs.h index a3675f6159d..97889de0c56 100644 --- a/engines/glk/magnetic/magnetic_defs.h +++ b/engines/glk/magnetic/magnetic_defs.h @@ -64,16 +64,16 @@ enum { INT32_MAX_VAL = 0x7fffffff }; /* Switch: SAVEMEM Purpose: Magnetic loads a complete graphics file into memory by default. - Setting this switch you tell Magnetic to load images on request - (saving memory, wasting load time) + Setting this switch you tell Magnetic to load images on request + (saving memory, wasting load time) #define SAVEMEM */ /* Switch: NO_ANIMATION Purpose: By default Magnetic plays animated graphics. - Setting this switch to ignore animations, Magnetic shows the - static parts of the images anyway! + Setting this switch to ignore animations, Magnetic shows the + static parts of the images anyway! #define NO_ANIMATION */ diff --git a/engines/glk/metaengine.cpp b/engines/glk/metaengine.cpp index 9a379670727..b6b777c85af 100644 --- a/engines/glk/metaengine.cpp +++ b/engines/glk/metaengine.cpp @@ -76,11 +76,11 @@ class GlkMetaEngine : public MetaEngine { private: Common::String findFileByGameId(const Common::String &gameId) const; public: - const char* getName() const override { - return "glk"; - } + const char* getName() const override { + return "glk"; + } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; Common::Error createInstance(OSystem *syst, Engine **engine) const override; SaveStateList listSaves(const char *target) const override; diff --git a/engines/glk/picture.cpp b/engines/glk/picture.cpp index c15ba59a939..27266d842ba 100644 --- a/engines/glk/picture.cpp +++ b/engines/glk/picture.cpp @@ -182,8 +182,8 @@ Picture *Pictures::load(const Common::String &name) { // Create new picture based on the image pic = new Picture(img->w, img->h, g_system->getScreenFormat()); pic->_refCount = 1; - pic->_name = name; - pic->_scaled = false; + pic->_name = name; + pic->_scaled = false; if (transColor != -1 || (!palette && img->format.aBits() > 0)) pic->clear(pic->getTransparentColor()); @@ -210,8 +210,8 @@ Picture *Pictures::load(const Common::String &name) { } } - store(pic); - return pic; + store(pic); + return pic; } Picture *Pictures::scale(Picture *src, size_t sx, size_t sy) { diff --git a/engines/glk/quest/geas_glk.h b/engines/glk/quest/geas_glk.h index c63f7896d83..c18dbcc5116 100644 --- a/engines/glk/quest/geas_glk.h +++ b/engines/glk/quest/geas_glk.h @@ -34,14 +34,14 @@ namespace Quest { Glk Window arrangment. - +---------+ - | B | - +---------+ - | M | - | | - +---------+ - | I | - +---------+ + +---------+ + | B | + +---------+ + | M | + | | + +---------+ + | I | + +---------+ B is a one line "banner window", showing the game name and author. Kept in the global variable, it's optional, null if unavailable. diff --git a/engines/glk/quest/geas_impl.h b/engines/glk/quest/geas_impl.h index c2bd56a52d1..a0e0aed480d 100644 --- a/engines/glk/quest/geas_impl.h +++ b/engines/glk/quest/geas_impl.h @@ -66,7 +66,7 @@ Common::WriteStream &operator<< (Common::WriteStream &o, const match_rv &rv); //o << rv.bindings.size(); //o << rv.bindings; for (uint i = 0; i < rv.bindings.size(); i ++) - o << rv.bindings[i] << ", "; + o << rv.bindings[i] << ", "; o << "]}"; return o; } diff --git a/engines/glk/quest/geas_runner.cpp b/engines/glk/quest/geas_runner.cpp index b9b25be7e5a..c8438e57c33 100644 --- a/engines/glk/quest/geas_runner.cpp +++ b/engines/glk/quest/geas_runner.cpp @@ -253,7 +253,7 @@ bool geas_implementation::has_obj_action(String obj, String prop) const { bool geas_implementation::get_obj_action(String objname, String actname, - String &rv) const { + String &rv) const { //String backup_object = this_object; //this_object = objname; @@ -285,7 +285,7 @@ bool geas_implementation::has_obj_property(String obj, String prop) const { } bool geas_implementation::get_obj_property(String obj, String prop, - String &string_rv) const { + String &string_rv) const { String is_prop = "properties " + prop; String not_prop = "properties not " + prop; for (uint i = state.props.size() - 1; i + 1 > 0; i --) diff --git a/engines/glk/quest/read_file.cpp b/engines/glk/quest/read_file.cpp index 2ceda40f061..d3aa691a460 100644 --- a/engines/glk/quest/read_file.cpp +++ b/engines/glk/quest/read_file.cpp @@ -136,9 +136,9 @@ extern Common::Array split_lines(String data); reserved_words dir_tag_property("north", "south", "east", "west", "northwest", "northeast", "southeast", "southwest", "up", "down", "out", (char *) NULL); void GeasFile::read_into(const Common::Array &in_data, - String in_parent, uint cur_line, bool recurse, - const reserved_words &props, - const reserved_words &actions) { + String in_parent, uint cur_line, bool recurse, + const reserved_words &props, + const reserved_words &actions) { //cerr << "r_i: Reading in from" << cur_line << ": " << in_data[cur_line] << endl; //output.push_back (GeasBlock()); //GeasBlock &out_block = output[output.size() - 1]; @@ -692,7 +692,7 @@ void handle_includes(const Common::Array &in_data, String filename, Comm } bool preprocess(Common::Array v, String fname, Common::Array &rv, - GeasInterface *gi) { + GeasInterface *gi) { //cerr << "Before preprocessing:\n" << v << "\n\n" << endl; /* cerr << "Before preprocessing:\n"; diff --git a/engines/glk/tads/os_banners.cpp b/engines/glk/tads/os_banners.cpp index 577e9f3dd35..40dd8d037f6 100644 --- a/engines/glk/tads/os_banners.cpp +++ b/engines/glk/tads/os_banners.cpp @@ -36,47 +36,47 @@ typedef banner_contents_t *contentid_t; /* for tracking banner windows */ struct os_banner_t { - uint id; /* unique identifier */ - uint valid; /* banner status */ + uint id; /* unique identifier */ + uint valid; /* banner status */ - osbanid_t prev; /* previous sibling */ - osbanid_t next; /* next sibling */ - osbanid_t children; /* child's descendents */ - osbanid_t parent; /* child's parent */ + osbanid_t prev; /* previous sibling */ + osbanid_t next; /* next sibling */ + osbanid_t children; /* child's descendents */ + osbanid_t parent; /* child's parent */ - uint method; /* glk window method */ - uint size; /* glk window size */ - uint type; /* glk window type */ - uint status; /* glk status style */ + uint method; /* glk window method */ + uint size; /* glk window size */ + uint type; /* glk window type */ + uint status; /* glk status style */ - uint cheight; /* glk char height */ - uint cwidth; /* glk char width */ + uint cheight; /* glk char height */ + uint cwidth; /* glk char width */ - uint fgcolor; /* foreground color */ - uint bgcolor; /* background color */ - uint fgcustom; /* custom colors */ - uint bgcustom; - uint bgtrans; + uint fgcolor; /* foreground color */ + uint bgcolor; /* background color */ + uint fgcustom; /* custom colors */ + uint bgcustom; + uint bgtrans; - contentid_t contents; /* window contents */ - uint style; /* active Glk style value */ - uint newline; /* active newline */ - uint move, x, y; /* active cursor position */ + contentid_t contents; /* window contents */ + uint style; /* active Glk style value */ + uint newline; /* active newline */ + uint move, x, y; /* active cursor position */ - winid_t win; /* glk window object */ + winid_t win; /* glk window object */ }; /* for reprinting banner contents */ struct banner_contents_t { - osbanid_t banner; /* content owner */ - contentid_t next; /* next set of contents */ + osbanid_t banner; /* content owner */ + contentid_t next; /* next set of contents */ - uint style; /* stored contents style */ - uint newline; /* stored newline */ - uint move, x, y; /* stored cursor position */ + uint style; /* stored contents style */ + uint newline; /* stored newline */ + uint move, x, y; /* stored cursor position */ - char *chars; - uint len; + char *chars; + uint len; }; static osbanid_t os_banners = NULL; @@ -95,713 +95,713 @@ void banner_contents_display(contentid_t contents); /* Implementation-specific functions for managing banner windows */ /* - os_banner_init(); - os_banner_insert(); - os_banner_styles_apply(); - os_banner_styles_reset(); - os_banners_close(); - os_banners_open(); - os_banners_redraw(); + os_banner_init(); + os_banner_insert(); + os_banner_styles_apply(); + os_banner_styles_reset(); + os_banners_close(); + os_banners_open(); + os_banners_redraw(); */ osbanid_t os_banner_init() { - osbanid_t instance; - instance = (osbanid_t)malloc(sizeof(os_banner_t)); - if (!instance) - return 0; + osbanid_t instance; + instance = (osbanid_t)malloc(sizeof(os_banner_t)); + if (!instance) + return 0; - instance->id = ++ os_banner_count; - instance->valid = 1; + instance->id = ++ os_banner_count; + instance->valid = 1; - instance->prev = 0; - instance->next = 0; - instance->children = 0; - instance->parent = 0; + instance->prev = 0; + instance->next = 0; + instance->children = 0; + instance->parent = 0; - instance->method = 0; - instance->size = 0; - instance->type = 0; - instance->status = 0; + instance->method = 0; + instance->size = 0; + instance->type = 0; + instance->status = 0; - instance->cheight = 0; - instance->cwidth = 0; + instance->cheight = 0; + instance->cwidth = 0; - instance->contents = 0; - instance->style = style_Normal; - instance->newline = 0; - instance->move = 0; - instance->x = 0; - instance->y = 0; + instance->contents = 0; + instance->style = style_Normal; + instance->newline = 0; + instance->move = 0; + instance->x = 0; + instance->y = 0; - instance->win = 0; + instance->win = 0; - return instance; + return instance; } osbanid_t os_banner_insert(osbanid_t parent, uint operation, osbanid_t other, - uint method, uint size, uint type, uint status) + uint method, uint size, uint type, uint status) { - if (!parent || !(parent->valid)) - return 0; + if (!parent || !(parent->valid)) + return 0; - if (operation == OS_BANNER_BEFORE || operation == OS_BANNER_AFTER) - if (!other || !(other->valid) || !(other->parent == parent)) - operation = OS_BANNER_LAST; + if (operation == OS_BANNER_BEFORE || operation == OS_BANNER_AFTER) + if (!other || !(other->valid) || !(other->parent == parent)) + operation = OS_BANNER_LAST; - osbanid_t baby = os_banner_init(); - if (!baby) - return 0; - baby->parent = parent; + osbanid_t baby = os_banner_init(); + if (!baby) + return 0; + baby->parent = parent; - if (!(parent->children)) - { - parent->children = baby; - } - else - { - osbanid_t child = parent->children; + if (!(parent->children)) + { + parent->children = baby; + } + else + { + osbanid_t child = parent->children; - switch (operation) - { - case OS_BANNER_FIRST: - parent->children = baby; - baby->next = child; - child->prev = baby; - break; + switch (operation) + { + case OS_BANNER_FIRST: + parent->children = baby; + baby->next = child; + child->prev = baby; + break; - case OS_BANNER_BEFORE: - while (child != other && child->next) - child = child->next; + case OS_BANNER_BEFORE: + while (child != other && child->next) + child = child->next; - if (child->prev) - { - child->prev->next = baby; - baby->prev = child->prev; - } - else - { - parent->children = baby; - } + if (child->prev) + { + child->prev->next = baby; + baby->prev = child->prev; + } + else + { + parent->children = baby; + } - baby->next = child; - child->prev = baby; - break; + baby->next = child; + child->prev = baby; + break; - case OS_BANNER_LAST: - while(child->next) - child = child->next; + case OS_BANNER_LAST: + while(child->next) + child = child->next; - baby->prev = child; - child->next = baby; - break; + baby->prev = child; + child->next = baby; + break; - case OS_BANNER_AFTER: - while (child != other && child->next) - child = child->next; + case OS_BANNER_AFTER: + while (child != other && child->next) + child = child->next; - if (child->next) - { - child->next->prev = baby; - baby->next = child->next; - } + if (child->next) + { + child->next->prev = baby; + baby->next = child->next; + } - baby->prev = child; - child->next = baby; - break; + baby->prev = child; + child->next = baby; + break; - default: break; - } - } + default: break; + } + } - baby->method = method; - baby->size = size; - baby->type = type; - baby->status = status; + baby->method = method; + baby->size = size; + baby->type = type; + baby->status = status; - return baby; + return baby; } void os_banner_styles_apply (osbanid_t banner) { - if (!banner || !(banner->valid)) - return; + if (!banner || !(banner->valid)) + return; - uint propval = banner->status ? 0 : (banner->type == wintype_TextGrid ? 0 : 1); - uint bgcustom = banner->bgtrans ? banner->bgcolor : banner->bgcustom; + uint propval = banner->status ? 0 : (banner->type == wintype_TextGrid ? 0 : 1); + uint bgcustom = banner->bgtrans ? banner->bgcolor : banner->bgcustom; - /* font style: monospace for text grid and tab aligned buffers, else proportional */ - g_vm->glk_stylehint_set(banner->type, style_Alert, stylehint_Proportional, propval); - g_vm->glk_stylehint_set(banner->type, style_Subheader, stylehint_Proportional, propval); - g_vm->glk_stylehint_set(banner->type, style_Emphasized, stylehint_Proportional, propval); - g_vm->glk_stylehint_set(banner->type, style_Normal, stylehint_Proportional, propval); - g_vm->glk_stylehint_set(banner->type, style_User1, stylehint_Proportional, propval); - g_vm->glk_stylehint_set(banner->type, style_User2, stylehint_Proportional, propval); + /* font style: monospace for text grid and tab aligned buffers, else proportional */ + g_vm->glk_stylehint_set(banner->type, style_Alert, stylehint_Proportional, propval); + g_vm->glk_stylehint_set(banner->type, style_Subheader, stylehint_Proportional, propval); + g_vm->glk_stylehint_set(banner->type, style_Emphasized, stylehint_Proportional, propval); + g_vm->glk_stylehint_set(banner->type, style_Normal, stylehint_Proportional, propval); + g_vm->glk_stylehint_set(banner->type, style_User1, stylehint_Proportional, propval); + g_vm->glk_stylehint_set(banner->type, style_User2, stylehint_Proportional, propval); - /* foreground color: user1 reverse, user2 custom */ - g_vm->glk_stylehint_set(banner->type, style_Alert, stylehint_TextColor, banner->fgcolor); - g_vm->glk_stylehint_set(banner->type, style_Subheader, stylehint_TextColor, banner->fgcolor); - g_vm->glk_stylehint_set(banner->type, style_Emphasized, stylehint_TextColor, banner->fgcolor); - g_vm->glk_stylehint_set(banner->type, style_Normal, stylehint_TextColor, banner->fgcolor); - g_vm->glk_stylehint_set(banner->type, style_User1, stylehint_TextColor, banner->bgcolor); - g_vm->glk_stylehint_set(banner->type, style_User2, stylehint_TextColor, banner->fgcustom); + /* foreground color: user1 reverse, user2 custom */ + g_vm->glk_stylehint_set(banner->type, style_Alert, stylehint_TextColor, banner->fgcolor); + g_vm->glk_stylehint_set(banner->type, style_Subheader, stylehint_TextColor, banner->fgcolor); + g_vm->glk_stylehint_set(banner->type, style_Emphasized, stylehint_TextColor, banner->fgcolor); + g_vm->glk_stylehint_set(banner->type, style_Normal, stylehint_TextColor, banner->fgcolor); + g_vm->glk_stylehint_set(banner->type, style_User1, stylehint_TextColor, banner->bgcolor); + g_vm->glk_stylehint_set(banner->type, style_User2, stylehint_TextColor, banner->fgcustom); - /* background color: user1 reverse, user2 custom */ - g_vm->glk_stylehint_set(banner->type, style_Alert, stylehint_BackColor, banner->bgcolor); - g_vm->glk_stylehint_set(banner->type, style_Subheader, stylehint_BackColor, banner->bgcolor); - g_vm->glk_stylehint_set(banner->type, style_Emphasized, stylehint_BackColor, banner->bgcolor); - g_vm->glk_stylehint_set(banner->type, style_Normal, stylehint_BackColor, banner->bgcolor); - g_vm->glk_stylehint_set(banner->type, style_User1, stylehint_BackColor, banner->fgcolor); - g_vm->glk_stylehint_set(banner->type, style_User2, stylehint_BackColor, bgcustom); + /* background color: user1 reverse, user2 custom */ + g_vm->glk_stylehint_set(banner->type, style_Alert, stylehint_BackColor, banner->bgcolor); + g_vm->glk_stylehint_set(banner->type, style_Subheader, stylehint_BackColor, banner->bgcolor); + g_vm->glk_stylehint_set(banner->type, style_Emphasized, stylehint_BackColor, banner->bgcolor); + g_vm->glk_stylehint_set(banner->type, style_Normal, stylehint_BackColor, banner->bgcolor); + g_vm->glk_stylehint_set(banner->type, style_User1, stylehint_BackColor, banner->fgcolor); + g_vm->glk_stylehint_set(banner->type, style_User2, stylehint_BackColor, bgcustom); } void os_banner_styles_reset (void) { - g_vm->glk_stylehint_clear(wintype_AllTypes, style_Alert, stylehint_Proportional); - g_vm->glk_stylehint_clear(wintype_AllTypes, style_Subheader, stylehint_Proportional); - g_vm->glk_stylehint_clear(wintype_AllTypes, style_Emphasized, stylehint_Proportional); - g_vm->glk_stylehint_clear(wintype_AllTypes, style_Normal, stylehint_Proportional); - g_vm->glk_stylehint_clear(wintype_AllTypes, style_User1, stylehint_Proportional); - g_vm->glk_stylehint_clear(wintype_AllTypes, style_User2, stylehint_Proportional); + g_vm->glk_stylehint_clear(wintype_AllTypes, style_Alert, stylehint_Proportional); + g_vm->glk_stylehint_clear(wintype_AllTypes, style_Subheader, stylehint_Proportional); + g_vm->glk_stylehint_clear(wintype_AllTypes, style_Emphasized, stylehint_Proportional); + g_vm->glk_stylehint_clear(wintype_AllTypes, style_Normal, stylehint_Proportional); + g_vm->glk_stylehint_clear(wintype_AllTypes, style_User1, stylehint_Proportional); + g_vm->glk_stylehint_clear(wintype_AllTypes, style_User2, stylehint_Proportional); - g_vm->glk_stylehint_clear(wintype_AllTypes, style_Alert, stylehint_TextColor); - g_vm->glk_stylehint_clear(wintype_AllTypes, style_Subheader, stylehint_TextColor); - g_vm->glk_stylehint_clear(wintype_AllTypes, style_Emphasized, stylehint_TextColor); - g_vm->glk_stylehint_clear(wintype_AllTypes, style_Normal, stylehint_TextColor); - g_vm->glk_stylehint_clear(wintype_AllTypes, style_User1, stylehint_TextColor); - g_vm->glk_stylehint_clear(wintype_AllTypes, style_User2, stylehint_TextColor); + g_vm->glk_stylehint_clear(wintype_AllTypes, style_Alert, stylehint_TextColor); + g_vm->glk_stylehint_clear(wintype_AllTypes, style_Subheader, stylehint_TextColor); + g_vm->glk_stylehint_clear(wintype_AllTypes, style_Emphasized, stylehint_TextColor); + g_vm->glk_stylehint_clear(wintype_AllTypes, style_Normal, stylehint_TextColor); + g_vm->glk_stylehint_clear(wintype_AllTypes, style_User1, stylehint_TextColor); + g_vm->glk_stylehint_clear(wintype_AllTypes, style_User2, stylehint_TextColor); - g_vm->glk_stylehint_clear(wintype_AllTypes, style_Alert, stylehint_BackColor); - g_vm->glk_stylehint_clear(wintype_AllTypes, style_Subheader, stylehint_BackColor); - g_vm->glk_stylehint_clear(wintype_AllTypes, style_Emphasized, stylehint_BackColor); - g_vm->glk_stylehint_clear(wintype_AllTypes, style_Normal, stylehint_BackColor); - g_vm->glk_stylehint_clear(wintype_AllTypes, style_User1, stylehint_BackColor); - g_vm->glk_stylehint_clear(wintype_AllTypes, style_User2, stylehint_BackColor); + g_vm->glk_stylehint_clear(wintype_AllTypes, style_Alert, stylehint_BackColor); + g_vm->glk_stylehint_clear(wintype_AllTypes, style_Subheader, stylehint_BackColor); + g_vm->glk_stylehint_clear(wintype_AllTypes, style_Emphasized, stylehint_BackColor); + g_vm->glk_stylehint_clear(wintype_AllTypes, style_Normal, stylehint_BackColor); + g_vm->glk_stylehint_clear(wintype_AllTypes, style_User1, stylehint_BackColor); + g_vm->glk_stylehint_clear(wintype_AllTypes, style_User2, stylehint_BackColor); #ifdef GARGLK - /* reset our default colors with a superfluous hint */ - g_vm->glk_stylehint_set(wintype_AllTypes, style_Normal, stylehint_TextColor, mainfg); - g_vm->glk_stylehint_set(wintype_AllTypes, style_Normal, stylehint_BackColor, mainbg); + /* reset our default colors with a superfluous hint */ + g_vm->glk_stylehint_set(wintype_AllTypes, style_Normal, stylehint_TextColor, mainfg); + g_vm->glk_stylehint_set(wintype_AllTypes, style_Normal, stylehint_BackColor, mainbg); #endif /* GARGLK */ } void os_banners_close(osbanid_t banner) { - if (!banner) - return; + if (!banner) + return; - os_banners_close(banner->children); - os_banners_close(banner->next); + os_banners_close(banner->children); + os_banners_close(banner->next); - if (banner->win && (banner->win != mainwin)) - { - g_vm->glk_window_close(banner->win, 0); - banner->win = 0; - } + if (banner->win && (banner->win != mainwin)) + { + g_vm->glk_window_close(banner->win, 0); + banner->win = 0; + } } void os_banners_open(osbanid_t banner) { - if (!banner) - return; + if (!banner) + return; - if (banner->valid) - { - if (banner->size && banner->parent && banner->parent->win) - { - os_banner_styles_apply(banner); - banner->win = g_vm->glk_window_open(banner->parent->win, banner->method, - banner->size, banner->type, banner->id); - banner_contents_display(banner->contents); - } - os_banners_open(banner->children); - } + if (banner->valid) + { + if (banner->size && banner->parent && banner->parent->win) + { + os_banner_styles_apply(banner); + banner->win = g_vm->glk_window_open(banner->parent->win, banner->method, + banner->size, banner->type, banner->id); + banner_contents_display(banner->contents); + } + os_banners_open(banner->children); + } - os_banners_open(banner->next); + os_banners_open(banner->next); } void os_banners_redraw() { - if (!os_banners) - return; + if (!os_banners) + return; - os_banners_close(os_banners); - os_banners_open(os_banners); - os_banner_styles_reset(); + os_banners_close(os_banners); + os_banners_open(os_banners); + os_banner_styles_reset(); } /* Implementation-specific functions for managing banner contents */ /* - banner_contents_init(); - banner_contents_insert(); - banner_contents_display(); - banner_contents_clear(); + banner_contents_init(); + banner_contents_insert(); + banner_contents_display(); + banner_contents_clear(); */ contentid_t banner_contents_init(void) { - contentid_t instance; - instance = (contentid_t)malloc(sizeof(banner_contents_t)); - if (!instance) - return 0; + contentid_t instance; + instance = (contentid_t)malloc(sizeof(banner_contents_t)); + if (!instance) + return 0; - instance->banner = 0; - instance->next = 0; + instance->banner = 0; + instance->next = 0; - instance->style = style_Normal; - instance->newline = 0; - instance->move = 0; - instance->x = 0; - instance->y = 0; + instance->style = style_Normal; + instance->newline = 0; + instance->move = 0; + instance->x = 0; + instance->y = 0; - instance->chars = 0; - instance->len = 0; + instance->chars = 0; + instance->len = 0; - return instance; + return instance; } void banner_contents_insert(contentid_t contents, const char *txt, size_t len) { - if (!contents) - return; + if (!contents) + return; - contents->chars = (char *)malloc(sizeof(char) * (len + 1)); - if (!(contents->chars)) - return; + contents->chars = (char *)malloc(sizeof(char) * (len + 1)); + if (!(contents->chars)) + return; - memcpy(contents->chars, txt, len); + memcpy(contents->chars, txt, len); - contents->chars[len] = '\0'; - contents->len = len; + contents->chars[len] = '\0'; + contents->len = len; } void banner_contents_display(contentid_t contents) { - if (!contents || !(contents->banner)) - return; + if (!contents || !(contents->banner)) + return; - winid_t win = contents->banner->win; - uint len = contents->len; + winid_t win = contents->banner->win; + uint len = contents->len; - g_vm->glk_set_window(win); + g_vm->glk_set_window(win); - if (contents->newline) - { - char ch = '\n'; - os_put_buffer(&ch, 1); - } - - if (len && (contents->chars[len-1] == '\n')) - { - len --; - contents->banner->newline = 1; - } - else - { - contents->banner->newline = 0; - } + if (contents->newline) + { + char ch = '\n'; + os_put_buffer(&ch, 1); + } + + if (len && (contents->chars[len-1] == '\n')) + { + len --; + contents->banner->newline = 1; + } + else + { + contents->banner->newline = 0; + } - if (contents->move) - { - g_vm->glk_window_move_cursor(win, contents->x, contents->y); - contents->banner->move = 0; - contents->banner->x = 0; - contents->banner->y = 0; - } + if (contents->move) + { + g_vm->glk_window_move_cursor(win, contents->x, contents->y); + contents->banner->move = 0; + contents->banner->x = 0; + contents->banner->y = 0; + } - g_vm->glk_set_style(contents->style); - os_put_buffer(contents->chars, len); - g_vm->glk_set_window(mainwin); - banner_contents_display(contents->next); + g_vm->glk_set_style(contents->style); + os_put_buffer(contents->chars, len); + g_vm->glk_set_window(mainwin); + banner_contents_display(contents->next); } void banner_contents_clear(contentid_t contents) { - if (!contents) - return; + if (!contents) + return; - banner_contents_clear(contents->next); + banner_contents_clear(contents->next); - if (contents->chars) - free(contents->chars); + if (contents->chars) + free(contents->chars); - free(contents); + free(contents); } /* Banner API functions */ void *os_banner_create(void *parent, int where, void *other, int wintype, - int align, int siz, int siz_units, - unsigned long style) + int align, int siz, int siz_units, + unsigned long style) { - osbanid_t gparent = (osbanid_t)parent; - osbanid_t gbanner; - uint gwinmeth = 0; - uint gwinsize = siz; - uint gwintype = 0; - uint gstatus = (style & OS_BANNER_STYLE_TAB_ALIGN); + osbanid_t gparent = (osbanid_t)parent; + osbanid_t gbanner; + uint gwinmeth = 0; + uint gwinsize = siz; + uint gwintype = 0; + uint gstatus = (style & OS_BANNER_STYLE_TAB_ALIGN); - if (gparent && !(gparent->valid)) - return 0; + if (gparent && !(gparent->valid)) + return 0; - if (!os_banners) - { - os_banners = os_banner_init(); - if (!os_banners) - return 0; - os_banners->win = mainwin; - } + if (!os_banners) + { + os_banners = os_banner_init(); + if (!os_banners) + return 0; + os_banners->win = mainwin; + } - if (!gparent) - gparent = os_banners; + if (!gparent) + gparent = os_banners; - switch (wintype) - { - case OS_BANNER_TYPE_TEXT: gwintype = wintype_TextBuffer; break; - case OS_BANNER_TYPE_TEXTGRID: gwintype = wintype_TextGrid; break; - default: gwintype = wintype_TextGrid; break; - } + switch (wintype) + { + case OS_BANNER_TYPE_TEXT: gwintype = wintype_TextBuffer; break; + case OS_BANNER_TYPE_TEXTGRID: gwintype = wintype_TextGrid; break; + default: gwintype = wintype_TextGrid; break; + } - switch (align) - { - case OS_BANNER_ALIGN_TOP: gwinmeth = winmethod_Above; break; - case OS_BANNER_ALIGN_BOTTOM: gwinmeth = winmethod_Below; break; - case OS_BANNER_ALIGN_LEFT: gwinmeth = winmethod_Left; break; - case OS_BANNER_ALIGN_RIGHT: gwinmeth = winmethod_Right; break; - default: gwinmeth = winmethod_Above; break; - } + switch (align) + { + case OS_BANNER_ALIGN_TOP: gwinmeth = winmethod_Above; break; + case OS_BANNER_ALIGN_BOTTOM: gwinmeth = winmethod_Below; break; + case OS_BANNER_ALIGN_LEFT: gwinmeth = winmethod_Left; break; + case OS_BANNER_ALIGN_RIGHT: gwinmeth = winmethod_Right; break; + default: gwinmeth = winmethod_Above; break; + } - switch (siz_units) - { - case OS_BANNER_SIZE_PCT: gwinmeth |= winmethod_Proportional; break; - case OS_BANNER_SIZE_ABS: gwinmeth |= winmethod_Fixed; break; - default: gwinmeth |= winmethod_Fixed; break; - } + switch (siz_units) + { + case OS_BANNER_SIZE_PCT: gwinmeth |= winmethod_Proportional; break; + case OS_BANNER_SIZE_ABS: gwinmeth |= winmethod_Fixed; break; + default: gwinmeth |= winmethod_Fixed; break; + } - gbanner = os_banner_insert(gparent, where, (osbanid_t)other, gwinmeth, gwinsize, gwintype, gstatus); + gbanner = os_banner_insert(gparent, where, (osbanid_t)other, gwinmeth, gwinsize, gwintype, gstatus); - if (gbanner) - { - gbanner->fgcolor = gstatus ? statusbg : mainfg; - gbanner->bgcolor = gstatus ? statusfg : mainbg; - gbanner->fgcustom = gbanner->fgcolor; - gbanner->bgcustom = gbanner->bgcolor; - gbanner->bgtrans = 1; - } + if (gbanner) + { + gbanner->fgcolor = gstatus ? statusbg : mainfg; + gbanner->bgcolor = gstatus ? statusfg : mainbg; + gbanner->fgcustom = gbanner->fgcolor; + gbanner->bgcustom = gbanner->bgcolor; + gbanner->bgtrans = 1; + } - os_banners_redraw(); + os_banners_redraw(); - return gbanner; + return gbanner; } void os_banner_set_size(void *banner_handle, int siz, int siz_units, int is_advisory) { - osbanid_t banner = (osbanid_t)banner_handle; + osbanid_t banner = (osbanid_t)banner_handle; - if (!banner || !banner->valid) - return; + if (!banner || !banner->valid) + return; - uint gwinsize = siz; - uint gwinmeth = 0; + uint gwinsize = siz; + uint gwinmeth = 0; - gwinmeth = banner->method & - (winmethod_Above | winmethod_Below | - winmethod_Left | winmethod_Right); + gwinmeth = banner->method & + (winmethod_Above | winmethod_Below | + winmethod_Left | winmethod_Right); - switch (siz_units) - { - case OS_BANNER_SIZE_PCT: gwinmeth |= winmethod_Proportional; break; - case OS_BANNER_SIZE_ABS: gwinmeth |= winmethod_Fixed; break; - default: gwinmeth |= winmethod_Fixed; break; - } + switch (siz_units) + { + case OS_BANNER_SIZE_PCT: gwinmeth |= winmethod_Proportional; break; + case OS_BANNER_SIZE_ABS: gwinmeth |= winmethod_Fixed; break; + default: gwinmeth |= winmethod_Fixed; break; + } - banner->method = gwinmeth; - banner->size = gwinsize; + banner->method = gwinmeth; + banner->size = gwinsize; - os_banners_redraw(); + os_banners_redraw(); } void os_banner_size_to_contents(void *banner_handle) { - osbanid_t banner = (osbanid_t)banner_handle; + osbanid_t banner = (osbanid_t)banner_handle; - if (!banner || !banner->valid || !banner->win) - return; + if (!banner || !banner->valid || !banner->win) + return; #ifdef GARGLK - if (banner->type == wintype_TextBuffer) - { + if (banner->type == wintype_TextBuffer) + { TextBufferWindow *win = dynamic_cast(banner->win); assert(win); - int size = win->_scrollMax; - if (win->_numChars) - size++; - os_banner_set_size(banner, size, OS_BANNER_SIZE_ABS, 0); - } + int size = win->_scrollMax; + if (win->_numChars) + size++; + os_banner_set_size(banner, size, OS_BANNER_SIZE_ABS, 0); + } #endif /* GARGLK */ } void os_banner_delete(void *banner_handle) { - osbanid_t banner = (osbanid_t)banner_handle; - if (!banner || !(banner->valid)) - return; + osbanid_t banner = (osbanid_t)banner_handle; + if (!banner || !(banner->valid)) + return; - banner->valid = 0; - os_banners_redraw(); + banner->valid = 0; + os_banners_redraw(); - if (banner->parent && banner->parent->children == banner) - banner->parent->children = banner->next; + if (banner->parent && banner->parent->children == banner) + banner->parent->children = banner->next; - if (banner->next) - banner->next->prev = banner->prev; + if (banner->next) + banner->next->prev = banner->prev; - if (banner->prev) - banner->prev->next = banner->next; + if (banner->prev) + banner->prev->next = banner->next; - banner_contents_clear(banner->contents); + banner_contents_clear(banner->contents); - free(banner); + free(banner); } void os_banner_orphan(void *banner_handle) { - os_banner_delete(banner_handle); + os_banner_delete(banner_handle); } int os_banner_getinfo(void *banner_handle, os_banner_info_t *info) { - osbanid_t banner = (osbanid_t)banner_handle; - if (!banner || !banner->valid || !banner->win) - return 1; + osbanid_t banner = (osbanid_t)banner_handle; + if (!banner || !banner->valid || !banner->win) + return 1; - //winid_t win = banner->win; - uint gwintype = banner->type; - uint gwinmeth = banner->method; - uint gstyletab = banner->status; + //winid_t win = banner->win; + uint gwintype = banner->type; + uint gwinmeth = banner->method; + uint gstyletab = banner->status; - if (gwinmeth & winmethod_Above) - info->align = OS_BANNER_ALIGN_TOP; - if (gwinmeth & winmethod_Below) - info->align = OS_BANNER_ALIGN_BOTTOM; - if (gwinmeth & winmethod_Left) - info->align = OS_BANNER_ALIGN_LEFT; - if (gwinmeth & winmethod_Right) - info->align = OS_BANNER_ALIGN_RIGHT; + if (gwinmeth & winmethod_Above) + info->align = OS_BANNER_ALIGN_TOP; + if (gwinmeth & winmethod_Below) + info->align = OS_BANNER_ALIGN_BOTTOM; + if (gwinmeth & winmethod_Left) + info->align = OS_BANNER_ALIGN_LEFT; + if (gwinmeth & winmethod_Right) + info->align = OS_BANNER_ALIGN_RIGHT; - info->style = gstyletab ? OS_BANNER_STYLE_TAB_ALIGN : 0; + info->style = gstyletab ? OS_BANNER_STYLE_TAB_ALIGN : 0; - g_vm->glk_window_get_size(banner->win, &(banner->cwidth), &(banner->cheight)); + g_vm->glk_window_get_size(banner->win, &(banner->cwidth), &(banner->cheight)); - info->rows = banner->cheight; - info->columns = banner->cwidth; + info->rows = banner->cheight; + info->columns = banner->cwidth; - info->pix_width = 0; - info->pix_height = 0; + info->pix_width = 0; + info->pix_height = 0; - info->os_line_wrap = gstyletab ? 0 : (gwintype == wintype_TextBuffer); + info->os_line_wrap = gstyletab ? 0 : (gwintype == wintype_TextBuffer); - return 1; + return 1; } int os_banner_get_charwidth(void *banner_handle) { - osbanid_t banner = (osbanid_t)banner_handle; - if (!banner || !banner->valid || !banner->win) - return 0; + osbanid_t banner = (osbanid_t)banner_handle; + if (!banner || !banner->valid || !banner->win) + return 0; - g_vm->glk_window_get_size(banner->win, &(banner->cwidth), &(banner->cheight)); + g_vm->glk_window_get_size(banner->win, &(banner->cwidth), &(banner->cheight)); - return banner->cwidth; + return banner->cwidth; } int os_banner_get_charheight(void *banner_handle) { - osbanid_t banner = (osbanid_t)banner_handle; - if (!banner || !banner->valid || !banner->win) - return 0; + osbanid_t banner = (osbanid_t)banner_handle; + if (!banner || !banner->valid || !banner->win) + return 0; - g_vm->glk_window_get_size(banner->win, &(banner->cwidth), &(banner->cheight)); + g_vm->glk_window_get_size(banner->win, &(banner->cwidth), &(banner->cheight)); - return banner->cheight; + return banner->cheight; } void os_banner_clear(void *banner_handle) { - osbanid_t banner = (osbanid_t)banner_handle; - if (!banner || !banner->valid) - return; + osbanid_t banner = (osbanid_t)banner_handle; + if (!banner || !banner->valid) + return; - if (banner->win) - { - winid_t win = banner->win; - g_vm->glk_window_clear(win); - } + if (banner->win) + { + winid_t win = banner->win; + g_vm->glk_window_clear(win); + } - banner_contents_clear(banner->contents); - banner->contents = 0; - banner->newline = 0; - banner->move = 0; - banner->x = 0; - banner->y = 0; + banner_contents_clear(banner->contents); + banner->contents = 0; + banner->newline = 0; + banner->move = 0; + banner->x = 0; + banner->y = 0; } void os_banner_disp(void *banner_handle, const char *txt, size_t len) { - osbanid_t banner = (osbanid_t)banner_handle; - if (!banner || !banner->valid || !banner->win) - return; + osbanid_t banner = (osbanid_t)banner_handle; + if (!banner || !banner->valid || !banner->win) + return; - contentid_t update = banner_contents_init(); - if (!update) - return; - update->banner = banner; + contentid_t update = banner_contents_init(); + if (!update) + return; + update->banner = banner; - if (!(banner->contents)) - { - banner->contents = update; - } - else - { - contentid_t contents = banner->contents; - while (contents->next) - contents = contents->next; - contents->next = update; - } + if (!(banner->contents)) + { + banner->contents = update; + } + else + { + contentid_t contents = banner->contents; + while (contents->next) + contents = contents->next; + contents->next = update; + } - update->style = banner->style; - update->newline = banner->newline; - update->move = banner->move; - update->x = banner->x; - update->y = banner->y; + update->style = banner->style; + update->newline = banner->newline; + update->move = banner->move; + update->x = banner->x; + update->y = banner->y; - banner_contents_insert(update, txt, len); - banner_contents_display(update); + banner_contents_insert(update, txt, len); + banner_contents_display(update); } void os_banner_goto(void *banner_handle, int row, int col) { - osbanid_t banner = (osbanid_t)banner_handle; - if (!banner || !banner->valid || !banner->win) - return; + osbanid_t banner = (osbanid_t)banner_handle; + if (!banner || !banner->valid || !banner->win) + return; - if (banner->type == wintype_TextGrid) - { - banner->move = 1; - banner->x = col; - banner->y = row; - } + if (banner->type == wintype_TextGrid) + { + banner->move = 1; + banner->x = col; + banner->y = row; + } } void os_banner_set_attr(void *banner_handle, int attr) { - osbanid_t banner = (osbanid_t)banner_handle; - if (!banner || !banner->valid) - return; + osbanid_t banner = (osbanid_t)banner_handle; + if (!banner || !banner->valid) + return; - if (attr & OS_ATTR_BOLD && attr & OS_ATTR_ITALIC) - banner->style = style_Alert; - else if (attr & OS_ATTR_BOLD) - banner->style = style_Subheader; - else if (attr & OS_ATTR_ITALIC) - banner->style = style_Emphasized; - else - banner->style = style_Normal; + if (attr & OS_ATTR_BOLD && attr & OS_ATTR_ITALIC) + banner->style = style_Alert; + else if (attr & OS_ATTR_BOLD) + banner->style = style_Subheader; + else if (attr & OS_ATTR_ITALIC) + banner->style = style_Emphasized; + else + banner->style = style_Normal; } void os_banner_set_color(void *banner_handle, os_color_t fg, os_color_t bg) { - osbanid_t banner = (osbanid_t)banner_handle; - if (!banner || !banner->valid) - return; + osbanid_t banner = (osbanid_t)banner_handle; + if (!banner || !banner->valid) + return; - uint reversed = 0; - uint normal = 0; - uint transparent = 0; + uint reversed = 0; + uint normal = 0; + uint transparent = 0; - /* evaluate parameters */ + /* evaluate parameters */ - if (os_color_is_param(fg)) - { - switch(fg) - { - case OS_COLOR_P_TEXTBG: - case OS_COLOR_P_STATUSBG: - reversed = 1; - break; + if (os_color_is_param(fg)) + { + switch(fg) + { + case OS_COLOR_P_TEXTBG: + case OS_COLOR_P_STATUSBG: + reversed = 1; + break; - case OS_COLOR_P_TEXT: - case OS_COLOR_P_STATUSLINE: - case OS_COLOR_P_INPUT: - normal = 1; - break; + case OS_COLOR_P_TEXT: + case OS_COLOR_P_STATUSLINE: + case OS_COLOR_P_INPUT: + normal = 1; + break; - default: - break; - } - } + default: + break; + } + } - if (os_color_is_param(bg)) - { - switch (bg) - { - case OS_COLOR_P_TRANSPARENT: - transparent = 1; - break; + if (os_color_is_param(bg)) + { + switch (bg) + { + case OS_COLOR_P_TRANSPARENT: + transparent = 1; + break; - default: - break; - } - } + default: + break; + } + } - /* choose a style */ + /* choose a style */ - if (normal && transparent) - banner->style = style_Normal; - else if (reversed) - banner->style = style_User1; - else - banner->style = style_User2; + if (normal && transparent) + banner->style = style_Normal; + else if (reversed) + banner->style = style_User1; + else + banner->style = style_User2; - /* process our custom color */ + /* process our custom color */ - if (banner->style == style_User2) - { - /* store current settings */ - uint oldfg = banner->fgcustom; - uint oldbg = banner->bgcustom; - uint oldtr = banner->bgtrans; + if (banner->style == style_User2) + { + /* store current settings */ + uint oldfg = banner->fgcustom; + uint oldbg = banner->bgcustom; + uint oldtr = banner->bgtrans; - /* reset custom color parameters */ - banner->fgcustom = banner->fgcolor; - banner->bgcustom = banner->bgcolor; - banner->bgtrans = 1; + /* reset custom color parameters */ + banner->fgcustom = banner->fgcolor; + banner->bgcustom = banner->bgcolor; + banner->bgtrans = 1; - if (!normal) - banner->fgcustom = fg; + if (!normal) + banner->fgcustom = fg; - if (!transparent) - { - banner->bgcustom = bg; - banner->bgtrans = 0; - } + if (!transparent) + { + banner->bgcustom = bg; + banner->bgtrans = 0; + } - if (!(banner->fgcustom == oldfg - && banner->bgcustom == oldbg - && banner->bgtrans == oldtr)) - os_banners_redraw(); - } + if (!(banner->fgcustom == oldfg + && banner->bgcustom == oldbg + && banner->bgtrans == oldtr)) + os_banners_redraw(); + } } void os_banner_set_screen_color(void *banner_handle, os_color_t color) { - osbanid_t banner = (osbanid_t)banner_handle; - if (!banner || !banner->valid) - return; + osbanid_t banner = (osbanid_t)banner_handle; + if (!banner || !banner->valid) + return; - if (!(os_color_is_param(color))) - banner->bgcolor = color; + if (!(os_color_is_param(color))) + banner->bgcolor = color; - os_banners_redraw(); + os_banners_redraw(); } void os_banner_flush(void *banner_handle) {} diff --git a/engines/glk/tads/os_banners.h b/engines/glk/tads/os_banners.h index f518d8e84fa..6b73d9a2033 100644 --- a/engines/glk/tads/os_banners.h +++ b/engines/glk/tads/os_banners.h @@ -178,8 +178,8 @@ namespace TADS { * be prepared for this routine to return null. */ void *os_banner_create(void *parent, int where, void *other, int wintype, - int align, int siz, int siz_units, - unsigned long style); + int align, int siz, int siz_units, + unsigned long style); /* @@ -418,45 +418,45 @@ void os_banner_orphan(void *banner_handle); */ struct os_banner_info_t { - /* alignment */ - int align; + /* alignment */ + int align; - /* style flags - these indicate the style flags actually in use */ - unsigned long style; + /* style flags - these indicate the style flags actually in use */ + unsigned long style; - /* - * Actual on-screen size of the banner, in rows and columns. If the - * banner is displayed in a proportional font or can display multiple - * fonts of different sizes, this is approximated by the number of "0" - * characters in the window's default font that will fit in the - * window's display area. - */ - int rows; - int columns; + /* + * Actual on-screen size of the banner, in rows and columns. If the + * banner is displayed in a proportional font or can display multiple + * fonts of different sizes, this is approximated by the number of "0" + * characters in the window's default font that will fit in the + * window's display area. + */ + int rows; + int columns; - /* - * Actual on-screen size of the banner in pixels. This is meaningful - * only for full HTML interpreter; for text-only interpreters, these - * are always set to zero. - * - * Note that even if we're running on a GUI operating system, these - * aren't meaningful unless this is a full HTML interpreter. Text-only - * interpreters should always set these to zero, even on GUI OS's. - */ - int pix_width; - int pix_height; + /* + * Actual on-screen size of the banner in pixels. This is meaningful + * only for full HTML interpreter; for text-only interpreters, these + * are always set to zero. + * + * Note that even if we're running on a GUI operating system, these + * aren't meaningful unless this is a full HTML interpreter. Text-only + * interpreters should always set these to zero, even on GUI OS's. + */ + int pix_width; + int pix_height; - /* - * OS line wrapping flag. If this is set, the window uses OS-level - * line wrapping because the window uses a proportional font, so the - * caller does not need to (and should not) perform line breaking in - * text displayed in the window. - * - * Note that OS line wrapping is a PERMANENT feature of the window. - * Callers can note this information once and expect it to remain - * fixed through the window's lifetime. - */ - int os_line_wrap; + /* + * OS line wrapping flag. If this is set, the window uses OS-level + * line wrapping because the window uses a proportional font, so the + * caller does not need to (and should not) perform line breaking in + * text displayed in the window. + * + * Note that OS line wrapping is a PERMANENT feature of the window. + * Callers can note this information once and expect it to remain + * fixed through the window's lifetime. + */ + int os_line_wrap; }; typedef struct os_banner_info_t os_banner_info_t; @@ -590,7 +590,7 @@ void os_banner_flush(void *banner_handle); * is true. */ void os_banner_set_size(void *banner_handle, int siz, int siz_units, - int is_advisory); + int is_advisory); /* * Set the banner to the size of its current contents. This can be used diff --git a/engines/glk/tads/os_buffer.cpp b/engines/glk/tads/os_buffer.cpp index cb6ae9086f9..46047784fc8 100644 --- a/engines/glk/tads/os_buffer.cpp +++ b/engines/glk/tads/os_buffer.cpp @@ -32,7 +32,7 @@ extern winid_t mainwin; #ifndef GLK_MODULE_UNICODE void os_put_buffer(const char *buf, size_t len) { - g_vm->glk_put_buffer(buf, len); + g_vm->glk_put_buffer(buf, len); } void os_get_buffer (char *buf, size_t len, size_t init) @@ -42,8 +42,8 @@ void os_get_buffer (char *buf, size_t len, size_t init) char *os_fill_buffer(char *buf, size_t len) { - buf[len] = '\0'; - return buf; + buf[len] = '\0'; + return buf; } #else @@ -52,46 +52,46 @@ static uint32 *input = 0; static uint max = 0; void os_put_buffer(const char *buf, size_t len) { - uint32 *out; - uint outlen; + uint32 *out; + uint outlen; - if (!len) - return; + if (!len) + return; - out = new uint32[len + 1]; - if (!out) - return; - outlen = len; + out = new uint32[len + 1]; + if (!out) + return; + outlen = len; - outlen = os_parse_chars((const unsigned char *)buf, len, out, outlen); + outlen = os_parse_chars((const unsigned char *)buf, len, out, outlen); - if (outlen) - g_vm->glk_put_buffer_uni(out, outlen); - else + if (outlen) + g_vm->glk_put_buffer_uni(out, outlen); + else g_vm->glk_put_buffer(buf, len); delete[] out; } void os_get_buffer(char *buf, size_t len, size_t init) { - input = (uint32 *)malloc(sizeof(uint) * (len + 1)); - max = len; + input = (uint32 *)malloc(sizeof(uint) * (len + 1)); + max = len; - if (init) - os_parse_chars((const unsigned char *)buf, init + 1, input, len); + if (init) + os_parse_chars((const unsigned char *)buf, init + 1, input, len); - g_vm->glk_request_line_event_uni(mainwin, input, len - 1, init); + g_vm->glk_request_line_event_uni(mainwin, input, len - 1, init); } char *os_fill_buffer(char *buf, size_t len) { - uint res = os_prepare_chars(input, len, (unsigned char *)buf, max); - buf[res] = '\0'; + uint res = os_prepare_chars(input, len, (unsigned char *)buf, max); + buf[res] = '\0'; - free(input); - input = nullptr; - max = 0; + free(input); + input = nullptr; + max = 0; - return buf; + return buf; } #endif /* GLK_MODULE_UNICODE */ diff --git a/engines/glk/tads/os_frob_tads.h b/engines/glk/tads/os_frob_tads.h index e8c08457606..a8177a3bc0b 100644 --- a/engines/glk/tads/os_frob_tads.h +++ b/engines/glk/tads/os_frob_tads.h @@ -126,7 +126,7 @@ typedef Common::FSNode *osdirhdl_t; /* Get a file's stat() type. */ int osfmode( const char* fname, int follow_links, unsigned long* mode, - unsigned long* attr ); + unsigned long* attr ); #if 0 /* The maximum width of a line of text. @@ -492,7 +492,7 @@ int os_rename_file(const char *oldname, const char *newname); * if the file could not be found in any of the standard locations. */ bool os_locate(const char *fname, int flen, const char *arg0, - char *buf, size_t bufsiz); + char *buf, size_t bufsiz); /* ------------------------------------------------------------------------ */ @@ -1094,7 +1094,7 @@ bool os_is_file_in_dir(const char *filename, const char *path, * quote or otherwise modify characters outside the 0-127 range. */ void os_cvt_dir_url(char *result_buf, size_t result_buf_size, - const char *src_path); + const char *src_path); /* * Convert a URL-style path into a filename path expressed in the local @@ -1192,7 +1192,7 @@ void os_cvt_dir_url(char *result_buf, size_t result_buf_size, * Character sets: use the same rules as for os_cvt_dir_url(). */ void os_cvt_url_dir(char *result_buf, size_t result_buf_size, - const char *src_url); + const char *src_url); } // End of namespace TADS diff --git a/engines/glk/tads/os_glk.cpp b/engines/glk/tads/os_glk.cpp index c7cd0213a0f..ff21fe76346 100644 --- a/engines/glk/tads/os_glk.cpp +++ b/engines/glk/tads/os_glk.cpp @@ -65,40 +65,40 @@ char G_os_gamename[OSFNMAX]; * argc/argv values unchanged.) */ int os_init(int *argc, char *argv[], const char *prompt, - char *buf, int bufsiz) + char *buf, int bufsiz) { - mainwin = g_vm->glk_window_open(0, 0, 0, wintype_TextBuffer, 0); - if (!mainwin) - error("fatal: could not open window!\n"); + mainwin = g_vm->glk_window_open(0, 0, 0, wintype_TextBuffer, 0); + if (!mainwin) + error("fatal: could not open window!\n"); - /* get default colors for main window */ - if (!g_vm->glk_style_measure(mainwin, style_Normal, stylehint_TextColor, &mainfg)) - mainfg = 0; + /* get default colors for main window */ + if (!g_vm->glk_style_measure(mainwin, style_Normal, stylehint_TextColor, &mainfg)) + mainfg = 0; - if (!g_vm->glk_style_measure(mainwin, style_Normal, stylehint_BackColor, &mainbg)) - mainbg = 0; + if (!g_vm->glk_style_measure(mainwin, style_Normal, stylehint_BackColor, &mainbg)) + mainbg = 0; - /* get default colors for status window */ - statuswin = g_vm->glk_window_open(mainwin, - winmethod_Above | winmethod_Fixed, 1, - wintype_TextGrid, 0); + /* get default colors for status window */ + statuswin = g_vm->glk_window_open(mainwin, + winmethod_Above | winmethod_Fixed, 1, + wintype_TextGrid, 0); - if (!g_vm->glk_style_measure(statuswin, style_Normal, stylehint_TextColor, &statusfg)) - statusfg = 0; + if (!g_vm->glk_style_measure(statuswin, style_Normal, stylehint_TextColor, &statusfg)) + statusfg = 0; - if (!g_vm->glk_style_measure(statuswin, style_Normal, stylehint_BackColor, &statusbg)) - statusbg = 0; + if (!g_vm->glk_style_measure(statuswin, style_Normal, stylehint_BackColor, &statusbg)) + statusbg = 0; - /* close statuswin; reopened on request */ - g_vm->glk_window_close(statuswin, 0); + /* close statuswin; reopened on request */ + g_vm->glk_window_close(statuswin, 0); - statuswin = nullptr; + statuswin = nullptr; - g_vm->glk_set_window(mainwin); + g_vm->glk_set_window(mainwin); - strcpy(rbuf, ""); + strcpy(rbuf, ""); - return 0; + return 0; } /* @@ -139,62 +139,62 @@ void os_sleep_ms(long delay_in_milliseconds) { * known, the function should fill in *result and return true. */ int os_get_sysinfo(int code, void *param, long *result) { - switch (code) - { - case SYSINFO_TEXT_HILITE: - *result = 1; - return true; - case SYSINFO_BANNERS: - *result = 1; - return true; - case SYSINFO_TEXT_COLORS: - *result = SYSINFO_TXC_RGB; - return true; + switch (code) + { + case SYSINFO_TEXT_HILITE: + *result = 1; + return true; + case SYSINFO_BANNERS: + *result = 1; + return true; + case SYSINFO_TEXT_COLORS: + *result = SYSINFO_TXC_RGB; + return true; #ifdef USE_HTML - case SYSINFO_INTERP_CLASS: - *result = SYSINFO_ICLASS_HTML; - return true; - case SYSINFO_HTML: - *result = 1; - return true; + case SYSINFO_INTERP_CLASS: + *result = SYSINFO_ICLASS_HTML; + return true; + case SYSINFO_HTML: + *result = 1; + return true; #else - case SYSINFO_INTERP_CLASS: - *result = SYSINFO_ICLASS_TEXTGUI; - return true; - case SYSINFO_HTML: - *result = 0; - return true; + case SYSINFO_INTERP_CLASS: + *result = SYSINFO_ICLASS_TEXTGUI; + return true; + case SYSINFO_HTML: + *result = 0; + return true; #endif - case SYSINFO_JPEG: - case SYSINFO_PNG: - case SYSINFO_WAV: - case SYSINFO_MIDI: - case SYSINFO_WAV_MIDI_OVL: - case SYSINFO_WAV_OVL: - case SYSINFO_PREF_IMAGES: - case SYSINFO_PREF_SOUNDS: - case SYSINFO_PREF_MUSIC: - case SYSINFO_PREF_LINKS: - case SYSINFO_MPEG: - case SYSINFO_MPEG1: - case SYSINFO_MPEG2: - case SYSINFO_MPEG3: - case SYSINFO_LINKS_HTTP: - case SYSINFO_LINKS_FTP: - case SYSINFO_LINKS_NEWS: - case SYSINFO_LINKS_MAILTO: - case SYSINFO_LINKS_TELNET: - case SYSINFO_PNG_TRANS: - case SYSINFO_PNG_ALPHA: - case SYSINFO_OGG: - *result = 0; - return true; + case SYSINFO_JPEG: + case SYSINFO_PNG: + case SYSINFO_WAV: + case SYSINFO_MIDI: + case SYSINFO_WAV_MIDI_OVL: + case SYSINFO_WAV_OVL: + case SYSINFO_PREF_IMAGES: + case SYSINFO_PREF_SOUNDS: + case SYSINFO_PREF_MUSIC: + case SYSINFO_PREF_LINKS: + case SYSINFO_MPEG: + case SYSINFO_MPEG1: + case SYSINFO_MPEG2: + case SYSINFO_MPEG3: + case SYSINFO_LINKS_HTTP: + case SYSINFO_LINKS_FTP: + case SYSINFO_LINKS_NEWS: + case SYSINFO_LINKS_MAILTO: + case SYSINFO_LINKS_TELNET: + case SYSINFO_PNG_TRANS: + case SYSINFO_PNG_ALPHA: + case SYSINFO_OGG: + *result = 0; + return true; - default: - return false; - } + default: + return false; + } } /* ------------------------------------------------------------------------ */ @@ -263,32 +263,32 @@ int os_get_sysinfo(int code, void *param, long *result) { */ void os_printz(const char *str) { - os_print(str, strlen(str)); + os_print(str, strlen(str)); } void os_print(const char *str, size_t len) { - if (curwin == 0 && str) - os_put_buffer(str, len); + if (curwin == 0 && str) + os_put_buffer(str, len); - if (curwin == 1) - { - const char *p; - size_t rem, max; + if (curwin == 1) + { + const char *p; + size_t rem, max; - /* The string requires some fiddling for the status window */ - for (p = str, rem = len ; rem != 0 && *p == '\n'; p++, --rem) - ; - if (rem != 0 && p[rem-1] == '\n') - --rem; + /* The string requires some fiddling for the status window */ + for (p = str, rem = len ; rem != 0 && *p == '\n'; p++, --rem) + ; + if (rem != 0 && p[rem-1] == '\n') + --rem; - /* if that leaves anything, update the statusline */ - if (rem != 0) - { - max = sizeof(lbuf) - strlen(lbuf) - 1; - strncat(lbuf, p, rem > max ? max : rem); - os_status_redraw(); - } - } + /* if that leaves anything, update the statusline */ + if (rem != 0) + { + max = sizeof(lbuf) - strlen(lbuf) - 1; + strncat(lbuf, p, rem > max ? max : rem); + os_status_redraw(); + } + } } @@ -314,25 +314,25 @@ void os_print(const char *str, size_t len) { void os_status(int stat) { - curwin = stat; + curwin = stat; - if (stat == 1) - { - if (statuswin == NULL) - { - g_vm->glk_stylehint_set(wintype_TextGrid, style_User1, stylehint_ReverseColor, 1); - statuswin = g_vm->glk_window_open(mainwin, - winmethod_Above | winmethod_Fixed, 1, - wintype_TextGrid, 0); - } - strcpy(lbuf, ""); - } + if (stat == 1) + { + if (statuswin == NULL) + { + g_vm->glk_stylehint_set(wintype_TextGrid, style_User1, stylehint_ReverseColor, 1); + statuswin = g_vm->glk_window_open(mainwin, + winmethod_Above | winmethod_Fixed, 1, + wintype_TextGrid, 0); + } + strcpy(lbuf, ""); + } } /* get the status line mode */ int os_get_status() { - return curwin; + return curwin; } /* @@ -345,50 +345,50 @@ int os_get_status() */ void os_score(int score, int turncount) { - char buf[40]; - sprintf(buf, "%d/%d", score, turncount); - os_strsc(buf); + char buf[40]; + sprintf(buf, "%d/%d", score, turncount); + os_strsc(buf); } /* display a string in the score area in the status line */ void os_strsc(const char *p) { - snprintf(rbuf, sizeof rbuf, "%s", p); - os_status_redraw(); + snprintf(rbuf, sizeof rbuf, "%s", p); + os_status_redraw(); } static void os_status_redraw(void) { - char fmt[32]; - char buf[256]; - uint wid; - uint div; + char fmt[32]; + char buf[256]; + uint wid; + uint div; - if (!statuswin) - return; + if (!statuswin) + return; - g_vm->glk_window_get_size(statuswin, &wid, NULL); - div = wid - strlen(rbuf) - 3; + g_vm->glk_window_get_size(statuswin, &wid, NULL); + div = wid - strlen(rbuf) - 3; - sprintf(fmt, " %%%ds %%s ", - (int)div); - sprintf(buf, fmt, lbuf, rbuf); + sprintf(fmt, " %%%ds %%s ", - (int)div); + sprintf(buf, fmt, lbuf, rbuf); - g_vm->glk_window_clear(statuswin); - g_vm->glk_set_window(statuswin); - g_vm->glk_set_style(style_User1); - os_put_buffer(buf, strlen(buf)); - g_vm->glk_set_window(mainwin); + g_vm->glk_window_clear(statuswin); + g_vm->glk_set_window(statuswin); + g_vm->glk_set_style(style_User1); + os_put_buffer(buf, strlen(buf)); + g_vm->glk_set_window(mainwin); } static void redraw_windows(void) { - os_status_redraw(); - os_banners_redraw(); + os_status_redraw(); + os_banners_redraw(); } /* clear the screen */ void oscls(void) { - g_vm->glk_window_clear(mainwin); + g_vm->glk_window_clear(mainwin); } /* ------------------------------------------------------------------------ */ @@ -401,15 +401,15 @@ void oscls(void) */ void os_set_text_attr(int attr) { - curattr = attr; - if (curattr & OS_ATTR_BOLD && curattr & OS_ATTR_ITALIC) - g_vm->glk_set_style(style_Alert); - else if (curattr & OS_ATTR_BOLD) - g_vm->glk_set_style(style_Subheader); - else if (curattr & OS_ATTR_ITALIC) - g_vm->glk_set_style(style_Emphasized); - else - g_vm->glk_set_style(style_Normal); + curattr = attr; + if (curattr & OS_ATTR_BOLD && curattr & OS_ATTR_ITALIC) + g_vm->glk_set_style(style_Alert); + else if (curattr & OS_ATTR_BOLD) + g_vm->glk_set_style(style_Subheader); + else if (curattr & OS_ATTR_ITALIC) + g_vm->glk_set_style(style_Emphasized); + else + g_vm->glk_set_style(style_Normal); } /* @@ -463,7 +463,7 @@ void os_set_screen_color(os_color_t color) void os_set_title(const char *title) { #ifdef GARGLK - g_vm->garglk_set_story_title(title); + g_vm->garglk_set_story_title(title); #endif } @@ -487,8 +487,8 @@ void os_set_title(const char *title) */ void os_more_prompt() { - os_printz("\n[more]\n"); - os_waitc(); + os_printz("\n[more]\n"); + os_waitc(); } /* ------------------------------------------------------------------------ */ @@ -514,32 +514,32 @@ void os_more_prompt() * should be performed, and no default suffix should be applied. */ int os_askfile(const char *prompt, char *fname_buf, int fname_buf_len, - int prompt_type, os_filetype_t file_type) + int prompt_type, os_filetype_t file_type) { - frefid_t fileref; - uint gprompt, gusage; + frefid_t fileref; + uint gprompt, gusage; - if (prompt_type == OS_AFP_OPEN) - gprompt = filemode_Read; - else - gprompt = filemode_ReadWrite; + if (prompt_type == OS_AFP_OPEN) + gprompt = filemode_Read; + else + gprompt = filemode_ReadWrite; - if (file_type == OSFTSAVE || file_type == OSFTT3SAV) - gusage = fileusage_SavedGame; - else if (file_type == OSFTLOG || file_type == OSFTTEXT) - gusage = fileusage_Transcript; - else - gusage = fileusage_Data; + if (file_type == OSFTSAVE || file_type == OSFTT3SAV) + gusage = fileusage_SavedGame; + else if (file_type == OSFTLOG || file_type == OSFTTEXT) + gusage = fileusage_Transcript; + else + gusage = fileusage_Data; - fileref = g_vm->glk_fileref_create_by_prompt(gusage, (FileMode)gprompt, 0); - if (fileref == NULL) - return OS_AFE_CANCEL; + fileref = g_vm->glk_fileref_create_by_prompt(gusage, (FileMode)gprompt, 0); + if (fileref == NULL) + return OS_AFE_CANCEL; - strcpy(fname_buf, g_vm->garglk_fileref_get_name(fileref)); + strcpy(fname_buf, g_vm->garglk_fileref_get_name(fileref)); - g_vm->glk_fileref_destroy(fileref); + g_vm->glk_fileref_destroy(fileref); - return OS_AFE_SUCCESS; + return OS_AFE_SUCCESS; } /* @@ -551,20 +551,20 @@ int os_askfile(const char *prompt, char *fname_buf, int fname_buf_len, */ unsigned char *os_gets(unsigned char *buf, size_t buflen) { - event_t event; + event_t event; char *b = (char *)buf; - os_get_buffer(b, buflen, 0); + os_get_buffer(b, buflen, 0); - do - { - g_vm->glk_select(&event); - if (event.type == evtype_Arrange) - redraw_windows(); - } - while (event.type != evtype_LineInput); + do + { + g_vm->glk_select(&event); + if (event.type == evtype_Arrange) + redraw_windows(); + } + while (event.type != evtype_LineInput); - return (unsigned char *)os_fill_buffer(b, event.val1); + return (unsigned char *)os_fill_buffer(b, event.val1); } /* @@ -647,74 +647,74 @@ static size_t timelen = 0; #endif int os_gets_timeout(unsigned char *buf, size_t bufl, - unsigned long timeout_in_milliseconds, int use_timeout) + unsigned long timeout_in_milliseconds, int use_timeout) { #if defined GLK_TIMERS && defined GLK_MODULE_LINE_ECHO - int timer = use_timeout ? timeout_in_milliseconds : 0; - int timeout = 0; - int initlen = 0; - event_t event; + int timer = use_timeout ? timeout_in_milliseconds : 0; + int timeout = 0; + int initlen = 0; + event_t event; - /* restore saved buffer contents */ - if (timebuf) - { - assert(timelen && timelen <= bufl); - memcpy(buf, timebuf, timelen); - initlen = timelen - 1; - buf[initlen] = 0; - free(timebuf); - timebuf = 0; - } + /* restore saved buffer contents */ + if (timebuf) + { + assert(timelen && timelen <= bufl); + memcpy(buf, timebuf, timelen); + initlen = timelen - 1; + buf[initlen] = 0; + free(timebuf); + timebuf = 0; + } - /* start timer and turn off line echo */ - if (timer) - { - g_vm->glk_request_timer_events(timer); - g_vm->glk_set_echo_line_event(mainwin, 0); - } + /* start timer and turn off line echo */ + if (timer) + { + g_vm->glk_request_timer_events(timer); + g_vm->glk_set_echo_line_event(mainwin, 0); + } - os_get_buffer(buf, bufl, initlen); + os_get_buffer(buf, bufl, initlen); - do - { - g_vm->glk_select(&event); - if (event.type == evtype_Arrange) - redraw_windows(); - else if (event.type == evtype_Timer && (timeout = 1)) - g_vm->glk_cancel_line_event(mainwin, &event); - } - while (event.type != evtype_LineInput); + do + { + g_vm->glk_select(&event); + if (event.type == evtype_Arrange) + redraw_windows(); + else if (event.type == evtype_Timer && (timeout = 1)) + g_vm->glk_cancel_line_event(mainwin, &event); + } + while (event.type != evtype_LineInput); - char *res = os_fill_buffer(buf, event.val1); + char *res = os_fill_buffer(buf, event.val1); - /* stop timer and turn on line echo */ - if (timer) - { - g_vm->glk_request_timer_events(0); - g_vm->glk_set_echo_line_event(mainwin, 1); - } + /* stop timer and turn on line echo */ + if (timer) + { + g_vm->glk_request_timer_events(0); + g_vm->glk_set_echo_line_event(mainwin, 1); + } - /* save or print buffer contents */ - if (res && timer) - { - if (timeout) - { - timelen = strlen(buf) + 1; - timebuf = malloc(timelen); - memcpy(timebuf, buf, timelen); - } - else - { - g_vm->glk_set_style(style_Input); - os_print(buf, strlen(buf)); - os_print("\n", 1); - g_vm->glk_set_style(style_Normal); - } - } + /* save or print buffer contents */ + if (res && timer) + { + if (timeout) + { + timelen = strlen(buf) + 1; + timebuf = malloc(timelen); + memcpy(timebuf, buf, timelen); + } + else + { + g_vm->glk_set_style(style_Input); + os_print(buf, strlen(buf)); + os_print("\n", 1); + g_vm->glk_set_style(style_Normal); + } + } - return timeout ? OS_EVT_TIMEOUT : res ? OS_EVT_LINE : OS_EVT_EOF; + return timeout ? OS_EVT_TIMEOUT : res ? OS_EVT_LINE : OS_EVT_EOF; #else - return OS_EVT_NOTIMEOUT; + return OS_EVT_NOTIMEOUT; #endif } @@ -742,19 +742,19 @@ int os_gets_timeout(unsigned char *buf, size_t bufl, void os_gets_cancel(int reset) { #if defined GLK_TIMERS && defined GLK_MODULE_LINE_ECHO - if (timebuf) - { - g_vm->glk_set_style(style_Input); - os_print(timebuf, strlen(timebuf)); - os_print("\n", 1); - g_vm->glk_set_style(style_Normal); + if (timebuf) + { + g_vm->glk_set_style(style_Input); + os_print(timebuf, strlen(timebuf)); + os_print("\n", 1); + g_vm->glk_set_style(style_Normal); - if (reset) - { - free(timebuf); - timebuf = 0; - } - } + if (reset) + { + free(timebuf); + timebuf = 0; + } + } #endif } @@ -781,49 +781,49 @@ void os_gets_cancel(int reset) */ static int glktotads(unsigned int key) { - if (key < 256) - return key; - switch (key) - { - case keycode_Up: - return CMD_UP; - case keycode_Down: - return CMD_DOWN; - case keycode_Left: - return CMD_LEFT; - case keycode_Right: - return CMD_RIGHT; - case keycode_PageUp: - return CMD_PGUP; - case keycode_PageDown: - return CMD_PGDN; - case keycode_Home: - return CMD_HOME; - case keycode_End: - return CMD_END; - case keycode_Func1: - return CMD_F1; - case keycode_Func2: - return CMD_F2; - case keycode_Func3: - return CMD_F3; - case keycode_Func4: - return CMD_F4; - case keycode_Func5: - return CMD_F5; - case keycode_Func6: - return CMD_F6; - case keycode_Func7: - return CMD_F7; - case keycode_Func8: - return CMD_F8; - case keycode_Func9: - return CMD_F9; - case keycode_Func10: - return CMD_F10; - default: - return 0; - } + if (key < 256) + return key; + switch (key) + { + case keycode_Up: + return CMD_UP; + case keycode_Down: + return CMD_DOWN; + case keycode_Left: + return CMD_LEFT; + case keycode_Right: + return CMD_RIGHT; + case keycode_PageUp: + return CMD_PGUP; + case keycode_PageDown: + return CMD_PGDN; + case keycode_Home: + return CMD_HOME; + case keycode_End: + return CMD_END; + case keycode_Func1: + return CMD_F1; + case keycode_Func2: + return CMD_F2; + case keycode_Func3: + return CMD_F3; + case keycode_Func4: + return CMD_F4; + case keycode_Func5: + return CMD_F5; + case keycode_Func6: + return CMD_F6; + case keycode_Func7: + return CMD_F7; + case keycode_Func8: + return CMD_F8; + case keycode_Func9: + return CMD_F9; + case keycode_Func10: + return CMD_F10; + default: + return 0; + } } static int bufchar = 0; @@ -832,40 +832,40 @@ static int timechar = 0; static int getglkchar(void) { - event_t event; + event_t event; - timechar = 0; + timechar = 0; - g_vm->glk_request_char_event(mainwin); + g_vm->glk_request_char_event(mainwin); - do - { - g_vm->glk_select(&event); - if (event.type == evtype_Arrange) - redraw_windows(); - else if (event.type == evtype_Timer) - timechar = 1; - } - while (event.type != evtype_CharInput && event.type != evtype_Timer); + do + { + g_vm->glk_select(&event); + if (event.type == evtype_Arrange) + redraw_windows(); + else if (event.type == evtype_Timer) + timechar = 1; + } + while (event.type != evtype_CharInput && event.type != evtype_Timer); - g_vm->glk_cancel_char_event(mainwin); + g_vm->glk_cancel_char_event(mainwin); - return timechar ? 0 : event.val1; + return timechar ? 0 : event.val1; } int os_getc(void) { - unsigned int c; + unsigned int c; - if (bufchar) - { - c = bufchar; - bufchar = 0; - return c; - } + if (bufchar) + { + c = bufchar; + bufchar = 0; + return c; + } - c = waitchar ? waitchar : getglkchar(); - waitchar = 0; + c = waitchar ? waitchar : getglkchar(); + waitchar = 0; if (c == keycode_Return) c = '\n'; @@ -874,12 +874,12 @@ int os_getc(void) else if (c == keycode_Escape) c = 27; - if (c < 256) - return c; + if (c < 256) + return c; - bufchar = glktotads(c); + bufchar = glktotads(c); - return 0; + return 0; } /* @@ -911,13 +911,13 @@ int os_getc(void) */ int os_getc_raw(void) { - return os_getc(); + return os_getc(); } /* wait for a character to become available from the keyboard */ void os_waitc(void) { - waitchar = getglkchar(); + waitchar = getglkchar(); } /* @@ -935,32 +935,32 @@ void os_waitc(void) * otherwise simply waits for the user to press a key. */ int os_get_event(unsigned long timeout_in_milliseconds, int use_timeout, - os_event_info_t *info) + os_event_info_t *info) { #ifdef GLK_TIMERS - /* start timer */ - int timer = use_timeout ? timeout_in_milliseconds : 0; - if (timer) - g_vm->glk_request_timer_events(timer); + /* start timer */ + int timer = use_timeout ? timeout_in_milliseconds : 0; + if (timer) + g_vm->glk_request_timer_events(timer); #else - /* we can't handle timeouts */ - if (use_timeout) - return OS_EVT_NOTIMEOUT; + /* we can't handle timeouts */ + if (use_timeout) + return OS_EVT_NOTIMEOUT; #endif - /* get a key */ - info->key[0] = os_getc_raw(); - if (info->key[0] == 0 && timechar == 0) - info->key[1] = os_getc_raw(); + /* get a key */ + info->key[0] = os_getc_raw(); + if (info->key[0] == 0 && timechar == 0) + info->key[1] = os_getc_raw(); #ifdef GLK_TIMERS - /* stop timer */ - if (timer) - g_vm->glk_request_timer_events(0); + /* stop timer */ + if (timer) + g_vm->glk_request_timer_events(0); #endif - /* return the event */ - return timechar ? OS_EVT_TIMEOUT : OS_EVT_KEY; + /* return the event */ + return timechar ? OS_EVT_TIMEOUT : OS_EVT_KEY; } osfildef *os_exeseek(const char *argv0, const char *typ) { diff --git a/engines/glk/tads/os_glk.h b/engines/glk/tads/os_glk.h index 3f82313229b..c63104ac8fb 100644 --- a/engines/glk/tads/os_glk.h +++ b/engines/glk/tads/os_glk.h @@ -202,116 +202,116 @@ int os_get_zoneinfo_key(char *buf, size_t buflen); * changes between standard time and daylight time, if applicable. */ struct os_tzrule_t { - /* - * Day of year, 1-365, NEVER counting Feb 29; set to 0 if not used. - * Corresponds to the "J" format in Unix TZ strings. (Called "Julian - * day" in the POSIX docs, thus the "J", even though it's a bit of a - * misnomer.)(Because of the invariance of the mapping from J-number to - * date, this is just an obtuse way of specifying a month/day date. - * But even so, we'll let the OS layer relay this back to us in - * J-number format and count on the portable caller to work out the - * date, rather than foisting that work on each platform - * implementation.) - */ - int jday; + /* + * Day of year, 1-365, NEVER counting Feb 29; set to 0 if not used. + * Corresponds to the "J" format in Unix TZ strings. (Called "Julian + * day" in the POSIX docs, thus the "J", even though it's a bit of a + * misnomer.)(Because of the invariance of the mapping from J-number to + * date, this is just an obtuse way of specifying a month/day date. + * But even so, we'll let the OS layer relay this back to us in + * J-number format and count on the portable caller to work out the + * date, rather than foisting that work on each platform + * implementation.) + */ + int jday; - /* - * Day of year, 1-366, counting Feb 29 on leap years; set to 0 if not - * used; ignored if 'jday' is nonzero. This corresponds to the Julian - * day sans "J" in TZ strings (almost - that TZ format uses 0-365 as - * its range, so bump it up by one when parsing a TZ string). This - * format is even more obtuse than the J-day format, in that it doesn't - * even have an invariant month/day mapping (not after day 59, anyway - - * day 60 is either February 29 or March 1, depending on the leapness - * of the year, and every day after that is similarly conditional). As - * far as I can tell, no one uses this option, so I'm not sure why it - * exists. The zoneinfo source format doesn't have a way to represent - * it, which says to me that no one has ever used it in a statutory DST - * start/end date definition in the whole history of time zones around - * the world, since the whole history of time zones around the world is - * exactly what the zoneinfo database captures in exhaustive and - * painstaking detail. If anyone had ever used it in defining a time - * zone, zoneinfo would have an option for it. My guess is that it's a - * fossilized bug from some early C RTL that's been retained out of an - * abundance of caution vis-a-vis compatibility, and was entirely - * replaced in practice by the J-number format as soon as someone - * noticed the fiddly leap year behavior. But for the sake of - * completeness... - */ - int yday; - - /* - * The month (1-12), week of the month, and day of the week (1-7 for - * Sunday to Saturday). Week 1 is the first week in which 'day' - * occurs, week 2 is the second, etc.; week 5 is the last occurrence of - * 'day' in the month. These fields are used for "second Sunday in - * March" types of rules. Set these to zero if they're not used; - * they're ignored in any case if 'jday' or 'yday' are non-zero. - */ - int month; - int week; - int day; + /* + * Day of year, 1-366, counting Feb 29 on leap years; set to 0 if not + * used; ignored if 'jday' is nonzero. This corresponds to the Julian + * day sans "J" in TZ strings (almost - that TZ format uses 0-365 as + * its range, so bump it up by one when parsing a TZ string). This + * format is even more obtuse than the J-day format, in that it doesn't + * even have an invariant month/day mapping (not after day 59, anyway - + * day 60 is either February 29 or March 1, depending on the leapness + * of the year, and every day after that is similarly conditional). As + * far as I can tell, no one uses this option, so I'm not sure why it + * exists. The zoneinfo source format doesn't have a way to represent + * it, which says to me that no one has ever used it in a statutory DST + * start/end date definition in the whole history of time zones around + * the world, since the whole history of time zones around the world is + * exactly what the zoneinfo database captures in exhaustive and + * painstaking detail. If anyone had ever used it in defining a time + * zone, zoneinfo would have an option for it. My guess is that it's a + * fossilized bug from some early C RTL that's been retained out of an + * abundance of caution vis-a-vis compatibility, and was entirely + * replaced in practice by the J-number format as soon as someone + * noticed the fiddly leap year behavior. But for the sake of + * completeness... + */ + int yday; + + /* + * The month (1-12), week of the month, and day of the week (1-7 for + * Sunday to Saturday). Week 1 is the first week in which 'day' + * occurs, week 2 is the second, etc.; week 5 is the last occurrence of + * 'day' in the month. These fields are used for "second Sunday in + * March" types of rules. Set these to zero if they're not used; + * they're ignored in any case if 'jday' or 'yday' are non-zero. + */ + int month; + int week; + int day; - /* time of day, in seconds after midnight (e.g., 2AM is 120 == 2*60*60) */ - int time; + /* time of day, in seconds after midnight (e.g., 2AM is 120 == 2*60*60) */ + int time; }; struct os_tzinfo_t { - /* - * The local offset from GMT, in seconds, for standard time and - * daylight time in this zone. These values are positive for zones - * east of GMT and negative for zones west: New York standard time - * (EST) is 5 hours west of GMT, so its offset is -5*60*60. - * - * Set both of these fields (if possible) regardless of whether - * standard or daylight time is currently in effect in the zone. The - * caller will select which offset to use based on the start/end rules, - * or based on the 'is_dst' flag if no rules are available. - * - * If it's only possible to determine the current wall clock offset, be - * it standard or daylight time, and it's not possible to determine the - * time difference between the two, simply set both of these to the - * current offset. This information isn't available from the standard - * C library, and many OS APIs also lack it. - */ - int32_t std_ofs; - int32_t dst_ofs; + /* + * The local offset from GMT, in seconds, for standard time and + * daylight time in this zone. These values are positive for zones + * east of GMT and negative for zones west: New York standard time + * (EST) is 5 hours west of GMT, so its offset is -5*60*60. + * + * Set both of these fields (if possible) regardless of whether + * standard or daylight time is currently in effect in the zone. The + * caller will select which offset to use based on the start/end rules, + * or based on the 'is_dst' flag if no rules are available. + * + * If it's only possible to determine the current wall clock offset, be + * it standard or daylight time, and it's not possible to determine the + * time difference between the two, simply set both of these to the + * current offset. This information isn't available from the standard + * C library, and many OS APIs also lack it. + */ + int32_t std_ofs; + int32_t dst_ofs; - /* - * The abbreviations for the local zone's standard time and daylight - * time, respectively, when displaying date/time values. E.g., "EST" - * and "EDT" for US Eastern Time. If the zone doesn't observe daylight - * time (it's on standard time year round), set dst_abbr to an empty - * string. - * - * As with std_ofs and dst_ofs, you can set both of these to the same - * string if it's only possible to determine the one that's currently - * in effect. - */ - char std_abbr[16]; - char dst_abbr[16]; + /* + * The abbreviations for the local zone's standard time and daylight + * time, respectively, when displaying date/time values. E.g., "EST" + * and "EDT" for US Eastern Time. If the zone doesn't observe daylight + * time (it's on standard time year round), set dst_abbr to an empty + * string. + * + * As with std_ofs and dst_ofs, you can set both of these to the same + * string if it's only possible to determine the one that's currently + * in effect. + */ + char std_abbr[16]; + char dst_abbr[16]; - /* - * The ongoing rules for switching between daylight and standard time - * in this zone, if available. 'dst_start' is the date when daylight - * savings starts, 'dst_end' is the date when standard time resumes. - * Set all fields to 0 if the start/stop dates aren't available, or the - * zone is on standard time year round. - */ - struct os_tzrule_t dst_start; - struct os_tzrule_t dst_end; + /* + * The ongoing rules for switching between daylight and standard time + * in this zone, if available. 'dst_start' is the date when daylight + * savings starts, 'dst_end' is the date when standard time resumes. + * Set all fields to 0 if the start/stop dates aren't available, or the + * zone is on standard time year round. + */ + struct os_tzrule_t dst_start; + struct os_tzrule_t dst_end; - /* - * True -> the zone is CURRENTLY on daylight savings time; false means - * it's currently on standard time. - * - * This is only used if the start/end rules aren't specified. In the - * absence of start/end rules, there's no way to know when the current - * standard/daylight phase ends, so we'll have to assume that the - * current mode is in effect permanently. In this case, the caller - * will use only be able to use the offset and abbreviation for the - * current mode and will have to ignore the other one. - */ - int is_dst; + /* + * True -> the zone is CURRENTLY on daylight savings time; false means + * it's currently on standard time. + * + * This is only used if the start/end rules aren't specified. In the + * absence of start/end rules, there's no way to know when the current + * standard/daylight phase ends, so we'll have to assume that the + * current mode is in effect permanently. In this case, the caller + * will use only be able to use the offset and abbreviation for the + * current mode and will have to ignore the other one. + */ + int is_dst; }; int os_get_timezone_info(struct os_tzinfo_t *info); @@ -855,32 +855,32 @@ long os_get_sys_clock_ms(); /* #define OSFATTR_WRITE - the file is writable by this process */ struct os_file_stat_t { - /* - * Size of the file, in bytes. For platforms lacking 64-bit types, we - * split this into high and low 32-bit portions. Platforms where the - * native stat() or equivalent only returns a 32-bit file size can - * simply set sizehi to zero, since sizelo can hold the entire size - * value. - */ - uint32_t sizelo; - uint32_t sizehi; + /* + * Size of the file, in bytes. For platforms lacking 64-bit types, we + * split this into high and low 32-bit portions. Platforms where the + * native stat() or equivalent only returns a 32-bit file size can + * simply set sizehi to zero, since sizelo can hold the entire size + * value. + */ + uint32_t sizelo; + uint32_t sizehi; - /* - * Creation time, modification time, and last access time. If the file - * system doesn't keep information on one or more of these, use - * (os_time_t)0 to indicate that the timestamp isn't available. It's - * fine to return any subset of these. Per the standard C stat(), - * these should be expressed as seconds after the Unix Epoch. - */ - os_time_t cre_time; - os_time_t mod_time; - os_time_t acc_time; + /* + * Creation time, modification time, and last access time. If the file + * system doesn't keep information on one or more of these, use + * (os_time_t)0 to indicate that the timestamp isn't available. It's + * fine to return any subset of these. Per the standard C stat(), + * these should be expressed as seconds after the Unix Epoch. + */ + os_time_t cre_time; + os_time_t mod_time; + os_time_t acc_time; - /* file mode, using the same flags as returned from osfmode() */ - unsigned long mode; + /* file mode, using the same flags as returned from osfmode() */ + unsigned long mode; - /* file attributes, using the same flags as returned from osfmode() */ - unsigned long attrs; + /* file attributes, using the same flags as returned from osfmode() */ + unsigned long attrs; }; @@ -1087,8 +1087,8 @@ void os_close_dir(osdirhdl_t handle); * minimal manipulation. */ void *os_find_first_file(const char *dir, - char *outbuf, size_t outbufsiz, int *isdir, - char *outpathbuf, size_t outpathbufsiz); + char *outbuf, size_t outbufsiz, int *isdir, + char *outpathbuf, size_t outpathbufsiz); /* * Implementation notes for porting os_find_first_file: @@ -1147,7 +1147,7 @@ void *os_find_first_file(const char *dir, * need not call os_find_close(). */ void *os_find_next_file(void *ctx, char *outbuf, size_t outbufsiz, - int *isdir, char *outpathbuf, size_t outpathbufsiz); + int *isdir, char *outpathbuf, size_t outpathbufsiz); /* * Cancel a search. The context pointer returned by the last call to @@ -1165,21 +1165,21 @@ void os_find_close(void *ctx); */ enum os_specfile_t { - /* not a special file */ - OS_SPECFILE_NONE, + /* not a special file */ + OS_SPECFILE_NONE, - /* - * current directory link - this is a file like the "." file on Unix - * or DOS, which is a special link that simply refers to itself - */ - OS_SPECFILE_SELF, + /* + * current directory link - this is a file like the "." file on Unix + * or DOS, which is a special link that simply refers to itself + */ + OS_SPECFILE_SELF, - /* - * parent directory link - this is a file like the ".." file on Unix - * or DOS, which is a special link that refers to the parent - * directory - */ - OS_SPECFILE_PARENT + /* + * parent directory link - this is a file like the ".." file on Unix + * or DOS, which is a special link that refers to the parent + * directory + */ + OS_SPECFILE_PARENT }; /* @@ -1293,7 +1293,7 @@ int os_get_exe_filename(char *buf, size_t buflen, const char *argv0); * users who need custom settings aren't stuck with the defaults. */ void os_get_special_path(char *buf, size_t buflen, - const char *argv0, int id); + const char *argv0, int id); /* * TADS 3 system resource path. This path is used to load system @@ -2004,7 +2004,7 @@ void os_csr_busy(int flag); * should be performed, and no default suffix should be applied. */ int os_askfile(const char *prompt, char *fname_buf, int fname_buf_len, - int prompt_type, os_filetype_t file_type); + int prompt_type, os_filetype_t file_type); /* * os_askfile status codes @@ -2126,7 +2126,7 @@ unsigned char *os_gets(unsigned char *buf, size_t bufl); * immediately with the OS_EVT_TIMEOUT result code. */ int os_gets_timeout(unsigned char *buf, size_t bufl, - unsigned long timeout_in_milliseconds, int use_timeout); + unsigned long timeout_in_milliseconds, int use_timeout); /* * Cancel an interrupted editing session. This MUST be called if any @@ -2272,41 +2272,41 @@ void os_waitc(void); */ union os_event_info_t { - /* - * OS_EVT_KEY - this returns the one or two characters of the - * keystroke. If the key is an extended key, so that os_getc() would - * return a two-character sequence for the keystroke, the first - * character should be zero and the second the extended key code. - * Otherwise, the first character should simply be the ASCII key code. - * - * The key code here is the "raw" keycode, equivalent to the codes - * returned by os_getc_raw(). Note in particular that this means that - * CTRL and Escape keys are presented as one-byte ASCII control - * characters, not as two-byte CMD_xxx sequences. - * - * For multi-byte character sets (Shift-JIS, for example), note that - * os_get_event() must NOT return a complete two-byte character here. - * The two bytes here are exclusively used to represent special - * CMD_xxx keys (such as arrow keys and function keys). For a - * keystroke that is represented in a multi-byte character set using - * more than one byte, os_get_event() must return a series of events. - * Return an ordinary OS_EVT_KEY for the first byte of the sequence, - * putting the byte in key[0]; then, return the second byte as a - * separate OS_EVT_KEY as the next event; and so on for any additional - * bytes. This will allow callers that are not multibyte-aware to - * treat multi-byte characters as though they were sequences of - * one-byte characters. - */ - int key[2]; + /* + * OS_EVT_KEY - this returns the one or two characters of the + * keystroke. If the key is an extended key, so that os_getc() would + * return a two-character sequence for the keystroke, the first + * character should be zero and the second the extended key code. + * Otherwise, the first character should simply be the ASCII key code. + * + * The key code here is the "raw" keycode, equivalent to the codes + * returned by os_getc_raw(). Note in particular that this means that + * CTRL and Escape keys are presented as one-byte ASCII control + * characters, not as two-byte CMD_xxx sequences. + * + * For multi-byte character sets (Shift-JIS, for example), note that + * os_get_event() must NOT return a complete two-byte character here. + * The two bytes here are exclusively used to represent special + * CMD_xxx keys (such as arrow keys and function keys). For a + * keystroke that is represented in a multi-byte character set using + * more than one byte, os_get_event() must return a series of events. + * Return an ordinary OS_EVT_KEY for the first byte of the sequence, + * putting the byte in key[0]; then, return the second byte as a + * separate OS_EVT_KEY as the next event; and so on for any additional + * bytes. This will allow callers that are not multibyte-aware to + * treat multi-byte characters as though they were sequences of + * one-byte characters. + */ + int key[2]; - /* - * OS_EVT_HREF - this returns the text of the HREF as a - * null-terminated string. - */ - char href[256]; + /* + * OS_EVT_HREF - this returns the text of the HREF as a + * null-terminated string. + */ + char href[256]; - /* command ID (for OS_EVT_COMMAND) */ - int cmd_id; + /* command ID (for OS_EVT_COMMAND) */ + int cmd_id; }; typedef union os_event_info_t os_event_info_t; @@ -2371,7 +2371,7 @@ typedef union os_event_info_t os_event_info_t; * should immediately return a timeout event. */ int os_get_event(unsigned long timeout_in_milliseconds, int use_timeout, - os_event_info_t *info); + os_event_info_t *info); /* ------------------------------------------------------------------------ */ @@ -2474,8 +2474,8 @@ int os_get_event(unsigned long timeout_in_milliseconds, int use_timeout, * an error occurs, return 0. */ int os_input_dialog(int icon_id, const char *prompt, int standard_button_set, - const char **buttons, int button_count, - int default_index, int cancel_index); + const char **buttons, int button_count, + int default_index, int cancel_index); /* * Standard button set ID's @@ -2544,7 +2544,7 @@ int os_paramfile(char *buf); * argc/argv values unchanged.) */ int os_init(int *argc, char *argv[], const char *prompt, - char *buf, int bufsiz); + char *buf, int bufsiz); /* * Termination functions. There are three main termination functions, @@ -2768,7 +2768,7 @@ const char *os_get_save_ext(); #ifndef os_xlat_html4 # ifndef OS_XLAT_HTML4_DEFINED void os_xlat_html4(unsigned int html4_char, - char *result, size_t result_buf_len); + char *result, size_t result_buf_len); # endif #endif diff --git a/engines/glk/tads/os_parse.cpp b/engines/glk/tads/os_parse.cpp index 267103aa76d..887c16f78ad 100644 --- a/engines/glk/tads/os_parse.cpp +++ b/engines/glk/tads/os_parse.cpp @@ -34,953 +34,953 @@ static uint os_charmap = OS_UTF8; uint is_cyrillic(unsigned char ch) { - if (ch >= 0xBC) - return 1; + if (ch >= 0xBC) + return 1; - switch (ch) - { - case 0x80: - case 0x81: - case 0x83: - case 0x8A: - case 0x8C: - case 0x8D: - case 0x8E: - case 0x8F: - case 0x90: - case 0x9A: - case 0x9C: - case 0x9D: - case 0x9E: - case 0x9F: - case 0xA1: - case 0xA2: - case 0xA3: - case 0xA5: - case 0xA8: - case 0xAA: - case 0xAF: - case 0xB2: - case 0xB3: - case 0xB4: - case 0xB8: - case 0xBA: - return 1; + switch (ch) + { + case 0x80: + case 0x81: + case 0x83: + case 0x8A: + case 0x8C: + case 0x8D: + case 0x8E: + case 0x8F: + case 0x90: + case 0x9A: + case 0x9C: + case 0x9D: + case 0x9E: + case 0x9F: + case 0xA1: + case 0xA2: + case 0xA3: + case 0xA5: + case 0xA8: + case 0xAA: + case 0xAF: + case 0xB2: + case 0xB3: + case 0xB4: + case 0xB8: + case 0xBA: + return 1; - default: - return 0; - } + default: + return 0; + } } uint is_macroman (unsigned char ch) { - switch (ch) - { - /* trademarks */ - case 0xA8: - case 0xAA: - return 1; + switch (ch) + { + /* trademarks */ + case 0xA8: + case 0xAA: + return 1; - /* dashes and right quotes */ - case 0xD0: - case 0xD1: - case 0xD3: - case 0xD5: - return 1; + /* dashes and right quotes */ + case 0xD0: + case 0xD1: + case 0xD3: + case 0xD5: + return 1; - /* accents */ - case 0x8E: - case 0x8F: - case 0x9A: - return 1; + /* accents */ + case 0x8E: + case 0x8F: + case 0x9A: + return 1; - default: - return 0; - } + default: + return 0; + } } uint is_cp1252 (unsigned char ch) { - switch (ch) - { - /* trademarks */ - case 0x99: - case 0xAE: - return 1; + switch (ch) + { + /* trademarks */ + case 0x99: + case 0xAE: + return 1; - /* dashes and right quotes */ - case 0x92: - case 0x94: - case 0x96: - case 0x97: - return 1; + /* dashes and right quotes */ + case 0x92: + case 0x94: + case 0x96: + case 0x97: + return 1; - /* accents */ - case 0xE8: - case 0xE9: - case 0xF6: - return 1; + /* accents */ + case 0xE8: + case 0xE9: + case 0xF6: + return 1; - default: - return 0; - } + default: + return 0; + } } uint identify_chars(const unsigned char *buf, uint buflen, uint32 *out, uint outlen) { - uint pos = 0; - uint val = 0; - uint count_macroman = 0; - uint count_cp1252 = 0; - uint wordlen = 0; - uint cyrilen = 0; - uint charmap = OS_UNKNOWN; + uint pos = 0; + uint val = 0; + uint count_macroman = 0; + uint count_cp1252 = 0; + uint wordlen = 0; + uint cyrilen = 0; + uint charmap = OS_UNKNOWN; - while (pos < buflen) - { - val = buf[pos++]; + while (pos < buflen) + { + val = buf[pos++]; - count_macroman += is_macroman(val); - count_cp1252 += is_cp1252(val); + count_macroman += is_macroman(val); + count_cp1252 += is_cp1252(val); - if (val != 0x20) - { - wordlen++; - cyrilen += is_cyrillic(val); - } - else - { - if (wordlen == cyrilen) - { - charmap = OS_CP1251; - break; - } - wordlen = 0; - cyrilen = 0; - } - } + if (val != 0x20) + { + wordlen++; + cyrilen += is_cyrillic(val); + } + else + { + if (wordlen == cyrilen) + { + charmap = OS_CP1251; + break; + } + wordlen = 0; + cyrilen = 0; + } + } - if (charmap == OS_CP1251) - os_charmap = OS_CP1251; - else if (count_cp1252 >= count_macroman) - os_charmap = OS_CP1252; - else - os_charmap = OS_MACROMAN; + if (charmap == OS_CP1251) + os_charmap = OS_CP1251; + else if (count_cp1252 >= count_macroman) + os_charmap = OS_CP1252; + else + os_charmap = OS_MACROMAN; - return os_parse_chars(buf, buflen, out, outlen); + return os_parse_chars(buf, buflen, out, outlen); } uint parse_utf8(const unsigned char *buf, uint buflen, uint32 *out, uint outlen) { - uint pos = 0; - uint outpos = 0; - uint res; - uint val0, val1, val2, val3; + uint pos = 0; + uint outpos = 0; + uint res; + uint val0, val1, val2, val3; - while (outpos < outlen) - { - if (pos >= buflen) - break; + while (outpos < outlen) + { + if (pos >= buflen) + break; - val0 = buf[pos++]; + val0 = buf[pos++]; - if (val0 < 0x80) - { - res = val0; - out[outpos++] = res; - continue; - } + if (val0 < 0x80) + { + res = val0; + out[outpos++] = res; + continue; + } - if ((val0 & 0xe0) == 0xc0) - { - if (pos+1 > buflen) - { - //printf("incomplete two-byte character\n"); - return identify_chars(buf, buflen, out, outlen); - } - val1 = buf[pos++]; - if ((val1 & 0xc0) != 0x80) - { - //printf("malformed two-byte character\n"); - return identify_chars(buf, buflen, out, outlen); - } - res = (val0 & 0x1f) << 6; - res |= (val1 & 0x3f); - out[outpos++] = res; - continue; - } + if ((val0 & 0xe0) == 0xc0) + { + if (pos+1 > buflen) + { + //printf("incomplete two-byte character\n"); + return identify_chars(buf, buflen, out, outlen); + } + val1 = buf[pos++]; + if ((val1 & 0xc0) != 0x80) + { + //printf("malformed two-byte character\n"); + return identify_chars(buf, buflen, out, outlen); + } + res = (val0 & 0x1f) << 6; + res |= (val1 & 0x3f); + out[outpos++] = res; + continue; + } - if ((val0 & 0xf0) == 0xe0) - { - if (pos+2 > buflen) - { - //printf("incomplete three-byte character\n"); - return identify_chars(buf, buflen, out, outlen); - } - val1 = buf[pos++]; - val2 = buf[pos++]; - if ((val1 & 0xc0) != 0x80) - { - //printf("malformed three-byte character\n"); - return identify_chars(buf, buflen, out, outlen); - } - if ((val2 & 0xc0) != 0x80) - { - //printf("malformed three-byte character\n"); - return identify_chars(buf, buflen, out, outlen); - } - res = (((val0 & 0xf)<<12) & 0x0000f000); - res |= (((val1 & 0x3f)<<6) & 0x00000fc0); - res |= (((val2 & 0x3f)) & 0x0000003f); - out[outpos++] = res; - continue; - } + if ((val0 & 0xf0) == 0xe0) + { + if (pos+2 > buflen) + { + //printf("incomplete three-byte character\n"); + return identify_chars(buf, buflen, out, outlen); + } + val1 = buf[pos++]; + val2 = buf[pos++]; + if ((val1 & 0xc0) != 0x80) + { + //printf("malformed three-byte character\n"); + return identify_chars(buf, buflen, out, outlen); + } + if ((val2 & 0xc0) != 0x80) + { + //printf("malformed three-byte character\n"); + return identify_chars(buf, buflen, out, outlen); + } + res = (((val0 & 0xf)<<12) & 0x0000f000); + res |= (((val1 & 0x3f)<<6) & 0x00000fc0); + res |= (((val2 & 0x3f)) & 0x0000003f); + out[outpos++] = res; + continue; + } - if ((val0 & 0xf0) == 0xf0) - { - if ((val0 & 0xf8) != 0xf0) - { - //printf("malformed four-byte character\n"); - return identify_chars(buf, buflen, out, outlen); - } - if (pos+3 > buflen) - { - //printf("incomplete four-byte character\n"); - return identify_chars(buf, buflen, out, outlen); - } - val1 = buf[pos++]; - val2 = buf[pos++]; - val3 = buf[pos++]; - if ((val1 & 0xc0) != 0x80) - { - //printf("malformed four-byte character\n"); - return identify_chars(buf, buflen, out, outlen); - } - if ((val2 & 0xc0) != 0x80) - { - //printf("malformed four-byte character\n"); - return identify_chars(buf, buflen, out, outlen); - } - if ((val3 & 0xc0) != 0x80) - { - //printf("malformed four-byte character\n"); - return identify_chars(buf, buflen, out, outlen); - } - res = (((val0 & 0x7)<<18) & 0x1c0000); - res |= (((val1 & 0x3f)<<12) & 0x03f000); - res |= (((val2 & 0x3f)<<6) & 0x000fc0); - res |= (((val3 & 0x3f)) & 0x00003f); - out[outpos++] = res; - continue; - } + if ((val0 & 0xf0) == 0xf0) + { + if ((val0 & 0xf8) != 0xf0) + { + //printf("malformed four-byte character\n"); + return identify_chars(buf, buflen, out, outlen); + } + if (pos+3 > buflen) + { + //printf("incomplete four-byte character\n"); + return identify_chars(buf, buflen, out, outlen); + } + val1 = buf[pos++]; + val2 = buf[pos++]; + val3 = buf[pos++]; + if ((val1 & 0xc0) != 0x80) + { + //printf("malformed four-byte character\n"); + return identify_chars(buf, buflen, out, outlen); + } + if ((val2 & 0xc0) != 0x80) + { + //printf("malformed four-byte character\n"); + return identify_chars(buf, buflen, out, outlen); + } + if ((val3 & 0xc0) != 0x80) + { + //printf("malformed four-byte character\n"); + return identify_chars(buf, buflen, out, outlen); + } + res = (((val0 & 0x7)<<18) & 0x1c0000); + res |= (((val1 & 0x3f)<<12) & 0x03f000); + res |= (((val2 & 0x3f)<<6) & 0x000fc0); + res |= (((val3 & 0x3f)) & 0x00003f); + out[outpos++] = res; + continue; + } - //printf("malformed character\n"); - return identify_chars(buf, buflen, out, outlen); - } + //printf("malformed character\n"); + return identify_chars(buf, buflen, out, outlen); + } - return outpos; + return outpos; } uint prepare_utf8(const uint32 *buf, uint buflen, unsigned char *out, uint outlen) { - uint i=0, k=0; + uint i=0, k=0; - /*convert UTF-32 to UTF-8 */ - while (i < buflen && k < outlen) - { - if ((buf[i] < 0x80)) - { - out[k] = buf[i]; - k++; - } - else if ((buf[i] < 0x800) && (k < outlen - 1)) - { - out[k ] = (0xC0 | ((buf[i] & 0x7C0) >> 6)); - out[k+1] = (0x80 | (buf[i] & 0x03F) ); - k = k + 2; - } - else if ((buf[i] < 0x10000) && (k < outlen - 2)) - { - out[k ] = (0xE0 | ((buf[i] & 0xF000) >> 12)); - out[k+1] = (0x80 | ((buf[i] & 0x0FC0) >> 6)); - out[k+2] = (0x80 | (buf[i] & 0x003F) ); - k = k + 3; - } - else if ((buf[i] < 0x200000) && (k < outlen - 3)) - { - out[k ] = (0xF0 | ((buf[i] & 0x1C0000) >> 18)); - out[k+1] = (0x80 | ((buf[i] & 0x03F000) >> 12)); - out[k+2] = (0x80 | ((buf[i] & 0x000FC0) >> 6)); - out[k+3] = (0x80 | (buf[i] & 0x00003F) ); - k = k + 4; - } - else - { - out[k] = '?'; - k++; - } - i++; - } + /*convert UTF-32 to UTF-8 */ + while (i < buflen && k < outlen) + { + if ((buf[i] < 0x80)) + { + out[k] = buf[i]; + k++; + } + else if ((buf[i] < 0x800) && (k < outlen - 1)) + { + out[k ] = (0xC0 | ((buf[i] & 0x7C0) >> 6)); + out[k+1] = (0x80 | (buf[i] & 0x03F) ); + k = k + 2; + } + else if ((buf[i] < 0x10000) && (k < outlen - 2)) + { + out[k ] = (0xE0 | ((buf[i] & 0xF000) >> 12)); + out[k+1] = (0x80 | ((buf[i] & 0x0FC0) >> 6)); + out[k+2] = (0x80 | (buf[i] & 0x003F) ); + k = k + 3; + } + else if ((buf[i] < 0x200000) && (k < outlen - 3)) + { + out[k ] = (0xF0 | ((buf[i] & 0x1C0000) >> 18)); + out[k+1] = (0x80 | ((buf[i] & 0x03F000) >> 12)); + out[k+2] = (0x80 | ((buf[i] & 0x000FC0) >> 6)); + out[k+3] = (0x80 | (buf[i] & 0x00003F) ); + k = k + 4; + } + else + { + out[k] = '?'; + k++; + } + i++; + } - return k; + return k; } /* http://unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1251.TXT */ static const uint CP1251ToUnicode[128] = { - 0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021, 0x20AC, 0x2030, - 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F, 0x0452, 0x2018, 0x2019, 0x201C, - 0x201D, 0x2022, 0x2013, 0x2014, 0x003F, 0x2122, 0x0459, 0x203A, 0x045A, 0x045C, - 0x045B, 0x045F, 0x00A0, 0x040E, 0x045E, 0x0408, 0x00A4, 0x0490, 0x00A6, 0x00A7, - 0x0401, 0x00A9, 0x0404, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x0407, 0x00B0, 0x00B1, - 0x0406, 0x0456, 0x0491, 0x00B5, 0x00B6, 0x00B7, 0x0451, 0x2116, 0x0454, 0x00BB, - 0x0458, 0x0405, 0x0455, 0x0457, 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, - 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, - 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, - 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, 0x0430, 0x0431, 0x0432, 0x0433, - 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, - 0x043E, 0x043F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, - 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F + 0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021, 0x20AC, 0x2030, + 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F, 0x0452, 0x2018, 0x2019, 0x201C, + 0x201D, 0x2022, 0x2013, 0x2014, 0x003F, 0x2122, 0x0459, 0x203A, 0x045A, 0x045C, + 0x045B, 0x045F, 0x00A0, 0x040E, 0x045E, 0x0408, 0x00A4, 0x0490, 0x00A6, 0x00A7, + 0x0401, 0x00A9, 0x0404, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x0407, 0x00B0, 0x00B1, + 0x0406, 0x0456, 0x0491, 0x00B5, 0x00B6, 0x00B7, 0x0451, 0x2116, 0x0454, 0x00BB, + 0x0458, 0x0405, 0x0455, 0x0457, 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, + 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, + 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, + 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, 0x0430, 0x0431, 0x0432, 0x0433, + 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, + 0x043E, 0x043F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, + 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F }; uint parse_cp1251(const unsigned char *buf, uint buflen, uint32 *out, uint outlen) { - uint pos = 0; - uint outpos = 0; - uint res; + uint pos = 0; + uint outpos = 0; + uint res; - while (outpos < outlen) - { - if (pos >= buflen) - break; + while (outpos < outlen) + { + if (pos >= buflen) + break; - res = buf[pos++]; + res = buf[pos++]; - if (res < 0x80) - out[outpos++] = res; - else - out[outpos++] = CP1251ToUnicode[res - 0x80]; - } + if (res < 0x80) + out[outpos++] = res; + else + out[outpos++] = CP1251ToUnicode[res - 0x80]; + } - return outpos; + return outpos; } static uint prepare_cp1251(const uint32 *buf, uint buflen, - unsigned char *out, uint outlen) + unsigned char *out, uint outlen) { - uint pos = 0; - uint outpos = 0; - uint res; + uint pos = 0; + uint outpos = 0; + uint res; - while (outpos < outlen) - { - if (pos >= buflen) - break; + while (outpos < outlen) + { + if (pos >= buflen) + break; - res = buf[pos++]; + res = buf[pos++]; - if (res < 0x80) - { - out[outpos++] = res; - continue; - } + if (res < 0x80) + { + out[outpos++] = res; + continue; + } - switch (res) - { - case 0x0402: out[outpos++] = 0x80; break; - case 0x0403: out[outpos++] = 0x81; break; - case 0x201A: out[outpos++] = 0x82; break; - case 0x0453: out[outpos++] = 0x83; break; - case 0x201E: out[outpos++] = 0x84; break; - case 0x2026: out[outpos++] = 0x85; break; - case 0x2020: out[outpos++] = 0x86; break; - case 0x2021: out[outpos++] = 0x87; break; - case 0x20AC: out[outpos++] = 0x88; break; - case 0x2030: out[outpos++] = 0x89; break; - case 0x0409: out[outpos++] = 0x8A; break; - case 0x2039: out[outpos++] = 0x8B; break; - case 0x040A: out[outpos++] = 0x8C; break; - case 0x040C: out[outpos++] = 0x8D; break; - case 0x040B: out[outpos++] = 0x8E; break; - case 0x040F: out[outpos++] = 0x8F; break; + switch (res) + { + case 0x0402: out[outpos++] = 0x80; break; + case 0x0403: out[outpos++] = 0x81; break; + case 0x201A: out[outpos++] = 0x82; break; + case 0x0453: out[outpos++] = 0x83; break; + case 0x201E: out[outpos++] = 0x84; break; + case 0x2026: out[outpos++] = 0x85; break; + case 0x2020: out[outpos++] = 0x86; break; + case 0x2021: out[outpos++] = 0x87; break; + case 0x20AC: out[outpos++] = 0x88; break; + case 0x2030: out[outpos++] = 0x89; break; + case 0x0409: out[outpos++] = 0x8A; break; + case 0x2039: out[outpos++] = 0x8B; break; + case 0x040A: out[outpos++] = 0x8C; break; + case 0x040C: out[outpos++] = 0x8D; break; + case 0x040B: out[outpos++] = 0x8E; break; + case 0x040F: out[outpos++] = 0x8F; break; - case 0x0452: out[outpos++] = 0x90; break; - case 0x2018: out[outpos++] = 0x91; break; - case 0x2019: out[outpos++] = 0x92; break; - case 0x201C: out[outpos++] = 0x93; break; - case 0x201D: out[outpos++] = 0x94; break; - case 0x2022: out[outpos++] = 0x95; break; - case 0x2013: out[outpos++] = 0x96; break; - case 0x2014: out[outpos++] = 0x97; break; - case 0x2122: out[outpos++] = 0x99; break; - case 0x0459: out[outpos++] = 0x9A; break; - case 0x203A: out[outpos++] = 0x9B; break; - case 0x045A: out[outpos++] = 0x9C; break; - case 0x045C: out[outpos++] = 0x9D; break; - case 0x045B: out[outpos++] = 0x9E; break; - case 0x045F: out[outpos++] = 0x9F; break; + case 0x0452: out[outpos++] = 0x90; break; + case 0x2018: out[outpos++] = 0x91; break; + case 0x2019: out[outpos++] = 0x92; break; + case 0x201C: out[outpos++] = 0x93; break; + case 0x201D: out[outpos++] = 0x94; break; + case 0x2022: out[outpos++] = 0x95; break; + case 0x2013: out[outpos++] = 0x96; break; + case 0x2014: out[outpos++] = 0x97; break; + case 0x2122: out[outpos++] = 0x99; break; + case 0x0459: out[outpos++] = 0x9A; break; + case 0x203A: out[outpos++] = 0x9B; break; + case 0x045A: out[outpos++] = 0x9C; break; + case 0x045C: out[outpos++] = 0x9D; break; + case 0x045B: out[outpos++] = 0x9E; break; + case 0x045F: out[outpos++] = 0x9F; break; - case 0x00A0: out[outpos++] = 0xA0; break; - case 0x040E: out[outpos++] = 0xA1; break; - case 0x045E: out[outpos++] = 0xA2; break; - case 0x0408: out[outpos++] = 0xA3; break; - case 0x00A4: out[outpos++] = 0xA4; break; - case 0x0490: out[outpos++] = 0xA5; break; - case 0x00A6: out[outpos++] = 0xA6; break; - case 0x00A7: out[outpos++] = 0xA7; break; - case 0x0401: out[outpos++] = 0xA8; break; - case 0x00A9: out[outpos++] = 0xA9; break; - case 0x0404: out[outpos++] = 0xAA; break; - case 0x00AB: out[outpos++] = 0xAB; break; - case 0x00AC: out[outpos++] = 0xAC; break; - case 0x00AD: out[outpos++] = 0xAD; break; - case 0x00AE: out[outpos++] = 0xAE; break; - case 0x0407: out[outpos++] = 0xAF; break; + case 0x00A0: out[outpos++] = 0xA0; break; + case 0x040E: out[outpos++] = 0xA1; break; + case 0x045E: out[outpos++] = 0xA2; break; + case 0x0408: out[outpos++] = 0xA3; break; + case 0x00A4: out[outpos++] = 0xA4; break; + case 0x0490: out[outpos++] = 0xA5; break; + case 0x00A6: out[outpos++] = 0xA6; break; + case 0x00A7: out[outpos++] = 0xA7; break; + case 0x0401: out[outpos++] = 0xA8; break; + case 0x00A9: out[outpos++] = 0xA9; break; + case 0x0404: out[outpos++] = 0xAA; break; + case 0x00AB: out[outpos++] = 0xAB; break; + case 0x00AC: out[outpos++] = 0xAC; break; + case 0x00AD: out[outpos++] = 0xAD; break; + case 0x00AE: out[outpos++] = 0xAE; break; + case 0x0407: out[outpos++] = 0xAF; break; - case 0x00B0: out[outpos++] = 0xB0; break; - case 0x00B1: out[outpos++] = 0xB1; break; - case 0x0406: out[outpos++] = 0xB2; break; - case 0x0456: out[outpos++] = 0xB3; break; - case 0x0491: out[outpos++] = 0xB4; break; - case 0x00B5: out[outpos++] = 0xB5; break; - case 0x00B6: out[outpos++] = 0xB6; break; - case 0x00B7: out[outpos++] = 0xB7; break; - case 0x0451: out[outpos++] = 0xB8; break; - case 0x2116: out[outpos++] = 0xB9; break; - case 0x0454: out[outpos++] = 0xBA; break; - case 0x00BB: out[outpos++] = 0xBB; break; - case 0x0458: out[outpos++] = 0xBC; break; - case 0x0405: out[outpos++] = 0xBD; break; - case 0x0455: out[outpos++] = 0xBE; break; - case 0x0457: out[outpos++] = 0xBF; break; + case 0x00B0: out[outpos++] = 0xB0; break; + case 0x00B1: out[outpos++] = 0xB1; break; + case 0x0406: out[outpos++] = 0xB2; break; + case 0x0456: out[outpos++] = 0xB3; break; + case 0x0491: out[outpos++] = 0xB4; break; + case 0x00B5: out[outpos++] = 0xB5; break; + case 0x00B6: out[outpos++] = 0xB6; break; + case 0x00B7: out[outpos++] = 0xB7; break; + case 0x0451: out[outpos++] = 0xB8; break; + case 0x2116: out[outpos++] = 0xB9; break; + case 0x0454: out[outpos++] = 0xBA; break; + case 0x00BB: out[outpos++] = 0xBB; break; + case 0x0458: out[outpos++] = 0xBC; break; + case 0x0405: out[outpos++] = 0xBD; break; + case 0x0455: out[outpos++] = 0xBE; break; + case 0x0457: out[outpos++] = 0xBF; break; - case 0x0410: out[outpos++] = 0xC0; break; - case 0x0411: out[outpos++] = 0xC1; break; - case 0x0412: out[outpos++] = 0xC2; break; - case 0x0413: out[outpos++] = 0xC3; break; - case 0x0414: out[outpos++] = 0xC4; break; - case 0x0415: out[outpos++] = 0xC5; break; - case 0x0416: out[outpos++] = 0xC6; break; - case 0x0417: out[outpos++] = 0xC7; break; - case 0x0418: out[outpos++] = 0xC8; break; - case 0x0419: out[outpos++] = 0xC9; break; - case 0x041A: out[outpos++] = 0xCA; break; - case 0x041B: out[outpos++] = 0xCB; break; - case 0x041C: out[outpos++] = 0xCC; break; - case 0x041D: out[outpos++] = 0xCD; break; - case 0x041E: out[outpos++] = 0xCE; break; - case 0x041F: out[outpos++] = 0xCF; break; + case 0x0410: out[outpos++] = 0xC0; break; + case 0x0411: out[outpos++] = 0xC1; break; + case 0x0412: out[outpos++] = 0xC2; break; + case 0x0413: out[outpos++] = 0xC3; break; + case 0x0414: out[outpos++] = 0xC4; break; + case 0x0415: out[outpos++] = 0xC5; break; + case 0x0416: out[outpos++] = 0xC6; break; + case 0x0417: out[outpos++] = 0xC7; break; + case 0x0418: out[outpos++] = 0xC8; break; + case 0x0419: out[outpos++] = 0xC9; break; + case 0x041A: out[outpos++] = 0xCA; break; + case 0x041B: out[outpos++] = 0xCB; break; + case 0x041C: out[outpos++] = 0xCC; break; + case 0x041D: out[outpos++] = 0xCD; break; + case 0x041E: out[outpos++] = 0xCE; break; + case 0x041F: out[outpos++] = 0xCF; break; - case 0x0420: out[outpos++] = 0xD0; break; - case 0x0421: out[outpos++] = 0xD1; break; - case 0x0422: out[outpos++] = 0xD2; break; - case 0x0423: out[outpos++] = 0xD3; break; - case 0x0424: out[outpos++] = 0xD4; break; - case 0x0425: out[outpos++] = 0xD5; break; - case 0x0426: out[outpos++] = 0xD6; break; - case 0x0427: out[outpos++] = 0xD7; break; - case 0x0428: out[outpos++] = 0xD8; break; - case 0x0429: out[outpos++] = 0xD9; break; - case 0x042A: out[outpos++] = 0xDA; break; - case 0x042B: out[outpos++] = 0xDB; break; - case 0x042C: out[outpos++] = 0xDC; break; - case 0x042D: out[outpos++] = 0xDD; break; - case 0x042E: out[outpos++] = 0xDE; break; - case 0x042F: out[outpos++] = 0xDF; break; + case 0x0420: out[outpos++] = 0xD0; break; + case 0x0421: out[outpos++] = 0xD1; break; + case 0x0422: out[outpos++] = 0xD2; break; + case 0x0423: out[outpos++] = 0xD3; break; + case 0x0424: out[outpos++] = 0xD4; break; + case 0x0425: out[outpos++] = 0xD5; break; + case 0x0426: out[outpos++] = 0xD6; break; + case 0x0427: out[outpos++] = 0xD7; break; + case 0x0428: out[outpos++] = 0xD8; break; + case 0x0429: out[outpos++] = 0xD9; break; + case 0x042A: out[outpos++] = 0xDA; break; + case 0x042B: out[outpos++] = 0xDB; break; + case 0x042C: out[outpos++] = 0xDC; break; + case 0x042D: out[outpos++] = 0xDD; break; + case 0x042E: out[outpos++] = 0xDE; break; + case 0x042F: out[outpos++] = 0xDF; break; - case 0x0430: out[outpos++] = 0xE0; break; - case 0x0431: out[outpos++] = 0xE1; break; - case 0x0432: out[outpos++] = 0xE2; break; - case 0x0433: out[outpos++] = 0xE3; break; - case 0x0434: out[outpos++] = 0xE4; break; - case 0x0435: out[outpos++] = 0xE5; break; - case 0x0436: out[outpos++] = 0xE6; break; - case 0x0437: out[outpos++] = 0xE7; break; - case 0x0438: out[outpos++] = 0xE8; break; - case 0x0439: out[outpos++] = 0xE9; break; - case 0x043A: out[outpos++] = 0xEA; break; - case 0x043B: out[outpos++] = 0xEB; break; - case 0x043C: out[outpos++] = 0xEC; break; - case 0x043D: out[outpos++] = 0xED; break; - case 0x043E: out[outpos++] = 0xEE; break; - case 0x043F: out[outpos++] = 0xEF; break; + case 0x0430: out[outpos++] = 0xE0; break; + case 0x0431: out[outpos++] = 0xE1; break; + case 0x0432: out[outpos++] = 0xE2; break; + case 0x0433: out[outpos++] = 0xE3; break; + case 0x0434: out[outpos++] = 0xE4; break; + case 0x0435: out[outpos++] = 0xE5; break; + case 0x0436: out[outpos++] = 0xE6; break; + case 0x0437: out[outpos++] = 0xE7; break; + case 0x0438: out[outpos++] = 0xE8; break; + case 0x0439: out[outpos++] = 0xE9; break; + case 0x043A: out[outpos++] = 0xEA; break; + case 0x043B: out[outpos++] = 0xEB; break; + case 0x043C: out[outpos++] = 0xEC; break; + case 0x043D: out[outpos++] = 0xED; break; + case 0x043E: out[outpos++] = 0xEE; break; + case 0x043F: out[outpos++] = 0xEF; break; - case 0x0440: out[outpos++] = 0xF0; break; - case 0x0441: out[outpos++] = 0xF1; break; - case 0x0442: out[outpos++] = 0xF2; break; - case 0x0443: out[outpos++] = 0xF3; break; - case 0x0444: out[outpos++] = 0xF4; break; - case 0x0445: out[outpos++] = 0xF5; break; - case 0x0446: out[outpos++] = 0xF6; break; - case 0x0447: out[outpos++] = 0xF7; break; - case 0x0448: out[outpos++] = 0xF8; break; - case 0x0449: out[outpos++] = 0xF9; break; - case 0x044A: out[outpos++] = 0xFA; break; - case 0x044B: out[outpos++] = 0xFB; break; - case 0x044C: out[outpos++] = 0xFC; break; - case 0x044D: out[outpos++] = 0xFD; break; - case 0x044E: out[outpos++] = 0xFE; break; - case 0x044F: out[outpos++] = 0xFF; break; + case 0x0440: out[outpos++] = 0xF0; break; + case 0x0441: out[outpos++] = 0xF1; break; + case 0x0442: out[outpos++] = 0xF2; break; + case 0x0443: out[outpos++] = 0xF3; break; + case 0x0444: out[outpos++] = 0xF4; break; + case 0x0445: out[outpos++] = 0xF5; break; + case 0x0446: out[outpos++] = 0xF6; break; + case 0x0447: out[outpos++] = 0xF7; break; + case 0x0448: out[outpos++] = 0xF8; break; + case 0x0449: out[outpos++] = 0xF9; break; + case 0x044A: out[outpos++] = 0xFA; break; + case 0x044B: out[outpos++] = 0xFB; break; + case 0x044C: out[outpos++] = 0xFC; break; + case 0x044D: out[outpos++] = 0xFD; break; + case 0x044E: out[outpos++] = 0xFE; break; + case 0x044F: out[outpos++] = 0xFF; break; - default: - /* undefined */ - out[outpos++] = '?'; - break; - } + default: + /* undefined */ + out[outpos++] = '?'; + break; + } - continue; - } + continue; + } - return outpos; + return outpos; } /* http://unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT */ static const uint CP1252ToUnicode[128] = { - 0x20AC, 0x003F, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x02C6, 0x2030, - 0x0160, 0x2039, 0x0152, 0x003F, 0x017D, 0x003F, 0x003F, 0x2018, 0x2019, 0x201C, - 0x201D, 0x2022, 0x2013, 0x2014, 0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x003F, - 0x017E, 0x0178, 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, - 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, 0x00B0, 0x00B1, - 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00BA, 0x00BB, - 0x00BC, 0x00BD, 0x00BE, 0x00BF, 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, - 0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, - 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, 0x00D8, 0x00D9, - 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, 0x00E0, 0x00E1, 0x00E2, 0x00E3, - 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, - 0x00EE, 0x00EF, 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, - 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF + 0x20AC, 0x003F, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x02C6, 0x2030, + 0x0160, 0x2039, 0x0152, 0x003F, 0x017D, 0x003F, 0x003F, 0x2018, 0x2019, 0x201C, + 0x201D, 0x2022, 0x2013, 0x2014, 0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x003F, + 0x017E, 0x0178, 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, + 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, 0x00B0, 0x00B1, + 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00BA, 0x00BB, + 0x00BC, 0x00BD, 0x00BE, 0x00BF, 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, + 0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, + 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, 0x00D8, 0x00D9, + 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, 0x00E0, 0x00E1, 0x00E2, 0x00E3, + 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, + 0x00EE, 0x00EF, 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, + 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF }; uint parse_cp1252(const unsigned char *buf, uint buflen, uint32 *out, uint outlen) { - uint pos = 0; - uint outpos = 0; - uint res; + uint pos = 0; + uint outpos = 0; + uint res; - while (outpos < outlen) - { - if (pos >= buflen) - break; + while (outpos < outlen) + { + if (pos >= buflen) + break; - res = buf[pos++]; + res = buf[pos++]; - if (res < 0x80) - out[outpos++] = res; - else - out[outpos++] = CP1252ToUnicode[res - 0x80]; - } + if (res < 0x80) + out[outpos++] = res; + else + out[outpos++] = CP1252ToUnicode[res - 0x80]; + } - return outpos; + return outpos; } static uint prepare_cp1252(const uint32 *buf, uint buflen, - unsigned char *out, uint outlen) + unsigned char *out, uint outlen) { - uint pos = 0; - uint outpos = 0; - uint res; + uint pos = 0; + uint outpos = 0; + uint res; - while (outpos < outlen) - { - if (pos >= buflen) - break; + while (outpos < outlen) + { + if (pos >= buflen) + break; - res = buf[pos++]; + res = buf[pos++]; - if (res < 0x80) - { - out[outpos++] = res; - continue; - } + if (res < 0x80) + { + out[outpos++] = res; + continue; + } - switch (res) - { - case 0x20AC: out[outpos++] = 0x80; break; - case 0x201A: out[outpos++] = 0x82; break; - case 0x0192: out[outpos++] = 0x83; break; - case 0x201E: out[outpos++] = 0x84; break; - case 0x2026: out[outpos++] = 0x85; break; - case 0x2020: out[outpos++] = 0x86; break; - case 0x2021: out[outpos++] = 0x87; break; - case 0x02C6: out[outpos++] = 0x88; break; - case 0x2030: out[outpos++] = 0x89; break; - case 0x0160: out[outpos++] = 0x8A; break; - case 0x2039: out[outpos++] = 0x8B; break; - case 0x0152: out[outpos++] = 0x8C; break; - case 0x017D: out[outpos++] = 0x8E; break; + switch (res) + { + case 0x20AC: out[outpos++] = 0x80; break; + case 0x201A: out[outpos++] = 0x82; break; + case 0x0192: out[outpos++] = 0x83; break; + case 0x201E: out[outpos++] = 0x84; break; + case 0x2026: out[outpos++] = 0x85; break; + case 0x2020: out[outpos++] = 0x86; break; + case 0x2021: out[outpos++] = 0x87; break; + case 0x02C6: out[outpos++] = 0x88; break; + case 0x2030: out[outpos++] = 0x89; break; + case 0x0160: out[outpos++] = 0x8A; break; + case 0x2039: out[outpos++] = 0x8B; break; + case 0x0152: out[outpos++] = 0x8C; break; + case 0x017D: out[outpos++] = 0x8E; break; - case 0x2018: out[outpos++] = 0x91; break; - case 0x2019: out[outpos++] = 0x92; break; - case 0x201C: out[outpos++] = 0x93; break; - case 0x201D: out[outpos++] = 0x94; break; - case 0x2022: out[outpos++] = 0x95; break; - case 0x2013: out[outpos++] = 0x96; break; - case 0x2014: out[outpos++] = 0x97; break; - case 0x02DC: out[outpos++] = 0x98; break; - case 0x2122: out[outpos++] = 0x99; break; - case 0x0161: out[outpos++] = 0x9A; break; - case 0x203A: out[outpos++] = 0x9B; break; - case 0x0153: out[outpos++] = 0x9C; break; - case 0x017E: out[outpos++] = 0x9E; break; - case 0x0178: out[outpos++] = 0x9F; break; + case 0x2018: out[outpos++] = 0x91; break; + case 0x2019: out[outpos++] = 0x92; break; + case 0x201C: out[outpos++] = 0x93; break; + case 0x201D: out[outpos++] = 0x94; break; + case 0x2022: out[outpos++] = 0x95; break; + case 0x2013: out[outpos++] = 0x96; break; + case 0x2014: out[outpos++] = 0x97; break; + case 0x02DC: out[outpos++] = 0x98; break; + case 0x2122: out[outpos++] = 0x99; break; + case 0x0161: out[outpos++] = 0x9A; break; + case 0x203A: out[outpos++] = 0x9B; break; + case 0x0153: out[outpos++] = 0x9C; break; + case 0x017E: out[outpos++] = 0x9E; break; + case 0x0178: out[outpos++] = 0x9F; break; - case 0x00A0: out[outpos++] = 0xA0; break; - case 0x00A1: out[outpos++] = 0xA1; break; - case 0x00A2: out[outpos++] = 0xA2; break; - case 0x00A3: out[outpos++] = 0xA3; break; - case 0x00A4: out[outpos++] = 0xA4; break; - case 0x00A5: out[outpos++] = 0xA5; break; - case 0x00A6: out[outpos++] = 0xA6; break; - case 0x00A7: out[outpos++] = 0xA7; break; - case 0x00A8: out[outpos++] = 0xA8; break; - case 0x00A9: out[outpos++] = 0xA9; break; - case 0x00AA: out[outpos++] = 0xAA; break; - case 0x00AB: out[outpos++] = 0xAB; break; - case 0x00AC: out[outpos++] = 0xAC; break; - case 0x00AD: out[outpos++] = 0xAD; break; - case 0x00AE: out[outpos++] = 0xAE; break; - case 0x00AF: out[outpos++] = 0xAF; break; + case 0x00A0: out[outpos++] = 0xA0; break; + case 0x00A1: out[outpos++] = 0xA1; break; + case 0x00A2: out[outpos++] = 0xA2; break; + case 0x00A3: out[outpos++] = 0xA3; break; + case 0x00A4: out[outpos++] = 0xA4; break; + case 0x00A5: out[outpos++] = 0xA5; break; + case 0x00A6: out[outpos++] = 0xA6; break; + case 0x00A7: out[outpos++] = 0xA7; break; + case 0x00A8: out[outpos++] = 0xA8; break; + case 0x00A9: out[outpos++] = 0xA9; break; + case 0x00AA: out[outpos++] = 0xAA; break; + case 0x00AB: out[outpos++] = 0xAB; break; + case 0x00AC: out[outpos++] = 0xAC; break; + case 0x00AD: out[outpos++] = 0xAD; break; + case 0x00AE: out[outpos++] = 0xAE; break; + case 0x00AF: out[outpos++] = 0xAF; break; - case 0x00B0: out[outpos++] = 0xB0; break; - case 0x00B1: out[outpos++] = 0xB1; break; - case 0x00B2: out[outpos++] = 0xB2; break; - case 0x00B3: out[outpos++] = 0xB3; break; - case 0x00B4: out[outpos++] = 0xB4; break; - case 0x00B5: out[outpos++] = 0xB5; break; - case 0x00B6: out[outpos++] = 0xB6; break; - case 0x00B7: out[outpos++] = 0xB7; break; - case 0x00B8: out[outpos++] = 0xB8; break; - case 0x00B9: out[outpos++] = 0xB9; break; - case 0x00BA: out[outpos++] = 0xBA; break; - case 0x00BB: out[outpos++] = 0xBB; break; - case 0x00BC: out[outpos++] = 0xBC; break; - case 0x00BD: out[outpos++] = 0xBD; break; - case 0x00BE: out[outpos++] = 0xBE; break; - case 0x00BF: out[outpos++] = 0xBF; break; + case 0x00B0: out[outpos++] = 0xB0; break; + case 0x00B1: out[outpos++] = 0xB1; break; + case 0x00B2: out[outpos++] = 0xB2; break; + case 0x00B3: out[outpos++] = 0xB3; break; + case 0x00B4: out[outpos++] = 0xB4; break; + case 0x00B5: out[outpos++] = 0xB5; break; + case 0x00B6: out[outpos++] = 0xB6; break; + case 0x00B7: out[outpos++] = 0xB7; break; + case 0x00B8: out[outpos++] = 0xB8; break; + case 0x00B9: out[outpos++] = 0xB9; break; + case 0x00BA: out[outpos++] = 0xBA; break; + case 0x00BB: out[outpos++] = 0xBB; break; + case 0x00BC: out[outpos++] = 0xBC; break; + case 0x00BD: out[outpos++] = 0xBD; break; + case 0x00BE: out[outpos++] = 0xBE; break; + case 0x00BF: out[outpos++] = 0xBF; break; - case 0x00C0: out[outpos++] = 0xC0; break; - case 0x00C1: out[outpos++] = 0xC1; break; - case 0x00C2: out[outpos++] = 0xC2; break; - case 0x00C3: out[outpos++] = 0xC3; break; - case 0x00C4: out[outpos++] = 0xC4; break; - case 0x00C5: out[outpos++] = 0xC5; break; - case 0x00C6: out[outpos++] = 0xC6; break; - case 0x00C7: out[outpos++] = 0xC7; break; - case 0x00C8: out[outpos++] = 0xC8; break; - case 0x00C9: out[outpos++] = 0xC9; break; - case 0x00CA: out[outpos++] = 0xCA; break; - case 0x00CB: out[outpos++] = 0xCB; break; - case 0x00CC: out[outpos++] = 0xCC; break; - case 0x00CD: out[outpos++] = 0xCD; break; - case 0x00CE: out[outpos++] = 0xCE; break; - case 0x00CF: out[outpos++] = 0xCF; break; + case 0x00C0: out[outpos++] = 0xC0; break; + case 0x00C1: out[outpos++] = 0xC1; break; + case 0x00C2: out[outpos++] = 0xC2; break; + case 0x00C3: out[outpos++] = 0xC3; break; + case 0x00C4: out[outpos++] = 0xC4; break; + case 0x00C5: out[outpos++] = 0xC5; break; + case 0x00C6: out[outpos++] = 0xC6; break; + case 0x00C7: out[outpos++] = 0xC7; break; + case 0x00C8: out[outpos++] = 0xC8; break; + case 0x00C9: out[outpos++] = 0xC9; break; + case 0x00CA: out[outpos++] = 0xCA; break; + case 0x00CB: out[outpos++] = 0xCB; break; + case 0x00CC: out[outpos++] = 0xCC; break; + case 0x00CD: out[outpos++] = 0xCD; break; + case 0x00CE: out[outpos++] = 0xCE; break; + case 0x00CF: out[outpos++] = 0xCF; break; - case 0x00D0: out[outpos++] = 0xD0; break; - case 0x00D1: out[outpos++] = 0xD1; break; - case 0x00D2: out[outpos++] = 0xD2; break; - case 0x00D3: out[outpos++] = 0xD3; break; - case 0x00D4: out[outpos++] = 0xD4; break; - case 0x00D5: out[outpos++] = 0xD5; break; - case 0x00D6: out[outpos++] = 0xD6; break; - case 0x00D7: out[outpos++] = 0xD7; break; - case 0x00D8: out[outpos++] = 0xD8; break; - case 0x00D9: out[outpos++] = 0xD9; break; - case 0x00DA: out[outpos++] = 0xDA; break; - case 0x00DB: out[outpos++] = 0xDB; break; - case 0x00DC: out[outpos++] = 0xDC; break; - case 0x00DD: out[outpos++] = 0xDD; break; - case 0x00DE: out[outpos++] = 0xDE; break; - case 0x00DF: out[outpos++] = 0xDF; break; + case 0x00D0: out[outpos++] = 0xD0; break; + case 0x00D1: out[outpos++] = 0xD1; break; + case 0x00D2: out[outpos++] = 0xD2; break; + case 0x00D3: out[outpos++] = 0xD3; break; + case 0x00D4: out[outpos++] = 0xD4; break; + case 0x00D5: out[outpos++] = 0xD5; break; + case 0x00D6: out[outpos++] = 0xD6; break; + case 0x00D7: out[outpos++] = 0xD7; break; + case 0x00D8: out[outpos++] = 0xD8; break; + case 0x00D9: out[outpos++] = 0xD9; break; + case 0x00DA: out[outpos++] = 0xDA; break; + case 0x00DB: out[outpos++] = 0xDB; break; + case 0x00DC: out[outpos++] = 0xDC; break; + case 0x00DD: out[outpos++] = 0xDD; break; + case 0x00DE: out[outpos++] = 0xDE; break; + case 0x00DF: out[outpos++] = 0xDF; break; - case 0x00E0: out[outpos++] = 0xE0; break; - case 0x00E1: out[outpos++] = 0xE1; break; - case 0x00E2: out[outpos++] = 0xE2; break; - case 0x00E3: out[outpos++] = 0xE3; break; - case 0x00E4: out[outpos++] = 0xE4; break; - case 0x00E5: out[outpos++] = 0xE5; break; - case 0x00E6: out[outpos++] = 0xE6; break; - case 0x00E7: out[outpos++] = 0xE7; break; - case 0x00E8: out[outpos++] = 0xE8; break; - case 0x00E9: out[outpos++] = 0xE9; break; - case 0x00EA: out[outpos++] = 0xEA; break; - case 0x00EB: out[outpos++] = 0xEB; break; - case 0x00EC: out[outpos++] = 0xEC; break; - case 0x00ED: out[outpos++] = 0xED; break; - case 0x00EE: out[outpos++] = 0xEE; break; - case 0x00EF: out[outpos++] = 0xEF; break; + case 0x00E0: out[outpos++] = 0xE0; break; + case 0x00E1: out[outpos++] = 0xE1; break; + case 0x00E2: out[outpos++] = 0xE2; break; + case 0x00E3: out[outpos++] = 0xE3; break; + case 0x00E4: out[outpos++] = 0xE4; break; + case 0x00E5: out[outpos++] = 0xE5; break; + case 0x00E6: out[outpos++] = 0xE6; break; + case 0x00E7: out[outpos++] = 0xE7; break; + case 0x00E8: out[outpos++] = 0xE8; break; + case 0x00E9: out[outpos++] = 0xE9; break; + case 0x00EA: out[outpos++] = 0xEA; break; + case 0x00EB: out[outpos++] = 0xEB; break; + case 0x00EC: out[outpos++] = 0xEC; break; + case 0x00ED: out[outpos++] = 0xED; break; + case 0x00EE: out[outpos++] = 0xEE; break; + case 0x00EF: out[outpos++] = 0xEF; break; - case 0x00F0: out[outpos++] = 0xF0; break; - case 0x00F1: out[outpos++] = 0xF1; break; - case 0x00F2: out[outpos++] = 0xF2; break; - case 0x00F3: out[outpos++] = 0xF3; break; - case 0x00F4: out[outpos++] = 0xF4; break; - case 0x00F5: out[outpos++] = 0xF5; break; - case 0x00F6: out[outpos++] = 0xF6; break; - case 0x00F7: out[outpos++] = 0xF7; break; - case 0x00F8: out[outpos++] = 0xF8; break; - case 0x00F9: out[outpos++] = 0xF9; break; - case 0x00FA: out[outpos++] = 0xFA; break; - case 0x00FB: out[outpos++] = 0xFB; break; - case 0x00FC: out[outpos++] = 0xFC; break; - case 0x00FD: out[outpos++] = 0xFD; break; - case 0x00FE: out[outpos++] = 0xFE; break; - case 0x00FF: out[outpos++] = 0xFF; break; + case 0x00F0: out[outpos++] = 0xF0; break; + case 0x00F1: out[outpos++] = 0xF1; break; + case 0x00F2: out[outpos++] = 0xF2; break; + case 0x00F3: out[outpos++] = 0xF3; break; + case 0x00F4: out[outpos++] = 0xF4; break; + case 0x00F5: out[outpos++] = 0xF5; break; + case 0x00F6: out[outpos++] = 0xF6; break; + case 0x00F7: out[outpos++] = 0xF7; break; + case 0x00F8: out[outpos++] = 0xF8; break; + case 0x00F9: out[outpos++] = 0xF9; break; + case 0x00FA: out[outpos++] = 0xFA; break; + case 0x00FB: out[outpos++] = 0xFB; break; + case 0x00FC: out[outpos++] = 0xFC; break; + case 0x00FD: out[outpos++] = 0xFD; break; + case 0x00FE: out[outpos++] = 0xFE; break; + case 0x00FF: out[outpos++] = 0xFF; break; - default: - /* undefined */ - out[outpos++] = '?'; - break; - } + default: + /* undefined */ + out[outpos++] = '?'; + break; + } - continue; - } + continue; + } - return outpos; + return outpos; } /* http://unicode.org/Public/MAPPINGS/VENDORS/APPLE/ROMAN.TXT */ static const uint MacRomanToUnicode[128] = { - 0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x00D1, 0x00D6, 0x00DC, 0x00E1, 0x00E0, 0x00E2, - 0x00E4, 0x00E3, 0x00E5, 0x00E7, 0x00E9, 0x00E8, 0x00EA, 0x00EB, 0x00ED, 0x00EC, - 0x00EE, 0x00EF, 0x00F1, 0x00F3, 0x00F2, 0x00F4, 0x00F6, 0x00F5, 0x00FA, 0x00F9, - 0x00FB, 0x00FC, 0x2020, 0x00B0, 0x00A2, 0x00A3, 0x00A7, 0x2022, 0x00B6, 0x00DF, - 0x00AE, 0x00A9, 0x2122, 0x00B4, 0x00A8, 0x2260, 0x00C6, 0x00D8, 0x221E, 0x00B1, - 0x2264, 0x2265, 0x00A5, 0x00B5, 0x2202, 0x2211, 0x220F, 0x03C0, 0x222B, 0x00AA, - 0x00BA, 0x03A9, 0x00E6, 0x00F8, 0x00BF, 0x00A1, 0x00AC, 0x221A, 0x0192, 0x2248, - 0x2206, 0x00AB, 0x00BB, 0x2026, 0x00A0, 0x00C0, 0x00C3, 0x00D5, 0x0152, 0x0153, - 0x2013, 0x2014, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x25CA, 0x00FF, 0x0178, - 0x2044, 0x20AC, 0x2039, 0x203A, 0xFB01, 0xFB02, 0x2021, 0x00B7, 0x201A, 0x201E, - 0x2030, 0x00C2, 0x00CA, 0x00C1, 0x00CB, 0x00C8, 0x00CD, 0x00CE, 0x00CF, 0x00CC, - 0x00D3, 0x00D4, 0xF8FF, 0x00D2, 0x00DA, 0x00DB, 0x00D9, 0x0131, 0x02C6, 0x02DC, - 0x00AF, 0x02D8, 0x02D9, 0x02DA, 0x00B8, 0x02DD, 0x02DB, 0x02C7 + 0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x00D1, 0x00D6, 0x00DC, 0x00E1, 0x00E0, 0x00E2, + 0x00E4, 0x00E3, 0x00E5, 0x00E7, 0x00E9, 0x00E8, 0x00EA, 0x00EB, 0x00ED, 0x00EC, + 0x00EE, 0x00EF, 0x00F1, 0x00F3, 0x00F2, 0x00F4, 0x00F6, 0x00F5, 0x00FA, 0x00F9, + 0x00FB, 0x00FC, 0x2020, 0x00B0, 0x00A2, 0x00A3, 0x00A7, 0x2022, 0x00B6, 0x00DF, + 0x00AE, 0x00A9, 0x2122, 0x00B4, 0x00A8, 0x2260, 0x00C6, 0x00D8, 0x221E, 0x00B1, + 0x2264, 0x2265, 0x00A5, 0x00B5, 0x2202, 0x2211, 0x220F, 0x03C0, 0x222B, 0x00AA, + 0x00BA, 0x03A9, 0x00E6, 0x00F8, 0x00BF, 0x00A1, 0x00AC, 0x221A, 0x0192, 0x2248, + 0x2206, 0x00AB, 0x00BB, 0x2026, 0x00A0, 0x00C0, 0x00C3, 0x00D5, 0x0152, 0x0153, + 0x2013, 0x2014, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x25CA, 0x00FF, 0x0178, + 0x2044, 0x20AC, 0x2039, 0x203A, 0xFB01, 0xFB02, 0x2021, 0x00B7, 0x201A, 0x201E, + 0x2030, 0x00C2, 0x00CA, 0x00C1, 0x00CB, 0x00C8, 0x00CD, 0x00CE, 0x00CF, 0x00CC, + 0x00D3, 0x00D4, 0xF8FF, 0x00D2, 0x00DA, 0x00DB, 0x00D9, 0x0131, 0x02C6, 0x02DC, + 0x00AF, 0x02D8, 0x02D9, 0x02DA, 0x00B8, 0x02DD, 0x02DB, 0x02C7 }; uint parse_mac(const unsigned char *buf, uint buflen, uint32 *out, uint outlen) { - uint pos = 0; - uint outpos = 0; - uint res; + uint pos = 0; + uint outpos = 0; + uint res; - while (outpos < outlen) - { - if (pos >= buflen) - break; + while (outpos < outlen) + { + if (pos >= buflen) + break; - res = buf[pos++]; + res = buf[pos++]; - if (res < 0x80) - out[outpos++] = res; - else - out[outpos++] = MacRomanToUnicode[res - 0x80]; - } + if (res < 0x80) + out[outpos++] = res; + else + out[outpos++] = MacRomanToUnicode[res - 0x80]; + } - return outpos; + return outpos; } static uint prepare_mac(const uint32 *buf, uint buflen, unsigned char *out, uint outlen) { - uint pos = 0; - uint outpos = 0; - uint res; + uint pos = 0; + uint outpos = 0; + uint res; - while (outpos < outlen) - { - if (pos >= buflen) - break; + while (outpos < outlen) + { + if (pos >= buflen) + break; - res = buf[pos++]; + res = buf[pos++]; - if (res < 0x80) - { - out[outpos++] = res; - continue; - } + if (res < 0x80) + { + out[outpos++] = res; + continue; + } - switch (res) - { - case 0x00C4: out[outpos++] = 0x80; break; - case 0x00C5: out[outpos++] = 0x81; break; - case 0x00C7: out[outpos++] = 0x82; break; - case 0x00C9: out[outpos++] = 0x83; break; - case 0x00D1: out[outpos++] = 0x84; break; - case 0x00D6: out[outpos++] = 0x85; break; - case 0x00DC: out[outpos++] = 0x86; break; - case 0x00E1: out[outpos++] = 0x87; break; - case 0x00E0: out[outpos++] = 0x88; break; - case 0x00E2: out[outpos++] = 0x89; break; - case 0x00E4: out[outpos++] = 0x8A; break; - case 0x00E3: out[outpos++] = 0x8B; break; - case 0x00E5: out[outpos++] = 0x8C; break; - case 0x00E7: out[outpos++] = 0x8D; break; - case 0x00E9: out[outpos++] = 0x8E; break; - case 0x00E8: out[outpos++] = 0x8F; break; + switch (res) + { + case 0x00C4: out[outpos++] = 0x80; break; + case 0x00C5: out[outpos++] = 0x81; break; + case 0x00C7: out[outpos++] = 0x82; break; + case 0x00C9: out[outpos++] = 0x83; break; + case 0x00D1: out[outpos++] = 0x84; break; + case 0x00D6: out[outpos++] = 0x85; break; + case 0x00DC: out[outpos++] = 0x86; break; + case 0x00E1: out[outpos++] = 0x87; break; + case 0x00E0: out[outpos++] = 0x88; break; + case 0x00E2: out[outpos++] = 0x89; break; + case 0x00E4: out[outpos++] = 0x8A; break; + case 0x00E3: out[outpos++] = 0x8B; break; + case 0x00E5: out[outpos++] = 0x8C; break; + case 0x00E7: out[outpos++] = 0x8D; break; + case 0x00E9: out[outpos++] = 0x8E; break; + case 0x00E8: out[outpos++] = 0x8F; break; - case 0x00EA: out[outpos++] = 0x90; break; - case 0x00EB: out[outpos++] = 0x91; break; - case 0x00ED: out[outpos++] = 0x92; break; - case 0x00EC: out[outpos++] = 0x93; break; - case 0x00EE: out[outpos++] = 0x94; break; - case 0x00EF: out[outpos++] = 0x95; break; - case 0x00F1: out[outpos++] = 0x96; break; - case 0x00F3: out[outpos++] = 0x97; break; - case 0x00F2: out[outpos++] = 0x98; break; - case 0x00F4: out[outpos++] = 0x99; break; - case 0x00F6: out[outpos++] = 0x9A; break; - case 0x00F5: out[outpos++] = 0x9B; break; - case 0x00FA: out[outpos++] = 0x9C; break; - case 0x00F9: out[outpos++] = 0x9D; break; - case 0x00FB: out[outpos++] = 0x9E; break; - case 0x00FC: out[outpos++] = 0x9F; break; + case 0x00EA: out[outpos++] = 0x90; break; + case 0x00EB: out[outpos++] = 0x91; break; + case 0x00ED: out[outpos++] = 0x92; break; + case 0x00EC: out[outpos++] = 0x93; break; + case 0x00EE: out[outpos++] = 0x94; break; + case 0x00EF: out[outpos++] = 0x95; break; + case 0x00F1: out[outpos++] = 0x96; break; + case 0x00F3: out[outpos++] = 0x97; break; + case 0x00F2: out[outpos++] = 0x98; break; + case 0x00F4: out[outpos++] = 0x99; break; + case 0x00F6: out[outpos++] = 0x9A; break; + case 0x00F5: out[outpos++] = 0x9B; break; + case 0x00FA: out[outpos++] = 0x9C; break; + case 0x00F9: out[outpos++] = 0x9D; break; + case 0x00FB: out[outpos++] = 0x9E; break; + case 0x00FC: out[outpos++] = 0x9F; break; - case 0x2020: out[outpos++] = 0xA0; break; - case 0x00B0: out[outpos++] = 0xA1; break; - case 0x00A2: out[outpos++] = 0xA2; break; - case 0x00A3: out[outpos++] = 0xA3; break; - case 0x00A7: out[outpos++] = 0xA4; break; - case 0x2022: out[outpos++] = 0xA5; break; - case 0x00B6: out[outpos++] = 0xA6; break; - case 0x00DF: out[outpos++] = 0xA7; break; - case 0x00AE: out[outpos++] = 0xA8; break; - case 0x00A9: out[outpos++] = 0xA9; break; - case 0x2122: out[outpos++] = 0xAA; break; - case 0x00B4: out[outpos++] = 0xAB; break; - case 0x00A8: out[outpos++] = 0xAC; break; - case 0x2260: out[outpos++] = 0xAD; break; - case 0x00C6: out[outpos++] = 0xAE; break; - case 0x00D8: out[outpos++] = 0xAF; break; + case 0x2020: out[outpos++] = 0xA0; break; + case 0x00B0: out[outpos++] = 0xA1; break; + case 0x00A2: out[outpos++] = 0xA2; break; + case 0x00A3: out[outpos++] = 0xA3; break; + case 0x00A7: out[outpos++] = 0xA4; break; + case 0x2022: out[outpos++] = 0xA5; break; + case 0x00B6: out[outpos++] = 0xA6; break; + case 0x00DF: out[outpos++] = 0xA7; break; + case 0x00AE: out[outpos++] = 0xA8; break; + case 0x00A9: out[outpos++] = 0xA9; break; + case 0x2122: out[outpos++] = 0xAA; break; + case 0x00B4: out[outpos++] = 0xAB; break; + case 0x00A8: out[outpos++] = 0xAC; break; + case 0x2260: out[outpos++] = 0xAD; break; + case 0x00C6: out[outpos++] = 0xAE; break; + case 0x00D8: out[outpos++] = 0xAF; break; - case 0x221E: out[outpos++] = 0xB0; break; - case 0x00B1: out[outpos++] = 0xB1; break; - case 0x2264: out[outpos++] = 0xB2; break; - case 0x2265: out[outpos++] = 0xB3; break; - case 0x00A5: out[outpos++] = 0xB4; break; - case 0x00B5: out[outpos++] = 0xB5; break; - case 0x2202: out[outpos++] = 0xB6; break; - case 0x2211: out[outpos++] = 0xB7; break; - case 0x220F: out[outpos++] = 0xB8; break; - case 0x03C0: out[outpos++] = 0xB9; break; - case 0x222B: out[outpos++] = 0xBA; break; - case 0x00AA: out[outpos++] = 0xBB; break; - case 0x00BA: out[outpos++] = 0xBC; break; - case 0x03A9: out[outpos++] = 0xBD; break; - case 0x00E6: out[outpos++] = 0xBE; break; - case 0x00F8: out[outpos++] = 0xBF; break; + case 0x221E: out[outpos++] = 0xB0; break; + case 0x00B1: out[outpos++] = 0xB1; break; + case 0x2264: out[outpos++] = 0xB2; break; + case 0x2265: out[outpos++] = 0xB3; break; + case 0x00A5: out[outpos++] = 0xB4; break; + case 0x00B5: out[outpos++] = 0xB5; break; + case 0x2202: out[outpos++] = 0xB6; break; + case 0x2211: out[outpos++] = 0xB7; break; + case 0x220F: out[outpos++] = 0xB8; break; + case 0x03C0: out[outpos++] = 0xB9; break; + case 0x222B: out[outpos++] = 0xBA; break; + case 0x00AA: out[outpos++] = 0xBB; break; + case 0x00BA: out[outpos++] = 0xBC; break; + case 0x03A9: out[outpos++] = 0xBD; break; + case 0x00E6: out[outpos++] = 0xBE; break; + case 0x00F8: out[outpos++] = 0xBF; break; - case 0x00BF: out[outpos++] = 0xC0; break; - case 0x00A1: out[outpos++] = 0xC1; break; - case 0x00AC: out[outpos++] = 0xC2; break; - case 0x221A: out[outpos++] = 0xC3; break; - case 0x0192: out[outpos++] = 0xC4; break; - case 0x2248: out[outpos++] = 0xC5; break; - case 0x2206: out[outpos++] = 0xC6; break; - case 0x00AB: out[outpos++] = 0xC7; break; - case 0x00BB: out[outpos++] = 0xC8; break; - case 0x2026: out[outpos++] = 0xC9; break; - case 0x00A0: out[outpos++] = 0xCA; break; - case 0x00C0: out[outpos++] = 0xCB; break; - case 0x00C3: out[outpos++] = 0xCC; break; - case 0x00D5: out[outpos++] = 0xCD; break; - case 0x0152: out[outpos++] = 0xCE; break; - case 0x0153: out[outpos++] = 0xCF; break; + case 0x00BF: out[outpos++] = 0xC0; break; + case 0x00A1: out[outpos++] = 0xC1; break; + case 0x00AC: out[outpos++] = 0xC2; break; + case 0x221A: out[outpos++] = 0xC3; break; + case 0x0192: out[outpos++] = 0xC4; break; + case 0x2248: out[outpos++] = 0xC5; break; + case 0x2206: out[outpos++] = 0xC6; break; + case 0x00AB: out[outpos++] = 0xC7; break; + case 0x00BB: out[outpos++] = 0xC8; break; + case 0x2026: out[outpos++] = 0xC9; break; + case 0x00A0: out[outpos++] = 0xCA; break; + case 0x00C0: out[outpos++] = 0xCB; break; + case 0x00C3: out[outpos++] = 0xCC; break; + case 0x00D5: out[outpos++] = 0xCD; break; + case 0x0152: out[outpos++] = 0xCE; break; + case 0x0153: out[outpos++] = 0xCF; break; - case 0x2013: out[outpos++] = 0xD0; break; - case 0x2014: out[outpos++] = 0xD1; break; - case 0x201C: out[outpos++] = 0xD2; break; - case 0x201D: out[outpos++] = 0xD3; break; - case 0x2018: out[outpos++] = 0xD4; break; - case 0x2019: out[outpos++] = 0xD5; break; - case 0x00F7: out[outpos++] = 0xD6; break; - case 0x25CA: out[outpos++] = 0xD7; break; - case 0x00FF: out[outpos++] = 0xD8; break; - case 0x0178: out[outpos++] = 0xD9; break; - case 0x2044: out[outpos++] = 0xDA; break; - case 0x20AC: out[outpos++] = 0xDB; break; - case 0x2039: out[outpos++] = 0xDC; break; - case 0x203A: out[outpos++] = 0xDD; break; - case 0xFB01: out[outpos++] = 0xDE; break; - case 0xFB02: out[outpos++] = 0xDF; break; + case 0x2013: out[outpos++] = 0xD0; break; + case 0x2014: out[outpos++] = 0xD1; break; + case 0x201C: out[outpos++] = 0xD2; break; + case 0x201D: out[outpos++] = 0xD3; break; + case 0x2018: out[outpos++] = 0xD4; break; + case 0x2019: out[outpos++] = 0xD5; break; + case 0x00F7: out[outpos++] = 0xD6; break; + case 0x25CA: out[outpos++] = 0xD7; break; + case 0x00FF: out[outpos++] = 0xD8; break; + case 0x0178: out[outpos++] = 0xD9; break; + case 0x2044: out[outpos++] = 0xDA; break; + case 0x20AC: out[outpos++] = 0xDB; break; + case 0x2039: out[outpos++] = 0xDC; break; + case 0x203A: out[outpos++] = 0xDD; break; + case 0xFB01: out[outpos++] = 0xDE; break; + case 0xFB02: out[outpos++] = 0xDF; break; - case 0x2021: out[outpos++] = 0xE0; break; - case 0x00B7: out[outpos++] = 0xE1; break; - case 0x201A: out[outpos++] = 0xE2; break; - case 0x201E: out[outpos++] = 0xE3; break; - case 0x2030: out[outpos++] = 0xE4; break; - case 0x00C2: out[outpos++] = 0xE5; break; - case 0x00CA: out[outpos++] = 0xE6; break; - case 0x00C1: out[outpos++] = 0xE7; break; - case 0x00CB: out[outpos++] = 0xE8; break; - case 0x00C8: out[outpos++] = 0xE9; break; - case 0x00CD: out[outpos++] = 0xEA; break; - case 0x00CE: out[outpos++] = 0xEB; break; - case 0x00CF: out[outpos++] = 0xEC; break; - case 0x00CC: out[outpos++] = 0xED; break; - case 0x00D3: out[outpos++] = 0xEE; break; - case 0x00D4: out[outpos++] = 0xEF; break; + case 0x2021: out[outpos++] = 0xE0; break; + case 0x00B7: out[outpos++] = 0xE1; break; + case 0x201A: out[outpos++] = 0xE2; break; + case 0x201E: out[outpos++] = 0xE3; break; + case 0x2030: out[outpos++] = 0xE4; break; + case 0x00C2: out[outpos++] = 0xE5; break; + case 0x00CA: out[outpos++] = 0xE6; break; + case 0x00C1: out[outpos++] = 0xE7; break; + case 0x00CB: out[outpos++] = 0xE8; break; + case 0x00C8: out[outpos++] = 0xE9; break; + case 0x00CD: out[outpos++] = 0xEA; break; + case 0x00CE: out[outpos++] = 0xEB; break; + case 0x00CF: out[outpos++] = 0xEC; break; + case 0x00CC: out[outpos++] = 0xED; break; + case 0x00D3: out[outpos++] = 0xEE; break; + case 0x00D4: out[outpos++] = 0xEF; break; - case 0xF8FF: out[outpos++] = 0xF0; break; - case 0x00D2: out[outpos++] = 0xF1; break; - case 0x00DA: out[outpos++] = 0xF2; break; - case 0x00DB: out[outpos++] = 0xF3; break; - case 0x00D9: out[outpos++] = 0xF4; break; - case 0x0131: out[outpos++] = 0xF5; break; - case 0x02C6: out[outpos++] = 0xF6; break; - case 0x02DC: out[outpos++] = 0xF7; break; - case 0x00AF: out[outpos++] = 0xF8; break; - case 0x02D8: out[outpos++] = 0xF9; break; - case 0x02D9: out[outpos++] = 0xFA; break; - case 0x02DA: out[outpos++] = 0xFB; break; - case 0x00B8: out[outpos++] = 0xFC; break; - case 0x02DD: out[outpos++] = 0xFD; break; - case 0x02DB: out[outpos++] = 0xFE; break; - case 0x02C7: out[outpos++] = 0xFF; break; + case 0xF8FF: out[outpos++] = 0xF0; break; + case 0x00D2: out[outpos++] = 0xF1; break; + case 0x00DA: out[outpos++] = 0xF2; break; + case 0x00DB: out[outpos++] = 0xF3; break; + case 0x00D9: out[outpos++] = 0xF4; break; + case 0x0131: out[outpos++] = 0xF5; break; + case 0x02C6: out[outpos++] = 0xF6; break; + case 0x02DC: out[outpos++] = 0xF7; break; + case 0x00AF: out[outpos++] = 0xF8; break; + case 0x02D8: out[outpos++] = 0xF9; break; + case 0x02D9: out[outpos++] = 0xFA; break; + case 0x02DA: out[outpos++] = 0xFB; break; + case 0x00B8: out[outpos++] = 0xFC; break; + case 0x02DD: out[outpos++] = 0xFD; break; + case 0x02DB: out[outpos++] = 0xFE; break; + case 0x02C7: out[outpos++] = 0xFF; break; - default: - /* undefined */ - out[outpos++] = '?'; - break; - } + default: + /* undefined */ + out[outpos++] = '?'; + break; + } - continue; - } + continue; + } - return outpos; + return outpos; } uint os_parse_chars(const unsigned char *buf, uint buflen, uint32 *out, uint outlen) { - switch (os_charmap) - { - case OS_UTF8: - return parse_utf8(buf, buflen, out, outlen); + switch (os_charmap) + { + case OS_UTF8: + return parse_utf8(buf, buflen, out, outlen); - case OS_CP1251: - return parse_cp1251(buf, buflen, out, outlen); + case OS_CP1251: + return parse_cp1251(buf, buflen, out, outlen); - case OS_CP1252: - return parse_cp1252(buf, buflen, out, outlen); + case OS_CP1252: + return parse_cp1252(buf, buflen, out, outlen); - case OS_MACROMAN: - return parse_mac(buf, buflen, out, outlen); + case OS_MACROMAN: + return parse_mac(buf, buflen, out, outlen); - default: - return 0; - } + default: + return 0; + } } uint os_prepare_chars(const uint32 *buf, uint buflen, unsigned char *out, uint outlen) { - switch (os_charmap) { - case OS_UTF8: - return prepare_utf8(buf, buflen, out, outlen); + switch (os_charmap) { + case OS_UTF8: + return prepare_utf8(buf, buflen, out, outlen); - case OS_CP1251: - return prepare_cp1251(buf, buflen, out, outlen); + case OS_CP1251: + return prepare_cp1251(buf, buflen, out, outlen); - case OS_CP1252: - return prepare_cp1252(buf, buflen, out, outlen); + case OS_CP1252: + return prepare_cp1252(buf, buflen, out, outlen); - case OS_MACROMAN: - return prepare_mac(buf, buflen, out, outlen); + case OS_MACROMAN: + return prepare_mac(buf, buflen, out, outlen); - default: - return 0; - } + default: + return 0; + } } #endif /* GLK_MODULE_UNICODE */ diff --git a/engines/glk/tads/tads2/appctx.h b/engines/glk/tads/tads2/appctx.h index 5f32217cc55..50f131a4a13 100644 --- a/engines/glk/tads/tads2/appctx.h +++ b/engines/glk/tads/tads2/appctx.h @@ -50,196 +50,196 @@ namespace TADS2 { * when the callback is invoked. */ struct appctxdef { - /** - * Get the .GAM file name. The run-time will call this only if it - * can't find a game file to load through some other means first. - * The run-time determines the game file first by looking at the - * command line, then by checking to see if a .GAM file is attached - * to the executable. If none of these checks yields a game, the - * run-time will call this routine to see if the host system wants - * to provide a game. This routine can be implemented on a GUI - * system, for example, to display a dialog prompting the user to - * select a game file to open. A trivial implementation of this - * routine (that merely returns false) is okay. - * - * This routine should return true (any non-zero value) if it - * provides the name of a file to open, false (zero) if not. - */ - int (*get_game_name)(void *appctxdat, char *buf, size_t buflen); - void *get_game_name_ctx; + /** + * Get the .GAM file name. The run-time will call this only if it + * can't find a game file to load through some other means first. + * The run-time determines the game file first by looking at the + * command line, then by checking to see if a .GAM file is attached + * to the executable. If none of these checks yields a game, the + * run-time will call this routine to see if the host system wants + * to provide a game. This routine can be implemented on a GUI + * system, for example, to display a dialog prompting the user to + * select a game file to open. A trivial implementation of this + * routine (that merely returns false) is okay. + * + * This routine should return true (any non-zero value) if it + * provides the name of a file to open, false (zero) if not. + */ + int (*get_game_name)(void *appctxdat, char *buf, size_t buflen); + void *get_game_name_ctx; - /** - * Set the .GAM file name. When the run-time determines the name of - * the file it will use to read the game, it calls this routine. - * The host system should note the game filename if it will need to - * access the game file itself (for example, to load resources). - */ - void (*set_game_name)(void *appctxdat, const char *fname); - void *set_game_name_ctx; + /** + * Set the .GAM file name. When the run-time determines the name of + * the file it will use to read the game, it calls this routine. + * The host system should note the game filename if it will need to + * access the game file itself (for example, to load resources). + */ + void (*set_game_name)(void *appctxdat, const char *fname); + void *set_game_name_ctx; - /** - * Set the root path for individual resources. By default, we use the - * directory containing the game file, but this can be used to override - * that. - */ - void (*set_res_dir)(void *appctxdat, const char *fname); - void *set_res_dir_ctx; + /** + * Set the root path for individual resources. By default, we use the + * directory containing the game file, but this can be used to override + * that. + */ + void (*set_res_dir)(void *appctxdat, const char *fname); + void *set_res_dir_ctx; - /** - * Set the resource map address in the game file. If the .GAM - * reader encounters a resource map in the file, it calls this - * routine with the seek offset of the first resource. Each - * resource's address is given as an offset from this point. - * - * fileno is the file number assigned by the host system in - * add_resfile. File number zero is always the .GAM file. - */ - void (*set_resmap_seek)(void *appctxdat, unsigned long seekpos, int fileno); - void *set_resmap_seek_ctx; + /** + * Set the resource map address in the game file. If the .GAM + * reader encounters a resource map in the file, it calls this + * routine with the seek offset of the first resource. Each + * resource's address is given as an offset from this point. + * + * fileno is the file number assigned by the host system in + * add_resfile. File number zero is always the .GAM file. + */ + void (*set_resmap_seek)(void *appctxdat, unsigned long seekpos, int fileno); + void *set_resmap_seek_ctx; - /** - * Add a resource entry. The 'ofs' entry is the byte offset of the - * start of the resource, relative to the seek position previously - * set with set_resmap_seek. 'siz' is the size of the resource in - * bytes; the resource is stored as contiguous bytes starting at the - * given offset for the given size. Note that resources may be - * added before the resource map seek position is set, so the host - * system must simply store the resource information for later use. - * The 'fileno' is zero for the .GAM file, or the number assigned by - * the host system in add_resfile for other resource files. - */ - void (*add_resource)(void *appctxdat, unsigned long ofs, - unsigned long siz, const char *nm, size_t nmlen, - int fileno); - void *add_resource_ctx; + /** + * Add a resource entry. The 'ofs' entry is the byte offset of the + * start of the resource, relative to the seek position previously + * set with set_resmap_seek. 'siz' is the size of the resource in + * bytes; the resource is stored as contiguous bytes starting at the + * given offset for the given size. Note that resources may be + * added before the resource map seek position is set, so the host + * system must simply store the resource information for later use. + * The 'fileno' is zero for the .GAM file, or the number assigned by + * the host system in add_resfile for other resource files. + */ + void (*add_resource)(void *appctxdat, unsigned long ofs, + unsigned long siz, const char *nm, size_t nmlen, + int fileno); + void *add_resource_ctx; - /** - * Add a resource link entry. 'fname' and 'fnamelen' give the name of - * a local file containing the resource data; 'resname' and - * 'resnamelen' give the name of the resource as it appears within the - * compiled game file. This creates a link from a .GAM resource name - * to a local filename, where the actual binary resource data reside, - * so that we can retrieve a resource by .GAM resource name without - * actually copying the data into the .GAM file. This is used mostly - * for debugging purposes: it allows the compiler to skip the step of - * copying the resource data into the .GAM file, but still allows the - * game to load resources by .GAM resource name, to create a testing - * environment that's consistent with the full build version (where the - * resources would actually be copied). - */ - void (*add_resource_link)(void *appctxdat, - const char *fname, size_t fnamelen, - const char *resname, size_t resnamelen); - void *add_resource_link_ctx; + /** + * Add a resource link entry. 'fname' and 'fnamelen' give the name of + * a local file containing the resource data; 'resname' and + * 'resnamelen' give the name of the resource as it appears within the + * compiled game file. This creates a link from a .GAM resource name + * to a local filename, where the actual binary resource data reside, + * so that we can retrieve a resource by .GAM resource name without + * actually copying the data into the .GAM file. This is used mostly + * for debugging purposes: it allows the compiler to skip the step of + * copying the resource data into the .GAM file, but still allows the + * game to load resources by .GAM resource name, to create a testing + * environment that's consistent with the full build version (where the + * resources would actually be copied). + */ + void (*add_resource_link)(void *appctxdat, + const char *fname, size_t fnamelen, + const char *resname, size_t resnamelen); + void *add_resource_link_ctx; - /** - * Add a resource path. 'path' is a string giving a directory prefix - * in local system notation. - * - * This adds a directory to the list of directories that we'll search - * when we're looking for an individual resource as an external file - * (such as a ".jpg" image file or ".ogg" sound file). This can be - * called zero or more times; each call adds another directory to - * search after any previous directories. We'll always search the - * default directory first (this is the directory containing the game - * file); then we'll search directories added with this call in the - * order in which the directories were added. - */ - void (*add_res_path)(void *appctxdat, const char *path, size_t len); - void *add_res_path_ctx; + /** + * Add a resource path. 'path' is a string giving a directory prefix + * in local system notation. + * + * This adds a directory to the list of directories that we'll search + * when we're looking for an individual resource as an external file + * (such as a ".jpg" image file or ".ogg" sound file). This can be + * called zero or more times; each call adds another directory to + * search after any previous directories. We'll always search the + * default directory first (this is the directory containing the game + * file); then we'll search directories added with this call in the + * order in which the directories were added. + */ + void (*add_res_path)(void *appctxdat, const char *path, size_t len); + void *add_res_path_ctx; - /** - * Find a resource entry. If the resource can be found, this must - * return an osfildef* handle to the resource, with its seek position - * set to the first byte of the resource data, and set *res_size to - * the size in bytes of the resource data in the file. If the - * resource cannot be found, returns null. - */ - osfildef *(*find_resource)(void *appctxdat, - const char *resname, size_t resnamelen, - unsigned long *res_size); - void *find_resource_ctx; + /** + * Find a resource entry. If the resource can be found, this must + * return an osfildef* handle to the resource, with its seek position + * set to the first byte of the resource data, and set *res_size to + * the size in bytes of the resource data in the file. If the + * resource cannot be found, returns null. + */ + osfildef *(*find_resource)(void *appctxdat, + const char *resname, size_t resnamelen, + unsigned long *res_size); + void *find_resource_ctx; - /** - * Add a resource file. The return value is a non-zero file number - * assigned by the host system; we'll use this number in subsequent - * calls to add_resource to add the resources from this file. - * - * After calling this routine to add the file, we'll parse the file - * and add any resources using add_resource. - */ - int (*add_resfile)(void *appctxdat, const char *fname); - void *add_resfile_ctx; + /** + * Add a resource file. The return value is a non-zero file number + * assigned by the host system; we'll use this number in subsequent + * calls to add_resource to add the resources from this file. + * + * After calling this routine to add the file, we'll parse the file + * and add any resources using add_resource. + */ + int (*add_resfile)(void *appctxdat, const char *fname); + void *add_resfile_ctx; - /** - * Determine if a resource exists. Returns true if the resource can - * be loaded, false if not. The resource name is in the standard - * URL-style format. - */ - int (*resfile_exists)(void *appctxdat, const char *res_name, - size_t res_name_len); - void *resfile_exists_ctx; + /** + * Determine if a resource exists. Returns true if the resource can + * be loaded, false if not. The resource name is in the standard + * URL-style format. + */ + int (*resfile_exists)(void *appctxdat, const char *res_name, + size_t res_name_len); + void *resfile_exists_ctx; - /** - * Resource file path. If we should look for resource files in a - * different location than the .GAM file, the host system can set - * this to a path that we should use to look for resource files. If - * it's null, we'll look in the directory that contains the .GAM - * file. Note that if the path is provided, it must be set up with - * a trailing path separator character, so that we can directly - * append a name to this path to form a valid fully-qualified - * filename. - */ - const char *ext_res_path; + /** + * Resource file path. If we should look for resource files in a + * different location than the .GAM file, the host system can set + * this to a path that we should use to look for resource files. If + * it's null, we'll look in the directory that contains the .GAM + * file. Note that if the path is provided, it must be set up with + * a trailing path separator character, so that we can directly + * append a name to this path to form a valid fully-qualified + * filename. + */ + const char *ext_res_path; - /** - * File safety level get/set. During initialization, we'll call the - * host system to tell it the file safety level selected by the user on - * the command line; if the host system is saving preference - * information, it should temporarily override its saved preferences - * and use the command line setting (and it may, if appropriate, want - * to save the command line setting as the saved preference setting, - * depending on how it handles preferences). During execution, any - * time the game tries to open a file (using the fopen built-in - * function), we'll call the host system to ask it for the current - * setting, and use this new setting rather than the original command - * line setting. - * - * Refer to bif.c for information on the meanings of the file safety - * levels. - */ - void (*set_io_safety_level)(void *ctx, int read, int write); - void (*get_io_safety_level)(void *ctx, int *read, int *write); - void *io_safety_level_ctx; + /** + * File safety level get/set. During initialization, we'll call the + * host system to tell it the file safety level selected by the user on + * the command line; if the host system is saving preference + * information, it should temporarily override its saved preferences + * and use the command line setting (and it may, if appropriate, want + * to save the command line setting as the saved preference setting, + * depending on how it handles preferences). During execution, any + * time the game tries to open a file (using the fopen built-in + * function), we'll call the host system to ask it for the current + * setting, and use this new setting rather than the original command + * line setting. + * + * Refer to bif.c for information on the meanings of the file safety + * levels. + */ + void (*set_io_safety_level)(void *ctx, int read, int write); + void (*get_io_safety_level)(void *ctx, int *read, int *write); + void *io_safety_level_ctx; - /** - * Network safety level get/set. This is analogous to the file safety - * level scheme, but controls access to network resources. There are - * two components to the network safety setting: client and server. - * The client component controls the game's ability to open network - * connections to access information on remote machines, such as - * opening http connections to access web sites. The server component - * controls the game's ability to create servers of its own and accept - * incoming connections. Each component can be set to one of the - * following: - * - *. 0 = no restrictions (least "safety"): all network access granted - *. 1 = 'localhost' access only - *. 2 = no network access - * - * This only applies to the TADS 3 VM. TADS 2 doesn't support any - * network features, so this doesn't apply. - */ - void (*set_net_safety_level)(void *ctx, int client_level, int srv_level); - void (*get_net_safety_level)(void *ctx, int *client_level, int *srv_level); - void *net_safety_level_ctx; + /** + * Network safety level get/set. This is analogous to the file safety + * level scheme, but controls access to network resources. There are + * two components to the network safety setting: client and server. + * The client component controls the game's ability to open network + * connections to access information on remote machines, such as + * opening http connections to access web sites. The server component + * controls the game's ability to create servers of its own and accept + * incoming connections. Each component can be set to one of the + * following: + * + *. 0 = no restrictions (least "safety"): all network access granted + *. 1 = 'localhost' access only + *. 2 = no network access + * + * This only applies to the TADS 3 VM. TADS 2 doesn't support any + * network features, so this doesn't apply. + */ + void (*set_net_safety_level)(void *ctx, int client_level, int srv_level); + void (*get_net_safety_level)(void *ctx, int *client_level, int *srv_level); + void *net_safety_level_ctx; - /** - * Name of run-time application for usage messages. If this is - * null, the default run-time application name will be used for - * usage messages. - */ - const char *usage_app_name; + /** + * Name of run-time application for usage messages. If this is + * null, the default run-time application name will be used for + * usage messages. + */ + const char *usage_app_name; }; } // End of namespace TADS2 diff --git a/engines/glk/tads/tads2/built_in.cpp b/engines/glk/tads/tads2/built_in.cpp index 4cc6e155ede..afb6703cd63 100644 --- a/engines/glk/tads/tads2/built_in.cpp +++ b/engines/glk/tads/tads2/built_in.cpp @@ -40,863 +40,863 @@ namespace TADS2 { /* yorn - yes or no */ void bifyon(bifcxdef *ctx, int argc) { - char rsp[128]; - char *p; - runsdef val; - char yesbuf[64]; - char nobuf[64]; - re_context rectx; - int match_yes; - int match_no; + char rsp[128]; + char *p; + runsdef val; + char yesbuf[64]; + char nobuf[64]; + re_context rectx; + int match_yes; + int match_no; - bifcntargs(ctx, 0, argc); /* check for proper argument count */ + bifcntargs(ctx, 0, argc); /* check for proper argument count */ - /* load the "yes" and "no" reply patterns */ - if (os_get_str_rsc(RESID_YORN_YES, yesbuf, sizeof(yesbuf))) - strcpy(yesbuf, "[Yy].*"); - if (os_get_str_rsc(RESID_YORN_NO, nobuf, sizeof(nobuf))) - strcpy(nobuf, "[Nn].*"); - - /* if we're in HTML mode, switch to input font */ - if (tio_is_html_mode()) - tioputs(ctx->bifcxtio, ""); + /* load the "yes" and "no" reply patterns */ + if (os_get_str_rsc(RESID_YORN_YES, yesbuf, sizeof(yesbuf))) + strcpy(yesbuf, "[Yy].*"); + if (os_get_str_rsc(RESID_YORN_NO, nobuf, sizeof(nobuf))) + strcpy(nobuf, "[Nn].*"); + + /* if we're in HTML mode, switch to input font */ + if (tio_is_html_mode()) + tioputs(ctx->bifcxtio, ""); - /* ensure the prompt is displayed */ - tioflushn(ctx->bifcxtio, 0); + /* ensure the prompt is displayed */ + tioflushn(ctx->bifcxtio, 0); - /* reset count of lines since the last keyboard input */ - tioreset(ctx->bifcxtio); + /* reset count of lines since the last keyboard input */ + tioreset(ctx->bifcxtio); - /* read a line of text */ - if (tiogets(ctx->bifcxtio, (char *)0, rsp, (int)sizeof(rsp))) - runsig(ctx->bifcxrun, ERR_RUNQUIT); + /* read a line of text */ + if (tiogets(ctx->bifcxtio, (char *)0, rsp, (int)sizeof(rsp))) + runsig(ctx->bifcxrun, ERR_RUNQUIT); - /* if we're in HTML mode, close the input font tag */ - if (tio_is_html_mode()) - tioputs(ctx->bifcxtio, ""); + /* if we're in HTML mode, close the input font tag */ + if (tio_is_html_mode()) + tioputs(ctx->bifcxtio, ""); - /* scan off leading spaces */ - for (p = rsp ; t_isspace(*p) ; ++p) ; + /* scan off leading spaces */ + for (p = rsp ; t_isspace(*p) ; ++p) ; - /* set up our regex context */ - re_init(&rectx, ctx->bifcxerr); + /* set up our regex context */ + re_init(&rectx, ctx->bifcxerr); - /* check for a "yes" response */ - match_yes = re_compile_and_match(&rectx, yesbuf, strlen(yesbuf), - p, strlen(p)); + /* check for a "yes" response */ + match_yes = re_compile_and_match(&rectx, yesbuf, strlen(yesbuf), + p, strlen(p)); - /* check for a "no" response */ - match_no = re_compile_and_match(&rectx, nobuf, strlen(nobuf), - p, strlen(p)); + /* check for a "no" response */ + match_no = re_compile_and_match(&rectx, nobuf, strlen(nobuf), + p, strlen(p)); - /* check the result */ - if (match_yes == (int)strlen(p)) - val.runsv.runsvnum = 1; - else if (match_no == (int)strlen(p)) - val.runsv.runsvnum = 0; - else - val.runsv.runsvnum = -1; + /* check the result */ + if (match_yes == (int)strlen(p)) + val.runsv.runsvnum = 1; + else if (match_no == (int)strlen(p)) + val.runsv.runsvnum = 0; + else + val.runsv.runsvnum = -1; - /* delete our regex context */ - re_delete(&rectx); + /* delete our regex context */ + re_delete(&rectx); - /* push the result */ - runpush(ctx->bifcxrun, DAT_NUMBER, &val); + /* push the result */ + runpush(ctx->bifcxrun, DAT_NUMBER, &val); } /* setfuse */ void bifsfs(bifcxdef *ctx, int argc) { - objnum func; - uint tm; - runsdef val; - voccxdef *voc = ctx->bifcxrun->runcxvoc; - - bifcntargs(ctx, 3, argc); /* check for proper argument count */ - func = runpopfn(ctx->bifcxrun); - tm = runpopnum(ctx->bifcxrun); - runpop(ctx->bifcxrun, &val); - - /* limitation: don't allow string or list for value */ - if (val.runstyp == DAT_LIST || val.runstyp == DAT_SSTRING) - runsig(ctx->bifcxrun, ERR_FUSEVAL); - - vocsetfd(voc, voc->voccxfus, func, (prpnum)0, - tm, &val, ERR_MANYFUS); + objnum func; + uint tm; + runsdef val; + voccxdef *voc = ctx->bifcxrun->runcxvoc; + + bifcntargs(ctx, 3, argc); /* check for proper argument count */ + func = runpopfn(ctx->bifcxrun); + tm = runpopnum(ctx->bifcxrun); + runpop(ctx->bifcxrun, &val); + + /* limitation: don't allow string or list for value */ + if (val.runstyp == DAT_LIST || val.runstyp == DAT_SSTRING) + runsig(ctx->bifcxrun, ERR_FUSEVAL); + + vocsetfd(voc, voc->voccxfus, func, (prpnum)0, + tm, &val, ERR_MANYFUS); } /* remfuse */ void bifrfs(bifcxdef *ctx, int argc) { - objnum func; - runsdef val; - voccxdef *voc = ctx->bifcxrun->runcxvoc; - - bifcntargs(ctx, 2, argc); - func = runpopfn(ctx->bifcxrun); - runpop(ctx->bifcxrun, &val); - vocremfd(voc, voc->voccxfus, func, (prpnum)0, - &val, ERR_NOFUSE); + objnum func; + runsdef val; + voccxdef *voc = ctx->bifcxrun->runcxvoc; + + bifcntargs(ctx, 2, argc); + func = runpopfn(ctx->bifcxrun); + runpop(ctx->bifcxrun, &val); + vocremfd(voc, voc->voccxfus, func, (prpnum)0, + &val, ERR_NOFUSE); } /* setdaemon */ void bifsdm(bifcxdef *ctx, int argc) { - objnum func; - runsdef val; - voccxdef *voc = ctx->bifcxrun->runcxvoc; - - bifcntargs(ctx, 2, argc); /* check for proper argument count */ - func = runpopfn(ctx->bifcxrun); - runpop(ctx->bifcxrun, &val); - - /* limitation: don't allow string or list for value */ - if (val.runstyp == DAT_LIST || val.runstyp == DAT_SSTRING) - runsig(ctx->bifcxrun, ERR_FUSEVAL); - - vocsetfd(voc, voc->voccxdmn, func, (prpnum)0, 0, - &val, ERR_MANYDMN); + objnum func; + runsdef val; + voccxdef *voc = ctx->bifcxrun->runcxvoc; + + bifcntargs(ctx, 2, argc); /* check for proper argument count */ + func = runpopfn(ctx->bifcxrun); + runpop(ctx->bifcxrun, &val); + + /* limitation: don't allow string or list for value */ + if (val.runstyp == DAT_LIST || val.runstyp == DAT_SSTRING) + runsig(ctx->bifcxrun, ERR_FUSEVAL); + + vocsetfd(voc, voc->voccxdmn, func, (prpnum)0, 0, + &val, ERR_MANYDMN); } /* remdaemon */ void bifrdm(bifcxdef *ctx, int argc) { - objnum func; - runsdef val; - voccxdef *voc = ctx->bifcxrun->runcxvoc; - - bifcntargs(ctx, 2, argc); - func = runpopfn(ctx->bifcxrun); - runpop(ctx->bifcxrun, &val); - vocremfd(voc, voc->voccxdmn, func, (prpnum)0, - &val, ERR_NODMN); + objnum func; + runsdef val; + voccxdef *voc = ctx->bifcxrun->runcxvoc; + + bifcntargs(ctx, 2, argc); + func = runpopfn(ctx->bifcxrun); + runpop(ctx->bifcxrun, &val); + vocremfd(voc, voc->voccxdmn, func, (prpnum)0, + &val, ERR_NODMN); } /* incturn */ void bifinc(bifcxdef *ctx, int argc) { - int turncnt; - - if (argc == 1) - { - /* get the number of turns to skip */ - turncnt = runpopnum(ctx->bifcxrun); - if (turncnt < 1) - runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "incturn"); - } - else - { - /* no arguments -> increment by one turn */ - bifcntargs(ctx, 0, argc); - turncnt = 1; - } + int turncnt; + + if (argc == 1) + { + /* get the number of turns to skip */ + turncnt = runpopnum(ctx->bifcxrun); + if (turncnt < 1) + runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "incturn"); + } + else + { + /* no arguments -> increment by one turn */ + bifcntargs(ctx, 0, argc); + turncnt = 1; + } - /* skip the given number of turns */ - vocturn(ctx->bifcxrun->runcxvoc, turncnt, TRUE); + /* skip the given number of turns */ + vocturn(ctx->bifcxrun->runcxvoc, turncnt, TRUE); } /* skipturn */ void bifskt(bifcxdef *ctx, int argc) { - int turncnt; + int turncnt; - bifcntargs(ctx, 1, argc); - turncnt = runpopnum(ctx->bifcxrun); - if (turncnt < 1) - runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "skipturn"); - vocturn(ctx->bifcxrun->runcxvoc, turncnt, FALSE); + bifcntargs(ctx, 1, argc); + turncnt = runpopnum(ctx->bifcxrun); + if (turncnt < 1) + runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "skipturn"); + vocturn(ctx->bifcxrun->runcxvoc, turncnt, FALSE); } /* quit */ void bifqui(bifcxdef *ctx, int argc) { - /* check for proper argument count */ - bifcntargs(ctx, 0, argc); + /* check for proper argument count */ + bifcntargs(ctx, 0, argc); - /* flush output buffer, and signal the end of the game */ - tioflush(ctx->bifcxtio); - errsig(ctx->bifcxerr, ERR_RUNQUIT); + /* flush output buffer, and signal the end of the game */ + tioflush(ctx->bifcxtio); + errsig(ctx->bifcxerr, ERR_RUNQUIT); } /* internal function to convert a TADS string into a C-string */ static void bifcstr(bifcxdef *ctx, char *buf, size_t bufsiz, uchar *str) { - size_t srcrem; - size_t dstrem; - uchar *src; - char *dst; + size_t srcrem; + size_t dstrem; + uchar *src; + char *dst; - /* get the length and text portion of the string */ - srcrem = osrp2(str) - 2; - str += 2; + /* get the length and text portion of the string */ + srcrem = osrp2(str) - 2; + str += 2; - /* scan the string, and convert escapes */ - for (src = str, dst = buf, dstrem = bufsiz ; - srcrem != 0 && dstrem != 0 ; ++src, --srcrem) - { - /* if we have an escape sequence, convert it */ - if (*src == '\\') - { - /* skip the backslash in the input */ - ++src; - --srcrem; + /* scan the string, and convert escapes */ + for (src = str, dst = buf, dstrem = bufsiz ; + srcrem != 0 && dstrem != 0 ; ++src, --srcrem) + { + /* if we have an escape sequence, convert it */ + if (*src == '\\') + { + /* skip the backslash in the input */ + ++src; + --srcrem; - /* if there's nothing left, store the backslash */ - if (srcrem == 0) - { - /* store the backslash */ - *dst++ = '\\'; - --dstrem; + /* if there's nothing left, store the backslash */ + if (srcrem == 0) + { + /* store the backslash */ + *dst++ = '\\'; + --dstrem; - /* there's nothing left to scan */ - break; - } + /* there's nothing left to scan */ + break; + } - /* see what the second half of the escape sequence is */ - switch(*src) - { - case 'n': - /* store a C-style newline character */ - *dst++ = '\n'; - --dstrem; - break; + /* see what the second half of the escape sequence is */ + switch(*src) + { + case 'n': + /* store a C-style newline character */ + *dst++ = '\n'; + --dstrem; + break; - case 't': - /* store a C-style tab */ - *dst++ = '\t'; - --dstrem; - break; + case 't': + /* store a C-style tab */ + *dst++ = '\t'; + --dstrem; + break; - case '(': - case ')': - /* entirely omit the highlighting sequences */ - break; + case '(': + case ')': + /* entirely omit the highlighting sequences */ + break; - default: - /* store everything else unchanged */ - *dst++ = *src; - --dstrem; - break; - } - } - else - { - /* copy this character unchanged */ - *dst++ = *src; - --dstrem; - } - } + default: + /* store everything else unchanged */ + *dst++ = *src; + --dstrem; + break; + } + } + else + { + /* copy this character unchanged */ + *dst++ = *src; + --dstrem; + } + } - /* if the buffer wasn't big enough, signal an error */ - if (dstrem == 0) - runsig(ctx->bifcxrun, ERR_BIFCSTR); + /* if the buffer wasn't big enough, signal an error */ + if (dstrem == 0) + runsig(ctx->bifcxrun, ERR_BIFCSTR); - /* null-terminate the result string */ - *dst = '\0'; + /* null-terminate the result string */ + *dst = '\0'; } /* save */ void bifsav(bifcxdef *ctx, int argc) { - uchar *fn; - char buf[OSFNMAX]; - int err; - runsdef val; - - bifcntargs(ctx, 1, argc); - fn = runpopstr(ctx->bifcxrun); - bifcstr(ctx, buf, (size_t)sizeof(buf), fn); - os_defext(buf, ctx->bifcxsavext != 0 ? ctx->bifcxsavext : "sav"); - err = fiosav(ctx->bifcxrun->runcxvoc, buf, ctx->bifcxrun->runcxgamename); - runpush(ctx->bifcxrun, runclog(err), &val); + uchar *fn; + char buf[OSFNMAX]; + int err; + runsdef val; + + bifcntargs(ctx, 1, argc); + fn = runpopstr(ctx->bifcxrun); + bifcstr(ctx, buf, (size_t)sizeof(buf), fn); + os_defext(buf, ctx->bifcxsavext != 0 ? ctx->bifcxsavext : "sav"); + err = fiosav(ctx->bifcxrun->runcxvoc, buf, ctx->bifcxrun->runcxgamename); + runpush(ctx->bifcxrun, runclog(err), &val); } /* restore */ void bifrso(bifcxdef *ctx, int argc) { - uchar *fn; - char buf[OSFNMAX]; - int err; - voccxdef *vctx = ctx->bifcxrun->runcxvoc; - - bifcntargs(ctx, 1, argc); - - /* check for special restore(nil) - restore game given as parameter */ - if (runtostyp(ctx->bifcxrun) == DAT_NIL) - { - /* get filename from startup parameter, if any */ - if (!os_paramfile(buf)) - { - /* no startup parameter */ - runpnum(ctx->bifcxrun, FIORSO_NO_PARAM_FILE); - return; - } - } - else - { - /* get string parameter - it's the filename */ - fn = runpopstr(ctx->bifcxrun); - bifcstr(ctx, buf, (size_t)sizeof(buf), fn); - os_defext(buf, ctx->bifcxsavext != 0 ? ctx->bifcxsavext : "sav"); - } + uchar *fn; + char buf[OSFNMAX]; + int err; + voccxdef *vctx = ctx->bifcxrun->runcxvoc; + + bifcntargs(ctx, 1, argc); + + /* check for special restore(nil) - restore game given as parameter */ + if (runtostyp(ctx->bifcxrun) == DAT_NIL) + { + /* get filename from startup parameter, if any */ + if (!os_paramfile(buf)) + { + /* no startup parameter */ + runpnum(ctx->bifcxrun, FIORSO_NO_PARAM_FILE); + return; + } + } + else + { + /* get string parameter - it's the filename */ + fn = runpopstr(ctx->bifcxrun); + bifcstr(ctx, buf, (size_t)sizeof(buf), fn); + os_defext(buf, ctx->bifcxsavext != 0 ? ctx->bifcxsavext : "sav"); + } - /* try restoring the file */ - err = fiorso(vctx, buf); + /* try restoring the file */ + err = fiorso(vctx, buf); - /* blow away all undo records */ - objulose(vctx->voccxundo); + /* blow away all undo records */ + objulose(vctx->voccxundo); - /* return the result code from fiorso */ - runpnum(ctx->bifcxrun, err); + /* return the result code from fiorso */ + runpnum(ctx->bifcxrun, err); - /* note that the rest of the command line is to be ignored */ - vctx->voccxflg |= VOCCXFCLEAR; + /* note that the rest of the command line is to be ignored */ + vctx->voccxflg |= VOCCXFCLEAR; } /* logging */ void biflog(bifcxdef *ctx, int argc) { - char buf[OSFNMAX]; - uchar *str; - - bifcntargs(ctx, 1, argc); - if (runtostyp(ctx->bifcxrun) == DAT_NIL) - { - rundisc(ctx->bifcxrun); - tiologcls(ctx->bifcxtio); - } - else - { - str = runpopstr(ctx->bifcxrun); - bifcstr(ctx, buf, (size_t)sizeof(buf), str); - tiologopn(ctx->bifcxtio, buf); - } + char buf[OSFNMAX]; + uchar *str; + + bifcntargs(ctx, 1, argc); + if (runtostyp(ctx->bifcxrun) == DAT_NIL) + { + rundisc(ctx->bifcxrun); + tiologcls(ctx->bifcxtio); + } + else + { + str = runpopstr(ctx->bifcxrun); + bifcstr(ctx, buf, (size_t)sizeof(buf), str); + tiologopn(ctx->bifcxtio, buf); + } } /* restart */ void bifres(bifcxdef *ctx, int argc) { - voccxdef *vctx = ctx->bifcxrun->runcxvoc; - objnum fn; + voccxdef *vctx = ctx->bifcxrun->runcxvoc; + objnum fn; - if (argc == 2) - fn = runpopfn(ctx->bifcxrun); /* get function if present */ - else - { - bifcntargs(ctx, 0, argc); /* check for proper argument count */ - fn = MCMONINV; /* no function was specified */ - } + if (argc == 2) + fn = runpopfn(ctx->bifcxrun); /* get function if present */ + else + { + bifcntargs(ctx, 0, argc); /* check for proper argument count */ + fn = MCMONINV; /* no function was specified */ + } - objulose(vctx->voccxundo); /* blow away all undo records */ - vocrevert(vctx); /* revert all objects to original state */ - vocdmnclr(vctx); /* clear out fuses/deamons/notifiers */ + objulose(vctx->voccxundo); /* blow away all undo records */ + vocrevert(vctx); /* revert all objects to original state */ + vocdmnclr(vctx); /* clear out fuses/deamons/notifiers */ - /* restore the original "Me" object */ - vctx->voccxme = vctx->voccxme_init; + /* restore the original "Me" object */ + vctx->voccxme = vctx->voccxme_init; - /* call preinit if necessary (call it before invoking the user callback) */ - if (vctx->voccxpreinit != MCMONINV) - runfn(ctx->bifcxrun, vctx->voccxpreinit, 0); + /* call preinit if necessary (call it before invoking the user callback) */ + if (vctx->voccxpreinit != MCMONINV) + runfn(ctx->bifcxrun, vctx->voccxpreinit, 0); - /* - * If a restart function was provided, call it. Note that we left - * the argument for the function on the stack, so there's no need to - * re-push it! - */ - if (fn != MCMONINV) runfn(ctx->bifcxrun, fn, 1); + /* + * If a restart function was provided, call it. Note that we left + * the argument for the function on the stack, so there's no need to + * re-push it! + */ + if (fn != MCMONINV) runfn(ctx->bifcxrun, fn, 1); - /* restart the game */ - errsig(ctx->bifcxerr, ERR_RUNRESTART); + /* restart the game */ + errsig(ctx->bifcxerr, ERR_RUNRESTART); } /* input - get a line of input from the keyboard */ void bifinp(bifcxdef *ctx, int argc) { - char inbuf[128]; + char inbuf[128]; - /* check for proper argument count */ - bifcntargs(ctx, 0, argc); + /* check for proper argument count */ + bifcntargs(ctx, 0, argc); - /* make sure the prompt is displayed */ - tioflushn(ctx->bifcxtio, 0); + /* make sure the prompt is displayed */ + tioflushn(ctx->bifcxtio, 0); - /* reset count of lines since the last keyboard input */ - tioreset(ctx->bifcxtio); + /* reset count of lines since the last keyboard input */ + tioreset(ctx->bifcxtio); - /* read a line of text */ - if (tiogets(ctx->bifcxtio, (char *)0, inbuf, (int)sizeof(inbuf))) - runsig(ctx->bifcxrun, ERR_RUNQUIT); + /* read a line of text */ + if (tiogets(ctx->bifcxtio, (char *)0, inbuf, (int)sizeof(inbuf))) + runsig(ctx->bifcxrun, ERR_RUNQUIT); - /* push the string, converting escapes */ - runpushcstr(ctx->bifcxrun, inbuf, strlen(inbuf), 0); + /* push the string, converting escapes */ + runpushcstr(ctx->bifcxrun, inbuf, strlen(inbuf), 0); } /* notify */ void bifnfy(bifcxdef *ctx, int argc) { - objnum objn; - prpnum prp; - uint tm; - voccxdef *voc = ctx->bifcxrun->runcxvoc; - - bifcntargs(ctx, 3, argc); /* check for proper argument count */ - objn = runpopobj(ctx->bifcxrun); - prp = runpopprp(ctx->bifcxrun); - tm = runpopnum(ctx->bifcxrun); + objnum objn; + prpnum prp; + uint tm; + voccxdef *voc = ctx->bifcxrun->runcxvoc; + + bifcntargs(ctx, 3, argc); /* check for proper argument count */ + objn = runpopobj(ctx->bifcxrun); + prp = runpopprp(ctx->bifcxrun); + tm = runpopnum(ctx->bifcxrun); - /* a time of zero means every turn */ - if (tm == 0) - tm = VOCDTIM_EACH_TURN; - - vocsetfd(voc, voc->voccxalm, objn, prp, tm, - (runsdef *)0, ERR_MANYNFY); + /* a time of zero means every turn */ + if (tm == 0) + tm = VOCDTIM_EACH_TURN; + + vocsetfd(voc, voc->voccxalm, objn, prp, tm, + (runsdef *)0, ERR_MANYNFY); } /* unnotify */ void bifunn(bifcxdef *ctx, int argc) { - objnum objn; - prpnum prop; - voccxdef *voc = ctx->bifcxrun->runcxvoc; - - bifcntargs(ctx, 2, argc); - objn = runpopobj(ctx->bifcxrun); - prop = runpopprp(ctx->bifcxrun); - vocremfd(voc, voc->voccxalm, objn, prop, - (runsdef *)0, ERR_NONFY); + objnum objn; + prpnum prop; + voccxdef *voc = ctx->bifcxrun->runcxvoc; + + bifcntargs(ctx, 2, argc); + objn = runpopobj(ctx->bifcxrun); + prop = runpopprp(ctx->bifcxrun); + vocremfd(voc, voc->voccxalm, objn, prop, + (runsdef *)0, ERR_NONFY); } /* trace on/off */ void biftrc(bifcxdef *ctx, int argc) { - runsdef val; - int n; - int flag; + runsdef val; + int n; + int flag; - if (argc == 2) - { - /* get the type indicator and the on/off status */ - n = runpopnum(ctx->bifcxrun); - flag = runpoplog(ctx->bifcxrun); + if (argc == 2) + { + /* get the type indicator and the on/off status */ + n = runpopnum(ctx->bifcxrun); + flag = runpoplog(ctx->bifcxrun); - /* see what type of debugging they want to turn on or off */ - switch(n) - { - case 1: - /* turn on parser tracing */ - if (flag) - ctx->bifcxrun->runcxvoc->voccxflg |= VOCCXFDBG; - else - ctx->bifcxrun->runcxvoc->voccxflg &= ~VOCCXFDBG; - break; + /* see what type of debugging they want to turn on or off */ + switch(n) + { + case 1: + /* turn on parser tracing */ + if (flag) + ctx->bifcxrun->runcxvoc->voccxflg |= VOCCXFDBG; + else + ctx->bifcxrun->runcxvoc->voccxflg &= ~VOCCXFDBG; + break; - default: - /* ignore other requests */ - runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "debugTrace"); - } - } - else - { - /* break into debugger; return whether debugger is present */ - bifcntargs(ctx, 0, argc); - runpush(ctx->bifcxrun, runclog(dbgstart(ctx->bifcxrun->runcxdbg)), - &val); - } + default: + /* ignore other requests */ + runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "debugTrace"); + } + } + else + { + /* break into debugger; return whether debugger is present */ + bifcntargs(ctx, 0, argc); + runpush(ctx->bifcxrun, runclog(dbgstart(ctx->bifcxrun->runcxdbg)), + &val); + } } /* say */ void bifsay(bifcxdef *ctx, int argc) { - uchar *str; - long num; - char numbuf[30]; + uchar *str; + long num; + char numbuf[30]; - if (argc != 2) bifcntargs(ctx, 1, argc); - - switch(runtostyp(ctx->bifcxrun)) - { - case DAT_NUMBER: - num = runpopnum(ctx->bifcxrun); - sprintf(numbuf, "%ld", num); - tioputs(ctx->bifcxtio, numbuf); - break; - - case DAT_SSTRING: - str = runpopstr(ctx->bifcxrun); - outfmt(ctx->bifcxtio, str); - break; - - case DAT_NIL: - (void)runpoplog(ctx->bifcxrun); - break; - - default: - runsig1(ctx->bifcxrun, ERR_INVTBIF, ERRTSTR, "say"); - } + if (argc != 2) bifcntargs(ctx, 1, argc); + + switch(runtostyp(ctx->bifcxrun)) + { + case DAT_NUMBER: + num = runpopnum(ctx->bifcxrun); + sprintf(numbuf, "%ld", num); + tioputs(ctx->bifcxtio, numbuf); + break; + + case DAT_SSTRING: + str = runpopstr(ctx->bifcxrun); + outfmt(ctx->bifcxtio, str); + break; + + case DAT_NIL: + (void)runpoplog(ctx->bifcxrun); + break; + + default: + runsig1(ctx->bifcxrun, ERR_INVTBIF, ERRTSTR, "say"); + } } /* car */ void bifcar(bifcxdef *ctx, int argc) { - uchar *lstp; - uint lstsiz; - runsdef val; - - bifcntargs(ctx, 1, argc); - bifchkarg(ctx, DAT_LIST); - - lstp = runpoplst(ctx->bifcxrun); - - /* get list's size, and point to its data string */ - lstsiz = osrp2(lstp) - 2; - lstp += 2; - - /* push first element if one is present, otherwise push nil */ - if (lstsiz) - runpbuf(ctx->bifcxrun, *lstp, lstp+1); - else - runpush(ctx->bifcxrun, DAT_NIL, &val); + uchar *lstp; + uint lstsiz; + runsdef val; + + bifcntargs(ctx, 1, argc); + bifchkarg(ctx, DAT_LIST); + + lstp = runpoplst(ctx->bifcxrun); + + /* get list's size, and point to its data string */ + lstsiz = osrp2(lstp) - 2; + lstp += 2; + + /* push first element if one is present, otherwise push nil */ + if (lstsiz) + runpbuf(ctx->bifcxrun, *lstp, lstp+1); + else + runpush(ctx->bifcxrun, DAT_NIL, &val); } /* cdr */ void bifcdr(bifcxdef *ctx, int argc) { - uchar *lstp; - uint siz; - uint lstsiz; - runsdef val; - runsdef stkval; - - bifcntargs(ctx, 1, argc); - bifchkarg(ctx, DAT_LIST); - - lstp = runpoplst(ctx->bifcxrun); - stkval.runstyp = DAT_LIST; - stkval.runsv.runsvstr = lstp; - - /* get list's size, and point to its data string */ - lstsiz = osrp2(lstp) - 2; - lstp += 2; - - if (lstsiz != 0) - { - /* deduct size of first element from size of list */ - siz = datsiz(*lstp, lstp+1) + 1; - lstsiz -= siz; + uchar *lstp; + uint siz; + uint lstsiz; + runsdef val; + runsdef stkval; + + bifcntargs(ctx, 1, argc); + bifchkarg(ctx, DAT_LIST); + + lstp = runpoplst(ctx->bifcxrun); + stkval.runstyp = DAT_LIST; + stkval.runsv.runsvstr = lstp; + + /* get list's size, and point to its data string */ + lstsiz = osrp2(lstp) - 2; + lstp += 2; + + if (lstsiz != 0) + { + /* deduct size of first element from size of list */ + siz = datsiz(*lstp, lstp+1) + 1; + lstsiz -= siz; - /* add in the size prefix for our new list size */ - lstsiz += 2; + /* add in the size prefix for our new list size */ + lstsiz += 2; - /* allocate space for new list containing rest of list */ - runhres1(ctx->bifcxrun, lstsiz, 1, &stkval); - lstp = stkval.runsv.runsvstr + siz + 2; + /* allocate space for new list containing rest of list */ + runhres1(ctx->bifcxrun, lstsiz, 1, &stkval); + lstp = stkval.runsv.runsvstr + siz + 2; - /* write out size followed by list value string */ - oswp2(ctx->bifcxrun->runcxhp, lstsiz); - memcpy(ctx->bifcxrun->runcxhp+2, lstp, (size_t)(lstsiz-2)); - - val.runsv.runsvstr = ctx->bifcxrun->runcxhp; - val.runstyp = DAT_LIST; - ctx->bifcxrun->runcxhp += lstsiz; - runrepush(ctx->bifcxrun, &val); - } - else - runpush(ctx->bifcxrun, DAT_NIL, &val); /* empty list - cdr is nil */ + /* write out size followed by list value string */ + oswp2(ctx->bifcxrun->runcxhp, lstsiz); + memcpy(ctx->bifcxrun->runcxhp+2, lstp, (size_t)(lstsiz-2)); + + val.runsv.runsvstr = ctx->bifcxrun->runcxhp; + val.runstyp = DAT_LIST; + ctx->bifcxrun->runcxhp += lstsiz; + runrepush(ctx->bifcxrun, &val); + } + else + runpush(ctx->bifcxrun, DAT_NIL, &val); /* empty list - cdr is nil */ } /* caps */ void bifcap(bifcxdef *ctx, int argc) { - bifcntargs(ctx, 0, argc); - tiocaps(ctx->bifxtio); /* set output driver next-char-capitalized flag */ + bifcntargs(ctx, 0, argc); + tiocaps(ctx->bifxtio); /* set output driver next-char-capitalized flag */ } /* nocaps */ void bifnoc(bifcxdef *ctx, int argc) { - bifcntargs(ctx, 0, argc); - tionocaps(ctx->bifxtio); /* set next-not-capitalized flag */ + bifcntargs(ctx, 0, argc); + tionocaps(ctx->bifxtio); /* set next-not-capitalized flag */ } /* length */ void biflen(bifcxdef *ctx, int argc) { - uchar *p; - runsdef val; - long len = 0; - int l; - - bifcntargs(ctx, 1, argc); - switch(runtostyp(ctx->bifcxrun)) - { - case DAT_SSTRING: - p = (uchar *)runpopstr(ctx->bifcxrun); - len = osrp2(p) - 2; - break; + uchar *p; + runsdef val; + long len = 0; + int l; + + bifcntargs(ctx, 1, argc); + switch(runtostyp(ctx->bifcxrun)) + { + case DAT_SSTRING: + p = (uchar *)runpopstr(ctx->bifcxrun); + len = osrp2(p) - 2; + break; - case DAT_LIST: - p = runpoplst(ctx->bifcxrun); - l = osrp2(p) - 2; - p += 2; - - /* count all elements in list */ - for (len = 0 ; l ; ++len) - { - int cursiz; - - /* get size of this element, and move past it */ - cursiz = datsiz(*p, p+1) + 1; - l -= cursiz; - p += cursiz; - } - break; + case DAT_LIST: + p = runpoplst(ctx->bifcxrun); + l = osrp2(p) - 2; + p += 2; + + /* count all elements in list */ + for (len = 0 ; l ; ++len) + { + int cursiz; + + /* get size of this element, and move past it */ + cursiz = datsiz(*p, p+1) + 1; + l -= cursiz; + p += cursiz; + } + break; - default: - runsig1(ctx->bifcxrun, ERR_INVTBIF, ERRTSTR, "length"); - } - - val.runsv.runsvnum = len; - runpush(ctx->bifcxrun, DAT_NUMBER, &val); + default: + runsig1(ctx->bifcxrun, ERR_INVTBIF, ERRTSTR, "length"); + } + + val.runsv.runsvnum = len; + runpush(ctx->bifcxrun, DAT_NUMBER, &val); } /* find */ void biffnd(bifcxdef *ctx, int argc) { - uchar *p1, *p2; - int len1, len2; + uchar *p1, *p2; + int len1, len2; int outv = 0; - runsdef val; - int typ = 0; - int siz; - - bifcntargs(ctx, 2, argc); - switch(runtostyp(ctx->bifcxrun)) - { - case DAT_SSTRING: - p1 = runpopstr(ctx->bifcxrun); - len1 = osrp2(p1) - 2; - p1 += 2; - - p2 = runpopstr(ctx->bifcxrun); - len2 = osrp2(p2) - 2; - p2 += 2; + runsdef val; + int typ = 0; + int siz; + + bifcntargs(ctx, 2, argc); + switch(runtostyp(ctx->bifcxrun)) + { + case DAT_SSTRING: + p1 = runpopstr(ctx->bifcxrun); + len1 = osrp2(p1) - 2; + p1 += 2; + + p2 = runpopstr(ctx->bifcxrun); + len2 = osrp2(p2) - 2; + p2 += 2; - /* look for p2 within p1 */ - for (typ = DAT_NIL, outv = 1 ; len1 >= len2 ; ++p1, --len1, ++outv) - { - if (!memcmp(p1, p2, (size_t)len2)) - { - typ = DAT_NUMBER; /* use number in outv after all */ - break; /* that's it - we've found it */ - } - } - break; - - case DAT_LIST: - p1 = runpoplst(ctx->bifcxrun); - len1 = osrp2(p1) - 2; - p1 += 2; + /* look for p2 within p1 */ + for (typ = DAT_NIL, outv = 1 ; len1 >= len2 ; ++p1, --len1, ++outv) + { + if (!memcmp(p1, p2, (size_t)len2)) + { + typ = DAT_NUMBER; /* use number in outv after all */ + break; /* that's it - we've found it */ + } + } + break; + + case DAT_LIST: + p1 = runpoplst(ctx->bifcxrun); + len1 = osrp2(p1) - 2; + p1 += 2; - /* get second item: any old datatype */ - runpop(ctx->bifcxrun, &val); - - for (typ = DAT_NIL, outv = 1 ; len1 ; ++outv, p1 += siz, len1 -= siz) - { - siz = datsiz(*p1, p1 + 1) + 1; /* get size of this element */ - if (val.runstyp != *p1) continue; /* types don't match */ - - switch(val.runstyp) - { - case DAT_NUMBER: - if (val.runsv.runsvnum != osrp4s(p1 + 1)) continue; - break; - - case DAT_SSTRING: - case DAT_LIST: - if (osrp2(p1 + 1) != osrp2(val.runsv.runsvstr) || - memcmp(p1 + 3, val.runsv.runsvstr + 2, - (size_t)(osrp2(p1 + 1) - 2))) - continue; - break; - - case DAT_PROPNUM: - if (osrp2(p1 + 1) != val.runsv.runsvprp) continue; - break; - - case DAT_OBJECT: - case DAT_FNADDR: - if (osrp2(p1 + 1) != val.runsv.runsvobj) continue; - break; - - default: - break; - } - - /* if we got here, it means we found a match */ - typ = DAT_NUMBER; /* use the value in outv */ - break; /* that's it - we've found it */ - } - break; - - default: - runsig1(ctx->bifcxrun, ERR_INVTBIF, ERRTSTR, "find"); - } - - /* push the value given by typ and outv */ - val.runsv.runsvnum = outv; - runpush(ctx->bifcxrun, typ, &val); + /* get second item: any old datatype */ + runpop(ctx->bifcxrun, &val); + + for (typ = DAT_NIL, outv = 1 ; len1 ; ++outv, p1 += siz, len1 -= siz) + { + siz = datsiz(*p1, p1 + 1) + 1; /* get size of this element */ + if (val.runstyp != *p1) continue; /* types don't match */ + + switch(val.runstyp) + { + case DAT_NUMBER: + if (val.runsv.runsvnum != osrp4s(p1 + 1)) continue; + break; + + case DAT_SSTRING: + case DAT_LIST: + if (osrp2(p1 + 1) != osrp2(val.runsv.runsvstr) || + memcmp(p1 + 3, val.runsv.runsvstr + 2, + (size_t)(osrp2(p1 + 1) - 2))) + continue; + break; + + case DAT_PROPNUM: + if (osrp2(p1 + 1) != val.runsv.runsvprp) continue; + break; + + case DAT_OBJECT: + case DAT_FNADDR: + if (osrp2(p1 + 1) != val.runsv.runsvobj) continue; + break; + + default: + break; + } + + /* if we got here, it means we found a match */ + typ = DAT_NUMBER; /* use the value in outv */ + break; /* that's it - we've found it */ + } + break; + + default: + runsig1(ctx->bifcxrun, ERR_INVTBIF, ERRTSTR, "find"); + } + + /* push the value given by typ and outv */ + val.runsv.runsvnum = outv; + runpush(ctx->bifcxrun, typ, &val); } /* setit - set current 'it' */ void bifsit(bifcxdef *ctx, int argc) { - objnum obj; - int typ; - voccxdef *vcx = ctx->bifcxrun->runcxvoc; - - /* check for extended version that allows setting him/her */ - if (argc == 2) - { - if (runtostyp(ctx->bifcxrun) == DAT_NIL) - { - rundisc(ctx->bifcxrun); /* discard the nil */ - obj = MCMONINV; /* use invalid object */ - } - else - obj = runpopobj(ctx->bifcxrun); /* get the object */ + objnum obj; + int typ; + voccxdef *vcx = ctx->bifcxrun->runcxvoc; + + /* check for extended version that allows setting him/her */ + if (argc == 2) + { + if (runtostyp(ctx->bifcxrun) == DAT_NIL) + { + rundisc(ctx->bifcxrun); /* discard the nil */ + obj = MCMONINV; /* use invalid object */ + } + else + obj = runpopobj(ctx->bifcxrun); /* get the object */ - typ = runpopnum(ctx->bifcxrun); /* get the code */ - vcx->voccxthc = 0; /* clear the 'them' list */ + typ = runpopnum(ctx->bifcxrun); /* get the code */ + vcx->voccxthc = 0; /* clear the 'them' list */ - switch(typ) - { - case 0: /* set "it" */ - vcx->voccxit = obj; - break; + switch(typ) + { + case 0: /* set "it" */ + vcx->voccxit = obj; + break; - case 1: /* set "him" */ - vcx->voccxhim = obj; - break; + case 1: /* set "him" */ + vcx->voccxhim = obj; + break; - case 2: /* set "her" */ - vcx->voccxher = obj; - break; - } - return; - } + case 2: /* set "her" */ + vcx->voccxher = obj; + break; + } + return; + } - /* "setit classic" has one argument only */ - bifcntargs(ctx, 1, argc); + /* "setit classic" has one argument only */ + bifcntargs(ctx, 1, argc); - /* check to see if we're setting 'it' or 'them' */ - if (runtostyp(ctx->bifcxrun) == DAT_LIST) - { - uchar *lst; - uint siz; - int cnt; + /* check to see if we're setting 'it' or 'them' */ + if (runtostyp(ctx->bifcxrun) == DAT_LIST) + { + uchar *lst; + uint siz; + int cnt; - lst = runpoplst(ctx->bifcxrun); - siz = osrp2(lst); - lst += 2; - siz -= 2; + lst = runpoplst(ctx->bifcxrun); + siz = osrp2(lst); + lst += 2; + siz -= 2; - for (cnt = 0 ; siz ; ) - { - /* if this is an object, add to 'them' list (otherwise ignore) */ - if (*lst == DAT_OBJECT) - vcx->voccxthm[cnt++] = osrp2(lst+1); + for (cnt = 0 ; siz ; ) + { + /* if this is an object, add to 'them' list (otherwise ignore) */ + if (*lst == DAT_OBJECT) + vcx->voccxthm[cnt++] = osrp2(lst+1); - lstadv(&lst, &siz); - } - vcx->voccxthc = cnt; - vcx->voccxit = MCMONINV; - } - else - { - /* set 'it', and delete 'them' list */ - if (runtostyp(ctx->bifcxrun) == DAT_NIL) - { - vcx->voccxit = MCMONINV; - rundisc(ctx->bifcxrun); - } - else - vcx->voccxit = runpopobj(ctx->bifcxrun); - vcx->voccxthc = 0; - } + lstadv(&lst, &siz); + } + vcx->voccxthc = cnt; + vcx->voccxit = MCMONINV; + } + else + { + /* set 'it', and delete 'them' list */ + if (runtostyp(ctx->bifcxrun) == DAT_NIL) + { + vcx->voccxit = MCMONINV; + rundisc(ctx->bifcxrun); + } + else + vcx->voccxit = runpopobj(ctx->bifcxrun); + vcx->voccxthc = 0; + } } /* randomize - seed random number generator */ void bifsrn(bifcxdef *ctx, int argc) { - bifcntargs(ctx, 0, argc); - os_rand(&ctx->bifcxrnd); - ctx->bifcxrndset = TRUE; + bifcntargs(ctx, 0, argc); + os_rand(&ctx->bifcxrnd); + ctx->bifcxrndset = TRUE; } /* rand - get a random number */ void bifrnd(bifcxdef *ctx, int argc) { - unsigned long result, max, randseed; - int tmp; - runsdef val; + unsigned long result, max, randseed; + int tmp; + runsdef val; - /* get argument - number giving upper bound of generated number */ - bifcntargs(ctx, 1, argc); - bifchkarg(ctx, DAT_NUMBER); - max = runpopnum(ctx->bifcxrun); + /* get argument - number giving upper bound of generated number */ + bifcntargs(ctx, 1, argc); + bifchkarg(ctx, DAT_NUMBER); + max = runpopnum(ctx->bifcxrun); - /* if the max is zero, just return zero */ - if (max == 0) - { - runpnum(ctx->bifcxrun, 0); - return; - } + /* if the max is zero, just return zero */ + if (max == 0) + { + runpnum(ctx->bifcxrun, 0); + return; + } - /* - * If the random number generator has been seeded by a call to - * randomize(), use the new, improved random number generator. If - * not, use the old random number generator to ensure that the same - * sequence of numbers is generated as always (to prevent breaking - * existing test scripts based on the old sequence). - */ - if (!ctx->bifcxrndset) - { - /* compute the next number in sequence, using old cheesy generator */ - randseed = ctx->bifcxrnd; - randseed *= 1033; - randseed += 5; - tmp = randseed / 16384; - randseed %= 16384; - result = tmp / 7; + /* + * If the random number generator has been seeded by a call to + * randomize(), use the new, improved random number generator. If + * not, use the old random number generator to ensure that the same + * sequence of numbers is generated as always (to prevent breaking + * existing test scripts based on the old sequence). + */ + if (!ctx->bifcxrndset) + { + /* compute the next number in sequence, using old cheesy generator */ + randseed = ctx->bifcxrnd; + randseed *= 1033; + randseed += 5; + tmp = randseed / 16384; + randseed %= 16384; + result = tmp / 7; - /* adjust the result to be in the requested range */ - result = ( randseed % max ) + 1; - - /* save the new seed value, and return the value */ - ctx->bifcxrnd = randseed; - val.runsv.runsvnum = result; - runpush(ctx->bifcxrun, DAT_NUMBER, &val); - } - else - { + /* adjust the result to be in the requested range */ + result = ( randseed % max ) + 1; + + /* save the new seed value, and return the value */ + ctx->bifcxrnd = randseed; + val.runsv.runsvnum = result; + runpush(ctx->bifcxrun, DAT_NUMBER, &val); + } + else + { #define BIF_RAND_M ((ulong)2147483647) #define BIF_RAND_Q ((ulong)127773) #define BIF_RAND_A ((ulong)16807) #define BIF_RAND_R ((ulong)2836) - long lo, hi, test; + long lo, hi, test; - lo = ctx->bifcxrnd / BIF_RAND_Q; - hi = ctx->bifcxrnd % BIF_RAND_Q; - test = BIF_RAND_A*lo - BIF_RAND_R*hi; - ctx->bifcxrnd = test; - if (test > 0) - ctx->bifcxrnd = test; - else - ctx->bifcxrnd = test + BIF_RAND_M; - runpnum(ctx->bifcxrun, (((ulong)ctx->bifcxrnd) % max) + 1); - } + lo = ctx->bifcxrnd / BIF_RAND_Q; + hi = ctx->bifcxrnd % BIF_RAND_Q; + test = BIF_RAND_A*lo - BIF_RAND_R*hi; + ctx->bifcxrnd = test; + if (test > 0) + ctx->bifcxrnd = test; + else + ctx->bifcxrnd = test + BIF_RAND_M; + runpnum(ctx->bifcxrun, (((ulong)ctx->bifcxrnd) % max) + 1); + } } /* @@ -904,19 +904,19 @@ void bifrnd(bifcxdef *ctx, int argc) */ static const char *bif_stristr(const char *s1, const char *s2) { - size_t s1len; - size_t s2len; + size_t s1len; + size_t s2len; - /* scan for a match */ - for (s1len = strlen(s1), s2len = strlen(s2) ; s1len >= s2len ; - ++s1, --s1len) - { - /* if this is a match, return this substring */ - if (memicmp(s1, s2, s2len) == 0) - return (const char *)s1; - } + /* scan for a match */ + for (s1len = strlen(s1), s2len = strlen(s2) ; s1len >= s2len ; + ++s1, --s1len) + { + /* if this is a match, return this substring */ + if (memicmp(s1, s2, s2len) == 0) + return (const char *)s1; + } - return 0; + return 0; } /* @@ -929,633 +929,633 @@ static const char *bif_stristr(const char *s1, const char *s2) */ void bifask(bifcxdef *ctx, int argc) { - uchar *prompt; - char buf[OSFNMAX + 2]; - char pbuf[128]; - int err; - int prompt_type; - int file_type; - ulong flags; + uchar *prompt; + char buf[OSFNMAX + 2]; + char pbuf[128]; + int err; + int prompt_type; + int file_type; + ulong flags; - /* make sure we have an acceptable number of arguments */ - if (argc != 1 && argc != 3 && argc != 4) - runsig(ctx->bifcxrun, ERR_BIFARGC); + /* make sure we have an acceptable number of arguments */ + if (argc != 1 && argc != 3 && argc != 4) + runsig(ctx->bifcxrun, ERR_BIFARGC); - /* get the first argument - the prompt string */ - prompt = runpopstr(ctx->bifcxrun); - bifcstr(ctx, pbuf, (size_t)sizeof(pbuf), prompt); + /* get the first argument - the prompt string */ + prompt = runpopstr(ctx->bifcxrun); + bifcstr(ctx, pbuf, (size_t)sizeof(pbuf), prompt); - /* presume we will have no flags */ - flags = 0; + /* presume we will have no flags */ + flags = 0; - /* if we have the prompt type and file type parameters, get them */ - if (argc >= 3) - { - /* get the prompt-type and the file-type arguments */ - prompt_type = (int)runpopnum(ctx->bifcxrun); - file_type = (int)runpopnum(ctx->bifcxrun); + /* if we have the prompt type and file type parameters, get them */ + if (argc >= 3) + { + /* get the prompt-type and the file-type arguments */ + prompt_type = (int)runpopnum(ctx->bifcxrun); + file_type = (int)runpopnum(ctx->bifcxrun); - /* if we have a fourth argument, it's the flags */ - if (argc == 4) - flags = runpopnum(ctx->bifcxrun); - } - else - { - static const char *save_strs[] = - { - "save", - "write", - 0 - }; - static const char *game_strs[] = - { - "restore", - "game", - 0 - }; - const char **sp; + /* if we have a fourth argument, it's the flags */ + if (argc == 4) + flags = runpopnum(ctx->bifcxrun); + } + else + { + static const char *save_strs[] = + { + "save", + "write", + 0 + }; + static const char *game_strs[] = + { + "restore", + "game", + 0 + }; + const char **sp; - /* - * No prompt type or file type were specified. Try to infer the - * dialog type and file type from the text of the prompt. (This - * is mostly to support older games, in particular those based - * on older versions of adv.t, since newer games should always - * provide explicit values for the file type and dialog type. - * We are thus inferring the types based on the prompt strings - * that older adv.t's used when calling askfile.) - * - * If the prompt contains any substring such as "save" or - * "write", specify that we're saving; otherwise, assume that - * we're opening an existing file for reading. - * - * If the prompt contains the substrings "restore" AND "game", - * assume that we're opening a game file; otherwise, don't make - * any assumptions, and use the "unknown" file type. - */ + /* + * No prompt type or file type were specified. Try to infer the + * dialog type and file type from the text of the prompt. (This + * is mostly to support older games, in particular those based + * on older versions of adv.t, since newer games should always + * provide explicit values for the file type and dialog type. + * We are thus inferring the types based on the prompt strings + * that older adv.t's used when calling askfile.) + * + * If the prompt contains any substring such as "save" or + * "write", specify that we're saving; otherwise, assume that + * we're opening an existing file for reading. + * + * If the prompt contains the substrings "restore" AND "game", + * assume that we're opening a game file; otherwise, don't make + * any assumptions, and use the "unknown" file type. + */ - /* presume we're going to open a saved-game file */ - prompt_type = OS_AFP_OPEN; - file_type = OSFTSAVE; + /* presume we're going to open a saved-game file */ + prompt_type = OS_AFP_OPEN; + file_type = OSFTSAVE; - /* look for any one of the "save" substrings */ - for (sp = save_strs ; *sp != 0 ; ++sp) - { - /* check to see if this substring matches */ - if (bif_stristr(pbuf, *sp)) - { - /* found it - use the "save" prompt */ - prompt_type = OS_AFP_SAVE; + /* look for any one of the "save" substrings */ + for (sp = save_strs ; *sp != 0 ; ++sp) + { + /* check to see if this substring matches */ + if (bif_stristr(pbuf, *sp)) + { + /* found it - use the "save" prompt */ + prompt_type = OS_AFP_SAVE; - /* no need to look any further */ - break; - } - } + /* no need to look any further */ + break; + } + } - /* - * look for *all* of the "restore game" strings - if we fail to - * find any of them, be conservative and make no assumptions - * about the file type - */ - for (sp = game_strs ; *sp != 0 ; ++sp) - { - if (bif_stristr(pbuf, *sp) == 0) - { - /* - * this one doesn't match - don't make assumptions about - * the file type - */ - file_type = OSFTUNK; + /* + * look for *all* of the "restore game" strings - if we fail to + * find any of them, be conservative and make no assumptions + * about the file type + */ + for (sp = game_strs ; *sp != 0 ; ++sp) + { + if (bif_stristr(pbuf, *sp) == 0) + { + /* + * this one doesn't match - don't make assumptions about + * the file type + */ + file_type = OSFTUNK; - /* no need to look any further */ - break; - } - } + /* no need to look any further */ + break; + } + } - /* check for a transcript */ - if (file_type == OSFTUNK - && prompt_type == OS_AFP_SAVE - && bif_stristr(pbuf, "script") != 0) - { - /* looks like a log file */ - file_type = OSFTLOG; - } - } + /* check for a transcript */ + if (file_type == OSFTUNK + && prompt_type == OS_AFP_SAVE + && bif_stristr(pbuf, "script") != 0) + { + /* looks like a log file */ + file_type = OSFTLOG; + } + } - /* ask for a file */ - err = tio_askfile(pbuf, buf, (int)sizeof(buf), prompt_type, (os_filetype_t)file_type); + /* ask for a file */ + err = tio_askfile(pbuf, buf, (int)sizeof(buf), prompt_type, (os_filetype_t)file_type); - /* - * if the caller requested extended return codes, return a list - * containing the return code as the first element and, if - * successful, the string as the second element - */ - if ((flags & BIF_ASKF_EXT_RET) != 0) - { - ushort len; - runsdef val; - uchar *p; - - /* - * Allocate space for the starter list - if we have a string to - * return, just allocate space for the number element for now; - * otherwise, allocate space for the number plus a nil second - * element (one byte). - */ - len = 2 + (1 + 4); - if (err != OS_AFE_SUCCESS) - ++len; + /* + * if the caller requested extended return codes, return a list + * containing the return code as the first element and, if + * successful, the string as the second element + */ + if ((flags & BIF_ASKF_EXT_RET) != 0) + { + ushort len; + runsdef val; + uchar *p; + + /* + * Allocate space for the starter list - if we have a string to + * return, just allocate space for the number element for now; + * otherwise, allocate space for the number plus a nil second + * element (one byte). + */ + len = 2 + (1 + 4); + if (err != OS_AFE_SUCCESS) + ++len; - /* allocate the space */ - runhres(ctx->bifcxrun, len, 0); + /* allocate the space */ + runhres(ctx->bifcxrun, len, 0); - /* set up our list pointer */ - val.runstyp = DAT_LIST; - val.runsv.runsvstr = p = ctx->bifcxrun->runcxhp; + /* set up our list pointer */ + val.runstyp = DAT_LIST; + val.runsv.runsvstr = p = ctx->bifcxrun->runcxhp; - /* write the length prefix */ - oswp2(p, len); - p += 2; + /* write the length prefix */ + oswp2(p, len); + p += 2; - /* write the return code as the first element */ - *p++ = DAT_NUMBER; - oswp4s(p, err); - p += 4; + /* write the return code as the first element */ + *p++ = DAT_NUMBER; + oswp4s(p, err); + p += 4; - /* write the 'nil' second element if there's an error */ - if (err != OS_AFE_SUCCESS) - *p++ = DAT_NIL; + /* write the 'nil' second element if there's an error */ + if (err != OS_AFE_SUCCESS) + *p++ = DAT_NIL; - /* commit the list's memory */ - ctx->bifcxrun->runcxhp = p; + /* commit the list's memory */ + ctx->bifcxrun->runcxhp = p; - /* push the list */ - runrepush(ctx->bifcxrun, &val); + /* push the list */ + runrepush(ctx->bifcxrun, &val); - /* if we were successful, add the string to the list */ - if (err == OS_AFE_SUCCESS) - { - runsdef val2; - - /* push the string value, converting to our string format */ - runpushcstr(ctx->bifcxrun, buf, strlen(buf), 1); + /* if we were successful, add the string to the list */ + if (err == OS_AFE_SUCCESS) + { + runsdef val2; + + /* push the string value, converting to our string format */ + runpushcstr(ctx->bifcxrun, buf, strlen(buf), 1); - /* add it to the list already on the stack */ - runpop(ctx->bifcxrun, &val2); - runpop(ctx->bifcxrun, &val); - runadd(ctx->bifcxrun, &val, &val2, 2); + /* add it to the list already on the stack */ + runpop(ctx->bifcxrun, &val2); + runpop(ctx->bifcxrun, &val); + runadd(ctx->bifcxrun, &val, &val2, 2); - /* re-push the result */ - runrepush(ctx->bifcxrun, &val); - } - } - else - { - /* - * use the traditional return codes - if askfile failed, return - * nil; otherwise, return the filename - */ - if (err) - runpnil(ctx->bifcxrun); - else - runpushcstr(ctx->bifcxrun, buf, strlen(buf), 0); - } + /* re-push the result */ + runrepush(ctx->bifcxrun, &val); + } + } + else + { + /* + * use the traditional return codes - if askfile failed, return + * nil; otherwise, return the filename + */ + if (err) + runpnil(ctx->bifcxrun); + else + runpushcstr(ctx->bifcxrun, buf, strlen(buf), 0); + } } /* setscore */ void bifssc(bifcxdef *ctx, int argc) { - int s1, s2; + int s1, s2; - /* optional new way - string argument */ - if (argc == 1 && runtostyp(ctx->bifcxrun) == DAT_SSTRING) - { - char buf[80]; - uchar *p; - - p = runpopstr(ctx->bifcxrun); - bifcstr(ctx, buf, (size_t)sizeof(buf), p); - tiostrsc(ctx->bifcxtio, buf); - } - else - { - /* old way - two numeric arguments (displays: x/y) */ - bifcntargs(ctx, 2, argc); - s1 = runpopnum(ctx->bifcxrun); - s2 = runpopnum(ctx->bifcxrun); - tioscore(ctx->bifcxtio, s1, s2); - } + /* optional new way - string argument */ + if (argc == 1 && runtostyp(ctx->bifcxrun) == DAT_SSTRING) + { + char buf[80]; + uchar *p; + + p = runpopstr(ctx->bifcxrun); + bifcstr(ctx, buf, (size_t)sizeof(buf), p); + tiostrsc(ctx->bifcxtio, buf); + } + else + { + /* old way - two numeric arguments (displays: x/y) */ + bifcntargs(ctx, 2, argc); + s1 = runpopnum(ctx->bifcxrun); + s2 = runpopnum(ctx->bifcxrun); + tioscore(ctx->bifcxtio, s1, s2); + } } /* substr */ void bifsub(bifcxdef *ctx, int argc) { - uchar *p; - int ofs; - int asklen; - int outlen; - int len; + uchar *p; + int ofs; + int asklen; + int outlen; + int len; - bifcntargs(ctx, 3, argc); + bifcntargs(ctx, 3, argc); - /* get the string argument */ - bifchkarg(ctx, DAT_SSTRING); - p = runpopstr(ctx->bifcxrun); - len = osrp2(p) - 2; - p += 2; - - /* get the offset argument */ - bifchkarg(ctx, DAT_NUMBER); - ofs = runpopnum(ctx->bifcxrun); - if (ofs < 1) runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "substr"); - - /* get the length argument */ - bifchkarg(ctx, DAT_NUMBER); - asklen = runpopnum(ctx->bifcxrun); - if (asklen < 0) runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "substr"); + /* get the string argument */ + bifchkarg(ctx, DAT_SSTRING); + p = runpopstr(ctx->bifcxrun); + len = osrp2(p) - 2; + p += 2; + + /* get the offset argument */ + bifchkarg(ctx, DAT_NUMBER); + ofs = runpopnum(ctx->bifcxrun); + if (ofs < 1) runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "substr"); + + /* get the length argument */ + bifchkarg(ctx, DAT_NUMBER); + asklen = runpopnum(ctx->bifcxrun); + if (asklen < 0) runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "substr"); - --ofs; /* convert offset to a zero bias (user provided 1-bias) */ - p += ofs; /* advance string pointer by offset */ + --ofs; /* convert offset to a zero bias (user provided 1-bias) */ + p += ofs; /* advance string pointer by offset */ - if (ofs >= len) - outlen = 0; /* offset is past end of string */ - else if (asklen > len - ofs) - outlen = len - ofs; /* just use rest of string */ - else - outlen = asklen; /* requested length can be provided */ - - runpstr(ctx->bifcxrun, (char *)p, outlen, 3); + if (ofs >= len) + outlen = 0; /* offset is past end of string */ + else if (asklen > len - ofs) + outlen = len - ofs; /* just use rest of string */ + else + outlen = asklen; /* requested length can be provided */ + + runpstr(ctx->bifcxrun, (char *)p, outlen, 3); } /* cvtstr - convert value to a string */ void bifcvs(bifcxdef *ctx, int argc) { - const char *p = nullptr; - int len = 0; - char buf[30]; - - bifcntargs(ctx, 1, argc); - switch(runtostyp(ctx->bifcxrun)) - { - case DAT_NIL: - p = "nil"; - len = 3; - (void)runpoplog(ctx->bifcxrun); - break; - - case DAT_TRUE: - p = "true"; - len = 4; - (void)runpoplog(ctx->bifcxrun); - break; - - case DAT_NUMBER: - sprintf(buf, "%ld", runpopnum(ctx->bifcxrun)); - p = buf; - len = strlen(buf); - break; + const char *p = nullptr; + int len = 0; + char buf[30]; + + bifcntargs(ctx, 1, argc); + switch(runtostyp(ctx->bifcxrun)) + { + case DAT_NIL: + p = "nil"; + len = 3; + (void)runpoplog(ctx->bifcxrun); + break; + + case DAT_TRUE: + p = "true"; + len = 4; + (void)runpoplog(ctx->bifcxrun); + break; + + case DAT_NUMBER: + sprintf(buf, "%ld", runpopnum(ctx->bifcxrun)); + p = buf; + len = strlen(buf); + break; - case DAT_SSTRING: - /* leave the string value on the stack unchanged */ - return; + case DAT_SSTRING: + /* leave the string value on the stack unchanged */ + return; - default: - /* throw the RUNEXITOBJ error */ - runsig1(ctx->bifcxrun, ERR_INVTBIF, ERRTSTR, "cvtstr"); - } - - runpstr(ctx->bifcxrun, p, len, 0); + default: + /* throw the RUNEXITOBJ error */ + runsig1(ctx->bifcxrun, ERR_INVTBIF, ERRTSTR, "cvtstr"); + } + + runpstr(ctx->bifcxrun, p, len, 0); } /* cvtnum - convert a value to a number */ void bifcvn(bifcxdef *ctx, int argc) { - runsdef val; - uchar *p; - int len; - int typ; - long acc; - int neg; - - bifcntargs(ctx, 1, argc); - p = runpopstr(ctx->bifcxrun); - len = osrp2(p) - 2; - p += 2; - - if (len == 3 && !memcmp(p, "nil", (size_t)3)) - typ = DAT_NIL; - else if (len == 4 && !memcmp(p, "true", (size_t)4)) - typ = DAT_TRUE; - else - { - typ = DAT_NUMBER; - for ( ; len != 0 && t_isspace(*p) ; ++p, --len) ; - if (len != 0 && *p == '-') - { - neg = TRUE; - for (++p, --len ; len != 0 && t_isspace(*p) ; ++p, --len) ; - } - else neg = FALSE; + runsdef val; + uchar *p; + int len; + int typ; + long acc; + int neg; + + bifcntargs(ctx, 1, argc); + p = runpopstr(ctx->bifcxrun); + len = osrp2(p) - 2; + p += 2; + + if (len == 3 && !memcmp(p, "nil", (size_t)3)) + typ = DAT_NIL; + else if (len == 4 && !memcmp(p, "true", (size_t)4)) + typ = DAT_TRUE; + else + { + typ = DAT_NUMBER; + for ( ; len != 0 && t_isspace(*p) ; ++p, --len) ; + if (len != 0 && *p == '-') + { + neg = TRUE; + for (++p, --len ; len != 0 && t_isspace(*p) ; ++p, --len) ; + } + else neg = FALSE; - /* accumulate the number digit by digit */ - for (acc = 0 ; len != 0 && Common::isDigit(*p) ; ++p, --len) - acc = (acc << 3) + (acc << 1) + ((*p) - '0'); + /* accumulate the number digit by digit */ + for (acc = 0 ; len != 0 && Common::isDigit(*p) ; ++p, --len) + acc = (acc << 3) + (acc << 1) + ((*p) - '0'); - if (neg) acc = -acc; - val.runsv.runsvnum = acc; - } - - runpush(ctx->bifcxrun, typ, &val); + if (neg) acc = -acc; + val.runsv.runsvnum = acc; + } + + runpush(ctx->bifcxrun, typ, &val); } /* general string conversion function */ static void bifcvtstr(bifcxdef *ctx, void (*cvtfn)(uchar *, int), int argc) { - uchar *p; - int len; - runsdef val; - runsdef stkval; - - bifcntargs(ctx, 1, argc); - bifchkarg(ctx, DAT_SSTRING); - - p = runpopstr(ctx->bifcxrun); - stkval.runstyp = DAT_SSTRING; - stkval.runsv.runsvstr = p; - len = osrp2(p); - - /* allocate space in heap for the string and convert */ - runhres1(ctx->bifcxrun, len, 1, &stkval); - p = stkval.runsv.runsvstr; - memcpy(ctx->bifcxrun->runcxhp, p, (size_t)len); - (*cvtfn)(ctx->bifcxrun->runcxhp + 2, len - 2); - - val.runsv.runsvstr = ctx->bifcxrun->runcxhp; - val.runstyp = DAT_SSTRING; - ctx->bifcxrun->runcxhp += len; - runrepush(ctx->bifcxrun, &val); + uchar *p; + int len; + runsdef val; + runsdef stkval; + + bifcntargs(ctx, 1, argc); + bifchkarg(ctx, DAT_SSTRING); + + p = runpopstr(ctx->bifcxrun); + stkval.runstyp = DAT_SSTRING; + stkval.runsv.runsvstr = p; + len = osrp2(p); + + /* allocate space in heap for the string and convert */ + runhres1(ctx->bifcxrun, len, 1, &stkval); + p = stkval.runsv.runsvstr; + memcpy(ctx->bifcxrun->runcxhp, p, (size_t)len); + (*cvtfn)(ctx->bifcxrun->runcxhp + 2, len - 2); + + val.runsv.runsvstr = ctx->bifcxrun->runcxhp; + val.runstyp = DAT_SSTRING; + ctx->bifcxrun->runcxhp += len; + runrepush(ctx->bifcxrun, &val); } /* routine to convert a counted-length string to uppercase */ static void bifstrupr(uchar *str, int len) { - for ( ; len ; --len, ++str) - { - if (*str == '\\' && len > 1) - --len, ++str; - else if (Common::isLower(*str)) - *str = toupper(*str); - } + for ( ; len ; --len, ++str) + { + if (*str == '\\' && len > 1) + --len, ++str; + else if (Common::isLower(*str)) + *str = toupper(*str); + } } /* upper */ void bifupr(bifcxdef *ctx, int argc) { - bifcvtstr(ctx, bifstrupr, argc); + bifcvtstr(ctx, bifstrupr, argc); } /* convert a counted-length string to lowercase */ static void bifstrlwr(uchar *str, int len) { - for ( ; len ; --len, ++str) - { - if (*str == '\\' && len > 1) - --len, ++str; - else if (Common::isUpper(*str)) - *str = tolower(*str); - } + for ( ; len ; --len, ++str) + { + if (*str == '\\' && len > 1) + --len, ++str; + else if (Common::isUpper(*str)) + *str = tolower(*str); + } } /* lower */ void biflwr(bifcxdef *ctx, int argc) { - bifcvtstr(ctx, bifstrlwr, argc); + bifcvtstr(ctx, bifstrlwr, argc); } /* internal check to determine if object is of a class */ int bifinh(voccxdef *voc, vocidef *v, objnum cls) { - int i; - objnum *sc; + int i; + objnum *sc; - if (!v) return(FALSE); - for (i = v->vocinsc, sc = v->vocisc ; i ; ++sc, --i) - { - if (*sc == cls - || bifinh(voc, vocinh(voc, *sc), cls)) - return(TRUE); - } - return(FALSE); + if (!v) return(FALSE); + for (i = v->vocinsc, sc = v->vocisc ; i ; ++sc, --i) + { + if (*sc == cls + || bifinh(voc, vocinh(voc, *sc), cls)) + return(TRUE); + } + return(FALSE); } /* isclass(obj, cls) */ void bifisc(bifcxdef *ctx, int argc) { - objnum obj; - objnum cls; - runsdef val; - voccxdef *voc = ctx->bifcxrun->runcxvoc; - - bifcntargs(ctx, 2, argc); + objnum obj; + objnum cls; + runsdef val; + voccxdef *voc = ctx->bifcxrun->runcxvoc; + + bifcntargs(ctx, 2, argc); - /* if checking for nil, return nil */ - if (runtostyp(ctx->bifcxrun) == DAT_NIL) - { - rundisc(ctx->bifcxrun); - rundisc(ctx->bifcxrun); - runpnil(ctx->bifcxrun); - return; - } + /* if checking for nil, return nil */ + if (runtostyp(ctx->bifcxrun) == DAT_NIL) + { + rundisc(ctx->bifcxrun); + rundisc(ctx->bifcxrun); + runpnil(ctx->bifcxrun); + return; + } - /* get the arguments: object, class */ - obj = runpopobj(ctx->bifcxrun); - cls = runpopobj(ctx->bifcxrun); + /* get the arguments: object, class */ + obj = runpopobj(ctx->bifcxrun); + cls = runpopobj(ctx->bifcxrun); - /* return the result from bifinh() */ - runpush(ctx->bifcxrun, runclog(bifinh(voc, vocinh(voc, obj), cls)), &val); + /* return the result from bifinh() */ + runpush(ctx->bifcxrun, runclog(bifinh(voc, vocinh(voc, obj), cls)), &val); } /* firstsc(obj) - get the first superclass of an object */ void bif1sc(bifcxdef *ctx, int argc) { - objnum obj; - objnum sc; + objnum obj; + objnum sc; - bifcntargs(ctx, 1, argc); - obj = runpopobj(ctx->bifcxrun); - sc = objget1sc(ctx->bifcxrun->runcxmem, obj); - runpobj(ctx->bifcxrun, sc); + bifcntargs(ctx, 1, argc); + obj = runpopobj(ctx->bifcxrun); + sc = objget1sc(ctx->bifcxrun->runcxmem, obj); + runpobj(ctx->bifcxrun, sc); } /* firstobj */ void biffob(bifcxdef *ctx, int argc) { - vocidef ***vpg; - vocidef **v; - objnum obj; - int i; - int j; - objnum cls = 0; - voccxdef *voc = ctx->bifcxrun->runcxvoc; + vocidef ***vpg; + vocidef **v; + objnum obj; + int i; + int j; + objnum cls = 0; + voccxdef *voc = ctx->bifcxrun->runcxvoc; - /* get class to search for, if one is specified */ - if (argc == 0) - cls = MCMONINV; - else if (argc == 1) - cls = runpopobj(ctx->bifcxrun); - else - runsig(ctx->bifcxrun, ERR_BIFARGC); - - for (vpg = voc->voccxinh, i = 0 ; i < VOCINHMAX ; ++vpg, ++i) - { - if (!*vpg) continue; - for (v = *vpg, obj = (i << 8), j = 0 ; j < 256 ; ++v, ++obj, ++j) - { - if (!*v || ((*v)->vociflg & VOCIFCLASS) - || (cls != MCMONINV && !bifinh(voc, *v, cls))) - continue; - - /* this is an object we can use - push it */ - runpobj(ctx->bifcxrun, obj); - return; - } - } - - /* no objects found at all - return nil */ - runpnil(ctx->bifcxrun); + /* get class to search for, if one is specified */ + if (argc == 0) + cls = MCMONINV; + else if (argc == 1) + cls = runpopobj(ctx->bifcxrun); + else + runsig(ctx->bifcxrun, ERR_BIFARGC); + + for (vpg = voc->voccxinh, i = 0 ; i < VOCINHMAX ; ++vpg, ++i) + { + if (!*vpg) continue; + for (v = *vpg, obj = (i << 8), j = 0 ; j < 256 ; ++v, ++obj, ++j) + { + if (!*v || ((*v)->vociflg & VOCIFCLASS) + || (cls != MCMONINV && !bifinh(voc, *v, cls))) + continue; + + /* this is an object we can use - push it */ + runpobj(ctx->bifcxrun, obj); + return; + } + } + + /* no objects found at all - return nil */ + runpnil(ctx->bifcxrun); } /* nextobj */ void bifnob(bifcxdef *ctx, int argc) { - objnum prv; - vocidef ***vpg; - vocidef **v; - objnum obj; - int i; - int j; - objnum cls = 0; - voccxdef *voc = ctx->bifcxrun->runcxvoc; + objnum prv; + vocidef ***vpg; + vocidef **v; + objnum obj; + int i; + int j; + objnum cls = 0; + voccxdef *voc = ctx->bifcxrun->runcxvoc; - /* get last position in search */ - prv = runpopobj(ctx->bifcxrun); - - /* get class to search for, if one is specified */ - if (argc == 1) - cls = MCMONINV; - else if (argc == 2) - cls = runpopobj(ctx->bifcxrun); - else - runsig(ctx->bifcxrun, ERR_BIFARGC); - - /* start at previous object plus 1 */ - i = (prv >> 8); - vpg = voc->voccxinh + i; - j = (prv & 255); - obj = prv; - v = (*vpg) + j; - - for (;;) - { - ++j; - ++obj; - ++v; - if (j == 256) - { - j = 0; - ++i; - ++vpg; - if (!*vpg) - { - obj += 255; - j += 255; - continue; - } - v = (*vpg); - } - if (i >= VOCINHMAX) - { - runpnil(ctx->bifcxrun); - return; - } - - if (!*v || ((*v)->vociflg & VOCIFCLASS) - || (cls != MCMONINV && !bifinh(voc, *v, cls))) - continue; - - /* this is an object we can use - push it */ - runpobj(ctx->bifcxrun, obj); - return; - } + /* get last position in search */ + prv = runpopobj(ctx->bifcxrun); + + /* get class to search for, if one is specified */ + if (argc == 1) + cls = MCMONINV; + else if (argc == 2) + cls = runpopobj(ctx->bifcxrun); + else + runsig(ctx->bifcxrun, ERR_BIFARGC); + + /* start at previous object plus 1 */ + i = (prv >> 8); + vpg = voc->voccxinh + i; + j = (prv & 255); + obj = prv; + v = (*vpg) + j; + + for (;;) + { + ++j; + ++obj; + ++v; + if (j == 256) + { + j = 0; + ++i; + ++vpg; + if (!*vpg) + { + obj += 255; + j += 255; + continue; + } + v = (*vpg); + } + if (i >= VOCINHMAX) + { + runpnil(ctx->bifcxrun); + return; + } + + if (!*v || ((*v)->vociflg & VOCIFCLASS) + || (cls != MCMONINV && !bifinh(voc, *v, cls))) + continue; + + /* this is an object we can use - push it */ + runpobj(ctx->bifcxrun, obj); + return; + } } /* setversion */ void bifsvn(bifcxdef *ctx, int argc) { - bifcntargs(ctx, 1, argc); - (void)runpopstr(ctx->bifcxrun); - /* note - setversion doesn't do anything in v2; uses timestamp instead */ + bifcntargs(ctx, 1, argc); + (void)runpopstr(ctx->bifcxrun); + /* note - setversion doesn't do anything in v2; uses timestamp instead */ } /* getarg */ void bifarg(bifcxdef *ctx, int argc) { - int argnum; - - bifcntargs(ctx, 1, argc); - bifchkarg(ctx, DAT_NUMBER); - - /* get and verify argument number */ - argnum = runpopnum(ctx->bifcxrun); - if (argnum < 1) runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "getarg"); + int argnum; + + bifcntargs(ctx, 1, argc); + bifchkarg(ctx, DAT_NUMBER); + + /* get and verify argument number */ + argnum = runpopnum(ctx->bifcxrun); + if (argnum < 1) runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "getarg"); - runrepush(ctx->bifcxrun, ctx->bifcxrun->runcxbp - argnum - 1); + runrepush(ctx->bifcxrun, ctx->bifcxrun->runcxbp - argnum - 1); } /* datatype */ void biftyp(bifcxdef *ctx, int argc) { - runsdef val; - - bifcntargs(ctx, 1, argc); - - /* get whatever it is, and push the type */ - runpop(ctx->bifcxrun, &val); - val.runsv.runsvnum = val.runstyp; /* new value is the datatype */ - runpush(ctx->bifcxrun, DAT_NUMBER, &val); + runsdef val; + + bifcntargs(ctx, 1, argc); + + /* get whatever it is, and push the type */ + runpop(ctx->bifcxrun, &val); + val.runsv.runsvnum = val.runstyp; /* new value is the datatype */ + runpush(ctx->bifcxrun, DAT_NUMBER, &val); } /* undo */ void bifund(bifcxdef *ctx, int argc) { - objucxdef *ucx = ctx->bifcxrun->runcxvoc->voccxundo; - mcmcxdef *mcx = ctx->bifcxrun->runcxmem; - errcxdef *ec = ctx->bifcxerr; - int err; - int undone; - runsdef val; + objucxdef *ucx = ctx->bifcxrun->runcxvoc->voccxundo; + mcmcxdef *mcx = ctx->bifcxrun->runcxmem; + errcxdef *ec = ctx->bifcxerr; + int err; + int undone; + runsdef val; - bifcntargs(ctx, 0, argc); /* no arguments */ + bifcntargs(ctx, 0, argc); /* no arguments */ - ERRBEGIN(ec) - if (ucx) - { - objundo(mcx, ucx); /* try to undo to previous savepoint */ - undone = TRUE; /* looks like we succeeded */ - } - else - undone = FALSE; /* no undo context; can't undo */ - ERRCATCH(ec, err) - if (err == ERR_NOUNDO || err == ERR_ICUNDO) - undone = FALSE; - else - errrse(ec); /* don't know how to handle other errors */ - ERREND(ec) + ERRBEGIN(ec) + if (ucx) + { + objundo(mcx, ucx); /* try to undo to previous savepoint */ + undone = TRUE; /* looks like we succeeded */ + } + else + undone = FALSE; /* no undo context; can't undo */ + ERRCATCH(ec, err) + if (err == ERR_NOUNDO || err == ERR_ICUNDO) + undone = FALSE; + else + errrse(ec); /* don't know how to handle other errors */ + ERREND(ec) - /* return a value indicating whether the undo operation succeeded */ - runpush(ctx->bifcxrun, runclog(undone), &val); + /* return a value indicating whether the undo operation succeeded */ + runpush(ctx->bifcxrun, runclog(undone), &val); - /* note that the rest of the command line is to be ignored */ - ctx->bifcxrun->runcxvoc->voccxflg |= VOCCXFCLEAR; + /* note that the rest of the command line is to be ignored */ + ctx->bifcxrun->runcxvoc->voccxflg |= VOCCXFCLEAR; } /* flags for defined() function */ @@ -1567,225 +1567,225 @@ void bifund(bifcxdef *ctx, int argc) /* defined */ void bifdef(bifcxdef *ctx, int argc) { - prpnum prpn; - objnum objn; - uint ofs; - runsdef val; - objnum def_objn; - int flag; + prpnum prpn; + objnum objn; + uint ofs; + runsdef val; + objnum def_objn; + int flag; - /* get object and property arguments */ - objn = runpopobj(ctx->bifcxrun); - prpn = runpopprp(ctx->bifcxrun); + /* get object and property arguments */ + objn = runpopobj(ctx->bifcxrun); + prpn = runpopprp(ctx->bifcxrun); - /* if there's a flag argument, get it as well */ - if (argc == 3) - { - /* get the flag */ - flag = (int)runpopnum(ctx->bifcxrun); - } - else - { - /* check the argument count */ - bifcntargs(ctx, 2, argc); + /* if there's a flag argument, get it as well */ + if (argc == 3) + { + /* get the flag */ + flag = (int)runpopnum(ctx->bifcxrun); + } + else + { + /* check the argument count */ + bifcntargs(ctx, 2, argc); - /* use the default flag value (DEFINES_OR_INHERITS) */ - flag = BIFDEF_DEFINED_ANY; - } + /* use the default flag value (DEFINES_OR_INHERITS) */ + flag = BIFDEF_DEFINED_ANY; + } - /* get the offset of the property and the defining object */ - ofs = objgetap(ctx->bifcxrun->runcxmem, objn, prpn, &def_objn, FALSE); + /* get the offset of the property and the defining object */ + ofs = objgetap(ctx->bifcxrun->runcxmem, objn, prpn, &def_objn, FALSE); - /* determine the type of information they want */ - switch(flag) - { - case BIFDEF_DEFINED_ANY: - /* if the property is defined, return true, else return nil */ - runpush(ctx->bifcxrun, runclog(ofs != 0), &val); - break; + /* determine the type of information they want */ + switch(flag) + { + case BIFDEF_DEFINED_ANY: + /* if the property is defined, return true, else return nil */ + runpush(ctx->bifcxrun, runclog(ofs != 0), &val); + break; - case BIFDEF_DEFINED_DIRECTLY: - /* if the property is defined directly by the object, return true */ - runpush(ctx->bifcxrun, runclog(ofs != 0 && def_objn == objn), &val); - break; - - case BIFDEF_DEFINED_INHERITS: - /* if the property is inherited, return true */ - runpush(ctx->bifcxrun, runclog(ofs != 0 && def_objn != objn), &val); - break; + case BIFDEF_DEFINED_DIRECTLY: + /* if the property is defined directly by the object, return true */ + runpush(ctx->bifcxrun, runclog(ofs != 0 && def_objn == objn), &val); + break; + + case BIFDEF_DEFINED_INHERITS: + /* if the property is inherited, return true */ + runpush(ctx->bifcxrun, runclog(ofs != 0 && def_objn != objn), &val); + break; - case BIFDEF_DEFINED_GET_CLASS: - /* if it's defined, return the defining object, otherwise nil */ - if (ofs == 0) - runpnil(ctx->bifcxrun); - else - runpobj(ctx->bifcxrun, def_objn); - break; + case BIFDEF_DEFINED_GET_CLASS: + /* if it's defined, return the defining object, otherwise nil */ + if (ofs == 0) + runpnil(ctx->bifcxrun); + else + runpobj(ctx->bifcxrun, def_objn); + break; - default: - /* invalid flag value */ - runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "defined"); - } + default: + /* invalid flag value */ + runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "defined"); + } } /* proptype */ void bifpty(bifcxdef *ctx, int argc) { - prpnum prpn; - objnum objn; - uint ofs; - runsdef val; - objnum orn; - objdef *objptr; - prpdef *propptr; + prpnum prpn; + objnum objn; + uint ofs; + runsdef val; + objnum orn; + objdef *objptr; + prpdef *propptr; - bifcntargs(ctx, 2, argc); - - /* get offset of obj.prop */ - objn = runpopobj(ctx->bifcxrun); - prpn = runpopprp(ctx->bifcxrun); - ofs = objgetap(ctx->bifcxrun->runcxmem, objn, prpn, &orn, FALSE); - - if (ofs) - { - /* lock the object, read the prpdef, and unlock it */ - objptr = (objdef *)mcmlck(ctx->bifcxrun->runcxmem, (mcmon)orn); - propptr = objofsp(objptr, ofs); - val.runsv.runsvnum = prptype(propptr); - mcmunlck(ctx->bifcxrun->runcxmem, (mcmon)orn); - } - else - { - /* property is not defined by object - indicate that type is nil */ - val.runsv.runsvnum = DAT_NIL; - } - - /* special case: DAT_DEMAND -> DAT_LIST (for contents properties) */ - if (val.runsv.runsvnum == DAT_DEMAND) - val.runsv.runsvnum = DAT_LIST; + bifcntargs(ctx, 2, argc); + + /* get offset of obj.prop */ + objn = runpopobj(ctx->bifcxrun); + prpn = runpopprp(ctx->bifcxrun); + ofs = objgetap(ctx->bifcxrun->runcxmem, objn, prpn, &orn, FALSE); + + if (ofs) + { + /* lock the object, read the prpdef, and unlock it */ + objptr = (objdef *)mcmlck(ctx->bifcxrun->runcxmem, (mcmon)orn); + propptr = objofsp(objptr, ofs); + val.runsv.runsvnum = prptype(propptr); + mcmunlck(ctx->bifcxrun->runcxmem, (mcmon)orn); + } + else + { + /* property is not defined by object - indicate that type is nil */ + val.runsv.runsvnum = DAT_NIL; + } + + /* special case: DAT_DEMAND -> DAT_LIST (for contents properties) */ + if (val.runsv.runsvnum == DAT_DEMAND) + val.runsv.runsvnum = DAT_LIST; - /* return the property type as a number */ - runpush(ctx->bifcxrun, DAT_NUMBER, &val); + /* return the property type as a number */ + runpush(ctx->bifcxrun, DAT_NUMBER, &val); } /* outhide */ void bifoph(bifcxdef *ctx, int argc) { - runsdef val; - int hidden, output_occurred; + runsdef val; + int hidden, output_occurred; - bifcntargs(ctx, 1, argc); - outstat(&hidden, &output_occurred); - if (runtostyp(ctx->bifcxrun) == DAT_TRUE) - { - /* throw away the flag */ - rundisc(ctx->bifcxrun); - - /* figure out appropriate return value */ - if (!hidden) - val.runsv.runsvnum = 0; - else if (!output_occurred) - val.runsv.runsvnum = 1; - else - val.runsv.runsvnum = 2; - runpush(ctx->bifcxrun, DAT_NUMBER, &val); + bifcntargs(ctx, 1, argc); + outstat(&hidden, &output_occurred); + if (runtostyp(ctx->bifcxrun) == DAT_TRUE) + { + /* throw away the flag */ + rundisc(ctx->bifcxrun); + + /* figure out appropriate return value */ + if (!hidden) + val.runsv.runsvnum = 0; + else if (!output_occurred) + val.runsv.runsvnum = 1; + else + val.runsv.runsvnum = 2; + runpush(ctx->bifcxrun, DAT_NUMBER, &val); - /* actually hide the output, resetting count flag */ - outhide(); - } - else if (runtostyp(ctx->bifcxrun) == DAT_NIL) - { - /* throw away the flag */ - rundisc(ctx->bifcxrun); + /* actually hide the output, resetting count flag */ + outhide(); + } + else if (runtostyp(ctx->bifcxrun) == DAT_NIL) + { + /* throw away the flag */ + rundisc(ctx->bifcxrun); - /* show output, returning status */ - runpush(ctx->bifcxrun, runclog(outshow()), &val); - } - else if (runtostyp(ctx->bifcxrun) == DAT_NUMBER) - { - int n = runpopnum(ctx->bifcxrun); + /* show output, returning status */ + runpush(ctx->bifcxrun, runclog(outshow()), &val); + } + else if (runtostyp(ctx->bifcxrun) == DAT_NUMBER) + { + int n = runpopnum(ctx->bifcxrun); - if (n == 0) - { - /* output was not hidden - show output and return status */ - runpush(ctx->bifcxrun, runclog(outshow()), &val); - } - else if (n == 1) - { - /* - * Output was hidden, but no output had occurred yet. - * Leave output hidden and return whether any output has - * occurred. - */ - runpush(ctx->bifcxrun, runclog(output_occurred), &val); - } - else if (n == 2) - { - /* - * Output was hidden, and output had already occurred. If - * more output has occurred, return true, else return nil. - * In either case, set the output_occurred flag back to - * true, since it was true before the outhide(true). - */ - runpush(ctx->bifcxrun, runclog(output_occurred), &val); - outsethidden(); - } - else - errsig1(ctx->bifcxerr, ERR_INVVBIF, ERRTSTR, "outhide"); - } - else - errsig(ctx->bifcxerr, ERR_REQNUM); + if (n == 0) + { + /* output was not hidden - show output and return status */ + runpush(ctx->bifcxrun, runclog(outshow()), &val); + } + else if (n == 1) + { + /* + * Output was hidden, but no output had occurred yet. + * Leave output hidden and return whether any output has + * occurred. + */ + runpush(ctx->bifcxrun, runclog(output_occurred), &val); + } + else if (n == 2) + { + /* + * Output was hidden, and output had already occurred. If + * more output has occurred, return true, else return nil. + * In either case, set the output_occurred flag back to + * true, since it was true before the outhide(true). + */ + runpush(ctx->bifcxrun, runclog(output_occurred), &val); + outsethidden(); + } + else + errsig1(ctx->bifcxerr, ERR_INVVBIF, ERRTSTR, "outhide"); + } + else + errsig(ctx->bifcxerr, ERR_REQNUM); } /* put a numeric value in a list */ static uchar *bifputnum(uchar *lstp, uint val) { - *lstp++ = DAT_NUMBER; - oswp4s(lstp, (long)val); - return(lstp + 4); + *lstp++ = DAT_NUMBER; + oswp4s(lstp, (long)val); + return(lstp + 4); } /* gettime */ void biftim(bifcxdef *ctx, int argc) { TimeDate tm; uint timer; - uchar ret[80]; - uchar *p; - runsdef val; - int typ; + uchar ret[80]; + uchar *p; + runsdef val; + int typ; int tm_yday; const int MONTH_DAYS[11] = { 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30 }; - if (argc == 1) - { - /* get the time type */ - typ = (int)runpopnum(ctx->bifcxrun); - } - else - { - /* make sure no arguments are specified */ - bifcntargs(ctx, 0, argc); + if (argc == 1) + { + /* get the time type */ + typ = (int)runpopnum(ctx->bifcxrun); + } + else + { + /* make sure no arguments are specified */ + bifcntargs(ctx, 0, argc); - /* use the default time type */ - typ = 1; - } + /* use the default time type */ + typ = 1; + } - switch(typ) - { - case 1: - /* - * default information format - list format with current system - * time and date - */ + switch(typ) + { + case 1: + /* + * default information format - list format with current system + * time and date + */ - /* make sure the time zone is set up properly */ - os_tzset(); - - /* get the local time information */ + /* make sure the time zone is set up properly */ + os_tzset(); + + /* get the local time information */ g_system->getTimeAndDate(tm); - - /* adjust values for return format */ - tm.tm_wday++; + + /* adjust values for return format */ + tm.tm_wday++; // Get number of days since start of year tm_yday = tm.tm_mday; @@ -1799,174 +1799,174 @@ void biftim(bifcxdef *ctx, int argc) { // TODO: Convert dae/tme to Unix style local time timer = 0; - - /* build return list value */ - oswp2(ret, 47); - p = ret + 2; - p = bifputnum(p, tm.tm_year); - p = bifputnum(p, tm.tm_mon); - p = bifputnum(p, tm.tm_mday); - p = bifputnum(p, tm.tm_wday); - p = bifputnum(p, tm_yday); - p = bifputnum(p, tm.tm_hour); - p = bifputnum(p, tm.tm_min); - p = bifputnum(p, tm.tm_sec); - *p++ = DAT_NUMBER; - oswp4s(p, (long)timer); - - val.runstyp = DAT_LIST; - val.runsv.runsvstr = ret; - runpush(ctx->bifcxrun, DAT_LIST, &val); - break; + + /* build return list value */ + oswp2(ret, 47); + p = ret + 2; + p = bifputnum(p, tm.tm_year); + p = bifputnum(p, tm.tm_mon); + p = bifputnum(p, tm.tm_mday); + p = bifputnum(p, tm.tm_wday); + p = bifputnum(p, tm_yday); + p = bifputnum(p, tm.tm_hour); + p = bifputnum(p, tm.tm_min); + p = bifputnum(p, tm.tm_sec); + *p++ = DAT_NUMBER; + oswp4s(p, (long)timer); + + val.runstyp = DAT_LIST; + val.runsv.runsvstr = ret; + runpush(ctx->bifcxrun, DAT_LIST, &val); + break; - case 2: - /* - * High-precision system timer value - returns the system time - * in milliseconds, relative to an arbitrary zero point - */ - runpnum(ctx->bifcxrun, os_get_sys_clock_ms()); - break; + case 2: + /* + * High-precision system timer value - returns the system time + * in milliseconds, relative to an arbitrary zero point + */ + runpnum(ctx->bifcxrun, os_get_sys_clock_ms()); + break; - default: - /* other types are invalid */ - runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "gettime"); - break; - } + default: + /* other types are invalid */ + runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "gettime"); + break; + } } /* getfuse */ void bifgfu(bifcxdef *ctx, int argc) { - vocddef *daem; - objnum func; - runsdef val; - runcxdef *rcx = ctx->bifcxrun; - int slots; - prpnum prop; - voccxdef *vcx = ctx->bifcxrun->runcxvoc; + vocddef *daem; + objnum func; + runsdef val; + runcxdef *rcx = ctx->bifcxrun; + int slots; + prpnum prop; + voccxdef *vcx = ctx->bifcxrun->runcxvoc; - bifcntargs(ctx, 2, argc); + bifcntargs(ctx, 2, argc); - if (runtostyp(rcx) == DAT_FNADDR) - { - /* check on a setfuse()-style fuse: get fnaddr, parm */ - func = runpopfn(rcx); - runpop(rcx, &val); + if (runtostyp(rcx) == DAT_FNADDR) + { + /* check on a setfuse()-style fuse: get fnaddr, parm */ + func = runpopfn(rcx); + runpop(rcx, &val); - for (slots = vcx->voccxfuc, daem = vcx->voccxfus ; - slots ; ++daem, --slots) - { - if (daem->vocdfn == func - && daem->vocdarg.runstyp == val.runstyp - && !memcmp(&val.runsv, &daem->vocdarg.runsv, - (size_t)datsiz(val.runstyp, &val.runsv))) - goto ret_num; - } - } - else - { - /* check on a notify()-style fuse: get object, &message */ - func = runpopobj(rcx); - prop = runpopprp(rcx); + for (slots = vcx->voccxfuc, daem = vcx->voccxfus ; + slots ; ++daem, --slots) + { + if (daem->vocdfn == func + && daem->vocdarg.runstyp == val.runstyp + && !memcmp(&val.runsv, &daem->vocdarg.runsv, + (size_t)datsiz(val.runstyp, &val.runsv))) + goto ret_num; + } + } + else + { + /* check on a notify()-style fuse: get object, &message */ + func = runpopobj(rcx); + prop = runpopprp(rcx); - for (slots = vcx->voccxalc, daem = vcx->voccxalm ; - slots ; ++daem, --slots) - { - if (daem->vocdfn == func && daem->vocdprp == prop) - goto ret_num; - } - } - - /* didn't find anything - return nil */ - runpush(rcx, DAT_NIL, &val); - return; - + for (slots = vcx->voccxalc, daem = vcx->voccxalm ; + slots ; ++daem, --slots) + { + if (daem->vocdfn == func && daem->vocdprp == prop) + goto ret_num; + } + } + + /* didn't find anything - return nil */ + runpush(rcx, DAT_NIL, &val); + return; + ret_num: - /* return current daem->vocdtim */ - runpnum(rcx, (long)daem->vocdtim); - return; + /* return current daem->vocdtim */ + runpnum(rcx, (long)daem->vocdtim); + return; } /* runfuses */ void bifruf(bifcxdef *ctx, int argc) { - int ret; - runsdef val; + int ret; + runsdef val; - bifcntargs(ctx, 0, argc); - ret = exefuse(ctx->bifcxrun->runcxvoc, TRUE); - runpush(ctx->bifcxrun, runclog(ret), &val); + bifcntargs(ctx, 0, argc); + ret = exefuse(ctx->bifcxrun->runcxvoc, TRUE); + runpush(ctx->bifcxrun, runclog(ret), &val); } /* rundaemons */ void bifrud(bifcxdef *ctx, int argc) { - bifcntargs(ctx, 0, argc); - exedaem(ctx->bifcxrun->runcxvoc); + bifcntargs(ctx, 0, argc); + exedaem(ctx->bifcxrun->runcxvoc); } /* intersect */ void bifsct(bifcxdef *bifctx, int argc) { - runcxdef *ctx = bifctx->bifcxrun; - uchar *l1; - uchar *l2; - uchar *l3; - uint siz1; - uint siz2; - uint siz3; - uchar *p; - uint l; - uint dsz1; - uint dsz2; - runsdef val; - runsdef stk1, stk2; - - bifcntargs(bifctx, 2, argc); - l1 = runpoplst(ctx); - siz1 = osrp2(l1); - l2 = runpoplst(ctx); - siz2 = osrp2(l2); + runcxdef *ctx = bifctx->bifcxrun; + uchar *l1; + uchar *l2; + uchar *l3; + uint siz1; + uint siz2; + uint siz3; + uchar *p; + uint l; + uint dsz1; + uint dsz2; + runsdef val; + runsdef stk1, stk2; + + bifcntargs(bifctx, 2, argc); + l1 = runpoplst(ctx); + siz1 = osrp2(l1); + l2 = runpoplst(ctx); + siz2 = osrp2(l2); - /* make sure the first list is smaller - if not, switch them */ - if (siz1 > siz2) - l3 = l1, l1 = l2, l2 = l3, siz3 = siz1, siz1 = siz2, siz2 = siz3; - - /* size of result is at most size of smaller list (which is now siz1) */ - stk1.runstyp = stk2.runstyp = DAT_LIST; - stk1.runsv.runsvstr = l1; - stk2.runsv.runsvstr = l2; - runhres2(ctx, siz1, 2, &stk1, &stk2); - l1 = stk1.runsv.runsvstr; - l2 = stk2.runsv.runsvstr; - l3 = ctx->runcxhp + 2; + /* make sure the first list is smaller - if not, switch them */ + if (siz1 > siz2) + l3 = l1, l1 = l2, l2 = l3, siz3 = siz1, siz1 = siz2, siz2 = siz3; + + /* size of result is at most size of smaller list (which is now siz1) */ + stk1.runstyp = stk2.runstyp = DAT_LIST; + stk1.runsv.runsvstr = l1; + stk2.runsv.runsvstr = l2; + runhres2(ctx, siz1, 2, &stk1, &stk2); + l1 = stk1.runsv.runsvstr; + l2 = stk2.runsv.runsvstr; + l3 = ctx->runcxhp + 2; - /* go through list1, and copy each element that is found in list2 */ - for (l1 += 2, l2 += 2, siz1 -= 2, siz2 -= 2 ; siz1 ; lstadv(&l1, &siz1)) - { - dsz1 = datsiz(*l1, l1 + 1) + 1; - for (l = siz2, p = l2 ; l ; lstadv(&p, &l)) - { - dsz2 = datsiz(*p, p + 1) + 1; + /* go through list1, and copy each element that is found in list2 */ + for (l1 += 2, l2 += 2, siz1 -= 2, siz2 -= 2 ; siz1 ; lstadv(&l1, &siz1)) + { + dsz1 = datsiz(*l1, l1 + 1) + 1; + for (l = siz2, p = l2 ; l ; lstadv(&p, &l)) + { + dsz2 = datsiz(*p, p + 1) + 1; #ifndef AMIGA - if (dsz1 == dsz2 && !memcmp(l1, p, (size_t)dsz1)) + if (dsz1 == dsz2 && !memcmp(l1, p, (size_t)dsz1)) #else /* AMIGA */ - if (!memcmp(l1, p, (size_t)dsz1) && (dsz1 == dsz2) ) + if (!memcmp(l1, p, (size_t)dsz1) && (dsz1 == dsz2) ) #endif /* AMIGA */ - { - memcpy(l3, p, (size_t)dsz1); - l3 += dsz1; - break; - } - } - } - - /* set up return value, take it out of the heap, and push value */ - val.runsv.runsvstr = ctx->runcxhp; - val.runstyp = DAT_LIST; - oswp2(ctx->runcxhp, (uint)(l3 - ctx->runcxhp)); - ctx->runcxhp = l3; - runrepush(ctx, &val); + { + memcpy(l3, p, (size_t)dsz1); + l3 += dsz1; + break; + } + } + } + + /* set up return value, take it out of the heap, and push value */ + val.runsv.runsvstr = ctx->runcxhp; + val.runstyp = DAT_LIST; + oswp2(ctx->runcxhp, (uint)(l3 - ctx->runcxhp)); + ctx->runcxhp = l3; + runrepush(ctx, &val); } /* @@ -1975,39 +1975,39 @@ void bifsct(bifcxdef *bifctx, int argc) */ static const char *ext_key_names[] = { - "[up]", /* CMD_UP - 1 */ - "[down]", /* CMD_DOWN - 2 */ - "[right]", /* CMD_RIGHT - 3 */ - "[left]", /* CMD_LEFT - 4 */ - "[end]", /* CMD_END - 5 */ - "[home]", /* CMD_HOME - 6 */ - "[del-eol]", /* CMD_DEOL - 7 */ - "[del-line]", /* CMD_KILL - 8 */ - "[del]", /* CMD_DEL - 9 */ - "[scroll]", /* CMD_SCR - 10 */ - "[page up]", /* CMD_PGUP - 11 */ - "[page down]", /* CMD_PGDN - 12 */ - "[top]", /* CMD_TOP - 13 */ - "[bottom]", /* CMD_BOT - 14 */ - "[f1]", /* CMD_F1 - 15 */ - "[f2]", /* CMD_F2 - 16 */ - "[f3]", /* CMD_F3 - 17 */ - "[f4]", /* CMD_F4 - 18 */ - "[f5]", /* CMD_F5 - 19 */ - "[f6]", /* CMD_F6 - 20 */ - "[f7]", /* CMD_F7 - 21 */ - "[f8]", /* CMD_F8 - 22 */ - "[f9]", /* CMD_F9 - 23 */ - "[f10]", /* CMD_F10 - 24 */ - "[?]", /* invalid key - CMD_CHOME - 25 */ - "[tab]", /* CMD_TAB - 26 */ - "[?]", /* invalid key - shift-F2 - 27 */ - "[?]", /* not used (obsolete) - 28 */ - "[word-left]", /* CMD_WORD_LEFT - 29 */ - "[word-right]", /* CMD_WORD_RIGHT - 30 */ - "[del-word]", /* CMD_WORDKILL - 31 */ - "[eof]", /* CMD_EOF - 32 */ - "[break]" /* CMD_BREAK - 33 */ + "[up]", /* CMD_UP - 1 */ + "[down]", /* CMD_DOWN - 2 */ + "[right]", /* CMD_RIGHT - 3 */ + "[left]", /* CMD_LEFT - 4 */ + "[end]", /* CMD_END - 5 */ + "[home]", /* CMD_HOME - 6 */ + "[del-eol]", /* CMD_DEOL - 7 */ + "[del-line]", /* CMD_KILL - 8 */ + "[del]", /* CMD_DEL - 9 */ + "[scroll]", /* CMD_SCR - 10 */ + "[page up]", /* CMD_PGUP - 11 */ + "[page down]", /* CMD_PGDN - 12 */ + "[top]", /* CMD_TOP - 13 */ + "[bottom]", /* CMD_BOT - 14 */ + "[f1]", /* CMD_F1 - 15 */ + "[f2]", /* CMD_F2 - 16 */ + "[f3]", /* CMD_F3 - 17 */ + "[f4]", /* CMD_F4 - 18 */ + "[f5]", /* CMD_F5 - 19 */ + "[f6]", /* CMD_F6 - 20 */ + "[f7]", /* CMD_F7 - 21 */ + "[f8]", /* CMD_F8 - 22 */ + "[f9]", /* CMD_F9 - 23 */ + "[f10]", /* CMD_F10 - 24 */ + "[?]", /* invalid key - CMD_CHOME - 25 */ + "[tab]", /* CMD_TAB - 26 */ + "[?]", /* invalid key - shift-F2 - 27 */ + "[?]", /* not used (obsolete) - 28 */ + "[word-left]", /* CMD_WORD_LEFT - 29 */ + "[word-right]", /* CMD_WORD_RIGHT - 30 */ + "[del-word]", /* CMD_WORDKILL - 31 */ + "[eof]", /* CMD_EOF - 32 */ + "[break]" /* CMD_BREAK - 33 */ }; /* @@ -2040,414 +2040,414 @@ static const char *ext_key_names[] = */ static int get_ext_key_name(char *namebuf, int c, int extc) { - /* if it's a control character, translate it */ - if (c >= 1 && c <= 27) - { - switch(c) - { - case 10: - case 13: - /* return '\n' for LF and CR characters */ - strcpy(namebuf, "\\n"); - return TRUE; + /* if it's a control character, translate it */ + if (c >= 1 && c <= 27) + { + switch(c) + { + case 10: + case 13: + /* return '\n' for LF and CR characters */ + strcpy(namebuf, "\\n"); + return TRUE; - case 9: - /* return '\t' for TAB characters */ - strcpy(namebuf, "\\t"); - return TRUE; + case 9: + /* return '\t' for TAB characters */ + strcpy(namebuf, "\\t"); + return TRUE; - case 8: - /* return '[bksp]' for backspace characters */ - strcpy(namebuf, "[bksp]"); - return TRUE; + case 8: + /* return '[bksp]' for backspace characters */ + strcpy(namebuf, "[bksp]"); + return TRUE; - case 27: - /* return '[esc]' for the escape key */ - strcpy(namebuf, "[esc]"); - return TRUE; + case 27: + /* return '[esc]' for the escape key */ + strcpy(namebuf, "[esc]"); + return TRUE; - default: - /* return '[ctrl-X]' for other control characters */ - strcpy(namebuf, "[ctrl-X]"); - namebuf[6] = (char)(c + 'a' - 1); - return TRUE; - } - } + default: + /* return '[ctrl-X]' for other control characters */ + strcpy(namebuf, "[ctrl-X]"); + namebuf[6] = (char)(c + 'a' - 1); + return TRUE; + } + } - /* if it's any other non-extended key, return it as-is */ - if (c != 0) - { - namebuf[0] = c; - namebuf[1] = '\0'; - return TRUE; - } - - /* if it's in the key name array, use the array entry */ - if (extc >= 1 - && extc <= (int)(sizeof(ext_key_names)/sizeof(ext_key_names[0]))) - { - /* use the array name */ - strcpy(namebuf, ext_key_names[extc - 1]); - return TRUE; - } + /* if it's any other non-extended key, return it as-is */ + if (c != 0) + { + namebuf[0] = c; + namebuf[1] = '\0'; + return TRUE; + } + + /* if it's in the key name array, use the array entry */ + if (extc >= 1 + && extc <= (int)(sizeof(ext_key_names)/sizeof(ext_key_names[0]))) + { + /* use the array name */ + strcpy(namebuf, ext_key_names[extc - 1]); + return TRUE; + } - /* if it's in the ALT key range, generate an ALT key name */ - if (extc >= CMD_ALT && extc <= CMD_ALT + 25) - { - /* generate an ALT key name */ - strcpy(namebuf, "[alt-X]"); - namebuf[5] = (char)(extc - CMD_ALT + 'a'); - return TRUE; - } + /* if it's in the ALT key range, generate an ALT key name */ + if (extc >= CMD_ALT && extc <= CMD_ALT + 25) + { + /* generate an ALT key name */ + strcpy(namebuf, "[alt-X]"); + namebuf[5] = (char)(extc - CMD_ALT + 'a'); + return TRUE; + } - /* it's not a valid key - use '[?]' as the name */ - strcpy(namebuf, "[?]"); - return FALSE; + /* it's not a valid key - use '[?]' as the name */ + strcpy(namebuf, "[?]"); + return FALSE; } /* inputkey */ void bifink(bifcxdef *ctx, int argc) { - int c; - int extc; - char str[20]; - size_t len; - - bifcntargs(ctx, 0, argc); - tioflushn(ctx->bifcxtio, 0); + int c; + int extc; + char str[20]; + size_t len; + + bifcntargs(ctx, 0, argc); + tioflushn(ctx->bifcxtio, 0); - /* get a key */ - c = os_getc_raw(); + /* get a key */ + c = os_getc_raw(); - /* if it's extended, get the second part of the extended sequence */ - extc = (c == 0 ? os_getc_raw() : 0); + /* if it's extended, get the second part of the extended sequence */ + extc = (c == 0 ? os_getc_raw() : 0); - /* map the extended key name */ - get_ext_key_name(str, c, extc); + /* map the extended key name */ + get_ext_key_name(str, c, extc); - /* get the length of the name */ - len = strlen(str); + /* get the length of the name */ + len = strlen(str); - /* reset the [more] counter */ - outreset(); + /* reset the [more] counter */ + outreset(); - /* return the string, translating escapes */ - runpstr(ctx->bifcxrun, str, len, 0); + /* return the string, translating escapes */ + runpstr(ctx->bifcxrun, str, len, 0); } /* get direct/indirect object word list */ void bifwrd(bifcxdef *ctx, int argc) { - int ob; - vocoldef *v; - uchar buf[128]; - uchar *dst; - const uchar *src; - uint len; - runsdef val; - - bifcntargs(ctx, 1, argc); + int ob; + vocoldef *v; + uchar buf[128]; + uchar *dst; + const uchar *src; + uint len; + runsdef val; + + bifcntargs(ctx, 1, argc); - /* figure out what word list to get */ - ob = runpopnum(ctx->bifcxrun); - switch(ob) - { - case 1: - v = ctx->bifcxrun->runcxvoc->voccxdobj; - break; + /* figure out what word list to get */ + ob = runpopnum(ctx->bifcxrun); + switch(ob) + { + case 1: + v = ctx->bifcxrun->runcxvoc->voccxdobj; + break; - case 2: - v = ctx->bifcxrun->runcxvoc->voccxiobj; - break; + case 2: + v = ctx->bifcxrun->runcxvoc->voccxiobj; + break; - default: - runpnil(ctx->bifcxrun); - return; - } + default: + runpnil(ctx->bifcxrun); + return; + } - /* now build a list of strings from the words, if there are any */ - if (v != 0 && voclistlen(v) != 0 && v->vocolfst != 0 && v->vocollst != 0) - { - for (dst = buf + 2, src = (const uchar *)v->vocolfst ; - src <= (const uchar *)v->vocollst ; src += len + 1) - { - *dst++ = DAT_SSTRING; - len = strlen((const char *)src); - oswp2(dst, len + 2); - strcpy((char *)dst + 2, (const char *)src); - dst += len + 2; - } - } - else - dst = buf + 2; + /* now build a list of strings from the words, if there are any */ + if (v != 0 && voclistlen(v) != 0 && v->vocolfst != 0 && v->vocollst != 0) + { + for (dst = buf + 2, src = (const uchar *)v->vocolfst ; + src <= (const uchar *)v->vocollst ; src += len + 1) + { + *dst++ = DAT_SSTRING; + len = strlen((const char *)src); + oswp2(dst, len + 2); + strcpy((char *)dst + 2, (const char *)src); + dst += len + 2; + } + } + else + dst = buf + 2; - /* finish setting up the list length and return it */ - len = dst - buf; - oswp2(buf, len); - val.runsv.runsvstr = buf; - val.runstyp = DAT_LIST; - runpush(ctx->bifcxrun, DAT_LIST, &val); + /* finish setting up the list length and return it */ + len = dst - buf; + oswp2(buf, len); + val.runsv.runsvstr = buf; + val.runstyp = DAT_LIST; + runpush(ctx->bifcxrun, DAT_LIST, &val); } /* add a vocabulary word to an object */ void bifadw(bifcxdef *ctx, int argc) { - uchar *wrd; - objnum objn; - prpnum prpn; - vocidef *voci; - int classflg; - voccxdef *voc = ctx->bifcxrun->runcxvoc; + uchar *wrd; + objnum objn; + prpnum prpn; + vocidef *voci; + int classflg; + voccxdef *voc = ctx->bifcxrun->runcxvoc; - bifcntargs(ctx, 3, argc); + bifcntargs(ctx, 3, argc); - /* get the arguments */ - objn = runpopobj(ctx->bifcxrun); - prpn = runpopprp(ctx->bifcxrun); - wrd = runpopstr(ctx->bifcxrun); + /* get the arguments */ + objn = runpopobj(ctx->bifcxrun); + prpn = runpopprp(ctx->bifcxrun); + wrd = runpopstr(ctx->bifcxrun); - /* make sure the property is a valid part of speech property */ - if (!prpisvoc(prpn)) - runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "addword"); + /* make sure the property is a valid part of speech property */ + if (!prpisvoc(prpn)) + runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "addword"); - /* get the vocidef for the object, and see if it's a class object */ - voci = vocinh(voc, objn); + /* get the vocidef for the object, and see if it's a class object */ + voci = vocinh(voc, objn); - classflg = VOCFNEW; - if (voci->vociflg & VOCIFCLASS) classflg |= VOCFCLASS; + classflg = VOCFNEW; + if (voci->vociflg & VOCIFCLASS) classflg |= VOCFCLASS; - /* add the word */ - vocadd(voc, prpn, objn, classflg, (char *)wrd); + /* add the word */ + vocadd(voc, prpn, objn, classflg, (char *)wrd); - /* generate undo for the operation */ - vocdusave_addwrd(voc, objn, prpn, classflg, (char *)wrd); + /* generate undo for the operation */ + vocdusave_addwrd(voc, objn, prpn, classflg, (char *)wrd); } /* delete a vocabulary word from an object */ void bifdlw(bifcxdef *ctx, int argc) { - uchar *wrd; - objnum objn; - prpnum prpn; - voccxdef *voc = ctx->bifcxrun->runcxvoc; + uchar *wrd; + objnum objn; + prpnum prpn; + voccxdef *voc = ctx->bifcxrun->runcxvoc; - bifcntargs(ctx, 3, argc); + bifcntargs(ctx, 3, argc); - /* get the arguments */ - objn = runpopobj(ctx->bifcxrun); - prpn = runpopprp(ctx->bifcxrun); - wrd = runpopstr(ctx->bifcxrun); + /* get the arguments */ + objn = runpopobj(ctx->bifcxrun); + prpn = runpopprp(ctx->bifcxrun); + wrd = runpopstr(ctx->bifcxrun); - /* make sure the property is a valid part of speech property */ - if (!prpisvoc(prpn)) - runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "delword"); + /* make sure the property is a valid part of speech property */ + if (!prpisvoc(prpn)) + runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "delword"); - /* delete the word */ - vocdel1(voc, objn, (char *)wrd, prpn, FALSE, FALSE, TRUE); + /* delete the word */ + vocdel1(voc, objn, (char *)wrd, prpn, FALSE, FALSE, TRUE); } /* callback context for word list builder */ struct bifgtw_cb_ctx { - uchar *p; - int typ; + uchar *p; + int typ; }; /* callback for word list builder */ static void bifgtw_cb(void *ctx0, vocdef *voc, vocwdef *vocw) { - struct bifgtw_cb_ctx *ctx = (struct bifgtw_cb_ctx *)ctx0; + struct bifgtw_cb_ctx *ctx = (struct bifgtw_cb_ctx *)ctx0; - /* ignore deleted objects */ - if (vocw->vocwflg & VOCFDEL) - return; + /* ignore deleted objects */ + if (vocw->vocwflg & VOCFDEL) + return; - /* ignore objects of the inappropriate type */ - if (vocw->vocwtyp != ctx->typ) - return; - - /* the datatype is string */ - *ctx->p = DAT_SSTRING; + /* ignore objects of the inappropriate type */ + if (vocw->vocwtyp != ctx->typ) + return; + + /* the datatype is string */ + *ctx->p = DAT_SSTRING; - /* copy the first word */ - memcpy(ctx->p + 3, voc->voctxt, (size_t)voc->voclen); + /* copy the first word */ + memcpy(ctx->p + 3, voc->voctxt, (size_t)voc->voclen); - /* if there are two words, add a space and the second word */ - if (voc->vocln2) - { - *(ctx->p + 3 + voc->voclen) = ' '; - memcpy(ctx->p + 4 + voc->voclen, voc->voctxt + voc->voclen, - (size_t)voc->vocln2); - oswp2(ctx->p + 1, voc->voclen + voc->vocln2 + 3); - ctx->p += voc->voclen + voc->vocln2 + 4; - } - else - { - oswp2(ctx->p + 1, voc->voclen+2); - ctx->p += voc->voclen + 3; - } + /* if there are two words, add a space and the second word */ + if (voc->vocln2) + { + *(ctx->p + 3 + voc->voclen) = ' '; + memcpy(ctx->p + 4 + voc->voclen, voc->voctxt + voc->voclen, + (size_t)voc->vocln2); + oswp2(ctx->p + 1, voc->voclen + voc->vocln2 + 3); + ctx->p += voc->voclen + voc->vocln2 + 4; + } + else + { + oswp2(ctx->p + 1, voc->voclen+2); + ctx->p += voc->voclen + 3; + } } /* get the list of words for an object for a particular part of speech */ void bifgtw(bifcxdef *ctx, int argc) { - objnum objn; - prpnum prpn; - voccxdef *voc = ctx->bifcxrun->runcxvoc; - int cnt; - int siz; - runsdef val; - struct bifgtw_cb_ctx fnctx; + objnum objn; + prpnum prpn; + voccxdef *voc = ctx->bifcxrun->runcxvoc; + int cnt; + int siz; + runsdef val; + struct bifgtw_cb_ctx fnctx; - bifcntargs(ctx, 2, argc); + bifcntargs(ctx, 2, argc); - /* get the arguments */ - objn = runpopobj(ctx->bifcxrun); - prpn = runpopprp(ctx->bifcxrun); - - /* make sure the property is a valid part of speech property */ - if (!prpisvoc(prpn)) - runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "delword"); + /* get the arguments */ + objn = runpopobj(ctx->bifcxrun); + prpn = runpopprp(ctx->bifcxrun); + + /* make sure the property is a valid part of speech property */ + if (!prpisvoc(prpn)) + runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "delword"); - /* get the size of the list we'll need to build */ - voc_count(voc, objn, prpn, &cnt, &siz); + /* get the size of the list we'll need to build */ + voc_count(voc, objn, prpn, &cnt, &siz); - /* - * calculate how much space it will take to make a list out of all - * these words: 2 bytes for the list length header; plus, for each - * entry, 1 byte for the type header, 2 bytes for the string size - * header, and possibly one extra byte for the two-word separator -- - * a total of 4 bytes extra per word. - */ - siz += 2 + 4*cnt; + /* + * calculate how much space it will take to make a list out of all + * these words: 2 bytes for the list length header; plus, for each + * entry, 1 byte for the type header, 2 bytes for the string size + * header, and possibly one extra byte for the two-word separator -- + * a total of 4 bytes extra per word. + */ + siz += 2 + 4*cnt; - /* reserve the space */ - runhres(ctx->bifcxrun, siz, 0); + /* reserve the space */ + runhres(ctx->bifcxrun, siz, 0); - /* set up our callback context, and build the list */ - fnctx.p = ctx->bifcxrun->runcxhp + 2; - fnctx.typ = prpn; - voc_iterate(voc, objn, bifgtw_cb, &fnctx); + /* set up our callback context, and build the list */ + fnctx.p = ctx->bifcxrun->runcxhp + 2; + fnctx.typ = prpn; + voc_iterate(voc, objn, bifgtw_cb, &fnctx); - /* set up the return value */ - val.runstyp = DAT_LIST; - val.runsv.runsvstr = ctx->bifcxrun->runcxhp; + /* set up the return value */ + val.runstyp = DAT_LIST; + val.runsv.runsvstr = ctx->bifcxrun->runcxhp; - /* write the list length, and advance past the space we used */ - oswp2(ctx->bifcxrun->runcxhp, fnctx.p - ctx->bifcxrun->runcxhp); - ctx->bifcxrun->runcxhp = fnctx.p; + /* write the list length, and advance past the space we used */ + oswp2(ctx->bifcxrun->runcxhp, fnctx.p - ctx->bifcxrun->runcxhp); + ctx->bifcxrun->runcxhp = fnctx.p; - /* return the list */ - runrepush(ctx->bifcxrun, &val); + /* return the list */ + runrepush(ctx->bifcxrun, &val); } /* verbinfo service routine - add an object to the output list */ static uchar *bifvin_putprpn(uchar *p, prpnum prpn) { - *p++ = DAT_PROPNUM; - oswp2(p, prpn); - return p + 2; + *p++ = DAT_PROPNUM; + oswp2(p, prpn); + return p + 2; } /* verbinfo */ void bifvin(bifcxdef *ctx, int argc) { - objnum verb; - objnum prep; - uchar tplbuf[VOCTPL2SIZ]; - int newstyle; + objnum verb; + objnum prep; + uchar tplbuf[VOCTPL2SIZ]; + int newstyle; - /* get the verb */ - verb = runpopobj(ctx->bifcxrun); - - /* check for the presence of a preposition */ - if (argc == 1) - { - /* no preposition */ - prep = MCMONINV; - } - else - { - /* the second argument is the preposition */ - bifcntargs(ctx, 2, argc); - prep = runpopobj(ctx->bifcxrun); - } + /* get the verb */ + verb = runpopobj(ctx->bifcxrun); + + /* check for the presence of a preposition */ + if (argc == 1) + { + /* no preposition */ + prep = MCMONINV; + } + else + { + /* the second argument is the preposition */ + bifcntargs(ctx, 2, argc); + prep = runpopobj(ctx->bifcxrun); + } - /* look up the template */ - if (voctplfnd(ctx->bifcxrun->runcxvoc, verb, prep, tplbuf, &newstyle)) - { - prpnum prp_do, prp_verdo, prp_io, prp_verio; - int flg_dis_do; - ushort siz; - uchar *p; - runsdef val; + /* look up the template */ + if (voctplfnd(ctx->bifcxrun->runcxvoc, verb, prep, tplbuf, &newstyle)) + { + prpnum prp_do, prp_verdo, prp_io, prp_verio; + int flg_dis_do; + ushort siz; + uchar *p; + runsdef val; - /* get the information from the template */ - prp_do = voctpldo(tplbuf); - prp_verdo = voctplvd(tplbuf); - prp_io = voctplio(tplbuf); - prp_verio = voctplvi(tplbuf); - flg_dis_do = (voctplflg(tplbuf) & VOCTPLFLG_DOBJ_FIRST) != 0; + /* get the information from the template */ + prp_do = voctpldo(tplbuf); + prp_verdo = voctplvd(tplbuf); + prp_io = voctplio(tplbuf); + prp_verio = voctplvi(tplbuf); + flg_dis_do = (voctplflg(tplbuf) & VOCTPLFLG_DOBJ_FIRST) != 0; - /* - * figure space for the return value: if there's a prep, three - * property pointers plus a boolean, otherwise just two property - * pointers - */ - siz = 2 + 2*(2+1); - if (prep != MCMONINV) - siz += (2+1) + 1; + /* + * figure space for the return value: if there's a prep, three + * property pointers plus a boolean, otherwise just two property + * pointers + */ + siz = 2 + 2*(2+1); + if (prep != MCMONINV) + siz += (2+1) + 1; - /* reserve the space */ - runhres(ctx->bifcxrun, siz, 0); + /* reserve the space */ + runhres(ctx->bifcxrun, siz, 0); - /* build the output list */ - p = ctx->bifcxrun->runcxhp; - oswp2(p, siz); - p += 2; + /* build the output list */ + p = ctx->bifcxrun->runcxhp; + oswp2(p, siz); + p += 2; - p = bifvin_putprpn(p, prp_verdo); - if (prep == MCMONINV) - { - p = bifvin_putprpn(p, prp_do); - } - else - { - p = bifvin_putprpn(p, prp_verio); - p = bifvin_putprpn(p, prp_io); - *p++ = runclog(flg_dis_do); - } + p = bifvin_putprpn(p, prp_verdo); + if (prep == MCMONINV) + { + p = bifvin_putprpn(p, prp_do); + } + else + { + p = bifvin_putprpn(p, prp_verio); + p = bifvin_putprpn(p, prp_io); + *p++ = runclog(flg_dis_do); + } - /* build the return value */ - val.runstyp = DAT_LIST; - val.runsv.runsvstr = ctx->bifcxrun->runcxhp; + /* build the return value */ + val.runstyp = DAT_LIST; + val.runsv.runsvstr = ctx->bifcxrun->runcxhp; - /* consume the space */ - ctx->bifcxrun->runcxhp += siz; + /* consume the space */ + ctx->bifcxrun->runcxhp += siz; - /* return the list */ - runrepush(ctx->bifcxrun, &val); - } - else - { - /* no template for this verb - return nil */ - runpnil(ctx->bifcxrun); - } + /* return the list */ + runrepush(ctx->bifcxrun, &val); + } + else + { + /* no template for this verb - return nil */ + runpnil(ctx->bifcxrun); + } } /* clearscreen */ void bifcls(bifcxdef *ctx, int argc) { - /* this takes no arguments */ - bifcntargs(ctx, 0, argc); + /* this takes no arguments */ + bifcntargs(ctx, 0, argc); - /* flush any pending output */ - tioflushn(ctx->bifcxtio, 0); - - /* clear the screen */ - oscls(); + /* flush any pending output */ + tioflushn(ctx->bifcxtio, 0); + + /* clear the screen */ + oscls(); } /* @@ -2476,744 +2476,744 @@ void bifcls(bifcxdef *ctx, int argc) */ void biffopen(bifcxdef *ctx, int argc) { - char fname[OSFNMAX]; - uchar *p; - uchar *mode; - int modelen; - int fnum; - osfildef *fp; - int bin_mode = TRUE; /* flag: mode is binary (rather than text) */ - int rw_mode = FALSE; /* flag: both read and write are allowed */ - char main_mode; /* 'r' for read, 'w' for write */ - int in_same_dir; /* flag: file is in current directory */ - appctxdef *appctx; - - bifcntargs(ctx, 2, argc); + char fname[OSFNMAX]; + uchar *p; + uchar *mode; + int modelen; + int fnum; + osfildef *fp; + int bin_mode = TRUE; /* flag: mode is binary (rather than text) */ + int rw_mode = FALSE; /* flag: both read and write are allowed */ + char main_mode; /* 'r' for read, 'w' for write */ + int in_same_dir; /* flag: file is in current directory */ + appctxdef *appctx; + + bifcntargs(ctx, 2, argc); - /* get the filename */ - p = runpopstr(ctx->bifcxrun); - bifcstr(ctx, fname, (size_t)sizeof(fname), p); + /* get the filename */ + p = runpopstr(ctx->bifcxrun); + bifcstr(ctx, fname, (size_t)sizeof(fname), p); - /* - * If it's a relative path, combine it with the game file path to form - * the absolute path. This ensures that relative paths are always - * relative to the original working directory if the OS-level working - * directory has changed. - */ - if (!os_is_file_absolute(fname)) - { - /* combine the game file path with the relative filename */ - char newname[OSFNMAX]; - os_build_full_path(newname, sizeof(newname), - ctx->bifcxrun->runcxgamepath, fname); + /* + * If it's a relative path, combine it with the game file path to form + * the absolute path. This ensures that relative paths are always + * relative to the original working directory if the OS-level working + * directory has changed. + */ + if (!os_is_file_absolute(fname)) + { + /* combine the game file path with the relative filename */ + char newname[OSFNMAX]; + os_build_full_path(newname, sizeof(newname), + ctx->bifcxrun->runcxgamepath, fname); - /* replace the original filename with the full path */ - strcpy(fname, newname); - } + /* replace the original filename with the full path */ + strcpy(fname, newname); + } - /* get the mode string */ - mode = runpopstr(ctx->bifcxrun); - modelen = osrp2(mode) - 2; - mode += 2; - if (modelen < 1) - goto bad_mode; + /* get the mode string */ + mode = runpopstr(ctx->bifcxrun); + modelen = osrp2(mode) - 2; + mode += 2; + if (modelen < 1) + goto bad_mode; - /* allocate a filenum for the file */ - for (fnum = 0 ; fnum < BIFFILMAX ; ++fnum) - { - if (ctx->bifcxfile[fnum].fp == 0) - break; - } - if (fnum == BIFFILMAX) - { - /* return nil to indicate failure */ - runpnil(ctx->bifcxrun); - return; - } + /* allocate a filenum for the file */ + for (fnum = 0 ; fnum < BIFFILMAX ; ++fnum) + { + if (ctx->bifcxfile[fnum].fp == 0) + break; + } + if (fnum == BIFFILMAX) + { + /* return nil to indicate failure */ + runpnil(ctx->bifcxrun); + return; + } - /* parse the main mode */ - switch(*mode) - { - case 'w': - case 'W': - main_mode = 'w'; - break; + /* parse the main mode */ + switch(*mode) + { + case 'w': + case 'W': + main_mode = 'w'; + break; - case 'r': - case 'R': - main_mode = 'r'; - break; + case 'r': + case 'R': + main_mode = 'r'; + break; - default: - goto bad_mode; - } + default: + goto bad_mode; + } - /* skip the main mode, and check for a '+' flag */ - ++mode; - --modelen; - if (modelen > 0 && *mode == '+') - { - /* note the read/write mode */ - rw_mode = TRUE; + /* skip the main mode, and check for a '+' flag */ + ++mode; + --modelen; + if (modelen > 0 && *mode == '+') + { + /* note the read/write mode */ + rw_mode = TRUE; - /* skip the speciifer */ - ++mode; - --modelen; - } + /* skip the speciifer */ + ++mode; + --modelen; + } - /* check for a binary/text specifier */ - if (modelen > 0) - { - switch(*mode) - { - case 'b': - case 'B': - bin_mode = TRUE; - break; + /* check for a binary/text specifier */ + if (modelen > 0) + { + switch(*mode) + { + case 'b': + case 'B': + bin_mode = TRUE; + break; - case 't': - case 'T': - bin_mode = FALSE; - break; + case 't': + case 'T': + bin_mode = FALSE; + break; - default: - goto bad_mode; - } + default: + goto bad_mode; + } - /* skip the binary/text specifier */ - ++mode; - --modelen; - } + /* skip the binary/text specifier */ + ++mode; + --modelen; + } - /* it's an error if there's anything left unparsed */ - if (modelen > 0) - goto bad_mode; + /* it's an error if there's anything left unparsed */ + if (modelen > 0) + goto bad_mode; - /* - * If we have a host application context, and it provides a file - * safety level callback function, ask the host system for its - * current file safety level, which overrides our current setting. - */ - appctx = ctx->bifcxappctx; - if (appctx != 0 && appctx->get_io_safety_level != 0) - { - /* - * ask the host system for the current level, and override any - * setting we previously had - */ - (*appctx->get_io_safety_level)( - appctx->io_safety_level_ctx, - &ctx->bifcxsafetyr, &ctx->bifcxsafetyw); - } + /* + * If we have a host application context, and it provides a file + * safety level callback function, ask the host system for its + * current file safety level, which overrides our current setting. + */ + appctx = ctx->bifcxappctx; + if (appctx != 0 && appctx->get_io_safety_level != 0) + { + /* + * ask the host system for the current level, and override any + * setting we previously had + */ + (*appctx->get_io_safety_level)( + appctx->io_safety_level_ctx, + &ctx->bifcxsafetyr, &ctx->bifcxsafetyw); + } - /* - * Check to see if the file is in the current working directory - if - * not, we may have to disallow the operation based on safety level - * settings. - */ - in_same_dir = os_is_file_in_dir( - fname, ctx->bifcxrun->runcxgamepath, TRUE, FALSE); + /* + * Check to see if the file is in the current working directory - if + * not, we may have to disallow the operation based on safety level + * settings. + */ + in_same_dir = os_is_file_in_dir( + fname, ctx->bifcxrun->runcxgamepath, TRUE, FALSE); - /* check file safety settings */ - switch(main_mode) - { - case 'w': - /* - * writing - we must be at a safety level no higher than 2 - * (read/write current directory) to write at all, and we must be - * level 0 to write a file that's not in the current directory - */ - if (ctx->bifcxsafetyw > 2 - || (!in_same_dir && ctx->bifcxsafetyw > 0)) - { - /* this operation is not allowed - return failure */ - runpnil(ctx->bifcxrun); - return; - } - break; + /* check file safety settings */ + switch(main_mode) + { + case 'w': + /* + * writing - we must be at a safety level no higher than 2 + * (read/write current directory) to write at all, and we must be + * level 0 to write a file that's not in the current directory + */ + if (ctx->bifcxsafetyw > 2 + || (!in_same_dir && ctx->bifcxsafetyw > 0)) + { + /* this operation is not allowed - return failure */ + runpnil(ctx->bifcxrun); + return; + } + break; - case 'r': - /* - * reading - we must be at a safety level no higher than 3 (read - * current directory) to read at all, and we must be at safety - * level 1 (read any directory) or lower to read a file that's not - * in the current directory - */ - if (ctx->bifcxsafetyr > 3 - || (!in_same_dir && ctx->bifcxsafetyr > 1)) - { - /* this operation is not allowed - return failure */ - runpnil(ctx->bifcxrun); - return; - } - break; + case 'r': + /* + * reading - we must be at a safety level no higher than 3 (read + * current directory) to read at all, and we must be at safety + * level 1 (read any directory) or lower to read a file that's not + * in the current directory + */ + if (ctx->bifcxsafetyr > 3 + || (!in_same_dir && ctx->bifcxsafetyr > 1)) + { + /* this operation is not allowed - return failure */ + runpnil(ctx->bifcxrun); + return; + } + break; - default: - /* - * fail the operation, as a code maintenance measure to make - * sure that we add appropriate cases to this switch (even if - * merely to allow the operation unconditionally) in the event - * that more modes are added in the future - */ - goto bad_mode; - } + default: + /* + * fail the operation, as a code maintenance measure to make + * sure that we add appropriate cases to this switch (even if + * merely to allow the operation unconditionally) in the event + * that more modes are added in the future + */ + goto bad_mode; + } - /* try opening the file */ - switch(main_mode) - { - case 'w': - /* check for binary vs text mode */ - if (bin_mode) - { - /* - * binary mode -- allow read/write or just writing, but in - * either case truncate the file if it already exists, and - * create a new file if it doesn't exist - */ - if (rw_mode) - fp = osfoprwtb(fname, OSFTDATA); - else - fp = osfopwb(fname, OSFTDATA); - } - else - { - /* text mode - don't allow read/write on a text file */ - if (rw_mode) - goto bad_mode; + /* try opening the file */ + switch(main_mode) + { + case 'w': + /* check for binary vs text mode */ + if (bin_mode) + { + /* + * binary mode -- allow read/write or just writing, but in + * either case truncate the file if it already exists, and + * create a new file if it doesn't exist + */ + if (rw_mode) + fp = osfoprwtb(fname, OSFTDATA); + else + fp = osfopwb(fname, OSFTDATA); + } + else + { + /* text mode - don't allow read/write on a text file */ + if (rw_mode) + goto bad_mode; - /* open the file */ - fp = osfopwt(fname, OSFTTEXT); - } - break; + /* open the file */ + fp = osfopwt(fname, OSFTTEXT); + } + break; - case 'r': - /* check for binary vs text mode */ - if (bin_mode) - { - /* - * Binary mode -- allow read/write or just reading; leave - * any existing file intact. - */ - if (rw_mode) - { - /* open for reading and writing, keeping existing data */ - fp = osfoprwb(fname, OSFTDATA); - } - else - { - /* open for read-only */ - fp = osfoprb(fname, OSFTDATA); - } - } - else - { - /* text mode -- only allow reading */ - if (rw_mode) - goto bad_mode; + case 'r': + /* check for binary vs text mode */ + if (bin_mode) + { + /* + * Binary mode -- allow read/write or just reading; leave + * any existing file intact. + */ + if (rw_mode) + { + /* open for reading and writing, keeping existing data */ + fp = osfoprwb(fname, OSFTDATA); + } + else + { + /* open for read-only */ + fp = osfoprb(fname, OSFTDATA); + } + } + else + { + /* text mode -- only allow reading */ + if (rw_mode) + goto bad_mode; - /* open the file */ - fp = osfoprt(fname, OSFTTEXT); - } - break; + /* open the file */ + fp = osfoprt(fname, OSFTTEXT); + } + break; - default: - goto bad_mode; - } + default: + goto bad_mode; + } - /* if we couldn't open it, return nil */ - if (fp == 0) - { - runpnil(ctx->bifcxrun); - return; - } + /* if we couldn't open it, return nil */ + if (fp == 0) + { + runpnil(ctx->bifcxrun); + return; + } - /* store the flags */ - ctx->bifcxfile[fnum].flags = 0; - if (bin_mode) - ctx->bifcxfile[fnum].flags |= BIFFIL_F_BINARY; + /* store the flags */ + ctx->bifcxfile[fnum].flags = 0; + if (bin_mode) + ctx->bifcxfile[fnum].flags |= BIFFIL_F_BINARY; - /* remember the file handle */ - ctx->bifcxfile[fnum].fp = fp; + /* remember the file handle */ + ctx->bifcxfile[fnum].fp = fp; - /* return the file number (i.e., the slot number) */ - runpnum(ctx->bifcxrun, (long)fnum); - return; + /* return the file number (i.e., the slot number) */ + runpnum(ctx->bifcxrun, (long)fnum); + return; - /* come here on a mode error */ + /* come here on a mode error */ bad_mode: - runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "fopen"); + runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "fopen"); } - + /* service routine for file routines - get and validate a file number */ static osfildef *bif_get_file(bifcxdef *ctx, int *fnump, int *bin_modep) { - long fnum; + long fnum; - /* get the file number and make sure it's valid */ - fnum = runpopnum(ctx->bifcxrun); - if (fnum < 0 || fnum >= BIFFILMAX || ctx->bifcxfile[fnum].fp == 0) - runsig(ctx->bifcxrun, ERR_BADFILE); + /* get the file number and make sure it's valid */ + fnum = runpopnum(ctx->bifcxrun); + if (fnum < 0 || fnum >= BIFFILMAX || ctx->bifcxfile[fnum].fp == 0) + runsig(ctx->bifcxrun, ERR_BADFILE); - /* put the validated file number, if the caller wants it */ - if (fnump != 0) - *fnump = (int)fnum; + /* put the validated file number, if the caller wants it */ + if (fnump != 0) + *fnump = (int)fnum; - /* set the binary-mode flag, if the caller wants it */ - if (bin_modep != 0) - *bin_modep = ((ctx->bifcxfile[fnum].flags & BIFFIL_F_BINARY) != 0); + /* set the binary-mode flag, if the caller wants it */ + if (bin_modep != 0) + *bin_modep = ((ctx->bifcxfile[fnum].flags & BIFFIL_F_BINARY) != 0); - /* return the file array pointer */ - return ctx->bifcxfile[fnum].fp; + /* return the file array pointer */ + return ctx->bifcxfile[fnum].fp; } void biffclose(bifcxdef *ctx, int argc) { - int fnum; - osfildef *fp; + int fnum; + osfildef *fp; - /* get the file number */ - bifcntargs(ctx, 1, argc); - fp = bif_get_file(ctx, &fnum, 0); + /* get the file number */ + bifcntargs(ctx, 1, argc); + fp = bif_get_file(ctx, &fnum, 0); - /* close the file and release the slot */ - osfcls(fp); - ctx->bifcxfile[fnum].fp = 0; + /* close the file and release the slot */ + osfcls(fp); + ctx->bifcxfile[fnum].fp = 0; } - + void bifftell(bifcxdef *ctx, int argc) { - osfildef *fp; + osfildef *fp; - /* get the file number */ - bifcntargs(ctx, 1, argc); - fp = bif_get_file(ctx, (int *)0, 0); + /* get the file number */ + bifcntargs(ctx, 1, argc); + fp = bif_get_file(ctx, (int *)0, 0); - /* return the seek position */ - runpnum(ctx->bifcxrun, osfpos(fp)); + /* return the seek position */ + runpnum(ctx->bifcxrun, osfpos(fp)); } - + void biffseek(bifcxdef *ctx, int argc) { - osfildef *fp; - long pos; + osfildef *fp; + long pos; - /* get the file pointer */ - bifcntargs(ctx, 2, argc); - fp = bif_get_file(ctx, (int *)0, 0); + /* get the file pointer */ + bifcntargs(ctx, 2, argc); + fp = bif_get_file(ctx, (int *)0, 0); - /* get the seek position, and seek there */ - pos = runpopnum(ctx->bifcxrun); - osfseek(fp, pos, OSFSK_SET); + /* get the seek position, and seek there */ + pos = runpopnum(ctx->bifcxrun); + osfseek(fp, pos, OSFSK_SET); } - + void biffseekeof(bifcxdef *ctx, int argc) { - osfildef *fp; + osfildef *fp; - /* get the file pointer */ - bifcntargs(ctx, 1, argc); - fp = bif_get_file(ctx, (int *)0, 0); + /* get the file pointer */ + bifcntargs(ctx, 1, argc); + fp = bif_get_file(ctx, (int *)0, 0); - /* seek to the end */ - osfseek(fp, 0L, OSFSK_END); + /* seek to the end */ + osfseek(fp, 0L, OSFSK_END); } - + void biffwrite(bifcxdef *ctx, int argc) { - osfildef *fp; - char typ; - char buf[32]; - runsdef val; - int bin_mode; - - /* get the file */ - bifcntargs(ctx, 2, argc); - fp = bif_get_file(ctx, (int *)0, &bin_mode); + osfildef *fp; + char typ; + char buf[32]; + runsdef val; + int bin_mode; + + /* get the file */ + bifcntargs(ctx, 2, argc); + fp = bif_get_file(ctx, (int *)0, &bin_mode); - /* get the value to write */ - runpop(ctx->bifcxrun, &val); - typ = val.runstyp; + /* get the value to write */ + runpop(ctx->bifcxrun, &val); + typ = val.runstyp; - if (bin_mode) - { - /* put a byte indicating the type */ - if (osfwb(fp, &typ, 1)) - goto ret_error; - - /* see what type of data we want to put */ - switch(typ) - { - case DAT_NUMBER: - oswp4s(buf, val.runsv.runsvnum); - if (osfwb(fp, buf, 4)) - goto ret_error; - break; - - case DAT_SSTRING: - /* write the string, including the length prefix */ - if (osfwb(fp, val.runsv.runsvstr, osrp2(val.runsv.runsvstr))) - goto ret_error; - break; - - case DAT_TRUE: - /* all we need for this is the type prefix */ - break; - - default: - /* other types are not acceptable */ - runsig1(ctx->bifcxrun, ERR_INVTBIF, ERRTSTR, "fwrite"); - } - } - else - { - uint rem; - uchar *p; - - switch(typ) - { - case DAT_SSTRING: - /* - * Copy and translate the string to our buffer, in pieces if - * the size of the string exceeds that of our buffer. If we - * encounter any escape codes, translate them. - */ - rem = osrp2(val.runsv.runsvstr) - 2; - p = val.runsv.runsvstr + 2; - while (rem > 0) - { - uchar *dst; - uchar dbuf[256]; + if (bin_mode) + { + /* put a byte indicating the type */ + if (osfwb(fp, &typ, 1)) + goto ret_error; + + /* see what type of data we want to put */ + switch(typ) + { + case DAT_NUMBER: + oswp4s(buf, val.runsv.runsvnum); + if (osfwb(fp, buf, 4)) + goto ret_error; + break; + + case DAT_SSTRING: + /* write the string, including the length prefix */ + if (osfwb(fp, val.runsv.runsvstr, osrp2(val.runsv.runsvstr))) + goto ret_error; + break; + + case DAT_TRUE: + /* all we need for this is the type prefix */ + break; + + default: + /* other types are not acceptable */ + runsig1(ctx->bifcxrun, ERR_INVTBIF, ERRTSTR, "fwrite"); + } + } + else + { + uint rem; + uchar *p; + + switch(typ) + { + case DAT_SSTRING: + /* + * Copy and translate the string to our buffer, in pieces if + * the size of the string exceeds that of our buffer. If we + * encounter any escape codes, translate them. + */ + rem = osrp2(val.runsv.runsvstr) - 2; + p = val.runsv.runsvstr + 2; + while (rem > 0) + { + uchar *dst; + uchar dbuf[256]; - /* fill up the buffer */ - for (dst = dbuf ; - rem != 0 && (size_t)(dst - dbuf) < sizeof(dbuf) - 1 ; - ++p, --rem) - { - /* if we have an escape character, translate it */ - if (*p == '\\' && rem > 1) - { - /* skip the opening slash */ - ++p; - --rem; + /* fill up the buffer */ + for (dst = dbuf ; + rem != 0 && (size_t)(dst - dbuf) < sizeof(dbuf) - 1 ; + ++p, --rem) + { + /* if we have an escape character, translate it */ + if (*p == '\\' && rem > 1) + { + /* skip the opening slash */ + ++p; + --rem; - /* translate it */ - switch(*p) - { - case 'n': - *dst++ = '\n'; - break; + /* translate it */ + switch(*p) + { + case 'n': + *dst++ = '\n'; + break; - case 't': - *dst++ = '\t'; - break; + case 't': + *dst++ = '\t'; + break; - default: - *dst++ = *p; - break; - } - } - else - { - /* copy this character directly */ - *dst++ = *p; - } - } + default: + *dst++ = *p; + break; + } + } + else + { + /* copy this character directly */ + *dst++ = *p; + } + } - /* null-terminate the buffer */ - *dst = '\0'; + /* null-terminate the buffer */ + *dst = '\0'; - /* write it out */ - if (osfputs((char *)dbuf, fp) == EOF) - goto ret_error; - } + /* write it out */ + if (osfputs((char *)dbuf, fp) == EOF) + goto ret_error; + } - /* done */ - break; + /* done */ + break; - default: - /* other types are not allowed */ - runsig1(ctx->bifcxrun, ERR_INVTBIF, ERRTSTR, "fwrite"); - } - } + default: + /* other types are not allowed */ + runsig1(ctx->bifcxrun, ERR_INVTBIF, ERRTSTR, "fwrite"); + } + } - /* success */ - runpnil(ctx->bifcxrun); - return; + /* success */ + runpnil(ctx->bifcxrun); + return; ret_error: - val.runstyp = DAT_TRUE; - runpush(ctx->bifcxrun, DAT_TRUE, &val); + val.runstyp = DAT_TRUE; + runpush(ctx->bifcxrun, DAT_TRUE, &val); } - + void biffread(bifcxdef *ctx, int argc) { - osfildef *fp; - char typ; - char buf[32]; - runsdef val; - ushort len; - int bin_mode; + osfildef *fp; + char typ; + char buf[32]; + runsdef val; + ushort len; + int bin_mode; - /* get the file pointer */ - bifcntargs(ctx, 1, argc); - fp = bif_get_file(ctx, (int *)0, &bin_mode); + /* get the file pointer */ + bifcntargs(ctx, 1, argc); + fp = bif_get_file(ctx, (int *)0, &bin_mode); - if (bin_mode) - { - /* binary file - read the type byte */ - if (osfrb(fp, &typ, 1)) - goto ret_error; - - /* read the data according to the type */ - switch(typ) - { - case DAT_NUMBER: - if (osfrb(fp, buf, 4)) - goto ret_error; - runpnum(ctx->bifcxrun, osrp4s(buf)); - break; - - case DAT_SSTRING: - /* get the size */ - if (osfrb(fp, buf, 2)) - goto ret_error; - len = osrp2(buf); - - /* reserve space */ - runhres(ctx->bifcxrun, len, 0); - - /* read the string into the reserved space */ - if (osfrb(fp, ctx->bifcxrun->runcxhp + 2, len - 2)) - goto ret_error; - - /* set up the string */ - oswp2(ctx->bifcxrun->runcxhp, len); - val.runstyp = DAT_SSTRING; - val.runsv.runsvstr = ctx->bifcxrun->runcxhp; - - /* consume the space */ - ctx->bifcxrun->runcxhp += len; - - /* push the value */ - runrepush(ctx->bifcxrun, &val); - break; - - case DAT_TRUE: - val.runstyp = DAT_TRUE; - runpush(ctx->bifcxrun, DAT_TRUE, &val); - break; - - default: - goto ret_error; - } - } - else - { - uchar dbuf[257]; - uchar *dst; - uchar *src; - uint dlen; - uint res_total; - int found_nl; + if (bin_mode) + { + /* binary file - read the type byte */ + if (osfrb(fp, &typ, 1)) + goto ret_error; + + /* read the data according to the type */ + switch(typ) + { + case DAT_NUMBER: + if (osfrb(fp, buf, 4)) + goto ret_error; + runpnum(ctx->bifcxrun, osrp4s(buf)); + break; + + case DAT_SSTRING: + /* get the size */ + if (osfrb(fp, buf, 2)) + goto ret_error; + len = osrp2(buf); + + /* reserve space */ + runhres(ctx->bifcxrun, len, 0); + + /* read the string into the reserved space */ + if (osfrb(fp, ctx->bifcxrun->runcxhp + 2, len - 2)) + goto ret_error; + + /* set up the string */ + oswp2(ctx->bifcxrun->runcxhp, len); + val.runstyp = DAT_SSTRING; + val.runsv.runsvstr = ctx->bifcxrun->runcxhp; + + /* consume the space */ + ctx->bifcxrun->runcxhp += len; + + /* push the value */ + runrepush(ctx->bifcxrun, &val); + break; + + case DAT_TRUE: + val.runstyp = DAT_TRUE; + runpush(ctx->bifcxrun, DAT_TRUE, &val); + break; + + default: + goto ret_error; + } + } + else + { + uchar dbuf[257]; + uchar *dst; + uchar *src; + uint dlen; + uint res_total; + int found_nl; - /* - * reserve some space in the heap - we'll initially reserve - * space for twice our buffer, in case every single character - * needs to be expanded into an escape sequence - */ - res_total = sizeof(dbuf) * 2; - runhres(ctx->bifcxrun, res_total, 0); + /* + * reserve some space in the heap - we'll initially reserve + * space for twice our buffer, in case every single character + * needs to be expanded into an escape sequence + */ + res_total = sizeof(dbuf) * 2; + runhres(ctx->bifcxrun, res_total, 0); - /* set up our output value */ - val.runstyp = DAT_SSTRING; - val.runsv.runsvstr = ctx->bifcxrun->runcxhp; - dst = ctx->bifcxrun->runcxhp + 2; + /* set up our output value */ + val.runstyp = DAT_SSTRING; + val.runsv.runsvstr = ctx->bifcxrun->runcxhp; + dst = ctx->bifcxrun->runcxhp + 2; - /* keep going until we find a newline or run out of data */ - for (found_nl = FALSE ; !found_nl ; ) - { - /* text-mode - read the result into our buffer */ - if (!osfgets((char *)dbuf, sizeof(dbuf) - 1, fp)) - { - /* - * if we found a newline, return what we have; - * otherwise, return an error - */ - if (found_nl) - break; - else - goto ret_error; - } - - /* - * make sure it's null-terminated, in case the buffer was - * full - */ - dbuf[256] = '\0'; - - /* translate into the heap area we've reserved */ - for (src = dbuf ; *src != '\0' ; ++src, ++dst) - { - /* determine if we need translations */ - switch(*src) - { - case '\n': - case '\r': - /* translate to a newline sequence */ - *dst++ = '\\'; - *dst = 'n'; - - /* note that we've found our newline */ - found_nl = TRUE; - break; - - case '\t': - /* translate to a tab sequence */ - *dst++ = '\\'; - *dst = 't'; - break; - - case '\\': - /* expand to a double-backslash sequence */ - *dst++ = '\\'; - *dst = '\\'; - break; + /* keep going until we find a newline or run out of data */ + for (found_nl = FALSE ; !found_nl ; ) + { + /* text-mode - read the result into our buffer */ + if (!osfgets((char *)dbuf, sizeof(dbuf) - 1, fp)) + { + /* + * if we found a newline, return what we have; + * otherwise, return an error + */ + if (found_nl) + break; + else + goto ret_error; + } + + /* + * make sure it's null-terminated, in case the buffer was + * full + */ + dbuf[256] = '\0'; + + /* translate into the heap area we've reserved */ + for (src = dbuf ; *src != '\0' ; ++src, ++dst) + { + /* determine if we need translations */ + switch(*src) + { + case '\n': + case '\r': + /* translate to a newline sequence */ + *dst++ = '\\'; + *dst = 'n'; + + /* note that we've found our newline */ + found_nl = TRUE; + break; + + case '\t': + /* translate to a tab sequence */ + *dst++ = '\\'; + *dst = 't'; + break; + + case '\\': + /* expand to a double-backslash sequence */ + *dst++ = '\\'; + *dst = '\\'; + break; - default: - /* leave other characters intact */ - *dst = *src; - break; - } - } + default: + /* leave other characters intact */ + *dst = *src; + break; + } + } - /* - * If we didn't find the newline, we'll need more space. - * This is a bit tricky, because the space we've already set - * up may move if we compact the heap while asking for more - * space. So, remember our current length, reserve another - * buffer-full of space, and set everything up at the new - * output location if necessary. - */ - if (!found_nl) - { - /* reserve another buffer-full (double for expansion) */ - res_total += sizeof(dbuf) * 2; + /* + * If we didn't find the newline, we'll need more space. + * This is a bit tricky, because the space we've already set + * up may move if we compact the heap while asking for more + * space. So, remember our current length, reserve another + * buffer-full of space, and set everything up at the new + * output location if necessary. + */ + if (!found_nl) + { + /* reserve another buffer-full (double for expansion) */ + res_total += sizeof(dbuf) * 2; - /* note our current offset */ - dlen = dst - val.runsv.runsvstr; - oswp2(val.runsv.runsvstr, dlen); + /* note our current offset */ + dlen = dst - val.runsv.runsvstr; + oswp2(val.runsv.runsvstr, dlen); - /* ask for the space */ - runhres(ctx->bifcxrun, res_total, 0); + /* ask for the space */ + runhres(ctx->bifcxrun, res_total, 0); - /* - * Since we were at the top of the heap before, we - * should still be at the top of the heap. If not, - * we'll have to copy from our old location to the new - * top of the heap. - */ - if (val.runsv.runsvstr != ctx->bifcxrun->runcxhp) - { - /* copy our existing text to our new location */ - memmove(ctx->bifcxrun->runcxhp, val.runsv.runsvstr, dlen); + /* + * Since we were at the top of the heap before, we + * should still be at the top of the heap. If not, + * we'll have to copy from our old location to the new + * top of the heap. + */ + if (val.runsv.runsvstr != ctx->bifcxrun->runcxhp) + { + /* copy our existing text to our new location */ + memmove(ctx->bifcxrun->runcxhp, val.runsv.runsvstr, dlen); - /* fix up our pointer */ - val.runsv.runsvstr = ctx->bifcxrun->runcxhp; - } + /* fix up our pointer */ + val.runsv.runsvstr = ctx->bifcxrun->runcxhp; + } - /* re-establish our output pointer at our new location */ - dst = val.runsv.runsvstr + dlen; - } - } + /* re-establish our output pointer at our new location */ + dst = val.runsv.runsvstr + dlen; + } + } - /* finish setting up the string */ - dlen = dst - val.runsv.runsvstr; - oswp2(val.runsv.runsvstr, dlen); + /* finish setting up the string */ + dlen = dst - val.runsv.runsvstr; + oswp2(val.runsv.runsvstr, dlen); - /* consume the space */ - ctx->bifcxrun->runcxhp += dlen; + /* consume the space */ + ctx->bifcxrun->runcxhp += dlen; - /* push the value */ - runrepush(ctx->bifcxrun, &val); - } + /* push the value */ + runrepush(ctx->bifcxrun, &val); + } - /* success - we've already pushed the return value */ - return; + /* success - we've already pushed the return value */ + return; ret_error: - runpnil(ctx->bifcxrun); + runpnil(ctx->bifcxrun); } void bifcapture(bifcxdef *ctx, int argc) { - mcmcxdef *mcx = ctx->bifcxrun->runcxmem; - mcmon obj; - uint siz; - uint ofs; - uchar *p; + mcmcxdef *mcx = ctx->bifcxrun->runcxmem; + mcmon obj; + uint siz; + uint ofs; + uchar *p; - /* get the capture on/off flag */ - bifcntargs(ctx, 1, argc); - switch(runtostyp(ctx->bifcxrun)) - { - case DAT_TRUE: - /* turn on capturing */ - tiocapture(ctx->bifcxtio, mcx, TRUE); + /* get the capture on/off flag */ + bifcntargs(ctx, 1, argc); + switch(runtostyp(ctx->bifcxrun)) + { + case DAT_TRUE: + /* turn on capturing */ + tiocapture(ctx->bifcxtio, mcx, TRUE); - /* - * The return value is a status code used to restore the - * original status on the bracketing call to turn off output. - * The only status necessary is the current output size. - */ - siz = tiocapturesize(ctx->bifcxtio); - runpnum(ctx->bifcxrun, (long)siz); - break; + /* + * The return value is a status code used to restore the + * original status on the bracketing call to turn off output. + * The only status necessary is the current output size. + */ + siz = tiocapturesize(ctx->bifcxtio); + runpnum(ctx->bifcxrun, (long)siz); + break; - case DAT_NUMBER: - /* get the original offset */ - ofs = runpopnum(ctx->bifcxrun); + case DAT_NUMBER: + /* get the original offset */ + ofs = runpopnum(ctx->bifcxrun); - /* get the capture object and size */ - obj = tiogetcapture(ctx->bifcxtio); - siz = tiocapturesize(ctx->bifcxtio); - if (obj == MCMONINV) - { - runpnil(ctx->bifcxrun); - return; - } + /* get the capture object and size */ + obj = tiogetcapture(ctx->bifcxtio); + siz = tiocapturesize(ctx->bifcxtio); + if (obj == MCMONINV) + { + runpnil(ctx->bifcxrun); + return; + } - /* turn off capturing and reset the buffer on the outermost call */ - if (ofs == 0) - { - tiocapture(ctx->bifcxtio, mcx, FALSE); - tioclrcapture(ctx->bifcxtio); - } + /* turn off capturing and reset the buffer on the outermost call */ + if (ofs == 0) + { + tiocapture(ctx->bifcxtio, mcx, FALSE); + tioclrcapture(ctx->bifcxtio); + } - /* lock the object */ - p = mcmlck(mcx, obj); + /* lock the object */ + p = mcmlck(mcx, obj); - /* include only the part that happened after the matching call */ - p += ofs; - siz = (ofs > siz) ? 0 : siz - ofs; + /* include only the part that happened after the matching call */ + p += ofs; + siz = (ofs > siz) ? 0 : siz - ofs; - ERRBEGIN(ctx->bifcxerr) + ERRBEGIN(ctx->bifcxerr) - /* push the string onto the stack */ - runpstr(ctx->bifcxrun, (char *)p, siz, 0); - - ERRCLEAN(ctx->bifcxerr) - /* done with the object - unlock it */ - mcmunlck(mcx, obj); - ERRENDCLN(ctx->bifcxerr) + /* push the string onto the stack */ + runpstr(ctx->bifcxrun, (char *)p, siz, 0); + + ERRCLEAN(ctx->bifcxerr) + /* done with the object - unlock it */ + mcmunlck(mcx, obj); + ERRENDCLN(ctx->bifcxerr) - /* done with the object - unlock it */ - mcmunlck(mcx, obj); - break; + /* done with the object - unlock it */ + mcmunlck(mcx, obj); + break; - default: - runsig1(ctx->bifcxrun, ERR_INVTBIF, ERRTSTR, "outcapture"); - } + default: + runsig1(ctx->bifcxrun, ERR_INVTBIF, ERRTSTR, "outcapture"); + } } /* @@ -3221,138 +3221,138 @@ void bifcapture(bifcxdef *ctx, int argc) */ void bifsysinfo(bifcxdef *ctx, int argc) { - runsdef val; - int id; - long result; + runsdef val; + int id; + long result; - /* see what we have */ - switch(id = (int)runpopnum(ctx->bifcxrun)) - { - case SYSINFO_SYSINFO: - /* systemInfo call is supported in this version - return true */ - bifcntargs(ctx, 1, argc); - val.runstyp = DAT_TRUE; - runpush(ctx->bifcxrun, DAT_TRUE, &val); - break; + /* see what we have */ + switch(id = (int)runpopnum(ctx->bifcxrun)) + { + case SYSINFO_SYSINFO: + /* systemInfo call is supported in this version - return true */ + bifcntargs(ctx, 1, argc); + val.runstyp = DAT_TRUE; + runpush(ctx->bifcxrun, DAT_TRUE, &val); + break; - case SYSINFO_VERSION: - /* get the run-time version string */ - bifcntargs(ctx, 1, argc); - runpushcstr(ctx->bifcxrun, TADS_RUNTIME_VERSION, - strlen(TADS_RUNTIME_VERSION), 0); - break; + case SYSINFO_VERSION: + /* get the run-time version string */ + bifcntargs(ctx, 1, argc); + runpushcstr(ctx->bifcxrun, TADS_RUNTIME_VERSION, + strlen(TADS_RUNTIME_VERSION), 0); + break; - case SYSINFO_OS_NAME: - /* get the operating system name */ - bifcntargs(ctx, 1, argc); - runpushcstr(ctx->bifcxrun, OS_SYSTEM_NAME, strlen(OS_SYSTEM_NAME), 0); - break; - - case SYSINFO_HTML: - case SYSINFO_JPEG: - case SYSINFO_PNG: - case SYSINFO_WAV: - case SYSINFO_MIDI: - case SYSINFO_WAV_MIDI_OVL: - case SYSINFO_WAV_OVL: - case SYSINFO_PREF_IMAGES: - case SYSINFO_PREF_SOUNDS: - case SYSINFO_PREF_MUSIC: - case SYSINFO_PREF_LINKS: - case SYSINFO_MPEG: - case SYSINFO_MPEG1: - case SYSINFO_MPEG2: - case SYSINFO_MPEG3: - case SYSINFO_LINKS_HTTP: - case SYSINFO_LINKS_FTP: - case SYSINFO_LINKS_NEWS: - case SYSINFO_LINKS_MAILTO: - case SYSINFO_LINKS_TELNET: - case SYSINFO_PNG_TRANS: - case SYSINFO_PNG_ALPHA: - case SYSINFO_OGG: - case SYSINFO_MNG: - case SYSINFO_MNG_TRANS: - case SYSINFO_MNG_ALPHA: - case SYSINFO_TEXT_HILITE: - case SYSINFO_INTERP_CLASS: - /* - * these information types are all handled by the OS layer, and - * take no additional arguments - */ - bifcntargs(ctx, 1, argc); - if (os_get_sysinfo(id, 0, &result)) - { - /* we got a valid result - return it */ - runpnum(ctx->bifcxrun, result); - } - else - { - /* the code was unknown - return nil */ - runpnil(ctx->bifcxrun); - } - break; + case SYSINFO_OS_NAME: + /* get the operating system name */ + bifcntargs(ctx, 1, argc); + runpushcstr(ctx->bifcxrun, OS_SYSTEM_NAME, strlen(OS_SYSTEM_NAME), 0); + break; + + case SYSINFO_HTML: + case SYSINFO_JPEG: + case SYSINFO_PNG: + case SYSINFO_WAV: + case SYSINFO_MIDI: + case SYSINFO_WAV_MIDI_OVL: + case SYSINFO_WAV_OVL: + case SYSINFO_PREF_IMAGES: + case SYSINFO_PREF_SOUNDS: + case SYSINFO_PREF_MUSIC: + case SYSINFO_PREF_LINKS: + case SYSINFO_MPEG: + case SYSINFO_MPEG1: + case SYSINFO_MPEG2: + case SYSINFO_MPEG3: + case SYSINFO_LINKS_HTTP: + case SYSINFO_LINKS_FTP: + case SYSINFO_LINKS_NEWS: + case SYSINFO_LINKS_MAILTO: + case SYSINFO_LINKS_TELNET: + case SYSINFO_PNG_TRANS: + case SYSINFO_PNG_ALPHA: + case SYSINFO_OGG: + case SYSINFO_MNG: + case SYSINFO_MNG_TRANS: + case SYSINFO_MNG_ALPHA: + case SYSINFO_TEXT_HILITE: + case SYSINFO_INTERP_CLASS: + /* + * these information types are all handled by the OS layer, and + * take no additional arguments + */ + bifcntargs(ctx, 1, argc); + if (os_get_sysinfo(id, 0, &result)) + { + /* we got a valid result - return it */ + runpnum(ctx->bifcxrun, result); + } + else + { + /* the code was unknown - return nil */ + runpnil(ctx->bifcxrun); + } + break; - case SYSINFO_HTML_MODE: - /* ask the output formatter for its current HTML setting */ - bifcntargs(ctx, 1, argc); - val.runstyp = runclog(tio_is_html_mode()); - runpush(ctx->bifcxrun, val.runstyp, &val); - break; + case SYSINFO_HTML_MODE: + /* ask the output formatter for its current HTML setting */ + bifcntargs(ctx, 1, argc); + val.runstyp = runclog(tio_is_html_mode()); + runpush(ctx->bifcxrun, val.runstyp, &val); + break; - case SYSINFO_TEXT_COLORS: - /* - * Text colors are only supported in full HTML interpreters. If - * this is an HTML interpreter, ask the underlying OS layer about - * color support; otherwise, colors are not available, since we - * don't handle colors in our text-only HTML subset. - * - * Colors are NOT supported in the HTML mini-parser in text-only - * interpreters in TADS 2. So, even if we're running in HTML - * mode, if this is a text-only interpreter, we can't display text - * colors. - */ - bifcntargs(ctx, 1, argc); - if (os_get_sysinfo(SYSINFO_HTML, 0, &result) && result != 0) - { - /* - * we're in HTML mode, so ask the underlying HTML OS - * implementation for its level of text color support - */ - if (os_get_sysinfo(id, 0, &result)) - { - /* push the OS-level result */ - runpnum(ctx->bifcxrun, result); - } - else - { - /* the OS code doesn't recognize it; assume no support */ - runpnum(ctx->bifcxrun, SYSINFO_TXC_NONE); - } - } - else - { - /* we're a text-only interpreter - no color support */ - runpnum(ctx->bifcxrun, SYSINFO_TXC_NONE); - } - break; + case SYSINFO_TEXT_COLORS: + /* + * Text colors are only supported in full HTML interpreters. If + * this is an HTML interpreter, ask the underlying OS layer about + * color support; otherwise, colors are not available, since we + * don't handle colors in our text-only HTML subset. + * + * Colors are NOT supported in the HTML mini-parser in text-only + * interpreters in TADS 2. So, even if we're running in HTML + * mode, if this is a text-only interpreter, we can't display text + * colors. + */ + bifcntargs(ctx, 1, argc); + if (os_get_sysinfo(SYSINFO_HTML, 0, &result) && result != 0) + { + /* + * we're in HTML mode, so ask the underlying HTML OS + * implementation for its level of text color support + */ + if (os_get_sysinfo(id, 0, &result)) + { + /* push the OS-level result */ + runpnum(ctx->bifcxrun, result); + } + else + { + /* the OS code doesn't recognize it; assume no support */ + runpnum(ctx->bifcxrun, SYSINFO_TXC_NONE); + } + } + else + { + /* we're a text-only interpreter - no color support */ + runpnum(ctx->bifcxrun, SYSINFO_TXC_NONE); + } + break; - case SYSINFO_BANNERS: - /* TADS 2 does not offer banner support */ - bifcntargs(ctx, 1, argc); - runpnum(ctx->bifcxrun, 0); - break; - - default: - /* - * Other codes fail harmlessly with a nil return value. Pop all - * remaining arguments and return nil. - */ - for ( ; argc > 1 ; --argc) - rundisc(ctx->bifcxrun); - runpnil(ctx->bifcxrun); - break; - } + case SYSINFO_BANNERS: + /* TADS 2 does not offer banner support */ + bifcntargs(ctx, 1, argc); + runpnum(ctx->bifcxrun, 0); + break; + + default: + /* + * Other codes fail harmlessly with a nil return value. Pop all + * remaining arguments and return nil. + */ + for ( ; argc > 1 ; --argc) + rundisc(ctx->bifcxrun); + runpnil(ctx->bifcxrun); + break; + } } /* @@ -3360,12 +3360,12 @@ void bifsysinfo(bifcxdef *ctx, int argc) */ void bifmore(bifcxdef *ctx, int argc) { - /* this function takes no arguments */ - bifcntargs(ctx, 0, argc); + /* this function takes no arguments */ + bifcntargs(ctx, 0, argc); - /* display the MORE prompt */ - tioflushn(ctx->bifcxtio, 1); - out_more_prompt(); + /* display the MORE prompt */ + tioflushn(ctx->bifcxtio, 1); + out_more_prompt(); } /* @@ -3373,20 +3373,20 @@ void bifmore(bifcxdef *ctx, int argc) */ void bifsetme(bifcxdef *ctx, int argc) { - objnum new_me; - - /* this function takes one argument */ - bifcntargs(ctx, 1, argc); + objnum new_me; + + /* this function takes one argument */ + bifcntargs(ctx, 1, argc); - /* get the new "Me" object */ - new_me = runpopobj(ctx->bifcxrun); + /* get the new "Me" object */ + new_me = runpopobj(ctx->bifcxrun); - /* "Me" cannot be nil */ - if (new_me == MCMONINV) - runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "parserSetMe"); + /* "Me" cannot be nil */ + if (new_me == MCMONINV) + runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "parserSetMe"); - /* set the current "Me" object in the parser */ - voc_set_me(ctx->bifcxrun->runcxvoc, new_me); + /* set the current "Me" object in the parser */ + voc_set_me(ctx->bifcxrun->runcxvoc, new_me); } /* @@ -3394,11 +3394,11 @@ void bifsetme(bifcxdef *ctx, int argc) */ void bifgetme(bifcxdef *ctx, int argc) { - /* this function takes no arguments */ - bifcntargs(ctx, 0, argc); + /* this function takes no arguments */ + bifcntargs(ctx, 0, argc); - /* return the current Me object */ - runpobj(ctx->bifcxrun, ctx->bifcxrun->runcxvoc->voccxme); + /* return the current Me object */ + runpobj(ctx->bifcxrun, ctx->bifcxrun->runcxvoc->voccxme); } /* @@ -3406,181 +3406,181 @@ void bifgetme(bifcxdef *ctx, int argc) */ void bifresearch(bifcxdef *ctx, int argc) { - uchar *patstr; - size_t patlen; - uchar *searchstr; - size_t searchlen; - int result_len; - int match_ofs; - - /* this function takes two parameters: pattern, string */ - bifcntargs(ctx, 2, argc); + uchar *patstr; + size_t patlen; + uchar *searchstr; + size_t searchlen; + int result_len; + int match_ofs; + + /* this function takes two parameters: pattern, string */ + bifcntargs(ctx, 2, argc); - /* get the pattern string */ - patstr = runpopstr(ctx->bifcxrun); - patlen = osrp2(patstr) - 2; - patstr += 2; + /* get the pattern string */ + patstr = runpopstr(ctx->bifcxrun); + patlen = osrp2(patstr) - 2; + patstr += 2; - /* get the search string */ - searchstr = runpopstr(ctx->bifcxrun); - searchlen = osrp2(searchstr) - 2; - searchstr += 2; + /* get the search string */ + searchstr = runpopstr(ctx->bifcxrun); + searchlen = osrp2(searchstr) - 2; + searchstr += 2; - /* search for the pattern in the string */ - match_ofs = re_compile_and_search(&ctx->bifcxregex, - (char *)patstr, patlen, - (char *)searchstr, searchlen, - &result_len); + /* search for the pattern in the string */ + match_ofs = re_compile_and_search(&ctx->bifcxregex, + (char *)patstr, patlen, + (char *)searchstr, searchlen, + &result_len); - /* - * if we didn't match, return nil; otherwise, return a list with the - * match offset and length - */ - if (match_ofs < 0) - { - /* no match - return nil */ - runpnil(ctx->bifcxrun); - } - else - { - ushort listsiz; - runsdef val; - uchar *p; - - /* - * build a list consisting of two numbers and a string: two - * bytes for the list header, then two elements at (one byte for - * the datatype header, four bytes for the number), then the - * string element with (one byte for the datatype, two bytes for - * the string length prefix, and the bytes of the string) - */ - listsiz = 2 + (1+4)*2 + (1 + 2 + (ushort)(result_len)); + /* + * if we didn't match, return nil; otherwise, return a list with the + * match offset and length + */ + if (match_ofs < 0) + { + /* no match - return nil */ + runpnil(ctx->bifcxrun); + } + else + { + ushort listsiz; + runsdef val; + uchar *p; + + /* + * build a list consisting of two numbers and a string: two + * bytes for the list header, then two elements at (one byte for + * the datatype header, four bytes for the number), then the + * string element with (one byte for the datatype, two bytes for + * the string length prefix, and the bytes of the string) + */ + listsiz = 2 + (1+4)*2 + (1 + 2 + (ushort)(result_len)); - /* allocate the space */ - runhres(ctx->bifcxrun, listsiz, 0); + /* allocate the space */ + runhres(ctx->bifcxrun, listsiz, 0); - /* set up the list stack item */ - val.runstyp = DAT_LIST; - p = val.runsv.runsvstr = ctx->bifcxrun->runcxhp; + /* set up the list stack item */ + val.runstyp = DAT_LIST; + p = val.runsv.runsvstr = ctx->bifcxrun->runcxhp; - /* set the list's length */ - oswp2(p, listsiz); - p += 2; + /* set the list's length */ + oswp2(p, listsiz); + p += 2; - /* - * Add the offset element. For consistency with TADS - * conventions, use 1 as the offset of the first character in - * the string - this makes it easy to use the offset value with - * substr(). - */ - *p++ = DAT_NUMBER; - oswp4s(p, match_ofs + 1); - p += 4; + /* + * Add the offset element. For consistency with TADS + * conventions, use 1 as the offset of the first character in + * the string - this makes it easy to use the offset value with + * substr(). + */ + *p++ = DAT_NUMBER; + oswp4s(p, match_ofs + 1); + p += 4; - /* add the length element */ - *p++ = DAT_NUMBER; - oswp4s(p, result_len); - p += 4; + /* add the length element */ + *p++ = DAT_NUMBER; + oswp4s(p, result_len); + p += 4; - /* add the result string */ - *p++ = DAT_SSTRING; - oswp2(p, result_len + 2); - p += 2; - memcpy(p, ctx->bifcxregex.strbuf + match_ofs, result_len); + /* add the result string */ + *p++ = DAT_SSTRING; + oswp2(p, result_len + 2); + p += 2; + memcpy(p, ctx->bifcxregex.strbuf + match_ofs, result_len); - /* reserve the space in the heap */ - ctx->bifcxrun->runcxhp += listsiz; + /* reserve the space in the heap */ + ctx->bifcxrun->runcxhp += listsiz; - /* return the list */ - runrepush(ctx->bifcxrun, &val); - } + /* return the list */ + runrepush(ctx->bifcxrun, &val); + } } /* reGetGroup */ void bifregroup(bifcxdef *ctx, int argc) { - int grp; - size_t len; - re_group_register *reg; - ushort hplen; - runsdef val; - uchar *p; - long numval; - - /* this function takes one parameter: the group number to retrieve */ - bifcntargs(ctx, 1, argc); + int grp; + size_t len; + re_group_register *reg; + ushort hplen; + runsdef val; + uchar *p; + long numval; + + /* this function takes one parameter: the group number to retrieve */ + bifcntargs(ctx, 1, argc); - /* get the group number */ - grp = (int)runpopnum(ctx->bifcxrun); + /* get the group number */ + grp = (int)runpopnum(ctx->bifcxrun); - /* make sure it's within range */ - if (grp < 1 || grp > RE_GROUP_REG_CNT) - runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "reGetGroup"); + /* make sure it's within range */ + if (grp < 1 || grp > RE_GROUP_REG_CNT) + runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "reGetGroup"); - /* adjust from a 1-bias to an array index */ - --grp; + /* adjust from a 1-bias to an array index */ + --grp; - /* if the group was never set, return nil */ - if (grp >= ctx->bifcxregex.cur_group) - { - runpnil(ctx->bifcxrun); - return; - } + /* if the group was never set, return nil */ + if (grp >= ctx->bifcxregex.cur_group) + { + runpnil(ctx->bifcxrun); + return; + } - /* get the register */ - reg = &ctx->bifcxregex.regs[grp]; + /* get the register */ + reg = &ctx->bifcxregex.regs[grp]; - /* if the group wasn't set, return nil */ - if (reg->start_ofs == 0 || reg->end_ofs == 0) - { - runpnil(ctx->bifcxrun); - return; - } + /* if the group wasn't set, return nil */ + if (reg->start_ofs == 0 || reg->end_ofs == 0) + { + runpnil(ctx->bifcxrun); + return; + } - /* calculate the length of the string in this group */ - len = reg->end_ofs - reg->start_ofs; + /* calculate the length of the string in this group */ + len = reg->end_ofs - reg->start_ofs; - /* - * reserve the necessary heap space: two bytes for the list length - * prefix, two number elements (one byte each for the type, four - * bytes each for the value), and the string element (one byte for - * the type, two bytes for the length prefix, plus the string - * itself). - */ - hplen = (ushort)(2 + 2*(1+4) + (1 + 2 + len)); - runhres(ctx->bifcxrun, hplen, 0); + /* + * reserve the necessary heap space: two bytes for the list length + * prefix, two number elements (one byte each for the type, four + * bytes each for the value), and the string element (one byte for + * the type, two bytes for the length prefix, plus the string + * itself). + */ + hplen = (ushort)(2 + 2*(1+4) + (1 + 2 + len)); + runhres(ctx->bifcxrun, hplen, 0); - /* set up the stack value */ - val.runstyp = DAT_LIST; - p = val.runsv.runsvstr = ctx->bifcxrun->runcxhp; + /* set up the stack value */ + val.runstyp = DAT_LIST; + p = val.runsv.runsvstr = ctx->bifcxrun->runcxhp; - /* put in the list length prefix */ - oswp2(p, hplen); - p += 2; + /* put in the list length prefix */ + oswp2(p, hplen); + p += 2; - /* add the starting character position of the group - adjust to 1-bias */ - *p++ = DAT_NUMBER; - numval = (long)(reg->start_ofs - ctx->bifcxregex.strbuf) + 1; - oswp4s(p, numval); - p += 4; + /* add the starting character position of the group - adjust to 1-bias */ + *p++ = DAT_NUMBER; + numval = (long)(reg->start_ofs - ctx->bifcxregex.strbuf) + 1; + oswp4s(p, numval); + p += 4; - /* add the length of the group */ - *p++ = DAT_NUMBER; - numval = (long)(reg->end_ofs - reg->start_ofs); - oswp4s(p, numval); - p += 4; + /* add the length of the group */ + *p++ = DAT_NUMBER; + numval = (long)(reg->end_ofs - reg->start_ofs); + oswp4s(p, numval); + p += 4; - /* set up the string */ - *p++ = DAT_SSTRING; - oswp2(p, len+2); - p += 2; - memcpy(p, reg->start_ofs, len); + /* set up the string */ + *p++ = DAT_SSTRING; + oswp2(p, len+2); + p += 2; + memcpy(p, reg->start_ofs, len); - /* consume the heap space */ - ctx->bifcxrun->runcxhp += hplen; + /* consume the heap space */ + ctx->bifcxrun->runcxhp += hplen; - /* push the result */ - runrepush(ctx->bifcxrun, &val); + /* push the result */ + runrepush(ctx->bifcxrun, &val); } @@ -3590,174 +3590,174 @@ void bifregroup(bifcxdef *ctx, int argc) void bifinpevt(bifcxdef *ctx, int argc) { unsigned long timeout = 0; - int use_timeout = FALSE; - os_event_info_t info; - int evt; - uchar *p; - ushort lstsiz; - runsdef val; - size_t paramlen = 0; - char keyname[20]; - - /* check for a timeout value */ - if (argc == 0) - { - /* there's no timeout */ - use_timeout = FALSE; - timeout = 0; - } - else if (argc >= 1) - { - /* get the timeout value */ - use_timeout = TRUE; - timeout = (unsigned long)runpopnum(ctx->bifcxrun); - } + int use_timeout = FALSE; + os_event_info_t info; + int evt; + uchar *p; + ushort lstsiz; + runsdef val; + size_t paramlen = 0; + char keyname[20]; + + /* check for a timeout value */ + if (argc == 0) + { + /* there's no timeout */ + use_timeout = FALSE; + timeout = 0; + } + else if (argc >= 1) + { + /* get the timeout value */ + use_timeout = TRUE; + timeout = (unsigned long)runpopnum(ctx->bifcxrun); + } - /* ensure we don't have too many arguments */ - if (argc > 1) - runsig(ctx->bifcxrun, ERR_BIFARGC); + /* ensure we don't have too many arguments */ + if (argc > 1) + runsig(ctx->bifcxrun, ERR_BIFARGC); - /* flush any pending output */ - tioflushn(ctx->bifcxtio, 0); + /* flush any pending output */ + tioflushn(ctx->bifcxtio, 0); - /* reset count of lines since keyboard input */ - tioreset(ctx->bifcxtio); + /* reset count of lines since keyboard input */ + tioreset(ctx->bifcxtio); - /* ask the OS code for an event */ - evt = os_get_event(timeout, use_timeout, &info); + /* ask the OS code for an event */ + evt = os_get_event(timeout, use_timeout, &info); - /* - * the list always minimally needs two bytes of length prefix plus a - * number with the event code (one byte for the type, four bytes for - * the value) - */ - lstsiz = 2 + (1 + 4); + /* + * the list always minimally needs two bytes of length prefix plus a + * number with the event code (one byte for the type, four bytes for + * the value) + */ + lstsiz = 2 + (1 + 4); - /* figure out how much space we'll need based on the event type */ - switch(evt) - { - case OS_EVT_KEY: - /* - * we need space for a string with one or two bytes (depending - * on whether or not we have an extended key code) - 1 byte for - * type code, 2 for length prefix, and 1 or 2 for the string's - * contents - */ - paramlen = (info.key[0] == 0 ? 2 : 1); + /* figure out how much space we'll need based on the event type */ + switch(evt) + { + case OS_EVT_KEY: + /* + * we need space for a string with one or two bytes (depending + * on whether or not we have an extended key code) - 1 byte for + * type code, 2 for length prefix, and 1 or 2 for the string's + * contents + */ + paramlen = (info.key[0] == 0 ? 2 : 1); - /* map the extended key */ - get_ext_key_name(keyname, info.key[0], info.key[1]); + /* map the extended key */ + get_ext_key_name(keyname, info.key[0], info.key[1]); - /* determine the length we need for the string */ - paramlen = strlen(keyname); + /* determine the length we need for the string */ + paramlen = strlen(keyname); - /* add it into the list */ - lstsiz += 1 + 2 + paramlen; - break; + /* add it into the list */ + lstsiz += 1 + 2 + paramlen; + break; - case OS_EVT_HREF: - /* - * we need space for the href string - 1 byte for type code, 2 - * for length prefix, plus the string's contents - */ - paramlen = strlen(info.href); - lstsiz += 1 + 2 + (ushort)paramlen; - break; + case OS_EVT_HREF: + /* + * we need space for the href string - 1 byte for type code, 2 + * for length prefix, plus the string's contents + */ + paramlen = strlen(info.href); + lstsiz += 1 + 2 + (ushort)paramlen; + break; - default: - /* other event types have no extra data */ - break; - } + default: + /* other event types have no extra data */ + break; + } - /* allocate space for the list */ - runhres(ctx->bifcxrun, lstsiz, 0); + /* allocate space for the list */ + runhres(ctx->bifcxrun, lstsiz, 0); - /* set up the stack value */ - val.runstyp = DAT_LIST; - p = val.runsv.runsvstr = ctx->bifcxrun->runcxhp; + /* set up the stack value */ + val.runstyp = DAT_LIST; + p = val.runsv.runsvstr = ctx->bifcxrun->runcxhp; - /* set up the list length prefix */ - oswp2(p, lstsiz); - p += 2; + /* set up the list length prefix */ + oswp2(p, lstsiz); + p += 2; - /* set up the event type element */ - *p++ = DAT_NUMBER; - oswp4s(p, evt); - p += 4; + /* set up the event type element */ + *p++ = DAT_NUMBER; + oswp4s(p, evt); + p += 4; - /* add the event parameters, if any */ - switch(evt) - { - case OS_EVT_KEY: - /* set up the string for the key */ - *p++ = DAT_SSTRING; - oswp2(p, paramlen + 2); - p += 2; + /* add the event parameters, if any */ + switch(evt) + { + case OS_EVT_KEY: + /* set up the string for the key */ + *p++ = DAT_SSTRING; + oswp2(p, paramlen + 2); + p += 2; - /* add the characters to the string */ - memcpy(p, keyname, paramlen); - p += paramlen; - break; + /* add the characters to the string */ + memcpy(p, keyname, paramlen); + p += paramlen; + break; - case OS_EVT_HREF: - /* add the string for the href */ - *p++ = DAT_SSTRING; - oswp2(p, paramlen + 2); - memcpy(p + 2, info.href, paramlen); - break; - } + case OS_EVT_HREF: + /* add the string for the href */ + *p++ = DAT_SSTRING; + oswp2(p, paramlen + 2); + memcpy(p + 2, info.href, paramlen); + break; + } - /* consume the heap space */ - ctx->bifcxrun->runcxhp += lstsiz; + /* consume the heap space */ + ctx->bifcxrun->runcxhp += lstsiz; - /* push the result */ - runrepush(ctx->bifcxrun, &val); + /* push the result */ + runrepush(ctx->bifcxrun, &val); } /* timeDelay */ void bifdelay(bifcxdef *ctx, int argc) { - long delay; - - /* ensure we have the right number of arguments */ - bifcntargs(ctx, 1, argc); + long delay; + + /* ensure we have the right number of arguments */ + bifcntargs(ctx, 1, argc); - /* flush any pending output */ - tioflushn(ctx->bifcxtio, 0); + /* flush any pending output */ + tioflushn(ctx->bifcxtio, 0); - /* get the delay time */ - delay = runpopnum(ctx->bifcxrun); + /* get the delay time */ + delay = runpopnum(ctx->bifcxrun); - /* let the system perform the delay */ - os_sleep_ms(delay); + /* let the system perform the delay */ + os_sleep_ms(delay); } /* setOutputFilter */ void bifsetoutfilter(bifcxdef *ctx, int argc) { - /* ensure we have the right number of arguments */ - bifcntargs(ctx, 1, argc); + /* ensure we have the right number of arguments */ + bifcntargs(ctx, 1, argc); - /* see what we have */ - switch(runtostyp(ctx->bifcxrun)) - { - case DAT_NIL: - /* remove the current filter */ - out_set_filter(MCMONINV); + /* see what we have */ + switch(runtostyp(ctx->bifcxrun)) + { + case DAT_NIL: + /* remove the current filter */ + out_set_filter(MCMONINV); - /* discard the argument */ - rundisc(ctx->bifcxrun); - break; + /* discard the argument */ + rundisc(ctx->bifcxrun); + break; - case DAT_FNADDR: - /* set the filter to the given function */ - out_set_filter(runpopfn(ctx->bifcxrun)); - break; + case DAT_FNADDR: + /* set the filter to the given function */ + out_set_filter(runpopfn(ctx->bifcxrun)); + break; - default: - /* anything else is invalid */ - runsig1(ctx->bifcxrun, ERR_INVTBIF, ERRTSTR, "setOutputFilter"); - } + default: + /* anything else is invalid */ + runsig1(ctx->bifcxrun, ERR_INVTBIF, ERRTSTR, "setOutputFilter"); + } } /* @@ -3768,23 +3768,23 @@ void bifsetoutfilter(bifcxdef *ctx, int argc) */ static objnum bif_get_optional_obj_arg(bifcxdef *ctx, int *rem_argc) { - /* if we're out of arguments, there's no object value */ - if (*rem_argc == 0) - return MCMONINV; + /* if we're out of arguments, there's no object value */ + if (*rem_argc == 0) + return MCMONINV; - /* - * if the next argument is not an object or nil, we're out of object - * arguments - */ - if (runtostyp(ctx->bifcxrun) != DAT_OBJECT - && runtostyp(ctx->bifcxrun) != DAT_NIL) - return MCMONINV; + /* + * if the next argument is not an object or nil, we're out of object + * arguments + */ + if (runtostyp(ctx->bifcxrun) != DAT_OBJECT + && runtostyp(ctx->bifcxrun) != DAT_NIL) + return MCMONINV; - /* we have an object - remove it from the remaining argument count */ - --(*rem_argc); + /* we have an object - remove it from the remaining argument count */ + --(*rem_argc); - /* pop and return the object value */ - return runpopobjnil(ctx->bifcxrun); + /* pop and return the object value */ + return runpopobjnil(ctx->bifcxrun); } /* @@ -3800,149 +3800,149 @@ static objnum bif_get_optional_obj_arg(bifcxdef *ctx, int *rem_argc) */ void bifexec(bifcxdef *ctx, int argc) { - objnum actor; - objnum verb; - objnum dobj; - objnum prep; - objnum iobj; - int err; + objnum actor; + objnum verb; + objnum dobj; + objnum prep; + objnum iobj; + int err; uint capture_start = 0; - uint capture_end; - objnum capture_obj; - ulong flags; - int hide_any; - int rem_argc; - - /* - * Check for the correct argument count. The first two arguments - * are required; additional arguments are optional. - */ - if (argc < 2 || argc > 6) - runsig(ctx->bifcxrun, ERR_BIFARGC); + uint capture_end; + objnum capture_obj; + ulong flags; + int hide_any; + int rem_argc; + + /* + * Check for the correct argument count. The first two arguments + * are required; additional arguments are optional. + */ + if (argc < 2 || argc > 6) + runsig(ctx->bifcxrun, ERR_BIFARGC); - /* pop the arguments - actor, verb, dobj, prep, iobj */ - actor = runpopobjnil(ctx->bifcxrun); - verb = runpopobjnil(ctx->bifcxrun); + /* pop the arguments - actor, verb, dobj, prep, iobj */ + actor = runpopobjnil(ctx->bifcxrun); + verb = runpopobjnil(ctx->bifcxrun); - /* - * The other object arguments are optional. If we run into a - * numeric argument, it's the flags value, in which case we're out - * of objects. - */ - rem_argc = argc - 2; - dobj = bif_get_optional_obj_arg(ctx, &rem_argc); - prep = bif_get_optional_obj_arg(ctx, &rem_argc); - iobj = bif_get_optional_obj_arg(ctx, &rem_argc); + /* + * The other object arguments are optional. If we run into a + * numeric argument, it's the flags value, in which case we're out + * of objects. + */ + rem_argc = argc - 2; + dobj = bif_get_optional_obj_arg(ctx, &rem_argc); + prep = bif_get_optional_obj_arg(ctx, &rem_argc); + iobj = bif_get_optional_obj_arg(ctx, &rem_argc); - /* if we have a flags argument, pop it */ - if (rem_argc > 0) - { - /* the last argument is the flags - pop the numeric value */ - flags = runpopnum(ctx->bifcxrun); + /* if we have a flags argument, pop it */ + if (rem_argc > 0) + { + /* the last argument is the flags - pop the numeric value */ + flags = runpopnum(ctx->bifcxrun); - /* remove it from the remaining argument counter */ - --rem_argc; - } - else - { - /* no flags specified - use zero by default */ - flags = 0; - } + /* remove it from the remaining argument counter */ + --rem_argc; + } + else + { + /* no flags specified - use zero by default */ + flags = 0; + } - /* - * make sure we don't have any arguments left - if we do, then it - * means that we got an incorrect type and skipped an argument when - * we were trying to sense the meanings of the arguments from their - * types - */ - if (rem_argc != 0) - runsig1(ctx->bifcxrun, ERR_INVTBIF, ERRTSTR, "execCommand"); + /* + * make sure we don't have any arguments left - if we do, then it + * means that we got an incorrect type and skipped an argument when + * we were trying to sense the meanings of the arguments from their + * types + */ + if (rem_argc != 0) + runsig1(ctx->bifcxrun, ERR_INVTBIF, ERRTSTR, "execCommand"); - /* if we're hiding any output, start output capture */ - hide_any = ((flags & (EC_HIDE_SUCCESS | EC_HIDE_ERROR)) != 0); - if (hide_any) - { - /* start capturing */ - tiocapture(ctx->bifcxtio, ctx->bifcxrun->runcxmem, TRUE); + /* if we're hiding any output, start output capture */ + hide_any = ((flags & (EC_HIDE_SUCCESS | EC_HIDE_ERROR)) != 0); + if (hide_any) + { + /* start capturing */ + tiocapture(ctx->bifcxtio, ctx->bifcxrun->runcxmem, TRUE); - /* note the current output position */ - capture_start = tiocapturesize(ctx->bifcxtio); - } + /* note the current output position */ + capture_start = tiocapturesize(ctx->bifcxtio); + } - /* execute the command */ - err = execmd_recurs(ctx->bifcxrun->runcxvoc, - actor, verb, dobj, prep, iobj, - (flags & EC_SKIP_VALIDDO) == 0, - (flags & EC_SKIP_VALIDIO) == 0); + /* execute the command */ + err = execmd_recurs(ctx->bifcxrun->runcxvoc, + actor, verb, dobj, prep, iobj, + (flags & EC_SKIP_VALIDDO) == 0, + (flags & EC_SKIP_VALIDIO) == 0); - /* if we're hiding any output, end hiding */ - if (hide_any) - { - uchar *p; - int hide; - - /* get the capture buffer size */ - capture_end = tiocapturesize(ctx->bifcxtio); + /* if we're hiding any output, end hiding */ + if (hide_any) + { + uchar *p; + int hide; + + /* get the capture buffer size */ + capture_end = tiocapturesize(ctx->bifcxtio); - /* turn off capture if it wasn't already on when we started */ - if (capture_start == 0) - tiocapture(ctx->bifcxtio, ctx->bifcxrun->runcxmem, FALSE); + /* turn off capture if it wasn't already on when we started */ + if (capture_start == 0) + tiocapture(ctx->bifcxtio, ctx->bifcxrun->runcxmem, FALSE); - /* determine whether we're hiding or showing the result */ - if (err == 0) - hide = ((flags & EC_HIDE_SUCCESS) != 0); - else - hide = ((flags & EC_HIDE_ERROR) != 0); + /* determine whether we're hiding or showing the result */ + if (err == 0) + hide = ((flags & EC_HIDE_SUCCESS) != 0); + else + hide = ((flags & EC_HIDE_ERROR) != 0); - /* show or hide the result, as appropriate */ - if (hide) - { - /* - * We're hiding this result, so do not display the string. - * If there's an enclosing capture, remove the string from - * the enclosing capture. - */ - if (capture_start != 0) - tiopopcapture(ctx->bifcxtio, capture_start); - } - else - { - /* - * We're showing the text. If we're in an enclosing - * capture, do nothing - simply leave the string in the - * enclosing capture buffer; otherwise, actually display it - */ - if (capture_start == 0) - { - /* lock the capture object */ - capture_obj = tiogetcapture(ctx->bifcxtio); - p = mcmlck(ctx->bifcxrun->runcxmem, capture_obj); - - ERRBEGIN(ctx->bifcxerr) - { - /* display the string */ - outformatlen((char *)p + capture_start, - capture_end - capture_start); - } - ERRCLEAN(ctx->bifcxerr) - { - /* unlock the capture object before signalling out */ - mcmunlck(ctx->bifcxrun->runcxmem, capture_obj); - } - ERRENDCLN(ctx->bifcxerr); + /* show or hide the result, as appropriate */ + if (hide) + { + /* + * We're hiding this result, so do not display the string. + * If there's an enclosing capture, remove the string from + * the enclosing capture. + */ + if (capture_start != 0) + tiopopcapture(ctx->bifcxtio, capture_start); + } + else + { + /* + * We're showing the text. If we're in an enclosing + * capture, do nothing - simply leave the string in the + * enclosing capture buffer; otherwise, actually display it + */ + if (capture_start == 0) + { + /* lock the capture object */ + capture_obj = tiogetcapture(ctx->bifcxtio); + p = mcmlck(ctx->bifcxrun->runcxmem, capture_obj); + + ERRBEGIN(ctx->bifcxerr) + { + /* display the string */ + outformatlen((char *)p + capture_start, + capture_end - capture_start); + } + ERRCLEAN(ctx->bifcxerr) + { + /* unlock the capture object before signalling out */ + mcmunlck(ctx->bifcxrun->runcxmem, capture_obj); + } + ERRENDCLN(ctx->bifcxerr); - /* unlock the capture object */ - mcmunlck(ctx->bifcxrun->runcxmem, capture_obj); - } - } - - /* clear the capture buffer if it wasn't on when we started */ - if (capture_start == 0) - tioclrcapture(ctx->bifcxtio); - } + /* unlock the capture object */ + mcmunlck(ctx->bifcxrun->runcxmem, capture_obj); + } + } + + /* clear the capture buffer if it wasn't on when we started */ + if (capture_start == 0) + tioclrcapture(ctx->bifcxtio); + } - /* push the result code */ - runpnum(ctx->bifcxrun, err); + /* push the result code */ + runpnum(ctx->bifcxrun, err); } /* @@ -3950,83 +3950,83 @@ void bifexec(bifcxdef *ctx, int argc) */ void bifgetobj(bifcxdef *ctx, int argc) { - int id; + int id; objnum obj = 0; - voccxdef *voc = ctx->bifcxrun->runcxvoc; - - /* check the argument count */ - bifcntargs(ctx, 1, argc); + voccxdef *voc = ctx->bifcxrun->runcxvoc; + + /* check the argument count */ + bifcntargs(ctx, 1, argc); - /* get the argument */ - id = (int)runpopnum(ctx->bifcxrun); + /* get the argument */ + id = (int)runpopnum(ctx->bifcxrun); - /* get the appropriate object */ - switch(id) - { - case 1: - /* get the current actor */ - obj = voc->voccxactor; + /* get the appropriate object */ + switch(id) + { + case 1: + /* get the current actor */ + obj = voc->voccxactor; - /* if there's no current actor, use the current 'me' by default */ - if (obj == MCMONINV) - obj = voc->voccxme; + /* if there's no current actor, use the current 'me' by default */ + if (obj == MCMONINV) + obj = voc->voccxme; - /* done */ - break; + /* done */ + break; - case 2: - /* verb */ - obj = voc->voccxverb; - break; + case 2: + /* verb */ + obj = voc->voccxverb; + break; - case 3: - /* direct object */ - obj = (voc->voccxdobj == 0 ? MCMONINV : voc->voccxdobj->vocolobj); - break; + case 3: + /* direct object */ + obj = (voc->voccxdobj == 0 ? MCMONINV : voc->voccxdobj->vocolobj); + break; - case 4: - /* preposition */ - obj = voc->voccxprep; - break; + case 4: + /* preposition */ + obj = voc->voccxprep; + break; - case 5: - /* indirect object */ - obj = (voc->voccxiobj == 0 ? MCMONINV : voc->voccxiobj->vocolobj); - break; + case 5: + /* indirect object */ + obj = (voc->voccxiobj == 0 ? MCMONINV : voc->voccxiobj->vocolobj); + break; - case 6: - /* "it" */ - obj = voc->voccxit; - break; + case 6: + /* "it" */ + obj = voc->voccxit; + break; - case 7: - /* "him" */ - obj = voc->voccxhim; - break; + case 7: + /* "him" */ + obj = voc->voccxhim; + break; - case 8: - /* "her" */ - obj = voc->voccxher; - break; + case 8: + /* "her" */ + obj = voc->voccxher; + break; - case 9: - /* them */ - voc_push_objlist(voc, voc->voccxthm, voc->voccxthc); + case 9: + /* them */ + voc_push_objlist(voc, voc->voccxthm, voc->voccxthc); - /* - * return directly, since we've already pushed the result (it's - * a list, not an object) - */ - return; + /* + * return directly, since we've already pushed the result (it's + * a list, not an object) + */ + return; - default: - /* invalid argument */ - runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "parserGetObj"); - break; - } + default: + /* invalid argument */ + runsig1(ctx->bifcxrun, ERR_INVVBIF, ERRTSTR, "parserGetObj"); + break; + } - /* return the object */ - runpobj(ctx->bifcxrun, obj); + /* return the object */ + runpobj(ctx->bifcxrun, obj); } /* @@ -4037,11 +4037,11 @@ void bifgetobj(bifcxdef *ctx, int argc) */ void bifparsenl(bifcxdef *ctx, int argc) { - /* check the argument count */ - bifcntargs(ctx, 6, argc); + /* check the argument count */ + bifcntargs(ctx, 6, argc); - /* call the parser */ - voc_parse_np(ctx->bifcxrun->runcxvoc); + /* call the parser */ + voc_parse_np(ctx->bifcxrun->runcxvoc); } /* @@ -4052,11 +4052,11 @@ void bifparsenl(bifcxdef *ctx, int argc) */ void bifprstok(bifcxdef *ctx, int argc) { - /* check arguments */ - bifcntargs(ctx, 1, argc); + /* check arguments */ + bifcntargs(ctx, 1, argc); - /* call the parser */ - voc_parse_tok(ctx->bifcxrun->runcxvoc); + /* call the parser */ + voc_parse_tok(ctx->bifcxrun->runcxvoc); } /* @@ -4067,11 +4067,11 @@ void bifprstok(bifcxdef *ctx, int argc) */ void bifprstoktyp(bifcxdef *ctx, int argc) { - /* check arguments */ - bifcntargs(ctx, 1, argc); + /* check arguments */ + bifcntargs(ctx, 1, argc); - /* call the parser */ - voc_parse_types(ctx->bifcxrun->runcxvoc); + /* call the parser */ + voc_parse_types(ctx->bifcxrun->runcxvoc); } /* @@ -4082,11 +4082,11 @@ void bifprstoktyp(bifcxdef *ctx, int argc) */ void bifprsdict(bifcxdef *ctx, int argc) { - /* check arguments */ - bifcntargs(ctx, 2, argc); + /* check arguments */ + bifcntargs(ctx, 2, argc); - /* call the parser */ - voc_parse_dict_lookup(ctx->bifcxrun->runcxvoc); + /* call the parser */ + voc_parse_dict_lookup(ctx->bifcxrun->runcxvoc); } /* @@ -4098,11 +4098,11 @@ void bifprsdict(bifcxdef *ctx, int argc) */ void bifprsrslv(bifcxdef *ctx, int argc) { - /* check arguments */ - bifcntargs(ctx, 9, argc); + /* check arguments */ + bifcntargs(ctx, 9, argc); - /* call the parser */ - voc_parse_disambig(ctx->bifcxrun->runcxvoc); + /* call the parser */ + voc_parse_disambig(ctx->bifcxrun->runcxvoc); } /* @@ -4111,11 +4111,11 @@ void bifprsrslv(bifcxdef *ctx, int argc) */ void bifprsrplcmd(bifcxdef *ctx, int argc) { - /* check arguments */ - bifcntargs(ctx, 1, argc); + /* check arguments */ + bifcntargs(ctx, 1, argc); - /* call the parser */ - voc_parse_replace_cmd(ctx->bifcxrun->runcxvoc); + /* call the parser */ + voc_parse_replace_cmd(ctx->bifcxrun->runcxvoc); } /* @@ -4123,11 +4123,11 @@ void bifprsrplcmd(bifcxdef *ctx, int argc) */ void bifexitobj(bifcxdef *ctx, int argc) { - /* no arguments are allowed */ - bifcntargs(ctx, 0, argc); + /* no arguments are allowed */ + bifcntargs(ctx, 0, argc); - /* throw the RUNEXITOBJ error */ - errsig(ctx->bifcxerr, ERR_RUNEXITOBJ); + /* throw the RUNEXITOBJ error */ + errsig(ctx->bifcxerr, ERR_RUNEXITOBJ); } /* @@ -4143,154 +4143,154 @@ void bifexitobj(bifcxdef *ctx, int argc) */ void bifinpdlg(bifcxdef *ctx, int argc) { - uchar *p; - char prompt[256]; - char lblbuf[256]; - const char *labels[10]; - char *dst; - char *xp; - uint len; - size_t bcnt; - int default_resp, cancel_resp; - int resp; - int std_btns; - int icon_id; + uchar *p; + char prompt[256]; + char lblbuf[256]; + const char *labels[10]; + char *dst; + char *xp; + uint len; + size_t bcnt; + int default_resp, cancel_resp; + int resp; + int std_btns; + int icon_id; - /* check for proper arguments */ - bifcntargs(ctx, 5, argc); + /* check for proper arguments */ + bifcntargs(ctx, 5, argc); - /* get the icon number */ - icon_id = runpopnum(ctx->bifcxrun); + /* get the icon number */ + icon_id = runpopnum(ctx->bifcxrun); - /* get the prompt string */ - p = runpopstr(ctx->bifcxrun); - bifcstr(ctx, prompt, (size_t)sizeof(prompt), p); + /* get the prompt string */ + p = runpopstr(ctx->bifcxrun); + bifcstr(ctx, prompt, (size_t)sizeof(prompt), p); - /* translate from internal to local characters */ - for (xp = prompt ; *xp != '\0' ; xp++) - *xp = (char)cmap_i2n(*xp); + /* translate from internal to local characters */ + for (xp = prompt ; *xp != '\0' ; xp++) + *xp = (char)cmap_i2n(*xp); - /* check for a standard button set selection */ - if (runtostyp(ctx->bifcxrun) == DAT_NUMBER) - { - /* get the standard button set ID */ - std_btns = runpopnum(ctx->bifcxrun); + /* check for a standard button set selection */ + if (runtostyp(ctx->bifcxrun) == DAT_NUMBER) + { + /* get the standard button set ID */ + std_btns = runpopnum(ctx->bifcxrun); - /* there are no actual buttons */ - bcnt = 0; - } - else - { - /* we're not using standard buttons */ - std_btns = 0; - - /* get the response string list */ - p = runpoplst(ctx->bifcxrun); - len = osrp2(p); - p += 2; - - /* build our internal button list */ - for (bcnt = 0, dst = lblbuf ; len != 0 ; lstadv(&p, &len)) - { - /* see what we have */ - if (*p == DAT_SSTRING) - { - /* it's a label string - convert to a C string */ - bifcstr(ctx, dst, sizeof(lblbuf) - (dst - lblbuf), p + 1); + /* there are no actual buttons */ + bcnt = 0; + } + else + { + /* we're not using standard buttons */ + std_btns = 0; + + /* get the response string list */ + p = runpoplst(ctx->bifcxrun); + len = osrp2(p); + p += 2; + + /* build our internal button list */ + for (bcnt = 0, dst = lblbuf ; len != 0 ; lstadv(&p, &len)) + { + /* see what we have */ + if (*p == DAT_SSTRING) + { + /* it's a label string - convert to a C string */ + bifcstr(ctx, dst, sizeof(lblbuf) - (dst - lblbuf), p + 1); - /* translate from internal to local characters */ - for (xp = dst ; *xp != '\0' ; xp++) - *xp = (char)cmap_i2n(*xp); - - /* set this button to point to the converted text */ - labels[bcnt++] = dst; - - /* move past this label in the button buffer */ - dst += strlen(dst) + 1; - } - else if (*p == DAT_NUMBER) - { - int id; - int resid; - - /* it's a standard system label ID - get the ID */ - id = (int)osrp4s(p + 1); + /* translate from internal to local characters */ + for (xp = dst ; *xp != '\0' ; xp++) + *xp = (char)cmap_i2n(*xp); + + /* set this button to point to the converted text */ + labels[bcnt++] = dst; + + /* move past this label in the button buffer */ + dst += strlen(dst) + 1; + } + else if (*p == DAT_NUMBER) + { + int id; + int resid; + + /* it's a standard system label ID - get the ID */ + id = (int)osrp4s(p + 1); - /* translate it to the appropriate string resource */ - switch(id) - { - case BIFINPDLG_LBL_OK: - resid = RESID_BTN_OK; - break; - - case BIFINPDLG_LBL_CANCEL: - resid = RESID_BTN_CANCEL; - break; - - case BIFINPDLG_LBL_YES: - resid = RESID_BTN_YES; - break; - - case BIFINPDLG_LBL_NO: - resid = RESID_BTN_NO; - break; + /* translate it to the appropriate string resource */ + switch(id) + { + case BIFINPDLG_LBL_OK: + resid = RESID_BTN_OK; + break; + + case BIFINPDLG_LBL_CANCEL: + resid = RESID_BTN_CANCEL; + break; + + case BIFINPDLG_LBL_YES: + resid = RESID_BTN_YES; + break; + + case BIFINPDLG_LBL_NO: + resid = RESID_BTN_NO; + break; - default: - resid = 0; - break; - } + default: + resid = 0; + break; + } - /* - * if we got a valid resource ID, load the resource; - * otherwise, skip this button - */ - if (resid != 0 - && !os_get_str_rsc(resid, dst, - sizeof(lblbuf) - (dst - lblbuf))) - { - /* set this button to point to the converted text */ - labels[bcnt++] = dst; + /* + * if we got a valid resource ID, load the resource; + * otherwise, skip this button + */ + if (resid != 0 + && !os_get_str_rsc(resid, dst, + sizeof(lblbuf) - (dst - lblbuf))) + { + /* set this button to point to the converted text */ + labels[bcnt++] = dst; - /* move past this label in the button buffer */ - dst += strlen(dst) + 1; - } - } - - /* if we have exhausted our label array, stop now */ - if (bcnt >= sizeof(labels)/sizeof(labels[0]) - || dst >= lblbuf + sizeof(lblbuf)) - break; - } - } + /* move past this label in the button buffer */ + dst += strlen(dst) + 1; + } + } + + /* if we have exhausted our label array, stop now */ + if (bcnt >= sizeof(labels)/sizeof(labels[0]) + || dst >= lblbuf + sizeof(lblbuf)) + break; + } + } - /* get the default response */ - if (runtostyp(ctx->bifcxrun) == DAT_NIL) - { - rundisc(ctx->bifcxrun); - default_resp = 0; - } - else - default_resp = runpopnum(ctx->bifcxrun); + /* get the default response */ + if (runtostyp(ctx->bifcxrun) == DAT_NIL) + { + rundisc(ctx->bifcxrun); + default_resp = 0; + } + else + default_resp = runpopnum(ctx->bifcxrun); - /* get the cancel response */ - if (runtostyp(ctx->bifcxrun) == DAT_NIL) - { - rundisc(ctx->bifcxrun); - cancel_resp = 0; - } - else - cancel_resp = runpopnum(ctx->bifcxrun); + /* get the cancel response */ + if (runtostyp(ctx->bifcxrun) == DAT_NIL) + { + rundisc(ctx->bifcxrun); + cancel_resp = 0; + } + else + cancel_resp = runpopnum(ctx->bifcxrun); - /* flush output before showing the dialog */ - tioflushn(ctx->bifcxtio, 0); + /* flush output before showing the dialog */ + tioflushn(ctx->bifcxtio, 0); - /* show the dialog */ - resp = tio_input_dialog(icon_id, prompt, std_btns, - (const char **)labels, bcnt, - default_resp, cancel_resp); + /* show the dialog */ + resp = tio_input_dialog(icon_id, prompt, std_btns, + (const char **)labels, bcnt, + default_resp, cancel_resp); - /* return the result */ - runpnum(ctx->bifcxrun, resp); + /* return the result */ + runpnum(ctx->bifcxrun, resp); } /* @@ -4298,34 +4298,34 @@ void bifinpdlg(bifcxdef *ctx, int argc) */ void bifresexists(bifcxdef *ctx, int argc) { - uchar *p; - char resname[OSFNMAX]; - appctxdef *appctx; - int found; - runsdef val; - - /* check for proper arguments */ - bifcntargs(ctx, 1, argc); + uchar *p; + char resname[OSFNMAX]; + appctxdef *appctx; + int found; + runsdef val; + + /* check for proper arguments */ + bifcntargs(ctx, 1, argc); - /* get the resource name string */ - p = runpopstr(ctx->bifcxrun); - bifcstr(ctx, resname, (size_t)sizeof(resname), p); + /* get the resource name string */ + p = runpopstr(ctx->bifcxrun); + bifcstr(ctx, resname, (size_t)sizeof(resname), p); - /* - * if we have a host application context, and it provides a resource - * finder function, ask the resource finder if the resource is - * available; otherwise, report that the resource is not loadable, - * since we must not be running a version of the interpreter that - * supports external resource loading - */ - appctx = ctx->bifcxappctx; - found = (appctx != 0 - && appctx->resfile_exists != 0 - && (*appctx->resfile_exists)(appctx->resfile_exists_ctx, - resname, strlen(resname))); + /* + * if we have a host application context, and it provides a resource + * finder function, ask the resource finder if the resource is + * available; otherwise, report that the resource is not loadable, + * since we must not be running a version of the interpreter that + * supports external resource loading + */ + appctx = ctx->bifcxappctx; + found = (appctx != 0 + && appctx->resfile_exists != 0 + && (*appctx->resfile_exists)(appctx->resfile_exists_ctx, + resname, strlen(resname))); - /* push the result */ - runpush(ctx->bifcxrun, runclog(found), &val); + /* push the result */ + runpush(ctx->bifcxrun, runclog(found), &val); } } // End of namespace TADS2 diff --git a/engines/glk/tads/tads2/built_in.h b/engines/glk/tads/tads2/built_in.h index c735d5627f3..2b6efcc5de7 100644 --- a/engines/glk/tads/tads2/built_in.h +++ b/engines/glk/tads/tads2/built_in.h @@ -49,8 +49,8 @@ struct voccxdef; /* file contexts for the built-in file handling functions */ struct biffildef { - osfildef *fp; /* underyling system file handle */ - uint flags; /* flags */ + osfildef *fp; /* underyling system file handle */ + uint flags; /* flags */ #define BIFFIL_F_BINARY 0x01 /* file is binary */ biffildef() : fp(nullptr), flags(0) {} @@ -58,20 +58,20 @@ struct biffildef { /* built-in execution context */ struct bifcxdef { - errcxdef *bifcxerr; /* error-handling context */ - runcxdef *bifcxrun; /* code execution context */ - tiocxdef *bifcxtio; /* text I/O context */ - long bifcxrnd; /* random number seed */ - int bifcxseed1; /* first seed for new generator */ - int bifcxseed2; /* second seed for new generator */ - int bifcxseed3; /* third seed for new generator */ - int bifcxrndset; /* randomize() has been called */ - biffildef bifcxfile[BIFFILMAX]; /* file handles for fopen, etc */ - int bifcxsafetyr; /* file I/O safety level - read */ - int bifcxsafetyw; /* file I/O safety level - write */ - const char *bifcxsavext; /* saved game extension (null by default) */ - appctxdef *bifcxappctx; /* host application context */ - re_context bifcxregex; /* regular expression searching context */ + errcxdef *bifcxerr; /* error-handling context */ + runcxdef *bifcxrun; /* code execution context */ + tiocxdef *bifcxtio; /* text I/O context */ + long bifcxrnd; /* random number seed */ + int bifcxseed1; /* first seed for new generator */ + int bifcxseed2; /* second seed for new generator */ + int bifcxseed3; /* third seed for new generator */ + int bifcxrndset; /* randomize() has been called */ + biffildef bifcxfile[BIFFILMAX]; /* file handles for fopen, etc */ + int bifcxsafetyr; /* file I/O safety level - read */ + int bifcxsafetyw; /* file I/O safety level - write */ + const char *bifcxsavext; /* saved game extension (null by default) */ + appctxdef *bifcxappctx; /* host application context */ + re_context bifcxregex; /* regular expression searching context */ bifcxdef() : bifcxerr(nullptr), bifcxrun(nullptr), bifcxtio(nullptr), bifcxrnd(0), bifcxseed1(0), bifcxseed2(0), bifcxseed3(0), bifcxrndset(0), diff --git a/engines/glk/tads/tads2/character_map.cpp b/engines/glk/tads/tads2/character_map.cpp index 82fe865fa72..4cf24c86d62 100644 --- a/engines/glk/tads/tads2/character_map.cpp +++ b/engines/glk/tads/tads2/character_map.cpp @@ -61,24 +61,24 @@ static int S_cmap_loaded; */ void cmap_init_default(void) { - size_t i; + size_t i; - /* initialize the input table */ - for (i = 0 ; i < sizeof(G_cmap_input)/sizeof(G_cmap_input[0]) ; ++i) - G_cmap_input[i] = (unsigned char)i; + /* initialize the input table */ + for (i = 0 ; i < sizeof(G_cmap_input)/sizeof(G_cmap_input[0]) ; ++i) + G_cmap_input[i] = (unsigned char)i; - /* initialize the output table */ - for (i = 0 ; i < sizeof(G_cmap_output)/sizeof(G_cmap_output[0]) ; ++i) - G_cmap_output[i] = (unsigned char)i; + /* initialize the output table */ + for (i = 0 ; i < sizeof(G_cmap_output)/sizeof(G_cmap_output[0]) ; ++i) + G_cmap_output[i] = (unsigned char)i; - /* we have a null ID */ - memset(G_cmap_id, 0, sizeof(G_cmap_id)); + /* we have a null ID */ + memset(G_cmap_id, 0, sizeof(G_cmap_id)); - /* indicate that it's the default */ - strcpy(G_cmap_ldesc, "(native/no mapping)"); + /* indicate that it's the default */ + strcpy(G_cmap_ldesc, "(native/no mapping)"); - /* note that we have no character set loaded */ - S_cmap_loaded = FALSE; + /* note that we have no character set loaded */ + S_cmap_loaded = FALSE; } /* ------------------------------------------------------------------------ */ @@ -87,151 +87,151 @@ void cmap_init_default(void) */ static int cmap_load_internal(char *filename) { - osfildef *fp; - static char sig1[] = CMAP_SIG_S100; - char buf[256]; - uchar lenbuf[2]; - size_t len; - int sysblk; + osfildef *fp; + static char sig1[] = CMAP_SIG_S100; + char buf[256]; + uchar lenbuf[2]; + size_t len; + int sysblk; - /* if there's no mapping file, use the default mapping */ - if (filename == 0) - { - /* initialize with the default mapping */ - cmap_init_default(); + /* if there's no mapping file, use the default mapping */ + if (filename == 0) + { + /* initialize with the default mapping */ + cmap_init_default(); - /* return success */ - return 0; - } - - /* open the file */ - fp = osfoprb(filename, OSFTCMAP); - if (fp == 0) - return 1; + /* return success */ + return 0; + } + + /* open the file */ + fp = osfoprb(filename, OSFTCMAP); + if (fp == 0) + return 1; - /* check the signature */ - if (osfrb(fp, buf, sizeof(sig1)) - || memcmp(buf, sig1, sizeof(sig1)) != 0) - { - osfcls(fp); - return 2; - } + /* check the signature */ + if (osfrb(fp, buf, sizeof(sig1)) + || memcmp(buf, sig1, sizeof(sig1)) != 0) + { + osfcls(fp); + return 2; + } - /* load the ID */ - G_cmap_id[4] = '\0'; - if (osfrb(fp, G_cmap_id, 4)) - { - osfcls(fp); - return 3; - } + /* load the ID */ + G_cmap_id[4] = '\0'; + if (osfrb(fp, G_cmap_id, 4)) + { + osfcls(fp); + return 3; + } - /* load the long description */ - if (osfrb(fp, lenbuf, 2) - || (len = osrp2(lenbuf)) > sizeof(G_cmap_ldesc) - || osfrb(fp, G_cmap_ldesc, len)) - { - osfcls(fp); - return 4; - } + /* load the long description */ + if (osfrb(fp, lenbuf, 2) + || (len = osrp2(lenbuf)) > sizeof(G_cmap_ldesc) + || osfrb(fp, G_cmap_ldesc, len)) + { + osfcls(fp); + return 4; + } - /* load the two tables - input, then output */ - if (osfrb(fp, G_cmap_input, sizeof(G_cmap_input)) - || osfrb(fp, G_cmap_output, sizeof(G_cmap_output))) - { - osfcls(fp); - return 5; - } + /* load the two tables - input, then output */ + if (osfrb(fp, G_cmap_input, sizeof(G_cmap_input)) + || osfrb(fp, G_cmap_output, sizeof(G_cmap_output))) + { + osfcls(fp); + return 5; + } - /* read the next section header */ - if (osfrb(fp, buf, 4)) - { - osfcls(fp); - return 6; - } + /* read the next section header */ + if (osfrb(fp, buf, 4)) + { + osfcls(fp); + return 6; + } - /* if it's "SYSI", read the system information string */ - if (!memcmp(buf, "SYSI", 4)) - { - /* read the length prefix, then the string */ - if (osfrb(fp, lenbuf, 2) - || (len = osrp2(lenbuf)) > sizeof(buf) - || osfrb(fp, buf, len)) - { - osfcls(fp); - return 7; - } + /* if it's "SYSI", read the system information string */ + if (!memcmp(buf, "SYSI", 4)) + { + /* read the length prefix, then the string */ + if (osfrb(fp, lenbuf, 2) + || (len = osrp2(lenbuf)) > sizeof(buf) + || osfrb(fp, buf, len)) + { + osfcls(fp); + return 7; + } - /* we have a system information block */ - sysblk = TRUE; - } - else - { - /* there's no system information block */ - sysblk = FALSE; - } + /* we have a system information block */ + sysblk = TRUE; + } + else + { + /* there's no system information block */ + sysblk = FALSE; + } - /* - * call the OS code, so that it can do any system-dependent - * initialization for the new character mapping - */ - os_advise_load_charmap(G_cmap_id, G_cmap_ldesc, sysblk ? buf : ""); + /* + * call the OS code, so that it can do any system-dependent + * initialization for the new character mapping + */ + os_advise_load_charmap(G_cmap_id, G_cmap_ldesc, sysblk ? buf : ""); - /* read the next section header */ - if (sysblk && osfrb(fp, buf, 4)) - { - osfcls(fp); - return 8; - } + /* read the next section header */ + if (sysblk && osfrb(fp, buf, 4)) + { + osfcls(fp); + return 8; + } - /* see if we have an entity list */ - if (!memcmp(buf, "ENTY", 4)) - { - /* read the entities */ - for (;;) - { - size_t blen; - unsigned int cval; - char expansion[CMAP_MAX_ENTITY_EXPANSION]; - - /* read the next item's length and character value */ - if (osfrb(fp, buf, 4)) - { - osfcls(fp); - return 9; - } + /* see if we have an entity list */ + if (!memcmp(buf, "ENTY", 4)) + { + /* read the entities */ + for (;;) + { + size_t blen; + unsigned int cval; + char expansion[CMAP_MAX_ENTITY_EXPANSION]; + + /* read the next item's length and character value */ + if (osfrb(fp, buf, 4)) + { + osfcls(fp); + return 9; + } - /* decode the values */ - blen = osrp2(buf); - cval = osrp2(buf+2); + /* decode the values */ + blen = osrp2(buf); + cval = osrp2(buf+2); - /* if we've reached the zero marker, we're done */ - if (blen == 0 && cval == 0) - break; + /* if we've reached the zero marker, we're done */ + if (blen == 0 && cval == 0) + break; - /* read the string */ - if (blen > CMAP_MAX_ENTITY_EXPANSION - || osfrb(fp, expansion, blen)) - { - osfcls(fp); - return 10; - } + /* read the string */ + if (blen > CMAP_MAX_ENTITY_EXPANSION + || osfrb(fp, expansion, blen)) + { + osfcls(fp); + return 10; + } - /* tell the output code about the expansion */ - tio_set_html_expansion(cval, expansion, blen); - } - } + /* tell the output code about the expansion */ + tio_set_html_expansion(cval, expansion, blen); + } + } - /* - * ignore anything else we find - if the file format is updated to - * include extra information in the future, and this old code tries - * to load an updated file, we'll just ignore the new information, - * which should always be placed after the "SYSI" block (if present) - * to ensure compatibility with past versions (such as this code) - */ + /* + * ignore anything else we find - if the file format is updated to + * include extra information in the future, and this old code tries + * to load an updated file, we'll just ignore the new information, + * which should always be placed after the "SYSI" block (if present) + * to ensure compatibility with past versions (such as this code) + */ - /* no problems - close the file and return success */ - osfcls(fp); - return 0; + /* no problems - close the file and return success */ + osfcls(fp); + return 0; } @@ -244,22 +244,22 @@ static int cmap_load_internal(char *filename) */ int cmap_load(char *filename) { - int err; - - /* try loading the file */ - if ((err = cmap_load_internal(filename)) != 0) - return err; + int err; + + /* try loading the file */ + if ((err = cmap_load_internal(filename)) != 0) + return err; - /* - * note that we've explicitly loaded a character set, if they named - * a character set (if not, this simply establishes the default - * setting, so we haven't explicitly loaded anything) - */ - if (filename != 0) - S_cmap_loaded = TRUE; + /* + * note that we've explicitly loaded a character set, if they named + * a character set (if not, this simply establishes the default + * setting, so we haven't explicitly loaded anything) + */ + if (filename != 0) + S_cmap_loaded = TRUE; - /* success */ - return 0; + /* success */ + return 0; } @@ -270,14 +270,14 @@ int cmap_load(char *filename) */ void cmap_override(void) { - /* apply the default mapping */ - cmap_init_default(); + /* apply the default mapping */ + cmap_init_default(); - /* - * pretend we have a character map loaded, so that we don't try to - * load another one if the game specifies a character set - */ - S_cmap_loaded = TRUE; + /* + * pretend we have a character map loaded, so that we don't try to + * load another one if the game specifies a character set + */ + S_cmap_loaded = TRUE; } @@ -287,52 +287,52 @@ void cmap_override(void) * loaded, and the game specifies a character set. */ void cmap_set_game_charset(errcxdef *ec, - char *internal_id, char *internal_ldesc, - char *argv0) + char *internal_id, char *internal_ldesc, + char *argv0) { - char filename[OSFNMAX]; - - /* - * If a character set is already explicitly loaded, ignore the - * game's character set - the player asked us to use a particular - * mapping, so ignore what the game wants. (This will probably - * result in incorrect display of non-ASCII character values, but - * the player is most likely to use this to avoid errors when an - * appropriate mapping file for the game is not available. In this - * case, the player informs us by setting the option that he or she - * knows and accepts that the game will not look exactly right.) - */ - if (S_cmap_loaded) - return; + char filename[OSFNMAX]; + + /* + * If a character set is already explicitly loaded, ignore the + * game's character set - the player asked us to use a particular + * mapping, so ignore what the game wants. (This will probably + * result in incorrect display of non-ASCII character values, but + * the player is most likely to use this to avoid errors when an + * appropriate mapping file for the game is not available. In this + * case, the player informs us by setting the option that he or she + * knows and accepts that the game will not look exactly right.) + */ + if (S_cmap_loaded) + return; - /* - * ask the operating system to name the mapping file -- this routine - * will determine, if possible, the current native character set, - * and apply a system-specific naming convention to tell us what - * mapping file we should open - */ - os_gen_charmap_filename(filename, internal_id, argv0); + /* + * ask the operating system to name the mapping file -- this routine + * will determine, if possible, the current native character set, + * and apply a system-specific naming convention to tell us what + * mapping file we should open + */ + os_gen_charmap_filename(filename, internal_id, argv0); - /* try loading the mapping file */ - if (cmap_load_internal(filename)) - errsig2(ec, ERR_CHRNOFILE, - ERRTSTR, errstr(ec, filename, strlen(filename)), - ERRTSTR, errstr(ec, internal_ldesc, strlen(internal_ldesc))); + /* try loading the mapping file */ + if (cmap_load_internal(filename)) + errsig2(ec, ERR_CHRNOFILE, + ERRTSTR, errstr(ec, filename, strlen(filename)), + ERRTSTR, errstr(ec, internal_ldesc, strlen(internal_ldesc))); - /* - * We were successful - the game's internal character set is now - * mapped to the current native character set. Even though we - * loaded an ldesc from the mapping file, forget that and store the - * internal ldesc that the game specified. The reason we do this is - * that it's possible that the player will dynamically switch native - * character sets in the future, at which point we'll need to - * re-load the mapping table, which could raise an error if a - * mapping file for the new character set isn't available. So, we - * may need to provide the same explanation later that we needed to - * provide here. Save the game's character set ldesc for that - * eventuality, since it describes exactly what the *game* wanted. - */ - strcpy(G_cmap_ldesc, internal_ldesc); + /* + * We were successful - the game's internal character set is now + * mapped to the current native character set. Even though we + * loaded an ldesc from the mapping file, forget that and store the + * internal ldesc that the game specified. The reason we do this is + * that it's possible that the player will dynamically switch native + * character sets in the future, at which point we'll need to + * re-load the mapping table, which could raise an error if a + * mapping file for the new character set isn't available. So, we + * may need to provide the same explanation later that we needed to + * provide here. Save the game's character set ldesc for that + * eventuality, since it describes exactly what the *game* wanted. + */ + strcpy(G_cmap_ldesc, internal_ldesc); } } // End of namespace TADS2 diff --git a/engines/glk/tads/tads2/character_map.h b/engines/glk/tads/tads2/character_map.h index c61406fd279..589cf3fef78 100644 --- a/engines/glk/tads/tads2/character_map.h +++ b/engines/glk/tads/tads2/character_map.h @@ -68,8 +68,8 @@ void cmap_override(void); * as the TADS executables. */ void cmap_set_game_charset(struct errcxdef *errctx, - char *internal_id, char *internal_ldesc, - char *argv0); + char *internal_id, char *internal_ldesc, + char *argv0); /* ------------------------------------------------------------------------ */ diff --git a/engines/glk/tads/tads2/command_line.cpp b/engines/glk/tads/tads2/command_line.cpp index c6bd5e0ddaa..3e62f8e616c 100644 --- a/engines/glk/tads/tads2/command_line.cpp +++ b/engines/glk/tads/tads2/command_line.cpp @@ -28,58 +28,58 @@ namespace TADS2 { /* get a toggle argument */ int cmdtog(errcxdef *ec, int prv, char *argp, int ofs, - void (*usagefn)(errcxdef *)) + void (*usagefn)(errcxdef *)) { - switch(argp[ofs + 1]) - { - case '+': - return(TRUE); - - case '-': - return(FALSE); - - case '\0': - return(!prv); - - default: - /* invalid - display usage if we have a callback for it */ - if (usagefn != 0) - (*usagefn)(ec); - NOTREACHEDV(int); - return 0; - } + switch(argp[ofs + 1]) + { + case '+': + return(TRUE); + + case '-': + return(FALSE); + + case '\0': + return(!prv); + + default: + /* invalid - display usage if we have a callback for it */ + if (usagefn != 0) + (*usagefn)(ec); + NOTREACHEDV(int); + return 0; + } } /* get an argument to a switch */ char *cmdarg(errcxdef *ec, char ***argpp, int *ip, int argc, int ofs, - void (*usagefn)(errcxdef *)) + void (*usagefn)(errcxdef *)) { - char *ret; + char *ret; - /* - * check to see if the argument is appended directly to the option; - * if not, look at the next string - */ - ret = (**argpp) + ofs + 1; - if (*ret == '\0') - { - /* - * it's not part of this string - get the argument from the next - * string in the vector - */ - ++(*ip); - ++(*argpp); - ret = (*ip >= argc ? 0 : **argpp); - } + /* + * check to see if the argument is appended directly to the option; + * if not, look at the next string + */ + ret = (**argpp) + ofs + 1; + if (*ret == '\0') + { + /* + * it's not part of this string - get the argument from the next + * string in the vector + */ + ++(*ip); + ++(*argpp); + ret = (*ip >= argc ? 0 : **argpp); + } - /* - * if we didn't find the argument, it's an error - display usage if - * we have a valid usage callback - */ - if ((ret == 0 || *ret == 0) && usagefn != 0) - (*usagefn)(ec); + /* + * if we didn't find the argument, it's an error - display usage if + * we have a valid usage callback + */ + if ((ret == 0 || *ret == 0) && usagefn != 0) + (*usagefn)(ec); - return ret; + return ret; } } // End of namespace TADS2 diff --git a/engines/glk/tads/tads2/command_line.h b/engines/glk/tads/tads2/command_line.h index a231fca1c40..3a23f41eb94 100644 --- a/engines/glk/tads/tads2/command_line.h +++ b/engines/glk/tads/tads2/command_line.h @@ -46,7 +46,7 @@ namespace TADS2 { * error instead. */ char *cmdarg(errcxdef *ec, char ***argpp, int *ip, int argc, - int ofs, void (*usagefn)(errcxdef*)); + int ofs, void (*usagefn)(errcxdef*)); /* @@ -61,7 +61,7 @@ char *cmdarg(errcxdef *ec, char ***argpp, int *ip, int argc, * which is not expected to return, but should signal an error. */ int cmdtog(struct errcxdef *ec, int prv, char *argp, int ofs, - void (*usagefn)(errcxdef*)); + void (*usagefn)(errcxdef*)); } // End of namespace TADS2 } // End of namespace TADS diff --git a/engines/glk/tads/tads2/data.cpp b/engines/glk/tads/tads2/data.cpp index dfd641c322c..8d9771fc680 100644 --- a/engines/glk/tads/tads2/data.cpp +++ b/engines/glk/tads/tads2/data.cpp @@ -34,39 +34,39 @@ namespace TADS2 { /* return size of a data value */ uint datsiz(dattyp typ, const void *val) { - switch(typ) - { - case DAT_NUMBER: - return(4); /* numbers are in 4-byte lsb-first format */ + switch(typ) + { + case DAT_NUMBER: + return(4); /* numbers are in 4-byte lsb-first format */ - case DAT_OBJECT: - return(2); /* object numbers are in 2-byte lsb-first format */ + case DAT_OBJECT: + return(2); /* object numbers are in 2-byte lsb-first format */ - case DAT_SSTRING: - case DAT_DSTRING: - case DAT_LIST: - return(osrp2((const char *)val)); + case DAT_SSTRING: + case DAT_DSTRING: + case DAT_LIST: + return(osrp2((const char *)val)); - case DAT_NIL: - case DAT_TRUE: - return(0); + case DAT_NIL: + case DAT_TRUE: + return(0); - case DAT_PROPNUM: - case DAT_SYN: - case DAT_FNADDR: - case DAT_REDIR: - return(2); - - case DAT_TPL: - /* template is counted array of 10-byte entries, plus length byte */ - return(1 + ((*(const uchar *)val) * VOCTPLSIZ)); + case DAT_PROPNUM: + case DAT_SYN: + case DAT_FNADDR: + case DAT_REDIR: + return(2); + + case DAT_TPL: + /* template is counted array of 10-byte entries, plus length byte */ + return(1 + ((*(const uchar *)val) * VOCTPLSIZ)); - case DAT_TPL2: - return(1 + ((*(const uchar *)val) * VOCTPL2SIZ)); + case DAT_TPL2: + return(1 + ((*(const uchar *)val) * VOCTPL2SIZ)); - default: - return(0); - } + default: + return(0); + } } } // End of namespace TADS2 diff --git a/engines/glk/tads/tads2/debug.cpp b/engines/glk/tads/tads2/debug.cpp index 10418dccec0..9e92529aa0c 100644 --- a/engines/glk/tads/tads2/debug.cpp +++ b/engines/glk/tads/tads2/debug.cpp @@ -34,439 +34,439 @@ namespace TADS2 { /* add a string to the history buffer */ void dbgaddhist(dbgcxdef *ctx, char *buf, int l) { - char *p; - int dell; + char *p; + int dell; - if (ctx->dbgcxhstf + l + 1 >= ctx->dbgcxhstl) - { - /* delete first lines until we have enough space */ - for (dell = 0, p = ctx->dbgcxhstp ; *p || dell < l ; ++p, ++dell) ; - if (*p) ++p; - memmove(ctx->dbgcxhstp, ctx->dbgcxhstp + dell, - (size_t)(ctx->dbgcxhstf - dell)); - ctx->dbgcxhstf -= dell; - } - memcpy(ctx->dbgcxhstp + ctx->dbgcxhstf, buf, (size_t)l); - ctx->dbgcxhstf += l; + if (ctx->dbgcxhstf + l + 1 >= ctx->dbgcxhstl) + { + /* delete first lines until we have enough space */ + for (dell = 0, p = ctx->dbgcxhstp ; *p || dell < l ; ++p, ++dell) ; + if (*p) ++p; + memmove(ctx->dbgcxhstp, ctx->dbgcxhstp + dell, + (size_t)(ctx->dbgcxhstf - dell)); + ctx->dbgcxhstf -= dell; + } + memcpy(ctx->dbgcxhstp + ctx->dbgcxhstf, buf, (size_t)l); + ctx->dbgcxhstf += l; } /* callback for dbgent - saves history line to a char buffer */ static void dbgent1(void *ctx0, const char *str, int strl) { - char **ctx = (char **)ctx0; - memcpy(*ctx, str, (size_t)strl); - *ctx += strl; + char **ctx = (char **)ctx0; + memcpy(*ctx, str, (size_t)strl); + *ctx += strl; } void dbgent(dbgcxdef *ctx, runsdef *bp, objnum self, objnum target, - prpnum prop, int binum, int argc) + prpnum prop, int binum, int argc) { - dbgfdef *p; - - ++(ctx->dbgcxdep); /* increment actual depth */ - if (ctx->dbgcxfcn == DBGMAXFRAME) - { - --(ctx->dbgcxfcn); /* back to top frame */ - memmove(ctx->dbgcxfrm, ctx->dbgcxfrm + 1, - (size_t)((DBGMAXFRAME - 1) * sizeof(dbgfdef))); - } - p = &ctx->dbgcxfrm[ctx->dbgcxfcn]; - ++(ctx->dbgcxfcn); /* increment frame pointer */ + dbgfdef *p; + + ++(ctx->dbgcxdep); /* increment actual depth */ + if (ctx->dbgcxfcn == DBGMAXFRAME) + { + --(ctx->dbgcxfcn); /* back to top frame */ + memmove(ctx->dbgcxfrm, ctx->dbgcxfrm + 1, + (size_t)((DBGMAXFRAME - 1) * sizeof(dbgfdef))); + } + p = &ctx->dbgcxfrm[ctx->dbgcxfcn]; + ++(ctx->dbgcxfcn); /* increment frame pointer */ - p->dbgfbp = bp; - p->dbgfself = self; - p->dbgftarg = target; - p->dbgfprop = prop; - p->dbgfbif = binum; - p->dbgfargc = argc; - p->dbgffr = 0; /* no frame has yet been recorded */ - p->dbgflin = 0; + p->dbgfbp = bp; + p->dbgfself = self; + p->dbgftarg = target; + p->dbgfprop = prop; + p->dbgfbif = binum; + p->dbgfargc = argc; + p->dbgffr = 0; /* no frame has yet been recorded */ + p->dbgflin = 0; - /* save call history */ - if (ctx->dbgcxflg & DBGCXFTRC) - { - char buf[128]; - char *tmp; - int l; + /* save call history */ + if (ctx->dbgcxflg & DBGCXFTRC) + { + char buf[128]; + char *tmp; + int l; - tmp = buf; - dbgstktr(ctx, dbgent1, &tmp, -1, TRUE, FALSE); - if ((l = (tmp - buf)) > 0 && buf[l-1] == '\n') --l; - buf[l++] = '\0'; - dbgaddhist(ctx, buf, l); - } + tmp = buf; + dbgstktr(ctx, dbgent1, &tmp, -1, TRUE, FALSE); + if ((l = (tmp - buf)) > 0 && buf[l-1] == '\n') --l; + buf[l++] = '\0'; + dbgaddhist(ctx, buf, l); + } } void dbglv(dbgcxdef *ctx, int exittype) { - --(ctx->dbgcxdep); /* decrement actual depth */ - if (ctx->dbgcxfcn) --(ctx->dbgcxfcn); /* decrement frame pointer */ + --(ctx->dbgcxdep); /* decrement actual depth */ + if (ctx->dbgcxfcn) --(ctx->dbgcxfcn); /* decrement frame pointer */ - /* - * if we're in STEP OUT/OVER mode, and the target context is level - * 0, and we're now at level 0, it means that we are stepping out of - * a routine called directly by the system and the debugger is - * supposed to break when that happens -- return to single-stepping - * mode so that we break into the debugger the next time the system - * calls a method - */ - if ((ctx->dbgcxflg & DBGCXFSS) != 0 - && (ctx->dbgcxflg & DBGCXFSO) != 0 - && ctx->dbgcxsof == 0 && ctx->dbgcxdep == 0) - { - /* - * stepping out/over at level 0 - go to normal single-step mode - * (clear the out/over flag) - */ - ctx->dbgcxflg &= ~DBGCXFSO; - } + /* + * if we're in STEP OUT/OVER mode, and the target context is level + * 0, and we're now at level 0, it means that we are stepping out of + * a routine called directly by the system and the debugger is + * supposed to break when that happens -- return to single-stepping + * mode so that we break into the debugger the next time the system + * calls a method + */ + if ((ctx->dbgcxflg & DBGCXFSS) != 0 + && (ctx->dbgcxflg & DBGCXFSO) != 0 + && ctx->dbgcxsof == 0 && ctx->dbgcxdep == 0) + { + /* + * stepping out/over at level 0 - go to normal single-step mode + * (clear the out/over flag) + */ + ctx->dbgcxflg &= ~DBGCXFSO; + } - /* record exit in call history if appropriate */ - if (ctx->dbgcxflg & DBGCXFTRC) - { - char buf[128]; - char *p; + /* record exit in call history if appropriate */ + if (ctx->dbgcxflg & DBGCXFTRC) + { + char buf[128]; + char *p; - switch(exittype) - { - case DBGEXVAL: - if (ctx->dbgcxfcn > 1) - { - memset(buf, ' ', (size_t)(ctx->dbgcxfcn - 1)); - dbgaddhist(ctx, buf, (int)ctx->dbgcxfcn - 1); - } - memcpy(buf, " => ", (size_t)4); - p = buf + 4; - dbgpval(ctx, ctx->dbgcxrun->runcxsp - 1, - dbgent1, &p, TRUE); - *p++ = '\0'; - dbgaddhist(ctx, buf, (int)(p - buf)); - break; + switch(exittype) + { + case DBGEXVAL: + if (ctx->dbgcxfcn > 1) + { + memset(buf, ' ', (size_t)(ctx->dbgcxfcn - 1)); + dbgaddhist(ctx, buf, (int)ctx->dbgcxfcn - 1); + } + memcpy(buf, " => ", (size_t)4); + p = buf + 4; + dbgpval(ctx, ctx->dbgcxrun->runcxsp - 1, + dbgent1, &p, TRUE); + *p++ = '\0'; + dbgaddhist(ctx, buf, (int)(p - buf)); + break; - case DBGEXPASS: - memcpy(buf, " [pass]", (size_t)8); - dbgaddhist(ctx, buf, 8); - break; - } - } + case DBGEXPASS: + memcpy(buf, " [pass]", (size_t)8); + dbgaddhist(ctx, buf, 8); + break; + } + } } /* get a symbol name; returns length of name */ int dbgnam(dbgcxdef *ctx, char *outbuf, int typ, int val) { - toksdef sym; + toksdef sym; - if (!ctx->dbgcxtab || !ctx->dbgcxtab->tokthhsh) - { - memcpy(outbuf, "", (size_t)17); - return(17); - } - - if (tokthfind((toktdef *)ctx->dbgcxtab, typ, val, &sym)) - { - memcpy(outbuf, sym.toksnam, (size_t)sym.tokslen); - return(sym.tokslen); - } - else if (typ == TOKSTOBJ) - { - if ((mcmon)val == MCMONINV) - { - memcpy(outbuf, "", 16); - return 16; - } - else - { - sprintf(outbuf, "", val); - return strlen(outbuf); - } - } - else - { - memcpy(outbuf, "", (size_t)9); - return(9); - } + if (!ctx->dbgcxtab || !ctx->dbgcxtab->tokthhsh) + { + memcpy(outbuf, "", (size_t)17); + return(17); + } + + if (tokthfind((toktdef *)ctx->dbgcxtab, typ, val, &sym)) + { + memcpy(outbuf, sym.toksnam, (size_t)sym.tokslen); + return(sym.tokslen); + } + else if (typ == TOKSTOBJ) + { + if ((mcmon)val == MCMONINV) + { + memcpy(outbuf, "", 16); + return 16; + } + else + { + sprintf(outbuf, "", val); + return strlen(outbuf); + } + } + else + { + memcpy(outbuf, "", (size_t)9); + return(9); + } } /* send a buffer value (as from a list) to ui callback for display */ static void dbgpbval(dbgcxdef *ctx, dattyp typ, const uchar *val, - void (*dispfn)(void *, const char *, int), - void *dispctx) + void (*dispfn)(void *, const char *, int), + void *dispctx) { - char buf[TOKNAMMAX + 1]; - const char *p = buf; - uint len; + char buf[TOKNAMMAX + 1]; + const char *p = buf; + uint len; - switch(typ) - { - case DAT_NUMBER: - sprintf(buf, "%ld", (long)osrp4s(val)); - len = strlen(buf); - break; - - case DAT_OBJECT: - len = dbgnam(ctx, buf, TOKSTOBJ, osrp2(val)); - break; - - case DAT_SSTRING: - len = osrp2(val) - 2; - p = (const char *)val + 2; - break; - - case DAT_NIL: - p = "nil"; - len = 3; - break; + switch(typ) + { + case DAT_NUMBER: + sprintf(buf, "%ld", (long)osrp4s(val)); + len = strlen(buf); + break; + + case DAT_OBJECT: + len = dbgnam(ctx, buf, TOKSTOBJ, osrp2(val)); + break; + + case DAT_SSTRING: + len = osrp2(val) - 2; + p = (const char *)val + 2; + break; + + case DAT_NIL: + p = "nil"; + len = 3; + break; - case DAT_LIST: - (*dispfn)(dispctx, "[", 1); - len = osrp2(val) - 2; - p = (const char *)val + 2; - while (len) - { - dbgpbval(ctx, (dattyp)*p, (const uchar *)(p + 1), dispfn, dispctx); - lstadv((uchar **)const_cast(&p), &len); - if (len) (*dispfn)(dispctx, " ", 1); - } - (*dispfn)(dispctx, "]", 1); - len = 0; - break; - - case DAT_TRUE: - p = "true"; - len = 4; - break; - - case DAT_FNADDR: - (*dispfn)(dispctx, "&", 1); - len = dbgnam(ctx, buf, TOKSTFUNC, osrp2(val)); - break; - - case DAT_PROPNUM: - (*dispfn)(dispctx, "&", 1); - len = dbgnam(ctx, buf, TOKSTPROP, osrp2(val)); - break; - - default: - p = "[unknown type]"; - len = 14; - break; - } + case DAT_LIST: + (*dispfn)(dispctx, "[", 1); + len = osrp2(val) - 2; + p = (const char *)val + 2; + while (len) + { + dbgpbval(ctx, (dattyp)*p, (const uchar *)(p + 1), dispfn, dispctx); + lstadv((uchar **)const_cast(&p), &len); + if (len) (*dispfn)(dispctx, " ", 1); + } + (*dispfn)(dispctx, "]", 1); + len = 0; + break; + + case DAT_TRUE: + p = "true"; + len = 4; + break; + + case DAT_FNADDR: + (*dispfn)(dispctx, "&", 1); + len = dbgnam(ctx, buf, TOKSTFUNC, osrp2(val)); + break; + + case DAT_PROPNUM: + (*dispfn)(dispctx, "&", 1); + len = dbgnam(ctx, buf, TOKSTPROP, osrp2(val)); + break; + + default: + p = "[unknown type]"; + len = 14; + break; + } - if (typ == DAT_SSTRING) (*dispfn)(dispctx, "'", 1); - if (len) (*dispfn)(dispctx, p, len); - if (typ == DAT_SSTRING) (*dispfn)(dispctx, "'", 1); + if (typ == DAT_SSTRING) (*dispfn)(dispctx, "'", 1); + if (len) (*dispfn)(dispctx, p, len); + if (typ == DAT_SSTRING) (*dispfn)(dispctx, "'", 1); } /* send a value to ui callback for display */ void dbgpval(dbgcxdef *ctx, runsdef *val, - void (*dispfn)(void *ctx, const char *str, int strl), - void *dispctx, - int showtype) + void (*dispfn)(void *ctx, const char *str, int strl), + void *dispctx, + int showtype) { - uchar buf[TOKNAMMAX + 1]; - uint len; - const uchar *p = buf; - const char *typ = 0; - - switch(val->runstyp) - { - case DAT_NUMBER: - sprintf((char *)buf, "%ld", val->runsv.runsvnum); - len = strlen((char *)buf); - typ = "number"; - break; - - case DAT_OBJECT: - len = dbgnam(ctx, (char *)buf, TOKSTOBJ, val->runsv.runsvobj); - typ = "object"; - break; - - case DAT_SSTRING: - len = osrp2(val->runsv.runsvstr) - 2; - p = val->runsv.runsvstr + 2; - typ = "string"; - break; - - case DAT_NIL: - p = (const uchar *)"nil"; - len = 3; - break; + uchar buf[TOKNAMMAX + 1]; + uint len; + const uchar *p = buf; + const char *typ = 0; + + switch(val->runstyp) + { + case DAT_NUMBER: + sprintf((char *)buf, "%ld", val->runsv.runsvnum); + len = strlen((char *)buf); + typ = "number"; + break; + + case DAT_OBJECT: + len = dbgnam(ctx, (char *)buf, TOKSTOBJ, val->runsv.runsvobj); + typ = "object"; + break; + + case DAT_SSTRING: + len = osrp2(val->runsv.runsvstr) - 2; + p = val->runsv.runsvstr + 2; + typ = "string"; + break; + + case DAT_NIL: + p = (const uchar *)"nil"; + len = 3; + break; - case DAT_LIST: { - if (showtype) (*dispfn)(dispctx, "list: ", 6); - (*dispfn)(dispctx, "[", 1); - len = osrp2(val->runsv.runsvstr) - 2; - uchar *up = val->runsv.runsvstr + 2; - while (len) - { - dbgpbval(ctx, (dattyp)*up, (const uchar *)(up + 1), dispfn, dispctx); - lstadv(&up, &len); - if (len) (*dispfn)(dispctx, " ", 1); - } - (*dispfn)(dispctx, "]", 1); - len = 0; + case DAT_LIST: { + if (showtype) (*dispfn)(dispctx, "list: ", 6); + (*dispfn)(dispctx, "[", 1); + len = osrp2(val->runsv.runsvstr) - 2; + uchar *up = val->runsv.runsvstr + 2; + while (len) + { + dbgpbval(ctx, (dattyp)*up, (const uchar *)(up + 1), dispfn, dispctx); + lstadv(&up, &len); + if (len) (*dispfn)(dispctx, " ", 1); + } + (*dispfn)(dispctx, "]", 1); + len = 0; p = up; - break; - } - case DAT_TRUE: - p = (const uchar *)"true"; - len = 4; - break; - - case DAT_FNADDR: - len = dbgnam(ctx, (char *)buf, TOKSTFUNC, val->runsv.runsvobj); - typ = "function pointer"; - break; - - case DAT_PROPNUM: - len = dbgnam(ctx, (char *)buf, TOKSTPROP, val->runsv.runsvprp); - typ = "property pointer"; - break; - - default: - p = (const uchar *)"[unknown type]"; - len = 14; - break; - } + break; + } + case DAT_TRUE: + p = (const uchar *)"true"; + len = 4; + break; + + case DAT_FNADDR: + len = dbgnam(ctx, (char *)buf, TOKSTFUNC, val->runsv.runsvobj); + typ = "function pointer"; + break; + + case DAT_PROPNUM: + len = dbgnam(ctx, (char *)buf, TOKSTPROP, val->runsv.runsvprp); + typ = "property pointer"; + break; + + default: + p = (const uchar *)"[unknown type]"; + len = 14; + break; + } - /* show the type prefix if desired, or add a quote if it's a string */ - if (typ && showtype) - { - /* show the type prefix */ - (*dispfn)(dispctx, typ, (int)strlen(typ)); - (*dispfn)(dispctx, ": ", 2); - } - else if (val->runstyp == DAT_SSTRING) - { - /* it's a string, and we're not showing a type - add a quote */ - (*dispfn)(dispctx, "'", 1); - } + /* show the type prefix if desired, or add a quote if it's a string */ + if (typ && showtype) + { + /* show the type prefix */ + (*dispfn)(dispctx, typ, (int)strlen(typ)); + (*dispfn)(dispctx, ": ", 2); + } + else if (val->runstyp == DAT_SSTRING) + { + /* it's a string, and we're not showing a type - add a quote */ + (*dispfn)(dispctx, "'", 1); + } - /* - * if possible, null-terminate the buffer - do this only if the - * length is actually within the buffer, which won't be the case if - * the text comes from someplace outside the buffer (which is the - * case if it's a string, for example) - */ - if (len < sizeof(buf)) - buf[len] = '\0'; + /* + * if possible, null-terminate the buffer - do this only if the + * length is actually within the buffer, which won't be the case if + * the text comes from someplace outside the buffer (which is the + * case if it's a string, for example) + */ + if (len < sizeof(buf)) + buf[len] = '\0'; - /* display a "&" prefix if it's an address of some kind */ - if (val->runstyp == DAT_PROPNUM || val->runstyp == DAT_FNADDR) - (*dispfn)(dispctx, "&", 1); + /* display a "&" prefix if it's an address of some kind */ + if (val->runstyp == DAT_PROPNUM || val->runstyp == DAT_FNADDR) + (*dispfn)(dispctx, "&", 1); - /* display the text */ - if (len != 0) - (*dispfn)(dispctx, (const char *)p, len); + /* display the text */ + if (len != 0) + (*dispfn)(dispctx, (const char *)p, len); - /* add a closing quote if it's a string and we showed an open quote */ - if (val->runstyp == DAT_SSTRING && !(typ && showtype)) - (*dispfn)(dispctx, "'", 1); + /* add a closing quote if it's a string and we showed an open quote */ + if (val->runstyp == DAT_SSTRING && !(typ && showtype)) + (*dispfn)(dispctx, "'", 1); } void dbgstktr(dbgcxdef *ctx, - void (*dispfn)(void *ctx, const char *str, int strl), - void *dispctx, - int level, int toponly, int include_markers) + void (*dispfn)(void *ctx, const char *str, int strl), + void *dispctx, + int level, int toponly, int include_markers) { - dbgfdef *f; - int i; - int j; - int k; - char buf[128]; - char *p; - char c; + dbgfdef *f; + int i; + int j; + int k; + char buf[128]; + char *p; + char c; - for (i = ctx->dbgcxfcn, j = ctx->dbgcxdep, f = &ctx->dbgcxfrm[i-1] - ; i ; --f, --j, --i) - { - p = buf; - if (toponly) - { - int v = (i < 50 ? i : 50); + for (i = ctx->dbgcxfcn, j = ctx->dbgcxdep, f = &ctx->dbgcxfrm[i-1] + ; i ; --f, --j, --i) + { + p = buf; + if (toponly) + { + int v = (i < 50 ? i : 50); - if (v > 1) - { - memset(buf, ' ', (size_t)(v - 1)); - dbgaddhist(ctx, buf, v-1); - } - } - else if (include_markers) - { - c = (i == level + 1 ? '*' : ' '); - sprintf(buf, "%3d%c ", j, c); - p += 4; - } + if (v > 1) + { + memset(buf, ' ', (size_t)(v - 1)); + dbgaddhist(ctx, buf, v-1); + } + } + else if (include_markers) + { + c = (i == level + 1 ? '*' : ' '); + sprintf(buf, "%3d%c ", j, c); + p += 4; + } - if (f->dbgftarg == MCMONINV) - p += dbgnam(ctx, p, TOKSTBIFN, f->dbgfbif); - else - p += dbgnam(ctx, p, - (f->dbgfself == MCMONINV ? TOKSTFUNC : TOKSTOBJ), - (int)f->dbgftarg); + if (f->dbgftarg == MCMONINV) + p += dbgnam(ctx, p, TOKSTBIFN, f->dbgfbif); + else + p += dbgnam(ctx, p, + (f->dbgfself == MCMONINV ? TOKSTFUNC : TOKSTOBJ), + (int)f->dbgftarg); - if (f->dbgfself != MCMONINV && f->dbgfself != f->dbgftarg) - { - memcpy(p, "dbgfself); - *p++ = '>'; - } - if (f->dbgfprop) - { - *p++ = '.'; - p += dbgnam(ctx, p, TOKSTPROP, (int)f->dbgfprop); - } - - /* display what we have so far */ - *p++ = '\0'; - (*dispfn)(dispctx, buf, (int)strlen(buf)); + if (f->dbgfself != MCMONINV && f->dbgfself != f->dbgftarg) + { + memcpy(p, "dbgfself); + *p++ = '>'; + } + if (f->dbgfprop) + { + *p++ = '.'; + p += dbgnam(ctx, p, TOKSTPROP, (int)f->dbgfprop); + } + + /* display what we have so far */ + *p++ = '\0'; + (*dispfn)(dispctx, buf, (int)strlen(buf)); - /* display arguments if there are any */ - if (f->dbgfself == MCMONINV || f->dbgfargc != 0) - { - (*dispfn)(dispctx, "(", 1); - for (k = 0 ; k < f->dbgfargc ; ++k) - { - dbgpval(ctx, f->dbgfbp - k - 2, dispfn, dispctx, FALSE); - if (k + 1 < f->dbgfargc) (*dispfn)(dispctx, ", ", 2); - } - (*dispfn)(dispctx, ")", 1); - } - - /* send out a newline, then move on to next frame */ - (*dispfn)(dispctx, "\n", 1); + /* display arguments if there are any */ + if (f->dbgfself == MCMONINV || f->dbgfargc != 0) + { + (*dispfn)(dispctx, "(", 1); + for (k = 0 ; k < f->dbgfargc ; ++k) + { + dbgpval(ctx, f->dbgfbp - k - 2, dispfn, dispctx, FALSE); + if (k + 1 < f->dbgfargc) (*dispfn)(dispctx, ", ", 2); + } + (*dispfn)(dispctx, ")", 1); + } + + /* send out a newline, then move on to next frame */ + (*dispfn)(dispctx, "\n", 1); - /* we're done if doing one function only */ - if (toponly) break; - } + /* we're done if doing one function only */ + if (toponly) break; + } } static void dbgdsdisp(void *ctx, const char *buf, int bufl) { - if (buf[0] == '\n') - tioflush((tiocxdef *)ctx); - else - tioputslen((tiocxdef *)ctx, (const char *)buf, bufl); + if (buf[0] == '\n') + tioflush((tiocxdef *)ctx); + else + tioputslen((tiocxdef *)ctx, (const char *)buf, bufl); } /* dump the stack */ void dbgds(dbgcxdef *ctx) { - /* don't do stack dumps if we're running from the debugger command line */ - if (ctx->dbgcxflg & DBGCXFIND) return; + /* don't do stack dumps if we're running from the debugger command line */ + if (ctx->dbgcxflg & DBGCXFIND) return; - tioflush(ctx->dbgcxtio); - tioshow(ctx->dbgcxtio); - dbgstktr(ctx, dbgdsdisp, ctx->dbgcxtio, -1, FALSE, TRUE); - tioflush(ctx->dbgcxtio); - ctx->dbgcxfcn = ctx->dbgcxdep = 0; + tioflush(ctx->dbgcxtio); + tioshow(ctx->dbgcxtio); + dbgstktr(ctx, dbgdsdisp, ctx->dbgcxtio, -1, FALSE, TRUE); + tioflush(ctx->dbgcxtio); + ctx->dbgcxfcn = ctx->dbgcxdep = 0; } /* get information about the currently executing source line */ void dbglget(dbgcxdef *ctx, uchar *buf) { - dbglgetlvl(ctx, buf, 0); + dbglgetlvl(ctx, buf, 0); } /* @@ -476,46 +476,46 @@ void dbglget(dbgcxdef *ctx, uchar *buf) */ int dbglgetlvl(dbgcxdef *ctx, uchar *buf, int level) { - uchar *linrec; - uchar *obj; - dbgfdef *fr; + uchar *linrec; + uchar *obj; + dbgfdef *fr; - /* make sure the level is valid */ - if (level > ctx->dbgcxfcn - 1) - return 1; + /* make sure the level is valid */ + if (level > ctx->dbgcxfcn - 1) + return 1; - /* get the frame at the given level */ - fr = &ctx->dbgcxfrm[ctx->dbgcxfcn - level - 1]; + /* get the frame at the given level */ + fr = &ctx->dbgcxfrm[ctx->dbgcxfcn - level - 1]; - /* if we're in an intrinsic, go to enclosing frame */ - if (fr->dbgftarg == MCMONINV) --fr; - - /* make sure we've encountered an OPCLINE in this frame */ - if (fr->dbgflin == 0) - return 1; + /* if we're in an intrinsic, go to enclosing frame */ + if (fr->dbgftarg == MCMONINV) --fr; + + /* make sure we've encountered an OPCLINE in this frame */ + if (fr->dbgflin == 0) + return 1; - /* we need to read from the target object - lock it */ - obj = mcmlck(ctx->dbgcxmem, (mcmon)fr->dbgftarg); + /* we need to read from the target object - lock it */ + obj = mcmlck(ctx->dbgcxmem, (mcmon)fr->dbgftarg); - linrec = obj + fr->dbgflin; - memcpy(buf, linrec + 3, (size_t)(*linrec - 3)); - - /* no longer need the target object locked */ - mcmunlck(ctx->dbgcxmem, (mcmon)fr->dbgftarg); + linrec = obj + fr->dbgflin; + memcpy(buf, linrec + 3, (size_t)(*linrec - 3)); + + /* no longer need the target object locked */ + mcmunlck(ctx->dbgcxmem, (mcmon)fr->dbgftarg); - /* success */ - return 0; + /* success */ + return 0; } /* tell the line source the location of the current line being compiled */ void dbgclin(tokcxdef *tokctx, objnum objn, uint ofs) { - uchar buf[4]; - - /* package the information and send it to the line source */ - oswp2(buf, objn); - oswp2(buf + 2, ofs); - lincmpinf(tokctx->tokcxlin, buf); + uchar buf[4]; + + /* package the information and send it to the line source */ + oswp2(buf, objn); + oswp2(buf + 2, ofs); + lincmpinf(tokctx->tokcxlin, buf); } } // End of namespace TADS2 diff --git a/engines/glk/tads/tads2/debug.h b/engines/glk/tads/tads2/debug.h index 3c53a89eece..2bad916dd6c 100644 --- a/engines/glk/tads/tads2/debug.h +++ b/engines/glk/tads/tads2/debug.h @@ -41,14 +41,14 @@ struct tokcxdef; /* stack frame record */ struct dbgfdef { - struct runsdef *dbgfbp; /* base pointer of frame */ - objnum dbgfself; /* 'self' object (MCMONINV for functions) */ - objnum dbgftarg; /* actual target object */ - prpnum dbgfprop; /* property being evalutated */ - int dbgfargc; /* number of arguments */ - int dbgfbif; /* set to built-in function number if in built-in */ - uint dbgffr; /* offset in object of local frame symbol table */ - uint dbgflin; /* OPCLINE operand of latest line */ + struct runsdef *dbgfbp; /* base pointer of frame */ + objnum dbgfself; /* 'self' object (MCMONINV for functions) */ + objnum dbgftarg; /* actual target object */ + prpnum dbgfprop; /* property being evalutated */ + int dbgfargc; /* number of arguments */ + int dbgfbif; /* set to built-in function number if in built-in */ + uint dbgffr; /* offset in object of local frame symbol table */ + uint dbgflin; /* OPCLINE operand of latest line */ }; typedef struct dbgfdef dbgfdef; @@ -61,18 +61,18 @@ typedef struct dbgfdef dbgfdef; /* breakpoint structure */ struct dbgbpdef { - objnum dbgbpself; /* the "self" object for the breakpoint */ - objnum dbgbptarg; /* actual target object for the breakpoint */ - uint dbgbpofs; /* offset in object of the breakpoint */ - uint dbgbpflg; /* breakpoint flags */ + objnum dbgbpself; /* the "self" object for the breakpoint */ + objnum dbgbptarg; /* actual target object for the breakpoint */ + uint dbgbpofs; /* offset in object of the breakpoint */ + uint dbgbpflg; /* breakpoint flags */ #define DBGBPFUSED 0x01 /* breakpoint has been set */ #define DBGBPFNAME 0x02 /* name of address has been stored */ #define DBGBPFCOND 0x04 /* breakpoint has a condition attached */ #define DBGBPFDISA 0x08 /* breakpoint is disabled */ #define DBGBPFCONDNAME 0x10 /* condition name string has been stored */ - uint dbgbpnam; /* offset of address name within dbgcxnam buffer */ - uint dbgbpcondnam; /* offset of condition string within buffer */ - objnum dbgbpcond; /* object containing compiled condition for bp */ + uint dbgbpnam; /* offset of address name within dbgcxnam buffer */ + uint dbgbpcondnam; /* offset of condition string within buffer */ + objnum dbgbpcond; /* object containing compiled condition for bp */ }; typedef struct dbgbpdef dbgbpdef; @@ -82,10 +82,10 @@ typedef struct dbgbpdef dbgbpdef; /* watch expression structure */ struct dbgwxdef { - objnum dbgwxobj; /* object containing compiled expression */ - objnum dbgwxself; /* 'self' for the expression */ - uint dbgwxnam; /* offset of expression text within dbgcxnam buffer */ - uint dbgwxflg; /* flags for this watch expression slot */ + objnum dbgwxobj; /* object containing compiled expression */ + objnum dbgwxself; /* 'self' for the expression */ + uint dbgwxnam; /* offset of expression text within dbgcxnam buffer */ + uint dbgwxflg; /* flags for this watch expression slot */ #define DBGWXFUSED 0x01 /* watch slot is in use */ #define DBGWXFNAME 0x02 /* name of watch has been stored */ }; @@ -97,16 +97,16 @@ typedef struct dbgwxdef dbgwxdef; /* debug context */ struct dbgcxdef { - struct tiocxdef *dbgcxtio; /* text i/o context */ - struct tokthdef *dbgcxtab; /* symbol table */ - struct mcmcxdef *dbgcxmem; /* memory cache manager context */ - struct errcxdef *dbgcxerr; /* error handling context */ - struct lindef *dbgcxlin; /* chain of line sources */ - int dbgcxfcn; /* number of frames in use */ - int dbgcxdep; /* actual depth (if overflow frame buffer) */ - int dbgcxfid; /* source file serial number */ - dbgfdef dbgcxfrm[DBGMAXFRAME]; /* stack frames */ - int dbgcxflg; /* flags for debug session */ + struct tiocxdef *dbgcxtio; /* text i/o context */ + struct tokthdef *dbgcxtab; /* symbol table */ + struct mcmcxdef *dbgcxmem; /* memory cache manager context */ + struct errcxdef *dbgcxerr; /* error handling context */ + struct lindef *dbgcxlin; /* chain of line sources */ + int dbgcxfcn; /* number of frames in use */ + int dbgcxdep; /* actual depth (if overflow frame buffer) */ + int dbgcxfid; /* source file serial number */ + dbgfdef dbgcxfrm[DBGMAXFRAME]; /* stack frames */ + int dbgcxflg; /* flags for debug session */ #define DBGCXFSS 0x01 /* single-stepping source lines */ #define DBGCXFSO 0x02 /* stepping over a function/method call */ #define DBGCXFOK 0x04 /* debugger is linked in */ @@ -114,31 +114,31 @@ struct dbgcxdef #define DBGCXFGBP 0x10 /* global breakpoints in effect */ #define DBGCXFTRC 0x20 /* call tracing activated */ #define DBGCXFLIN2 0x40 /* new-style line records (line numbers) */ - int dbgcxsof; /* frame depth at step-over time */ - dbgbpdef dbgcxbp[DBGBPMAX]; /* breakpoints */ - dbgwxdef dbgcxwx[DBGWXMAX]; /* watch expressions */ - struct prscxdef *dbgcxprs; /* parsing context */ - struct runcxdef *dbgcxrun; /* execution context */ - uint dbgcxnamf; /* next free byte of dbgcxnam buffer */ - uint dbgcxnams; /* size of dbgcxnam buffer */ - char *dbgcxnam; /* space for bp address names */ - char *dbgcxhstp; /* call history buffer */ - uint dbgcxhstl; /* history buffer length */ - uint dbgcxhstf; /* offset of next free byte of history */ + int dbgcxsof; /* frame depth at step-over time */ + dbgbpdef dbgcxbp[DBGBPMAX]; /* breakpoints */ + dbgwxdef dbgcxwx[DBGWXMAX]; /* watch expressions */ + struct prscxdef *dbgcxprs; /* parsing context */ + struct runcxdef *dbgcxrun; /* execution context */ + uint dbgcxnamf; /* next free byte of dbgcxnam buffer */ + uint dbgcxnams; /* size of dbgcxnam buffer */ + char *dbgcxnam; /* space for bp address names */ + char *dbgcxhstp; /* call history buffer */ + uint dbgcxhstl; /* history buffer length */ + uint dbgcxhstf; /* offset of next free byte of history */ - /* - * This member is for the use of the user interface code. If the - * user interface implementation needs to store additional context, - * it can allocate a structure of its own (it should probably do - * this in dbguini()) and store a pointer to that structure here. - * Since the user interface entrypoints always have the debugger - * context passed as a parameter, the user interface code can - * recover its extra context information by following this pointer - * and casting it to its private structure type. The TADS code - * won't do anything with this pointer except initialize it to null - * when initializing the debugger context. - */ - void *dbgcxui; + /* + * This member is for the use of the user interface code. If the + * user interface implementation needs to store additional context, + * it can allocate a structure of its own (it should probably do + * this in dbguini()) and store a pointer to that structure here. + * Since the user interface entrypoints always have the debugger + * context passed as a parameter, the user interface code can + * recover its extra context information by following this pointer + * and casting it to its private structure type. The TADS code + * won't do anything with this pointer except initialize it to null + * when initializing the debugger context. + */ + void *dbgcxui; }; typedef struct dbgcxdef dbgcxdef; @@ -190,7 +190,7 @@ int dbgpresent(); /* add a debug tracing record */ /* void dbgenter(dbgcxdef *ctx, runsdef *bp, objnum self, objnum target, - prpnum prop, int binum, int argc); */ + prpnum prop, int binum, int argc); */ /* tell debugger where the current line's local frame table is located */ /* void dbgframe(dbgcxdef *ctx, uint ofsfr, ofslin); */ @@ -204,7 +204,7 @@ int dbgpresent(); * or method as it was originally. */ /* void dbgssi(dbgcxdef *ctx, uint ofs, int instr, - int err, uchar *noreg *p); */ + int err, uchar *noreg *p); */ /* pop debug trace level */ /* void dbgleave(dbgcxdef *ctx, int exittype); */ @@ -276,8 +276,8 @@ int dbgbpset(dbgcxdef *ctx, char *addr, int *bpnum); * was set. */ int dbgbpat(dbgcxdef *ctx, objnum objn, objnum self, - uint ofs, int *bpnum, char *bpname, int toggle, - char *condition, int *did_set); + uint ofs, int *bpnum, char *bpname, int toggle, + char *condition, int *did_set); /* * Set a breakpoint at an object + offset location, optionally with a @@ -285,8 +285,8 @@ int dbgbpat(dbgcxdef *ctx, objnum objn, objnum self, * in use, we'll return an error. */ int dbgbpatid(dbgcxdef *ctx, int bpnum, objnum target, objnum self, - uint ofs, char *bpname, int toggle, char *cond, - int *did_set); + uint ofs, char *bpname, int toggle, char *cond, + int *did_set); /* * Determine if there's a breakpoint at a given code location. Fills in @@ -320,25 +320,25 @@ int dbgbpsetcond(dbgcxdef *ctx, int bpnum, char *cond); /* list breakpoints, using user callback to do display */ void dbgbplist(dbgcxdef *ctx, - void (*dispfn)(void *ctx, const char *str, int len), - void *dispctx); + void (*dispfn)(void *ctx, const char *str, int len), + void *dispctx); /* enumerate breakpoints */ void dbgbpenum(dbgcxdef *ctx, - void (*cbfunc)(void *cbctx, int bpnum, const char *desc, - const char *cond, int disabled), void *cbctx); + void (*cbfunc)(void *cbctx, int bpnum, const char *desc, + const char *cond, int disabled), void *cbctx); /* call callback with lindef data for each breakpoint currently set */ void dbgbpeach(dbgcxdef *ctx, - void (*fn)(void *, int, uchar *, uint), - void *fnctx); + void (*fn)(void *, int, uchar *, uint), + void *fnctx); /* * Get information on a specific breakpoint. Returns zero on success, * non-zero on failure. */ int dbgbpgetinfo(dbgcxdef *ctx, int bpnum, char *descbuf, size_t descbuflen, - char *condbuf, size_t condbuflen); + char *condbuf, size_t condbuflen); /* * Evaluate an expression (a text string to be parsed) at a particular @@ -348,8 +348,8 @@ int dbgbpgetinfo(dbgcxdef *ctx, int bpnum, char *descbuf, size_t descbuflen, * prefix, otherwise we'll simply display the value. */ int dbgeval(dbgcxdef *ctx, char *expr, - void (*dispfn)(void *dispctx, const char *str, int strl), - void *dispctx, int level, int showtype); + void (*dispfn)(void *dispctx, const char *str, int strl), + void *dispctx, int level, int showtype); /* * Evaluate an expression, extended version. For aggregate values @@ -363,19 +363,19 @@ int dbgeval(dbgcxdef *ctx, char *expr, * there for information on the purpose of this flag. */ int dbgevalext(dbgcxdef *ctx, char *expr, - void (*dispfn)(void *dispctx, const char *str, int strl), - void *dispctx, int level, int showtype, dattyp *dat, - void (*aggcb)(void *aggctx, const char *subname, - int subnamelen, const char *relationship), - void *aggctx, int speculative); + void (*dispfn)(void *dispctx, const char *str, int strl), + void *dispctx, int level, int showtype, dattyp *dat, + void (*aggcb)(void *aggctx, const char *subname, + int subnamelen, const char *relationship), + void *aggctx, int speculative); /* * enumerate local variables at a given stack context level by calling * the given function once for each local variable */ void dbgenumlcl(dbgcxdef *ctx, int level, - void (*func)(void *ctx, const char *lclnam, size_t lclnamlen), - void *cbctx); + void (*func)(void *ctx, const char *lclnam, size_t lclnamlen), + void *cbctx); /* * Compile an expression in a given frame context. Returns an error @@ -396,12 +396,12 @@ void dbgenumlcl(dbgcxdef *ctx, int level, * calls. */ int dbgcompile(dbgcxdef *ctx, char *expr, dbgfdef *fr, objnum *objn, - int speculative); + int speculative); /* display a stack traceback through a user callback */ void dbgstktr(dbgcxdef *ctx, - void (*dispfn)(void *dispctx, const char *str, int strl), - void *dispctx, int level, int toponly, int include_markers); + void (*dispfn)(void *dispctx, const char *str, int strl), + void *dispctx, int level, int toponly, int include_markers); /* format a display of where execution is stopped into a buffer */ void dbgwhere(dbgcxdef *ctx, char *buf); @@ -414,8 +414,8 @@ int dbgwxdel(dbgcxdef *ctx, int wxnum); /* update all watch expressions */ void dbgwxupd(dbgcxdef *ctx, - void (*dispfn)(void *dispctx, const char *txt, int len), - void *dispctx); + void (*dispfn)(void *dispctx, const char *txt, int len), + void *dispctx); /* switch to a new active lindef */ void dbgswitch(struct lindef **linp, struct lindef *newlin); @@ -492,7 +492,7 @@ int dbgu_err_resume(dbgcxdef *ctx); * contain a valid filename. */ int dbgu_find_src(const char *origname, int origlen, - char *fullname, size_t full_len, int must_find_file); + char *fullname, size_t full_len, int must_find_file); /* @@ -560,7 +560,7 @@ void trcsho(void); #define dbgrst(ctx) ((ctx)->dbgcxfcn = (ctx)->dbgcxdep = 0) #define dbgframe(ctx, frofs, linofs) \ (((ctx)->dbgcxfrm[(ctx)->dbgcxfcn - 1].dbgffr = (frofs)), \ - ((ctx)->dbgcxfrm[(ctx)->dbgcxfcn - 1].dbgflin = (linofs))) + ((ctx)->dbgcxfrm[(ctx)->dbgcxfcn - 1].dbgflin = (linofs))) #define dbgssi(ctx, ofs, instr, err, p) dbgss(ctx, ofs, instr, err, p) #endif /* DBG_OFF */ @@ -568,7 +568,7 @@ void trcsho(void); /* private internal routines */ void dbgent(dbgcxdef *ctx, struct runsdef *bp, objnum self, objnum target, - prpnum prop, int binum, int argc); + prpnum prop, int binum, int argc); void dbglv(dbgcxdef *ctx, int exittype); @@ -577,11 +577,11 @@ void dbgds(dbgcxdef *ctx); void dbgss(dbgcxdef *ctx, uint ofs, int instr, int err, uchar *noreg *p); void dbgpval(struct dbgcxdef *ctx, struct runsdef *val, - void (*dispfn)(void *, const char *, int), - void *dispctx, int showtype); + void (*dispfn)(void *, const char *, int), + void *dispctx, int showtype); int dbgtabsea(struct toktdef *tab, char *name, int namel, int hash, - struct toksdef *ret); + struct toksdef *ret); } // End of namespace TADS2 } // End of namespace TADS diff --git a/engines/glk/tads/tads2/error.cpp b/engines/glk/tads/tads2/error.cpp index 9f6ee0489c7..e06f9128614 100644 --- a/engines/glk/tads/tads2/error.cpp +++ b/engines/glk/tads/tads2/error.cpp @@ -30,135 +30,135 @@ namespace TADS2 { /* format an error message, sprintf-style, using an erradef array */ int errfmt(char *outbuf, int outbufl, const char *fmt, int argc, const erradef *argv) { - int outlen = 0; - int argi = 0; - int len = 0; - char buf[20]; + int outlen = 0; + int argi = 0; + int len = 0; + char buf[20]; const char *p = nullptr; - char fmtchar; + char fmtchar; - while (*fmt) - { - switch(*fmt) - { - case '\\': - ++fmt; - len = 1; - switch(*fmt) - { - case '\0': - --fmt; - break; - case '\n': - p = "\n"; - break; - case '\t': - p = "\t"; - break; - default: - p = fmt; - break; - } - break; - - case '%': - ++fmt; - fmtchar = *fmt; - if (argi >= argc) fmtchar = 1; /* too many - ignore it */ - switch(fmtchar) - { - case '\0': - --fmt; - break; - - case '%': - p = "%"; - len = 1; - break; - - case 'd': - sprintf(buf, "%d", argv[argi].erraint); - len = strlen(buf); - p = buf; - break; - - case 's': - p = argv[argi].errastr; - len = strlen(p); - break; - - case 't': - { - int i; - static struct - { - int tokid; - const char *toknam; - } toklist[] = - { - { TOKTSEM, "semicolon" }, - { TOKTCOLON, "colon" }, - { TOKTFUNCTION, "\"function\"" }, - { TOKTCOMMA, "comma" }, - { TOKTLBRACE, "left brace ('{')" }, - { TOKTRPAR, "right paren (')')" }, - { TOKTRBRACK, "right square bracket (']')" }, - { TOKTWHILE, "\"while\"" }, - { TOKTLPAR, "left paren ('(')" }, - { TOKTEQ, "'='" }, - { 0, (const char *)nullptr } - }; - - for (i = 0 ; toklist[i].toknam ; ++i) - { - if (toklist[i].tokid == argv[argi].erraint) - { - p = toklist[i].toknam; - break; - } - } - if (!toklist[i].toknam) - p = ""; - len = strlen(p); - break; - } - - default: - p = ""; - len = 0; - --argi; - break; - } - ++argi; - break; - - default: - p = fmt; - len = 1; - break; - } + while (*fmt) + { + switch(*fmt) + { + case '\\': + ++fmt; + len = 1; + switch(*fmt) + { + case '\0': + --fmt; + break; + case '\n': + p = "\n"; + break; + case '\t': + p = "\t"; + break; + default: + p = fmt; + break; + } + break; + + case '%': + ++fmt; + fmtchar = *fmt; + if (argi >= argc) fmtchar = 1; /* too many - ignore it */ + switch(fmtchar) + { + case '\0': + --fmt; + break; + + case '%': + p = "%"; + len = 1; + break; + + case 'd': + sprintf(buf, "%d", argv[argi].erraint); + len = strlen(buf); + p = buf; + break; + + case 's': + p = argv[argi].errastr; + len = strlen(p); + break; + + case 't': + { + int i; + static struct + { + int tokid; + const char *toknam; + } toklist[] = + { + { TOKTSEM, "semicolon" }, + { TOKTCOLON, "colon" }, + { TOKTFUNCTION, "\"function\"" }, + { TOKTCOMMA, "comma" }, + { TOKTLBRACE, "left brace ('{')" }, + { TOKTRPAR, "right paren (')')" }, + { TOKTRBRACK, "right square bracket (']')" }, + { TOKTWHILE, "\"while\"" }, + { TOKTLPAR, "left paren ('(')" }, + { TOKTEQ, "'='" }, + { 0, (const char *)nullptr } + }; + + for (i = 0 ; toklist[i].toknam ; ++i) + { + if (toklist[i].tokid == argv[argi].erraint) + { + p = toklist[i].toknam; + break; + } + } + if (!toklist[i].toknam) + p = ""; + len = strlen(p); + break; + } + + default: + p = ""; + len = 0; + --argi; + break; + } + ++argi; + break; + + default: + p = fmt; + len = 1; + break; + } - /* copy output that was set up above */ - if (len) - { - if (outbufl >= len) - { - memcpy(outbuf, p, (size_t)len); - outbufl -= len; - outbuf += len; - } - else if (outbufl) - { - memcpy(outbuf, p, (size_t)outbufl); - outbufl = 0; - } - outlen += len; - } - ++fmt; - } - - if (outbufl) *outbuf++ = '\0'; - return(outlen); + /* copy output that was set up above */ + if (len) + { + if (outbufl >= len) + { + memcpy(outbuf, p, (size_t)len); + outbufl -= len; + outbuf += len; + } + else if (outbufl) + { + memcpy(outbuf, p, (size_t)outbufl); + outbufl = 0; + } + outlen += len; + } + ++fmt; + } + + if (outbufl) *outbuf++ = '\0'; + return(outlen); } @@ -166,7 +166,7 @@ int errfmt(char *outbuf, int outbufl, const char *fmt, int argc, const erradef * /* base error signal function */ void errsign(errcxdef *ctx, int e) { - ctx->errcxofs = 0; + ctx->errcxofs = 0; #if 0 longjmp(ctx->errcxptr->errbuf, e); #else diff --git a/engines/glk/tads/tads2/error_handling.cpp b/engines/glk/tads/tads2/error_handling.cpp index 5f7267408f2..124bd7f762f 100644 --- a/engines/glk/tads/tads2/error_handling.cpp +++ b/engines/glk/tads/tads2/error_handling.cpp @@ -30,110 +30,110 @@ namespace TADS2 { /* format an error message, sprintf-style, using an erradef array */ int errfmt(char *outbuf, int outbufl, char *fmt, int argc, erradef *argv) { - int outlen = 0; - int argi = 0; - int len; - char buf[20]; - const char *p = nullptr; - char fmtchar; + int outlen = 0; + int argi = 0; + int len; + char buf[20]; + const char *p = nullptr; + char fmtchar; - while (*fmt != '\0' && outbufl > 1) - { - switch(*fmt) - { - case '\\': - ++fmt; - len = 1; - switch(*fmt) - { - case '\0': - --fmt; - break; - case '\n': - p = "\n"; - break; - case '\t': - p = "\t"; - break; - default: - p = fmt; - break; - } - break; - - case '%': - ++fmt; - fmtchar = *fmt; - if (argi >= argc) fmtchar = 1; /* too many - ignore it */ - switch(fmtchar) - { - case '\0': - --fmt; - len = 0; - break; - - case '%': - p = "%"; - len = 1; - break; - - case 'd': - sprintf(buf, "%d", argv[argi].erraint); - len = strlen(buf); - p = buf; - break; - - case 'u': - sprintf(buf, "%u", argv[argi].erraint); - len = strlen(buf); - p = buf; - break; - - case 's': - p = argv[argi].errastr; - len = strlen(p); - break; - - default: - p = ""; - len = 0; - --argi; - break; - } - ++argi; - break; - - default: - p = fmt; - len = 1; - break; - } + while (*fmt != '\0' && outbufl > 1) + { + switch(*fmt) + { + case '\\': + ++fmt; + len = 1; + switch(*fmt) + { + case '\0': + --fmt; + break; + case '\n': + p = "\n"; + break; + case '\t': + p = "\t"; + break; + default: + p = fmt; + break; + } + break; + + case '%': + ++fmt; + fmtchar = *fmt; + if (argi >= argc) fmtchar = 1; /* too many - ignore it */ + switch(fmtchar) + { + case '\0': + --fmt; + len = 0; + break; + + case '%': + p = "%"; + len = 1; + break; + + case 'd': + sprintf(buf, "%d", argv[argi].erraint); + len = strlen(buf); + p = buf; + break; + + case 'u': + sprintf(buf, "%u", argv[argi].erraint); + len = strlen(buf); + p = buf; + break; + + case 's': + p = argv[argi].errastr; + len = strlen(p); + break; + + default: + p = ""; + len = 0; + --argi; + break; + } + ++argi; + break; + + default: + p = fmt; + len = 1; + break; + } - /* copy output that was set up above */ - if (len != 0) - { - if (outbufl >= len) - { - memcpy(outbuf, p, (size_t)len); - outbufl -= len; - outbuf += len; - } - else if (outbufl > 1) - { - memcpy(outbuf, p, (size_t)outbufl - 1); - outbufl = 1; - } - outlen += len; - } - ++fmt; - } + /* copy output that was set up above */ + if (len != 0) + { + if (outbufl >= len) + { + memcpy(outbuf, p, (size_t)len); + outbufl -= len; + outbuf += len; + } + else if (outbufl > 1) + { + memcpy(outbuf, p, (size_t)outbufl - 1); + outbufl = 1; + } + outlen += len; + } + ++fmt; + } - /* add a null terminator */ - if (outbufl != 0) - *outbuf++ = '\0'; + /* add a null terminator */ + if (outbufl != 0) + *outbuf++ = '\0'; - /* return the length */ - return outlen; + /* return the length */ + return outlen; } #if defined(DEBUG) && !defined(ERR_NO_MACRO) @@ -147,9 +147,9 @@ int errfmt(char *outbuf, int outbufl, char *fmt, int argc, erradef *argv) /* base error signal function */ void errsign(errcxdef *ctx, int e, const char *facility) { - strncpy(ctx->errcxptr->errfac, facility, ERRFACMAX); - ctx->errcxptr->errfac[ERRFACMAX] = '\0'; - ctx->errcxofs = 0; + strncpy(ctx->errcxptr->errfac, facility, ERRFACMAX); + ctx->errcxptr->errfac[ERRFACMAX] = '\0'; + ctx->errcxofs = 0; #if 0 longjmp(ctx->errcxptr->errbuf, e); #else @@ -160,43 +160,43 @@ void errsign(errcxdef *ctx, int e, const char *facility) /* signal an error with no arguments */ void errsigf(errcxdef *ctx, const char *facility, int e) { - errargc(ctx, 0); - errsign(ctx, e, facility); + errargc(ctx, 0); + errsign(ctx, e, facility); } /* enter a string argument */ char *errstr(errcxdef *ctx, const char *str, int len) { - char *ret = &ctx->errcxbuf[ctx->errcxofs]; - - memcpy(ret, str, (size_t)len); - ret[len] = '\0'; - ctx->errcxofs += len + 1; - return(ret); + char *ret = &ctx->errcxbuf[ctx->errcxofs]; + + memcpy(ret, str, (size_t)len); + ret[len] = '\0'; + ctx->errcxofs += len + 1; + return(ret); } /* resignal current error */ void errrse1(errcxdef *ctx, errdef *fr) { - errargc(ctx, fr->erraac); - memcpy(ctx->errcxptr->erraav, fr->erraav, - (size_t)(fr->erraac * sizeof(erradef))); - errsign(ctx, fr->errcode, fr->errfac); + errargc(ctx, fr->erraac); + memcpy(ctx->errcxptr->erraav, fr->erraav, + (size_t)(fr->erraac * sizeof(erradef))); + errsign(ctx, fr->errcode, fr->errfac); } /* log an error: base function */ void errlogn(errcxdef *ctx, int err, const char *facility) { - ctx->errcxofs = 0; - (*ctx->errcxlog)(ctx->errcxlgc, facility, err, ctx->errcxptr->erraac, - ctx->errcxptr->erraav); + ctx->errcxofs = 0; + (*ctx->errcxlog)(ctx->errcxlgc, facility, err, ctx->errcxptr->erraac, + ctx->errcxptr->erraav); } /* log an error with no arguments */ void errlogf(errcxdef *ctx, const char *facility, int err) { - errargc(ctx, 0); - errlogn(ctx, err, facility); + errargc(ctx, 0); + errlogn(ctx, err, facility); } #endif /* ERR_NO_MACRO */ diff --git a/engines/glk/tads/tads2/error_handling.h b/engines/glk/tads/tads2/error_handling.h index d1275944fde..fc30084a176 100644 --- a/engines/glk/tads/tads2/error_handling.h +++ b/engines/glk/tads/tads2/error_handling.h @@ -73,16 +73,16 @@ namespace TADS2 { #define ERRFACMAX 6 union erradef { - int erraint; /* integer argument */ - const char *errastr; /* text string argument */ + int erraint; /* integer argument */ + const char *errastr; /* text string argument */ }; struct errdef { - struct errdef *errprv; /* previous error frame */ - int errcode; /* error code of exception being handled */ - char errfac[ERRFACMAX+1]; /* facility of current error */ - erradef erraav[10]; /* parameters for error */ - int erraac; /* count of parameters in argc */ + struct errdef *errprv; /* previous error frame */ + int errcode; /* error code of exception being handled */ + char errfac[ERRFACMAX+1]; /* facility of current error */ + erradef erraav[10]; /* parameters for error */ + int erraac; /* count of parameters in argc */ }; #define ERRBUFSIZ 512 @@ -91,23 +91,23 @@ struct errdef { * Seek location record for an error message by number */ struct errmfdef { - uint errmfnum; /* error number */ - ulong errmfseek; /* seek location of this message */ + uint errmfnum; /* error number */ + ulong errmfseek; /* seek location of this message */ }; typedef struct errmfdef errmfdef; struct errcxdef { - errdef *errcxptr; /* current error frame */ - void (*errcxlog)(void *, const char *fac, int err, int argc, erradef *); - /* error logging callback function */ - void *errcxlgc; /* context for error logging callback */ - int errcxofs; /* offset in argument buffer */ - char errcxbuf[ERRBUFSIZ]; /* space for argument strings */ - osfildef *errcxfp; /* message file, if one is being used */ - errmfdef *errcxseek; /* seek locations of messages in file */ - uint errcxsksz; /* size of errcxseek array */ - ulong errcxbase; /* offset in physical file of logical error file */ - struct appctxdef *errcxappctx; /* host application context */ + errdef *errcxptr; /* current error frame */ + void (*errcxlog)(void *, const char *fac, int err, int argc, erradef *); + /* error logging callback function */ + void *errcxlgc; /* context for error logging callback */ + int errcxofs; /* offset in argument buffer */ + char errcxbuf[ERRBUFSIZ]; /* space for argument strings */ + osfildef *errcxfp; /* message file, if one is being used */ + errmfdef *errcxseek; /* seek locations of messages in file */ + uint errcxsksz; /* size of errcxseek array */ + ulong errcxbase; /* offset in physical file of logical error file */ + struct appctxdef *errcxappctx; /* host application context */ }; /** @@ -115,47 +115,47 @@ struct errcxdef { */ #define ERRBEGIN(ctx) \ { \ - errdef fr_; \ - if (1 /*(fr_.errcode = setjmp(fr_.errbuf)) == 0 */) \ - { \ - fr_.errprv = (ctx)->errcxptr; \ - (ctx)->errcxptr = &fr_; + errdef fr_; \ + if (1 /*(fr_.errcode = setjmp(fr_.errbuf)) == 0 */) \ + { \ + fr_.errprv = (ctx)->errcxptr; \ + (ctx)->errcxptr = &fr_; /** * End protected code, begin error handler */ #define ERRCATCH(ctx, e) \ - assert(1==1 && (ctx)->errcxptr != fr_.errprv); \ - (ctx)->errcxptr = fr_.errprv; \ - } \ - else \ - { \ - assert(2==2 && (ctx)->errcxptr != fr_.errprv); \ - (e) = fr_.errcode; \ - (ctx)->errcxptr = fr_.errprv; - + assert(1==1 && (ctx)->errcxptr != fr_.errprv); \ + (ctx)->errcxptr = fr_.errprv; \ + } \ + else \ + { \ + assert(2==2 && (ctx)->errcxptr != fr_.errprv); \ + (e) = fr_.errcode; \ + (ctx)->errcxptr = fr_.errprv; + /* retrieve argument (int, string) in current error frame */ #define errargint(argnum) (fr_.erraav[argnum].erraint) #define errargstr(argnum) (fr_.erraav[argnum].errastr) - + #define ERREND(ctx) \ - } \ + } \ } /* end protected code, begin cleanup (no handling; just cleaning up) */ #define ERRCLEAN(ctx) \ - assert((ctx)->errcxptr != fr_.errprv); \ - (ctx)->errcxptr = fr_.errprv; \ - } \ - else \ - { \ - assert((ctx)->errcxptr != fr_.errprv); \ - (ctx)->errcxptr = fr_.errprv; + assert((ctx)->errcxptr != fr_.errprv); \ + (ctx)->errcxptr = fr_.errprv; \ + } \ + else \ + { \ + assert((ctx)->errcxptr != fr_.errprv); \ + (ctx)->errcxptr = fr_.errprv; #define ERRENDCLN(ctx) \ - errrse(ctx); \ - } \ + errrse(ctx); \ + } \ } @@ -192,13 +192,13 @@ void errsign(errcxdef *ctx, int e, const char *facility); void errjmp(jump_buf buf, int e); # define errsign(ctx, e, fac) \ (strncpy((ctx)->errcxptr->errfac, fac, ERRFACMAX),\ - (ctx)->errcxptr->errfac[ERRFACMAX]='\0',\ - (ctx)->errcxofs=0, errjmp((ctx)->errcxptr->errbuf, e)) + (ctx)->errcxptr->errfac[ERRFACMAX]='\0',\ + (ctx)->errcxofs=0, errjmp((ctx)->errcxptr->errbuf, e)) # else /* DEBUG */ # define errsign(ctx, e, fac) \ (strncpy((ctx)->errcxptr->errfac, fac, ERRFACMAX),\ - (ctx)->errcxptr->errfac[ERRFACMAX]='\0',\ - (ctx)->errcxofs=0, longjmp((ctx)->errcxptr->errbuf, e)) + (ctx)->errcxptr->errfac[ERRFACMAX]='\0',\ + (ctx)->errcxofs=0, longjmp((ctx)->errcxptr->errbuf, e)) # endif /* DEBUG */ #endif /* ERR_NO_MACRO */ @@ -229,7 +229,7 @@ void errrse1(errcxdef *ctx, errdef *fr); # define errrse(ctx) \ (errargc(ctx, fr_.erraac),\ memcpy((ctx)->errcxptr->erraav, fr_.erraav, \ - (size_t)(fr_.erraac*sizeof(erradef))),\ + (size_t)(fr_.erraac*sizeof(erradef))),\ errsign(ctx, fr_.errcode, fr_.errfac)) #endif /* ERR_NO_MACRO */ @@ -253,8 +253,8 @@ void errrse1(errcxdef *ctx, errdef *fr); /* void errcopyargs(errcxdef *ctx, errdef *fr); */ #define errcopyargs(ctx, fr) \ (errargc((ctx), (fr)->erraac), \ - memcpy((ctx)->errcxptr->erraav, (fr)->erraav, \ - (size_t)((fr)->erraac*sizeof(erradef)))) + memcpy((ctx)->errcxptr->erraav, (fr)->erraav, \ + (size_t)((fr)->erraac*sizeof(erradef)))) /* log error that's been caught, using arguments already caught */ #define errclog(ctx) \ @@ -309,7 +309,7 @@ void errlogf(errcxdef *ctx, const char *facility, int err); * will be computed and returned.) */ int errfmt(char *outbuf, int outbufl, char *fmt, int argc, - erradef *argv); + erradef *argv); /* get the text of an error */ void errmsg(errcxdef *ctx, char *outbuf, uint outbufl, uint err); @@ -323,8 +323,8 @@ void lerfre(errcxdef *ctx); /* error message structure - number + text */ struct errmdef { - uint errmerr; /* error number */ - char *errmtxt; /* text of error message */ + uint errmerr; /* error number */ + char *errmtxt; /* text of error message */ }; } // End of namespace TADS2 diff --git a/engines/glk/tads/tads2/execute_command.cpp b/engines/glk/tads/tads2/execute_command.cpp index ffec9d6c598..9ea8b135cb4 100644 --- a/engines/glk/tads/tads2/execute_command.cpp +++ b/engines/glk/tads/tads2/execute_command.cpp @@ -91,211 +91,211 @@ namespace TADS2 { /* allocate and initialize a fuse/daemon/notifier array */ void vocinialo(voccxdef *ctx, vocddef **what, int cnt) { - vocddef *p; - - *what = (vocddef *)mchalo(ctx->voccxerr, - (cnt * sizeof(vocddef)), "vocinialo"); + vocddef *p; + + *what = (vocddef *)mchalo(ctx->voccxerr, + (cnt * sizeof(vocddef)), "vocinialo"); - /* set all object/function entries to MCMONINV to indicate not-in-use */ - for (p = *what ; cnt ; ++p, --cnt) - p->vocdfn = MCMONINV; + /* set all object/function entries to MCMONINV to indicate not-in-use */ + for (p = *what ; cnt ; ++p, --cnt) + p->vocdfn = MCMONINV; } /* internal service routine to clear one set of fuses/deamons/alerters */ static void vocdmn1clr(vocddef *dmn, uint cnt) { - for ( ; cnt ; --cnt, ++dmn) dmn->vocdfn = MCMONINV; + for ( ; cnt ; --cnt, ++dmn) dmn->vocdfn = MCMONINV; } /* delete all fuses/daemons/alerters */ void vocdmnclr(voccxdef *ctx) { - vocdmn1clr(ctx->voccxfus, ctx->voccxfuc); - vocdmn1clr(ctx->voccxdmn, ctx->voccxdmc); - vocdmn1clr(ctx->voccxalm, ctx->voccxalc); + vocdmn1clr(ctx->voccxfus, ctx->voccxfuc); + vocdmn1clr(ctx->voccxdmn, ctx->voccxdmc); + vocdmn1clr(ctx->voccxalm, ctx->voccxalc); } /* save undo information for a daemon/fuse/notifier */ static void vocdusav(voccxdef *ctx, vocddef *what) { - uchar *p; - objucxdef *uc = ctx->voccxundo; - ushort siz = sizeof(what) + sizeof(*what) + 1; - - /* if we don't need to save undo, quit now */ - if (uc == 0 || !objuok(uc)) - return; + uchar *p; + objucxdef *uc = ctx->voccxundo; + ushort siz = sizeof(what) + sizeof(*what) + 1; + + /* if we don't need to save undo, quit now */ + if (uc == 0 || !objuok(uc)) + return; - /* reserve space for our record */ - p = objures(uc, OBJUCLI, siz); - - /* set up our undo record */ - *p = VOC_UNDO_DAEMON; - memcpy(p + 1, &what, (size_t)sizeof(what)); - memcpy(p + 1 + sizeof(what), what, (size_t)sizeof(*what)); - - uc->objucxhead += siz; + /* reserve space for our record */ + p = objures(uc, OBJUCLI, siz); + + /* set up our undo record */ + *p = VOC_UNDO_DAEMON; + memcpy(p + 1, &what, (size_t)sizeof(what)); + memcpy(p + 1 + sizeof(what), what, (size_t)sizeof(*what)); + + uc->objucxhead += siz; } /* apply undo information for a daemon/fuse/notifier */ void vocdundo(void *ctx0, uchar *data) { - voccxdef *ctx = (voccxdef *)ctx0; - vocddef *daemon; - objnum objn; - ushort siz; - ushort wrdsiz; - uchar *p; - int sccnt; - objnum sc; - int len1, len2; - prpnum prp; - int flags; - uchar *wrd; + voccxdef *ctx = (voccxdef *)ctx0; + vocddef *daemon; + objnum objn; + ushort siz; + ushort wrdsiz; + uchar *p; + int sccnt; + objnum sc; + int len1, len2; + prpnum prp; + int flags; + uchar *wrd; - switch(*data) - { - case VOC_UNDO_DAEMON: - memcpy(&daemon, data + 1, (size_t)sizeof(daemon)); - memcpy(daemon, data + 1 + sizeof(daemon), (size_t)sizeof(*daemon)); - break; + switch(*data) + { + case VOC_UNDO_DAEMON: + memcpy(&daemon, data + 1, (size_t)sizeof(daemon)); + memcpy(daemon, data + 1 + sizeof(daemon), (size_t)sizeof(*daemon)); + break; - case VOC_UNDO_NEWOBJ: - /* get the object number */ - objn = osrp2(data + 1); + case VOC_UNDO_NEWOBJ: + /* get the object number */ + objn = osrp2(data + 1); - /* delete the object's inheritance and vocabulary records */ - vocdel(ctx, objn); - vocidel(ctx, objn); + /* delete the object's inheritance and vocabulary records */ + vocdel(ctx, objn); + vocidel(ctx, objn); - /* delete the object */ - mcmfre(ctx->voccxmem, (mcmon)objn); - break; + /* delete the object */ + mcmfre(ctx->voccxmem, (mcmon)objn); + break; - case VOC_UNDO_DELOBJ: - /* get the object's number and size */ - objn = osrp2(data + 1); - siz = osrp2(data + 3); - wrdsiz = osrp2(data + 5); + case VOC_UNDO_DELOBJ: + /* get the object's number and size */ + objn = osrp2(data + 1); + siz = osrp2(data + 3); + wrdsiz = osrp2(data + 5); - /* allocate the object with its original number */ - p = mcmalonum(ctx->voccxmem, siz, (mcmon)objn); + /* allocate the object with its original number */ + p = mcmalonum(ctx->voccxmem, siz, (mcmon)objn); - /* copy the contents back to the object */ - memcpy(p, data + 7, (size_t)siz); + /* copy the contents back to the object */ + memcpy(p, data + 7, (size_t)siz); - /* get its superclass if it has one */ - sccnt = objnsc(p); - if (sccnt) sc = osrp2(objsc(p)); + /* get its superclass if it has one */ + sccnt = objnsc(p); + if (sccnt) sc = osrp2(objsc(p)); - /* unlock the object, and create its inheritance records */ - mcmunlck(ctx->voccxmem, (mcmon)objn); - vociadd(ctx, objn, MCMONINV, sccnt, &sc, VOCIFNEW | VOCIFVOC); + /* unlock the object, and create its inheritance records */ + mcmunlck(ctx->voccxmem, (mcmon)objn); + vociadd(ctx, objn, MCMONINV, sccnt, &sc, VOCIFNEW | VOCIFVOC); - /* restore the words as well */ - data += 7 + siz; - while (wrdsiz) - { - /* get the lengths from the buffer */ - len1 = osrp2(data + 2); - len2 = osrp2(data + 4); + /* restore the words as well */ + data += 7 + siz; + while (wrdsiz) + { + /* get the lengths from the buffer */ + len1 = osrp2(data + 2); + len2 = osrp2(data + 4); - /* add the word */ - vocadd2(ctx, data[0], objn, data[1], data+6, len1, - data+6+len1, len2); - - /* remove this object from the word size */ - wrdsiz -= 6 + len1 + len2; - data += 6 + len1 + len2; - } - break; + /* add the word */ + vocadd2(ctx, data[0], objn, data[1], data+6, len1, + data+6+len1, len2); + + /* remove this object from the word size */ + wrdsiz -= 6 + len1 + len2; + data += 6 + len1 + len2; + } + break; - case VOC_UNDO_ADDVOC: - case VOC_UNDO_DELVOC: - flags = *(data + 1); - prp = *(data + 2); - objn = osrp2(data + 3); - wrd = data + 5; - if (*data == VOC_UNDO_ADDVOC) - vocdel1(ctx, objn, (char *)wrd, prp, FALSE, FALSE, FALSE); - else - vocadd(ctx, prp, objn, flags, (char *)wrd); - break; + case VOC_UNDO_ADDVOC: + case VOC_UNDO_DELVOC: + flags = *(data + 1); + prp = *(data + 2); + objn = osrp2(data + 3); + wrd = data + 5; + if (*data == VOC_UNDO_ADDVOC) + vocdel1(ctx, objn, (char *)wrd, prp, FALSE, FALSE, FALSE); + else + vocadd(ctx, prp, objn, flags, (char *)wrd); + break; - case VOC_UNDO_SETME: - ctx->voccxme = osrp2(data + 1); - break; - } + case VOC_UNDO_SETME: + ctx->voccxme = osrp2(data + 1); + break; + } } /* determine size of one of our client undo records */ ushort OS_LOADDS vocdusz(void *ctx0, uchar *data) { - VARUSED(ctx0); + VARUSED(ctx0); - switch(*data) - { - case VOC_UNDO_DAEMON: - /* it's the size of the structures, plus one for the header */ - return (ushort)((sizeof(vocddef *) + sizeof(vocddef)) + 1); + switch(*data) + { + case VOC_UNDO_DAEMON: + /* it's the size of the structures, plus one for the header */ + return (ushort)((sizeof(vocddef *) + sizeof(vocddef)) + 1); - case VOC_UNDO_NEWOBJ: - /* 2 bytes for the objnum plus 1 for the header */ - return 2 + 1; + case VOC_UNDO_NEWOBJ: + /* 2 bytes for the objnum plus 1 for the header */ + return 2 + 1; - case VOC_UNDO_DELOBJ: - /* - * 1 (header) + 2 (objnum) + 2 (size) + 2 (word size) + object - * data size + word size - */ - return osrp2(data+3) + osrp2(data+5) + 1+2+2+2; + case VOC_UNDO_DELOBJ: + /* + * 1 (header) + 2 (objnum) + 2 (size) + 2 (word size) + object + * data size + word size + */ + return osrp2(data+3) + osrp2(data+5) + 1+2+2+2; - case VOC_UNDO_ADDVOC: - case VOC_UNDO_DELVOC: - /* 1 (header) + 2 (objnum) + 1 (flags) + 1 (type) + word size */ - return osrp2(data + 5) + 5; + case VOC_UNDO_ADDVOC: + case VOC_UNDO_DELVOC: + /* 1 (header) + 2 (objnum) + 1 (flags) + 1 (type) + word size */ + return osrp2(data + 5) + 5; - default: - return 0; - } + default: + return 0; + } } /* save undo for object creation */ void vocdusave_newobj(voccxdef *ctx, objnum objn) { - objucxdef *uc = ctx->voccxundo; - uchar *p; + objucxdef *uc = ctx->voccxundo; + uchar *p; - p = objures(uc, OBJUCLI, 3); - *p = VOC_UNDO_NEWOBJ; - oswp2(p+1, objn); + p = objures(uc, OBJUCLI, 3); + *p = VOC_UNDO_NEWOBJ; + oswp2(p+1, objn); - uc->objucxhead += 3; + uc->objucxhead += 3; } /* save undo information for a change in the "Me" object */ void vocdusave_me(voccxdef *ctx, objnum old_me) { - uchar *p; - objucxdef *uc = ctx->voccxundo; + uchar *p; + objucxdef *uc = ctx->voccxundo; - /* if we don't need to save undo, there's nothing to do */ - if (uc == 0 || !objuok(uc)) - return; + /* if we don't need to save undo, there's nothing to do */ + if (uc == 0 || !objuok(uc)) + return; - /* reserve space for our record */ - p = objures(uc, OBJUCLI, 3); - *p = VOC_UNDO_SETME; - oswp2(p+1, old_me); + /* reserve space for our record */ + p = objures(uc, OBJUCLI, 3); + *p = VOC_UNDO_SETME; + oswp2(p+1, old_me); - /* absorb the space */ - uc->objucxhead += 3; + /* absorb the space */ + uc->objucxhead += 3; } /* callback context structure */ struct delobj_cb_ctx { - uchar *p; + uchar *p; }; /* @@ -305,179 +305,179 @@ struct delobj_cb_ctx */ static void delobj_cb(void *ctx0, vocdef *voc, vocwdef *vocw) { - struct delobj_cb_ctx *ctx = (struct delobj_cb_ctx *)ctx0; - uchar *p = ctx->p; - - /* write this object's header to the stream */ - p[0] = vocw->vocwtyp; - p[1] = vocw->vocwflg; - oswp2(p+2, voc->voclen); - oswp2(p+4, voc->vocln2); + struct delobj_cb_ctx *ctx = (struct delobj_cb_ctx *)ctx0; + uchar *p = ctx->p; + + /* write this object's header to the stream */ + p[0] = vocw->vocwtyp; + p[1] = vocw->vocwflg; + oswp2(p+2, voc->voclen); + oswp2(p+4, voc->vocln2); - /* write the words as well */ - memcpy(p+6, voc->voctxt, (size_t)(voc->voclen + voc->vocln2)); + /* write the words as well */ + memcpy(p+6, voc->voctxt, (size_t)(voc->voclen + voc->vocln2)); - /* advance the pointer */ - ctx->p += 6 + voc->voclen + voc->vocln2; + /* advance the pointer */ + ctx->p += 6 + voc->voclen + voc->vocln2; } /* save undo for object deletion */ void vocdusave_delobj(voccxdef *ctx, objnum objn) { - objucxdef *uc = ctx->voccxundo; - uchar *p; - uchar *objp; - uint siz; - int wrdsiz; - int wrdcnt; - struct delobj_cb_ctx fnctx; + objucxdef *uc = ctx->voccxundo; + uchar *p; + uchar *objp; + uint siz; + int wrdsiz; + int wrdcnt; + struct delobj_cb_ctx fnctx; - /* figure out how much we need to save */ - objp = mcmlck(ctx->voccxmem, (mcmon)objn); - siz = objfree(objp); + /* figure out how much we need to save */ + objp = mcmlck(ctx->voccxmem, (mcmon)objn); + siz = objfree(objp); - /* figure the word size */ - voc_count(ctx, objn, 0, &wrdcnt, &wrdsiz); + /* figure the word size */ + voc_count(ctx, objn, 0, &wrdcnt, &wrdsiz); - /* - * we need to store an additional 6 bytes (2-length1, 2-length2, - * 1-type, 1-flags) for each word - */ - wrdsiz += wrdcnt*6; + /* + * we need to store an additional 6 bytes (2-length1, 2-length2, + * 1-type, 1-flags) for each word + */ + wrdsiz += wrdcnt*6; - /* set up the undo header */ - p = objures(uc, OBJUCLI, (ushort)(7 + siz + wrdsiz)); - *p = VOC_UNDO_DELOBJ; - oswp2(p+1, objn); - oswp2(p+3, siz); - oswp2(p+5, wrdsiz); + /* set up the undo header */ + p = objures(uc, OBJUCLI, (ushort)(7 + siz + wrdsiz)); + *p = VOC_UNDO_DELOBJ; + oswp2(p+1, objn); + oswp2(p+3, siz); + oswp2(p+5, wrdsiz); - /* save the object's data */ - memcpy(p+7, objp, (size_t)siz); + /* save the object's data */ + memcpy(p+7, objp, (size_t)siz); - /* write the words */ - fnctx.p = p+7 + siz; - voc_iterate(ctx, objn, delobj_cb, &fnctx); + /* write the words */ + fnctx.p = p+7 + siz; + voc_iterate(ctx, objn, delobj_cb, &fnctx); - /* unlock the object and advance the undo pointer */ - mcmunlck(ctx->voccxmem, (mcmon)objn); - uc->objucxhead += 7 + siz + wrdsiz; + /* unlock the object and advance the undo pointer */ + mcmunlck(ctx->voccxmem, (mcmon)objn); + uc->objucxhead += 7 + siz + wrdsiz; } /* save undo for word creation */ void vocdusave_addwrd(voccxdef *ctx, objnum objn, prpnum typ, int flags, - char *wrd) + char *wrd) { - ushort wrdsiz; - uchar *p; - objucxdef *uc = ctx->voccxundo; + ushort wrdsiz; + uchar *p; + objucxdef *uc = ctx->voccxundo; - /* figure out how much space we need, and reserve it */ - wrdsiz = osrp2(wrd); - p = objures(uc, OBJUCLI, (ushort)(5 + wrdsiz)); + /* figure out how much space we need, and reserve it */ + wrdsiz = osrp2(wrd); + p = objures(uc, OBJUCLI, (ushort)(5 + wrdsiz)); - *p = VOC_UNDO_ADDVOC; - *(p+1) = flags; - *(p+2) = (uchar)typ; - oswp2(p+3, objn); - memcpy(p+5, wrd, (size_t)wrdsiz); + *p = VOC_UNDO_ADDVOC; + *(p+1) = flags; + *(p+2) = (uchar)typ; + oswp2(p+3, objn); + memcpy(p+5, wrd, (size_t)wrdsiz); - uc->objucxhead += 5 + wrdsiz; + uc->objucxhead += 5 + wrdsiz; } /* save undo for word deletion */ void vocdusave_delwrd(voccxdef *ctx, objnum objn, prpnum typ, int flags, - char *wrd) + char *wrd) { - ushort wrdsiz; - uchar *p; - objucxdef *uc = ctx->voccxundo; + ushort wrdsiz; + uchar *p; + objucxdef *uc = ctx->voccxundo; - /* figure out how much space we need, and reserve it */ - wrdsiz = osrp2(wrd); - p = objures(uc, OBJUCLI, (ushort)(5 + wrdsiz)); + /* figure out how much space we need, and reserve it */ + wrdsiz = osrp2(wrd); + p = objures(uc, OBJUCLI, (ushort)(5 + wrdsiz)); - *p = VOC_UNDO_DELVOC; - *(p+1) = flags; - *(p+2) = (uchar)typ; - oswp2(p+3, objn); - memcpy(p+5, wrd, (size_t)wrdsiz); + *p = VOC_UNDO_DELVOC; + *(p+1) = flags; + *(p+2) = (uchar)typ; + oswp2(p+3, objn); + memcpy(p+5, wrd, (size_t)wrdsiz); - uc->objucxhead += 5 + wrdsiz; + uc->objucxhead += 5 + wrdsiz; } - + /* set a fuse/daemon/notifier */ void vocsetfd(voccxdef *ctx, vocddef *what, objnum func, prpnum prop, - uint tm, runsdef *val, int err) + uint tm, runsdef *val, int err) { int slots = 0; - - if (what == ctx->voccxdmn) - slots = ctx->voccxdmc; - else if (what == ctx->voccxalm) - slots = ctx->voccxalc; - else if (what == ctx->voccxfus) - slots = ctx->voccxfuc; - else - errsig(ctx->voccxerr, ERR_BADSETF); - - /* find a free slot, and set up our fuse/daemon */ - for ( ; slots ; ++what, --slots) - { - if (what->vocdfn == MCMONINV) - { - /* save an undo record for this slot before changing */ - vocdusav(ctx, what); - - /* record the information */ - what->vocdfn = func; - if (val != 0) - OSCPYSTRUCT(what->vocdarg, *val); - what->vocdprp = prop; - what->vocdtim = tm; + + if (what == ctx->voccxdmn) + slots = ctx->voccxdmc; + else if (what == ctx->voccxalm) + slots = ctx->voccxalc; + else if (what == ctx->voccxfus) + slots = ctx->voccxfuc; + else + errsig(ctx->voccxerr, ERR_BADSETF); + + /* find a free slot, and set up our fuse/daemon */ + for ( ; slots ; ++what, --slots) + { + if (what->vocdfn == MCMONINV) + { + /* save an undo record for this slot before changing */ + vocdusav(ctx, what); + + /* record the information */ + what->vocdfn = func; + if (val != 0) + OSCPYSTRUCT(what->vocdarg, *val); + what->vocdprp = prop; + what->vocdtim = tm; - /* - * the fuse/notifier/daemon is set - no need to look further - * for an open slot - */ - return; - } - } + /* + * the fuse/notifier/daemon is set - no need to look further + * for an open slot + */ + return; + } + } - /* we didn't find an open slot - signal the appropriate error */ - errsig(ctx->voccxerr, err); + /* we didn't find an open slot - signal the appropriate error */ + errsig(ctx->voccxerr, err); } /* remove a fuse/daemon/notifier */ void vocremfd(voccxdef *ctx, vocddef *what, objnum func, prpnum prop, - runsdef *val, int err) + runsdef *val, int err) { int slots = 0; - - if (what == ctx->voccxdmn) slots = ctx->voccxdmc; - else if (what == ctx->voccxalm) slots = ctx->voccxalc; - else if (what == ctx->voccxfus) slots = ctx->voccxfuc; - else errsig(ctx->voccxerr, ERR_BADREMF); - - /* find the slot with this same fuse/daemon/notifier, and remove it */ - for ( ; slots ; ++what, --slots) - { - if (what->vocdfn == func - && what->vocdprp == prop - && (!val || (val->runstyp == what->vocdarg.runstyp - && !memcmp(&val->runsv, &what->vocdarg.runsv, - (size_t)datsiz(val->runstyp, - &val->runsv))))) - { - /* save an undo record for this slot before changing */ - vocdusav(ctx, what); + + if (what == ctx->voccxdmn) slots = ctx->voccxdmc; + else if (what == ctx->voccxalm) slots = ctx->voccxalc; + else if (what == ctx->voccxfus) slots = ctx->voccxfuc; + else errsig(ctx->voccxerr, ERR_BADREMF); + + /* find the slot with this same fuse/daemon/notifier, and remove it */ + for ( ; slots ; ++what, --slots) + { + if (what->vocdfn == func + && what->vocdprp == prop + && (!val || (val->runstyp == what->vocdarg.runstyp + && !memcmp(&val->runsv, &what->vocdarg.runsv, + (size_t)datsiz(val->runstyp, + &val->runsv))))) + { + /* save an undo record for this slot before changing */ + vocdusav(ctx, what); - what->vocdfn = MCMONINV; - return; - } - } + what->vocdfn = MCMONINV; + return; + } + } /* errsig(ctx->voccxerr, err); <<>> */ } @@ -492,50 +492,50 @@ void vocremfd(voccxdef *ctx, vocddef *what, objnum func, prpnum prop, */ void vocturn(voccxdef *ctx, int turncnt, int do_fuses) { - vocddef *p; - int i; - int do_exe; + vocddef *p; + int i; + int do_exe; - while (turncnt--) - { - /* presume we won't find anything to execute */ - do_exe = FALSE; - - /* go through notifiers, looking for fuse-type notifiers */ - for (i = ctx->voccxalc, p = ctx->voccxalm ; i ; ++p, --i) - { - if (p->vocdfn != MCMONINV - && p->vocdtim != VOCDTIM_EACH_TURN - && p->vocdtim != 0) - { - /* save an undo record for this slot before changing */ - vocdusav(ctx, p); - - if (--(p->vocdtim) == 0) - do_exe = TRUE; - } - } - - /* now go through the fuses */ - for (i = ctx->voccxfuc, p = ctx->voccxfus ; i ; ++p, --i) - { - if (p->vocdfn != MCMONINV && p->vocdtim != 0) - { - /* save an undo record for this slot before changing */ - vocdusav(ctx, p); + while (turncnt--) + { + /* presume we won't find anything to execute */ + do_exe = FALSE; + + /* go through notifiers, looking for fuse-type notifiers */ + for (i = ctx->voccxalc, p = ctx->voccxalm ; i ; ++p, --i) + { + if (p->vocdfn != MCMONINV + && p->vocdtim != VOCDTIM_EACH_TURN + && p->vocdtim != 0) + { + /* save an undo record for this slot before changing */ + vocdusav(ctx, p); + + if (--(p->vocdtim) == 0) + do_exe = TRUE; + } + } + + /* now go through the fuses */ + for (i = ctx->voccxfuc, p = ctx->voccxfus ; i ; ++p, --i) + { + if (p->vocdfn != MCMONINV && p->vocdtim != 0) + { + /* save an undo record for this slot before changing */ + vocdusav(ctx, p); - if (--(p->vocdtim) == 0) - do_exe = TRUE; - } - } + if (--(p->vocdtim) == 0) + do_exe = TRUE; + } + } - /* - * if we'll be doing more, and anything burned down, run - * current fuses before going on to the next turn - */ - if ((!do_fuses || turncnt) && do_exe) - exefuse(ctx, do_fuses); - } + /* + * if we'll be doing more, and anything burned down, run + * current fuses before going on to the next turn + */ + if ((!do_fuses || turncnt) && do_exe) + exefuse(ctx, do_fuses); + } } /* @@ -548,37 +548,37 @@ void vocturn(voccxdef *ctx, int turncnt, int do_fuses) * lack verDo or verIo). */ static void exeperr(voccxdef *ctx, objnum verb, objnum dobj, - objnum prep, objnum iobj) + objnum prep, objnum iobj) { - if (ctx->voccxper2 != MCMONINV) - { - runpobj(ctx->voccxrun, iobj); - runpobj(ctx->voccxrun, prep); - runpobj(ctx->voccxrun, dobj); - runpobj(ctx->voccxrun, verb); - runfn(ctx->voccxrun, ctx->voccxper2, 4); - return; - } - - vocerr(ctx, VOCERR(110), "I don't know how to "); - runppr(ctx->voccxrun, verb, PRP_SDESC, 0); - - if (dobj != MCMONINV) - { - vocerr(ctx, VOCERR(111), " "); - runppr(ctx->voccxrun, dobj, PRP_THEDESC, 0); - } - else - { - vocerr(ctx, VOCERR(112), " anything "); - if (prep != MCMONINV) - runppr(ctx->voccxrun, prep, PRP_SDESC, 0); - else - vocerr(ctx, VOCERR(113), "to"); - vocerr(ctx, VOCERR(114), " "); - runppr(ctx->voccxrun, iobj, PRP_THEDESC, 0); - } - vocerr(ctx, VOCERR(115), "."); + if (ctx->voccxper2 != MCMONINV) + { + runpobj(ctx->voccxrun, iobj); + runpobj(ctx->voccxrun, prep); + runpobj(ctx->voccxrun, dobj); + runpobj(ctx->voccxrun, verb); + runfn(ctx->voccxrun, ctx->voccxper2, 4); + return; + } + + vocerr(ctx, VOCERR(110), "I don't know how to "); + runppr(ctx->voccxrun, verb, PRP_SDESC, 0); + + if (dobj != MCMONINV) + { + vocerr(ctx, VOCERR(111), " "); + runppr(ctx->voccxrun, dobj, PRP_THEDESC, 0); + } + else + { + vocerr(ctx, VOCERR(112), " anything "); + if (prep != MCMONINV) + runppr(ctx->voccxrun, prep, PRP_SDESC, 0); + else + vocerr(ctx, VOCERR(113), "to"); + vocerr(ctx, VOCERR(114), " "); + runppr(ctx->voccxrun, iobj, PRP_THEDESC, 0); + } + vocerr(ctx, VOCERR(115), "."); } @@ -587,45 +587,45 @@ static void exeperr(voccxdef *ctx, objnum verb, objnum dobj, */ void exedaem(voccxdef *ctx) { - runcxdef *rcx = ctx->voccxrun; - vocddef *daemon; - int i; - runsdef val; - int err; + runcxdef *rcx = ctx->voccxrun; + vocddef *daemon; + int i; + runsdef val; + int err; - for (i = ctx->voccxdmc, daemon = ctx->voccxdmn ; i ; ++daemon, --i) - { - if (daemon->vocdfn != MCMONINV) - { - objnum thisd = daemon->vocdfn; - - ERRBEGIN(ctx->voccxerr) + for (i = ctx->voccxdmc, daemon = ctx->voccxdmn ; i ; ++daemon, --i) + { + if (daemon->vocdfn != MCMONINV) + { + objnum thisd = daemon->vocdfn; + + ERRBEGIN(ctx->voccxerr) - OSCPYSTRUCT(val, daemon->vocdarg); - runpush(rcx, val.runstyp, &val); - runfn(rcx, thisd, 1); - - ERRCATCH(ctx->voccxerr, err) - if (err != ERR_RUNEXIT && err != ERR_RUNEXITOBJ) - errrse(ctx->voccxerr); - ERREND(ctx->voccxerr) - } - } - for (i = ctx->voccxalc, daemon = ctx->voccxalm ; i ; ++daemon, --i) - { - if (daemon->vocdfn != MCMONINV - && daemon->vocdtim == VOCDTIM_EACH_TURN) - { - ERRBEGIN(ctx->voccxerr) + OSCPYSTRUCT(val, daemon->vocdarg); + runpush(rcx, val.runstyp, &val); + runfn(rcx, thisd, 1); + + ERRCATCH(ctx->voccxerr, err) + if (err != ERR_RUNEXIT && err != ERR_RUNEXITOBJ) + errrse(ctx->voccxerr); + ERREND(ctx->voccxerr) + } + } + for (i = ctx->voccxalc, daemon = ctx->voccxalm ; i ; ++daemon, --i) + { + if (daemon->vocdfn != MCMONINV + && daemon->vocdtim == VOCDTIM_EACH_TURN) + { + ERRBEGIN(ctx->voccxerr) - runppr(rcx, daemon->vocdfn, daemon->vocdprp, 0); - - ERRCATCH(ctx->voccxerr, err) - if (err != ERR_RUNEXIT && err != ERR_RUNEXITOBJ) - errrse(ctx->voccxerr); - ERREND(ctx->voccxerr) - } - } + runppr(rcx, daemon->vocdfn, daemon->vocdprp, 0); + + ERRCATCH(ctx->voccxerr, err) + if (err != ERR_RUNEXIT && err != ERR_RUNEXITOBJ) + errrse(ctx->voccxerr); + ERREND(ctx->voccxerr) + } + } } /* @@ -634,71 +634,71 @@ void exedaem(voccxdef *ctx) */ int exefuse(voccxdef *ctx, int do_run) { - runcxdef *rcx = ctx->voccxrun; - vocddef *daemon; - int i; - int found = FALSE; - runsdef val; - int err; + runcxdef *rcx = ctx->voccxrun; + vocddef *daemon; + int i; + int found = FALSE; + runsdef val; + int err; - /* first, execute any expired function-based fuses */ - for (i = ctx->voccxfuc, daemon = ctx->voccxfus ; i ; ++daemon, --i) - { - if (daemon->vocdfn != MCMONINV && daemon->vocdtim == 0) - { - objnum thisf = daemon->vocdfn; - - found = TRUE; - ERRBEGIN(ctx->voccxerr) + /* first, execute any expired function-based fuses */ + for (i = ctx->voccxfuc, daemon = ctx->voccxfus ; i ; ++daemon, --i) + { + if (daemon->vocdfn != MCMONINV && daemon->vocdtim == 0) + { + objnum thisf = daemon->vocdfn; + + found = TRUE; + ERRBEGIN(ctx->voccxerr) - /* save an undo record for this slot before changing */ - vocdusav(ctx, daemon); + /* save an undo record for this slot before changing */ + vocdusav(ctx, daemon); - /* remove the fuse prior to running */ - daemon->vocdfn = MCMONINV; + /* remove the fuse prior to running */ + daemon->vocdfn = MCMONINV; - if (do_run) - { - OSCPYSTRUCT(val, daemon->vocdarg); - runpush(rcx, val.runstyp, &val); - runfn(rcx, thisf, 1); - } - - ERRCATCH(ctx->voccxerr, err) - if (err != ERR_RUNEXIT && err != ERR_RUNEXITOBJ) - errrse(ctx->voccxerr); - ERREND(ctx->voccxerr) - } - } + if (do_run) + { + OSCPYSTRUCT(val, daemon->vocdarg); + runpush(rcx, val.runstyp, &val); + runfn(rcx, thisf, 1); + } + + ERRCATCH(ctx->voccxerr, err) + if (err != ERR_RUNEXIT && err != ERR_RUNEXITOBJ) + errrse(ctx->voccxerr); + ERREND(ctx->voccxerr) + } + } - /* next, execute any expired method-based notifier fuses */ - for (i = ctx->voccxalc, daemon = ctx->voccxalm ; i ; ++daemon, --i) - { - if (daemon->vocdfn != MCMONINV && daemon->vocdtim == 0) - { - objnum thisa = daemon->vocdfn; + /* next, execute any expired method-based notifier fuses */ + for (i = ctx->voccxalc, daemon = ctx->voccxalm ; i ; ++daemon, --i) + { + if (daemon->vocdfn != MCMONINV && daemon->vocdtim == 0) + { + objnum thisa = daemon->vocdfn; - found = TRUE; - ERRBEGIN(ctx->voccxerr) + found = TRUE; + ERRBEGIN(ctx->voccxerr) - /* save an undo record for this slot before changing */ - vocdusav(ctx, daemon); + /* save an undo record for this slot before changing */ + vocdusav(ctx, daemon); - /* delete it prior to running it */ - daemon->vocdfn = MCMONINV; + /* delete it prior to running it */ + daemon->vocdfn = MCMONINV; - if (do_run) - runppr(rcx, thisa, daemon->vocdprp, 0); - - ERRCATCH(ctx->voccxerr, err) - if (err != ERR_RUNEXIT && err != ERR_RUNEXITOBJ) - errrse(ctx->voccxerr); - ERREND(ctx->voccxerr) - } - } + if (do_run) + runppr(rcx, thisa, daemon->vocdprp, 0); + + ERRCATCH(ctx->voccxerr, err) + if (err != ERR_RUNEXIT && err != ERR_RUNEXITOBJ) + errrse(ctx->voccxerr); + ERREND(ctx->voccxerr) + } + } - /* return true if we found any expired fuses */ - return found; + /* return true if we found any expired fuses */ + return found; } /* ------------------------------------------------------------------------ */ @@ -710,17 +710,17 @@ int exefuse(voccxdef *ctx, int do_run) * *actofs to zero if there's no action routine. */ static void exe_get_tpl(voccxdef *ctx, objnum verb, - uint *tplofs, uint *actofs) + uint *tplofs, uint *actofs) { - /* look up the new-style template first */ - *tplofs = objgetap(ctx->voccxmem, verb, PRP_TPL2, (objnum *)0, FALSE); + /* look up the new-style template first */ + *tplofs = objgetap(ctx->voccxmem, verb, PRP_TPL2, (objnum *)0, FALSE); - /* if there's no new-style template, look up the old-style template */ - if (*tplofs == 0) - *tplofs = objgetap(ctx->voccxmem, verb, PRP_TPL, (objnum *)0, FALSE); + /* if there's no new-style template, look up the old-style template */ + if (*tplofs == 0) + *tplofs = objgetap(ctx->voccxmem, verb, PRP_TPL, (objnum *)0, FALSE); - /* also look to see if the verb has an Action method */ - *actofs = objgetap(ctx->voccxmem, verb, PRP_ACTION, (objnum *)0, FALSE); + /* also look to see if the verb has an Action method */ + *actofs = objgetap(ctx->voccxmem, verb, PRP_ACTION, (objnum *)0, FALSE); } @@ -730,59 +730,59 @@ static void exe_get_tpl(voccxdef *ctx, objnum verb, * 'abort' was thrown during execution. */ int exe_fuses_and_daemons(voccxdef *ctx, int err, int do_fuses, - objnum actor, objnum verb, - vocoldef *dobj_list, int dobj_cnt, - objnum prep, objnum iobj) + objnum actor, objnum verb, + vocoldef *dobj_list, int dobj_cnt, + objnum prep, objnum iobj) { - int err2; + int err2; - /* presume no error */ - err2 = 0; - - /* execute fuses and daemons if desired - trap any errors that occur */ - if (do_fuses) - { - ERRBEGIN(ctx->voccxerr) - { - /* execute daemons */ - exedaem(ctx); - - /* execute fuses */ - (void)exefuse(ctx, TRUE); - } - ERRCATCH(ctx->voccxerr, err2) - { - /* - * if 'abort' was invoked, ignore it, since it's now had the - * desired effect of skipping any remaining fuses and - * daemons; resignal any other error - */ - if (err2 != ERR_RUNABRT) - errrse(ctx->voccxerr); - - /* replace any previous error with the new error code */ - err = err2; - } - ERREND(ctx->voccxerr); - } + /* presume no error */ + err2 = 0; + + /* execute fuses and daemons if desired - trap any errors that occur */ + if (do_fuses) + { + ERRBEGIN(ctx->voccxerr) + { + /* execute daemons */ + exedaem(ctx); + + /* execute fuses */ + (void)exefuse(ctx, TRUE); + } + ERRCATCH(ctx->voccxerr, err2) + { + /* + * if 'abort' was invoked, ignore it, since it's now had the + * desired effect of skipping any remaining fuses and + * daemons; resignal any other error + */ + if (err2 != ERR_RUNABRT) + errrse(ctx->voccxerr); + + /* replace any previous error with the new error code */ + err = err2; + } + ERREND(ctx->voccxerr); + } - /* execute endCommand if it's defined */ - if (ctx->voccxendcmd != MCMONINV) - { - /* push the arguments */ - runpnum(ctx->voccxrun, err); - runpobj(ctx->voccxrun, iobj); - runpobj(ctx->voccxrun, prep); - voc_push_vocoldef_list(ctx, dobj_list, dobj_cnt); - runpobj(ctx->voccxrun, verb); - runpobj(ctx->voccxrun, actor); + /* execute endCommand if it's defined */ + if (ctx->voccxendcmd != MCMONINV) + { + /* push the arguments */ + runpnum(ctx->voccxrun, err); + runpobj(ctx->voccxrun, iobj); + runpobj(ctx->voccxrun, prep); + voc_push_vocoldef_list(ctx, dobj_list, dobj_cnt); + runpobj(ctx->voccxrun, verb); + runpobj(ctx->voccxrun, actor); - /* call endCommand */ - runfn(ctx->voccxrun, ctx->voccxendcmd, 6); - } + /* call endCommand */ + runfn(ctx->voccxrun, ctx->voccxendcmd, 6); + } - /* return the error status */ - return err; + /* return the error status */ + return err; } /* ------------------------------------------------------------------------ */ @@ -790,33 +790,33 @@ int exe_fuses_and_daemons(voccxdef *ctx, int err, int do_fuses, * execute iobjGen/dobjGen methods, if appropriate */ static int exegen(voccxdef *ctx, objnum obj, prpnum genprop, - prpnum verprop, prpnum actprop) + prpnum verprop, prpnum actprop) { - int hasgen; /* has xobjGen property */ - objnum genobj; /* object with xobjGen property */ - int hasver; /* has verXoVerb property */ - objnum verobj; /* object with verXoVerb property */ - int hasact; /* has xoVerb property */ - objnum actobj; /* object with xoVerb property */ - - /* ignore it if there's no object here */ - if (obj == MCMONINV) return(FALSE); + int hasgen; /* has xobjGen property */ + objnum genobj; /* object with xobjGen property */ + int hasver; /* has verXoVerb property */ + objnum verobj; /* object with verXoVerb property */ + int hasact; /* has xoVerb property */ + objnum actobj; /* object with xoVerb property */ + + /* ignore it if there's no object here */ + if (obj == MCMONINV) return(FALSE); - /* look up the xobjGen property, and ignore if not present */ - hasgen = objgetap(ctx->voccxmem, obj, genprop, &genobj, FALSE); - if (!hasgen) return(FALSE); + /* look up the xobjGen property, and ignore if not present */ + hasgen = objgetap(ctx->voccxmem, obj, genprop, &genobj, FALSE); + if (!hasgen) return(FALSE); - /* look up the verXoVerb and xoVerb properties */ - hasver = objgetap(ctx->voccxmem, obj, verprop, &verobj, FALSE); - hasact = objgetap(ctx->voccxmem, obj, actprop, &actobj, FALSE); + /* look up the verXoVerb and xoVerb properties */ + hasver = objgetap(ctx->voccxmem, obj, verprop, &verobj, FALSE); + hasact = objgetap(ctx->voccxmem, obj, actprop, &actobj, FALSE); - /* ignore if verXoVerb or xoVerb "overrides" xobjGen */ - if ((hasver && !bifinh(ctx, vocinh(ctx, genobj), verobj)) - || (hasact && !bifinh(ctx, vocinh(ctx, genobj), actobj))) - return FALSE; - - /* all conditions are met - execute dobjGen */ - return TRUE; + /* ignore if verXoVerb or xoVerb "overrides" xobjGen */ + if ((hasver && !bifinh(ctx, vocinh(ctx, genobj), verobj)) + || (hasact && !bifinh(ctx, vocinh(ctx, genobj), actobj))) + return FALSE; + + /* all conditions are met - execute dobjGen */ + return TRUE; } /* ------------------------------------------------------------------------ */ @@ -824,48 +824,48 @@ static int exegen(voccxdef *ctx, objnum obj, prpnum genprop, * Save "again" information for a direct or indirect object */ static void exe_save_again_obj(vocoldef *againv, const vocoldef *objv, - char **bufp) + char **bufp) { - /* if there's an object, save it */ - if (objv != 0) - { - /* copy the object information structure */ - memcpy(againv, objv, sizeof(*againv)); + /* if there's an object, save it */ + if (objv != 0) + { + /* copy the object information structure */ + memcpy(againv, objv, sizeof(*againv)); - /* copy the original command words to the "again" buffer */ - if (objv->vocolfst != 0 && objv->vocollst != 0) - { - size_t copylen; - - /* - * Compute the length of the entire list. The words are - * arranged consecutively in the buffer, separated by null - * bytes, so we must copy everything from the first word to - * the start of the last word, plus the length of the last - * word, plus the last word's trailing null byte. - */ - copylen = objv->vocollst - objv->vocolfst - + strlen(objv->vocollst) + 1; + /* copy the original command words to the "again" buffer */ + if (objv->vocolfst != 0 && objv->vocollst != 0) + { + size_t copylen; + + /* + * Compute the length of the entire list. The words are + * arranged consecutively in the buffer, separated by null + * bytes, so we must copy everything from the first word to + * the start of the last word, plus the length of the last + * word, plus the last word's trailing null byte. + */ + copylen = objv->vocollst - objv->vocolfst + + strlen(objv->vocollst) + 1; - /* copy the text */ - memcpy(*bufp, objv->vocolfst, copylen); + /* copy the text */ + memcpy(*bufp, objv->vocolfst, copylen); - /* - * set the new structure to point into the copy, not the - * original - */ - againv->vocolfst = *bufp; - againv->vocollst = *bufp + (objv->vocollst - objv->vocolfst); + /* + * set the new structure to point into the copy, not the + * original + */ + againv->vocolfst = *bufp; + againv->vocollst = *bufp + (objv->vocollst - objv->vocolfst); - /* skip past the space we've consumed in the buffer */ - *bufp += copylen; - } - } - else - { - /* there's nothing to save - just set the object ID to invalid */ - againv->vocolobj = MCMONINV; - } + /* skip past the space we've consumed in the buffer */ + *bufp += copylen; + } + } + else + { + /* there's nothing to save - just set the object ID to invalid */ + againv->vocolobj = MCMONINV; + } } /* @@ -877,17 +877,17 @@ static void exe_save_again_obj(vocoldef *againv, const vocoldef *objv, * list, which is the same as the first argument. */ static vocoldef *exe_restore_again_obj(vocoldef again_array[2], - const vocoldef *saved_obj) + const vocoldef *saved_obj) { - /* copy the saved object into the first array element */ - memcpy(&again_array[0], saved_obj, sizeof(again_array[0])); + /* copy the saved object into the first array element */ + memcpy(&again_array[0], saved_obj, sizeof(again_array[0])); - /* clear the second element to indicate the end of the object list */ - again_array[1].vocolobj = MCMONINV; - again_array[1].vocolflg = 0; + /* clear the second element to indicate the end of the object list */ + again_array[1].vocolobj = MCMONINV; + again_array[1].vocolflg = 0; - /* return a pointer to the first array element */ - return &again_array[0]; + /* return a pointer to the first array element */ + return &again_array[0]; } /* ------------------------------------------------------------------------ */ @@ -901,705 +901,705 @@ static vocoldef *exe_restore_again_obj(vocoldef again_array[2], * before each function invocation. */ static int exe1cmd(voccxdef *ctx, objnum actor, objnum verb, vocoldef *dobjv, - objnum *prepptr, vocoldef *iobjv, int endturn, uchar *tpl, - int newstyle, int recursive, - int validate_dobj, int validate_iobj, - vocoldef *dobj_list, int cur_dobj_idx, int dobj_cnt, - int show_multi_prefix, int multi_flags) + objnum *prepptr, vocoldef *iobjv, int endturn, uchar *tpl, + int newstyle, int recursive, + int validate_dobj, int validate_iobj, + vocoldef *dobj_list, int cur_dobj_idx, int dobj_cnt, + int show_multi_prefix, int multi_flags) { - objnum loc; - int err; - runcxdef *rcx = ctx->voccxrun; - objnum prep = *prepptr; - objnum dobj = (dobjv != 0 ? dobjv->vocolobj : MCMONINV); - objnum iobj = (iobjv != 0 ? iobjv->vocolobj : MCMONINV); - int tplflags; - int dobj_first; - objnum old_tio_actor; - vocoldef *old_ctx_dobj; - vocoldef *old_ctx_iobj; - objnum old_verb; - objnum old_actor; - objnum old_prep; - int do_fuses; - int do_postact; - vocoldef again_dobj[2]; - vocoldef again_iobj[2]; + objnum loc; + int err; + runcxdef *rcx = ctx->voccxrun; + objnum prep = *prepptr; + objnum dobj = (dobjv != 0 ? dobjv->vocolobj : MCMONINV); + objnum iobj = (iobjv != 0 ? iobjv->vocolobj : MCMONINV); + int tplflags; + int dobj_first; + objnum old_tio_actor; + vocoldef *old_ctx_dobj; + vocoldef *old_ctx_iobj; + objnum old_verb; + objnum old_actor; + objnum old_prep; + int do_fuses; + int do_postact; + vocoldef again_dobj[2]; + vocoldef again_iobj[2]; - /* presume no error will occur */ - err = 0; + /* presume no error will occur */ + err = 0; - /* - * Presume we'll run fuses and daemons if this is the end of the - * turn. We only do fuses and daemons once per command, even if the - * command contains multiple objects; 'endturn' will be true only - * when this is the last object of the command. - */ - do_fuses = endturn; + /* + * Presume we'll run fuses and daemons if this is the end of the + * turn. We only do fuses and daemons once per command, even if the + * command contains multiple objects; 'endturn' will be true only + * when this is the last object of the command. + */ + do_fuses = endturn; - /* presume we will call postAction */ - do_postact = TRUE; + /* presume we will call postAction */ + do_postact = TRUE; - /* remember the original tio-level actor setting */ - old_tio_actor = tiogetactor(ctx->voccxtio); + /* remember the original tio-level actor setting */ + old_tio_actor = tiogetactor(ctx->voccxtio); - /* remember the original command settings (in case this is recursive) */ - old_actor = ctx->voccxactor; - old_verb = ctx->voccxverb; - old_prep = ctx->voccxprep; - old_ctx_dobj = ctx->voccxdobj; - old_ctx_iobj = ctx->voccxiobj; + /* remember the original command settings (in case this is recursive) */ + old_actor = ctx->voccxactor; + old_verb = ctx->voccxverb; + old_prep = ctx->voccxprep; + old_ctx_dobj = ctx->voccxdobj; + old_ctx_iobj = ctx->voccxiobj; - /* the default actor is Me */ - if (actor == MCMONINV) - actor = ctx->voccxme; + /* the default actor is Me */ + if (actor == MCMONINV) + actor = ctx->voccxme; - /* if command is "again", get information from previous command */ - if (verb == ctx->voccxvag) - { - /* it's "again" - repeat the last command */ - actor = ctx->voccxlsa; - verb = ctx->voccxlsv; - dobj = ctx->voccxlsd.vocolobj; - iobj = ctx->voccxlsi.vocolobj; - prep = ctx->voccxlsp; - tpl = ctx->voccxlst; - newstyle = ctx->voccxlssty; + /* if command is "again", get information from previous command */ + if (verb == ctx->voccxvag) + { + /* it's "again" - repeat the last command */ + actor = ctx->voccxlsa; + verb = ctx->voccxlsv; + dobj = ctx->voccxlsd.vocolobj; + iobj = ctx->voccxlsi.vocolobj; + prep = ctx->voccxlsp; + tpl = ctx->voccxlst; + newstyle = ctx->voccxlssty; - /* - * If we have a direct or indirect object, restore the full - * object information structure pointers (in particular, this - * restores the word lists). - */ - if (dobj != MCMONINV) - dobjv = exe_restore_again_obj(again_dobj, &ctx->voccxlsd); - if (iobj != MCMONINV) - iobjv = exe_restore_again_obj(again_iobj, &ctx->voccxlsi); + /* + * If we have a direct or indirect object, restore the full + * object information structure pointers (in particular, this + * restores the word lists). + */ + if (dobj != MCMONINV) + dobjv = exe_restore_again_obj(again_dobj, &ctx->voccxlsd); + if (iobj != MCMONINV) + iobjv = exe_restore_again_obj(again_iobj, &ctx->voccxlsi); - /* - * make sure the command is repeatable: there must have been a - * verb, and the objects specified must still be accessible - */ - if (verb == MCMONINV) - { - /* - * if the last command was lost due to an object deletion, - * show the message "you can't repeat that command"; - * otherwise, show the message "there's no command to - * repeat" - */ - if ((ctx->voccxflg & VOCCXAGAINDEL) != 0) - vocerr(ctx, VOCERR(27), "You can't repeat that command."); - else - vocerr(ctx, VOCERR(26), "There's no command to repeat."); + /* + * make sure the command is repeatable: there must have been a + * verb, and the objects specified must still be accessible + */ + if (verb == MCMONINV) + { + /* + * if the last command was lost due to an object deletion, + * show the message "you can't repeat that command"; + * otherwise, show the message "there's no command to + * repeat" + */ + if ((ctx->voccxflg & VOCCXAGAINDEL) != 0) + vocerr(ctx, VOCERR(27), "You can't repeat that command."); + else + vocerr(ctx, VOCERR(26), "There's no command to repeat."); - /* flush the output and return failure */ - tioflush(ctx->voccxtio); - return 0; - } - else if ((dobj != MCMONINV && - !vocchkaccess(ctx, dobj, PRP_VALIDDO, 0, actor, verb)) - || (iobj != MCMONINV && - !vocchkaccess(ctx, iobj, PRP_VALIDIO, 0, actor, verb)) - || !vocchkaccess(ctx, actor, PRP_VALIDACTOR, 0, actor, verb)) - { - vocerr(ctx, VOCERR(27), "You can't repeat that command."); - tioflush(ctx->voccxtio); - return(0); - } - } - else - { - /* verify the direct object if present */ - if (validate_dobj - && dobj != MCMONINV - && !vocchkaccess(ctx, dobj, PRP_VALIDDO, 0, actor, verb)) - { - /* generate an appropriate message */ - if (vocchkvis(ctx, dobj, actor)) - { - /* it's visible but not accessible */ - vocnoreach(ctx, &dobj, 1, actor, verb, prep, - PRP_DODEFAULT, FALSE, 0, 0, 1); - } - else - { - /* it's not even visible */ - if (recursive) - vocerr(ctx, VOCERR(39), "You don't see that here."); - else - vocerr(ctx, VOCERR(38), - "You don't see that here any more."); - } - - /* indicate the error */ - return ERR_PRS_VAL_DO_FAIL; - } - - /* verify the indirect object if present */ - if (validate_iobj - && iobj != MCMONINV - && !vocchkaccess(ctx, iobj, PRP_VALIDIO, 0, actor, verb)) - { - /* generate the error message */ - if (vocchkvis(ctx, iobj, actor)) - { - /* it's visible but not accessible */ - vocnoreach(ctx, &iobj, 1, actor, verb, prep, - PRP_IODEFAULT, FALSE, 0, 0, 1); - } - else - { - /* it's not even visible */ - if (recursive) - vocerr(ctx, VOCERR(39), "You don't see that here."); - else - vocerr(ctx, VOCERR(38), - "You don't see that here any more."); - } - - /* indicate the error */ - return ERR_PRS_VAL_IO_FAIL; - } + /* flush the output and return failure */ + tioflush(ctx->voccxtio); + return 0; + } + else if ((dobj != MCMONINV && + !vocchkaccess(ctx, dobj, PRP_VALIDDO, 0, actor, verb)) + || (iobj != MCMONINV && + !vocchkaccess(ctx, iobj, PRP_VALIDIO, 0, actor, verb)) + || !vocchkaccess(ctx, actor, PRP_VALIDACTOR, 0, actor, verb)) + { + vocerr(ctx, VOCERR(27), "You can't repeat that command."); + tioflush(ctx->voccxtio); + return(0); + } + } + else + { + /* verify the direct object if present */ + if (validate_dobj + && dobj != MCMONINV + && !vocchkaccess(ctx, dobj, PRP_VALIDDO, 0, actor, verb)) + { + /* generate an appropriate message */ + if (vocchkvis(ctx, dobj, actor)) + { + /* it's visible but not accessible */ + vocnoreach(ctx, &dobj, 1, actor, verb, prep, + PRP_DODEFAULT, FALSE, 0, 0, 1); + } + else + { + /* it's not even visible */ + if (recursive) + vocerr(ctx, VOCERR(39), "You don't see that here."); + else + vocerr(ctx, VOCERR(38), + "You don't see that here any more."); + } + + /* indicate the error */ + return ERR_PRS_VAL_DO_FAIL; + } + + /* verify the indirect object if present */ + if (validate_iobj + && iobj != MCMONINV + && !vocchkaccess(ctx, iobj, PRP_VALIDIO, 0, actor, verb)) + { + /* generate the error message */ + if (vocchkvis(ctx, iobj, actor)) + { + /* it's visible but not accessible */ + vocnoreach(ctx, &iobj, 1, actor, verb, prep, + PRP_IODEFAULT, FALSE, 0, 0, 1); + } + else + { + /* it's not even visible */ + if (recursive) + vocerr(ctx, VOCERR(39), "You don't see that here."); + else + vocerr(ctx, VOCERR(38), + "You don't see that here any more."); + } + + /* indicate the error */ + return ERR_PRS_VAL_IO_FAIL; + } - /* - * save the command, unless this is a recursive call from the - * game, so that we can repeat this command if the next is - * "again" - */ - if (!recursive) - { - char *dst; - - /* save the command parameters */ - ctx->voccxlsa = actor; - ctx->voccxlsv = verb; - ctx->voccxlsp = prep; - ctx->voccxlssty = newstyle; - if (tpl != 0) - memcpy(ctx->voccxlst, tpl, - (size_t)(newstyle ? VOCTPL2SIZ : VOCTPLSIZ)); + /* + * save the command, unless this is a recursive call from the + * game, so that we can repeat this command if the next is + * "again" + */ + if (!recursive) + { + char *dst; + + /* save the command parameters */ + ctx->voccxlsa = actor; + ctx->voccxlsv = verb; + ctx->voccxlsp = prep; + ctx->voccxlssty = newstyle; + if (tpl != 0) + memcpy(ctx->voccxlst, tpl, + (size_t)(newstyle ? VOCTPL2SIZ : VOCTPLSIZ)); - /* set up to write into the "again" word buffer */ - dst = ctx->voccxagainbuf; + /* set up to write into the "again" word buffer */ + dst = ctx->voccxagainbuf; - /* save the direct object information */ - exe_save_again_obj(&ctx->voccxlsd, dobjv, &dst); + /* save the direct object information */ + exe_save_again_obj(&ctx->voccxlsd, dobjv, &dst); - /* save the indirect object information */ - exe_save_again_obj(&ctx->voccxlsi, iobjv, &dst); + /* save the indirect object information */ + exe_save_again_obj(&ctx->voccxlsi, iobjv, &dst); - /* - * clear the flag indicating that "again" was lost due to - * object deletion, because we obviously have a valid - * "again" at this point - */ - ctx->voccxflg &= ~VOCCXAGAINDEL; - } - } - - /* remember the flags */ - tplflags = (tpl != 0 && newstyle ? voctplflg(tpl) : 0); - dobj_first = (tplflags & VOCTPLFLG_DOBJ_FIRST); + /* + * clear the flag indicating that "again" was lost due to + * object deletion, because we obviously have a valid + * "again" at this point + */ + ctx->voccxflg &= ~VOCCXAGAINDEL; + } + } + + /* remember the flags */ + tplflags = (tpl != 0 && newstyle ? voctplflg(tpl) : 0); + dobj_first = (tplflags & VOCTPLFLG_DOBJ_FIRST); - /* set up actor for tio subsystem - format strings need to know */ - tiosetactor(ctx->voccxtio, actor); + /* set up actor for tio subsystem - format strings need to know */ + tiosetactor(ctx->voccxtio, actor); - /* store current dobj and iobj vocoldef's for later reference */ - ctx->voccxdobj = dobjv; - ctx->voccxiobj = iobjv; + /* store current dobj and iobj vocoldef's for later reference */ + ctx->voccxdobj = dobjv; + ctx->voccxiobj = iobjv; - /* store the rest of the current command objects for reference */ - ctx->voccxactor = actor; - ctx->voccxverb = verb; - ctx->voccxprep = prep; - - ERRBEGIN(ctx->voccxerr) + /* store the rest of the current command objects for reference */ + ctx->voccxactor = actor; + ctx->voccxverb = verb; + ctx->voccxprep = prep; + + ERRBEGIN(ctx->voccxerr) - /* reset the run-time context if this is a top-level call */ - if (!recursive) - runrst(rcx); + /* reset the run-time context if this is a top-level call */ + if (!recursive) + runrst(rcx); - /* - * if this is the first object, invoke the game's preCommand - * function, passing the list of all of the direct objects - */ - if (cur_dobj_idx == 0 && ctx->voccxprecmd != MCMONINV) - { - /* push the arguments: actor, verb, dobj-list, prep, iobj */ - runpobj(rcx, iobj); - runpobj(rcx, prep); - voc_push_vocoldef_list(ctx, dobj_list, dobj_cnt); - runpobj(rcx, verb); - runpobj(rcx, actor); + /* + * if this is the first object, invoke the game's preCommand + * function, passing the list of all of the direct objects + */ + if (cur_dobj_idx == 0 && ctx->voccxprecmd != MCMONINV) + { + /* push the arguments: actor, verb, dobj-list, prep, iobj */ + runpobj(rcx, iobj); + runpobj(rcx, prep); + voc_push_vocoldef_list(ctx, dobj_list, dobj_cnt); + runpobj(rcx, verb); + runpobj(rcx, actor); - /* catch errors specially for preCommand */ + /* catch errors specially for preCommand */ // ERRBEGIN(ctx->voccxerr) // { - /* invoke preCommand */ - runfn(rcx, ctx->voccxprecmd, 5); + /* invoke preCommand */ + runfn(rcx, ctx->voccxprecmd, 5); // } // ERRCATCH(ctx->voccxerr, err) // { - /* - * if the error was 'exit', translate it to EXITPRECMD so - * that we handle the outer loop correctly (exiting from - * preCommand skips execution for all subsequent objects, - * but doesn't skip fuses and daemons) - */ - if (err == ERR_RUNEXIT) - errsig(ctx->voccxerr, ERR_RUNEXITPRECMD); + /* + * if the error was 'exit', translate it to EXITPRECMD so + * that we handle the outer loop correctly (exiting from + * preCommand skips execution for all subsequent objects, + * but doesn't skip fuses and daemons) + */ + if (err == ERR_RUNEXIT) + errsig(ctx->voccxerr, ERR_RUNEXITPRECMD); - /* no special handling - just resignal the error */ - errrse(ctx->voccxerr); + /* no special handling - just resignal the error */ + errrse(ctx->voccxerr); // } // ERREND(ctx->voccxerr); - } + } - /* show the pre-object prefix if the caller instructed us to do so */ - voc_multi_prefix(ctx, dobj, show_multi_prefix, multi_flags, - cur_dobj_idx, dobj_cnt); + /* show the pre-object prefix if the caller instructed us to do so */ + voc_multi_prefix(ctx, dobj, show_multi_prefix, multi_flags, + cur_dobj_idx, dobj_cnt); - /* - * check to see if the verb has verbAction defined - if so, invoke - * the method - */ - if (objgetap(ctx->voccxmem, verb, PRP_VERBACTION, (objnum *)0, FALSE)) - { - /* call verb.verbAction(actor, dobj, prep, iobj) */ - runpobj(rcx, iobj); - runpobj(rcx, prep); - runpobj(rcx, dobj); - runpobj(rcx, actor); - runppr(rcx, verb, PRP_VERBACTION, 4); - } + /* + * check to see if the verb has verbAction defined - if so, invoke + * the method + */ + if (objgetap(ctx->voccxmem, verb, PRP_VERBACTION, (objnum *)0, FALSE)) + { + /* call verb.verbAction(actor, dobj, prep, iobj) */ + runpobj(rcx, iobj); + runpobj(rcx, prep); + runpobj(rcx, dobj); + runpobj(rcx, actor); + runppr(rcx, verb, PRP_VERBACTION, 4); + } - /* invoke cmdActor.actorAction(verb, dobj, prep, iobj) */ - runpobj(rcx, iobj); - runpobj(rcx, prep); - runpobj(rcx, dobj); - runpobj(rcx, verb); - runppr(rcx, actor, PRP_ACTORACTION, 4); + /* invoke cmdActor.actorAction(verb, dobj, prep, iobj) */ + runpobj(rcx, iobj); + runpobj(rcx, prep); + runpobj(rcx, dobj); + runpobj(rcx, verb); + runppr(rcx, actor, PRP_ACTORACTION, 4); - /* reset the run-time context if this is a top-level call */ - if (!recursive) - runrst(rcx); + /* reset the run-time context if this is a top-level call */ + if (!recursive) + runrst(rcx); - /* invoke actor.location.roomAction(actor, verb, dobj, prep, iobj) */ - runppr(rcx, actor, PRP_LOCATION, 0); - if (runtostyp(rcx) == DAT_OBJECT) - { - loc = runpopobj(rcx); + /* invoke actor.location.roomAction(actor, verb, dobj, prep, iobj) */ + runppr(rcx, actor, PRP_LOCATION, 0); + if (runtostyp(rcx) == DAT_OBJECT) + { + loc = runpopobj(rcx); - /* reset the run-time context if this is a top-level call */ - if (!recursive) - runrst(rcx); + /* reset the run-time context if this is a top-level call */ + if (!recursive) + runrst(rcx); - /* call roomAction */ - runpobj(rcx, iobj); - runpobj(rcx, prep); - runpobj(rcx, dobj); - runpobj(rcx, verb); - runpobj(rcx, actor); - runppr(rcx, loc, PRP_ROOMACTION, 5); - } - else - { - /* the location isn't an object, so discard it */ - rundisc(rcx); - } - - /* if there's an indirect object, execute iobjCheck */ - if (iobj != MCMONINV) - { - /* reset the run-time context if this is a top-level call */ - if (!recursive) - runrst(rcx); + /* call roomAction */ + runpobj(rcx, iobj); + runpobj(rcx, prep); + runpobj(rcx, dobj); + runpobj(rcx, verb); + runpobj(rcx, actor); + runppr(rcx, loc, PRP_ROOMACTION, 5); + } + else + { + /* the location isn't an object, so discard it */ + rundisc(rcx); + } + + /* if there's an indirect object, execute iobjCheck */ + if (iobj != MCMONINV) + { + /* reset the run-time context if this is a top-level call */ + if (!recursive) + runrst(rcx); - /* invoke iobjCheck */ - runpobj(rcx, prep); - runpobj(rcx, dobj); - runpobj(rcx, verb); - runpobj(rcx, actor); - runppr(rcx, iobj, PRP_IOBJCHECK, 4); - } + /* invoke iobjCheck */ + runpobj(rcx, prep); + runpobj(rcx, dobj); + runpobj(rcx, verb); + runpobj(rcx, actor); + runppr(rcx, iobj, PRP_IOBJCHECK, 4); + } - /* - * If there's an indirect object, and the indirect object doesn't - * directly define io, call iobj.iobjGen(actor, verb, dobj, - * prep) - */ - if (iobj != MCMONINV - && exegen(ctx, iobj, PRP_IOBJGEN, voctplvi(tpl), voctplio(tpl))) - { - /* reset the run-time context if this is a top-level call */ - if (!recursive) - runrst(rcx); + /* + * If there's an indirect object, and the indirect object doesn't + * directly define io, call iobj.iobjGen(actor, verb, dobj, + * prep) + */ + if (iobj != MCMONINV + && exegen(ctx, iobj, PRP_IOBJGEN, voctplvi(tpl), voctplio(tpl))) + { + /* reset the run-time context if this is a top-level call */ + if (!recursive) + runrst(rcx); - /* invoke iobjGen */ - runpobj(rcx, prep); - runpobj(rcx, dobj); - runpobj(rcx, verb); - runpobj(rcx, actor); - runppr(rcx, iobj, PRP_IOBJGEN, 4); - } + /* invoke iobjGen */ + runpobj(rcx, prep); + runpobj(rcx, dobj); + runpobj(rcx, verb); + runpobj(rcx, actor); + runppr(rcx, iobj, PRP_IOBJGEN, 4); + } - /* if there's an direct object, execute dobjCheck */ - if (dobj != MCMONINV) - { - /* reset the run-time context if this is a top-level call */ - if (!recursive) - runrst(rcx); + /* if there's an direct object, execute dobjCheck */ + if (dobj != MCMONINV) + { + /* reset the run-time context if this is a top-level call */ + if (!recursive) + runrst(rcx); - /* invoke dobjCheck */ - runpobj(rcx, prep); - runpobj(rcx, iobj); - runpobj(rcx, verb); - runpobj(rcx, actor); - runppr(rcx, dobj, PRP_DOBJCHECK, 4); - } + /* invoke dobjCheck */ + runpobj(rcx, prep); + runpobj(rcx, iobj); + runpobj(rcx, verb); + runpobj(rcx, actor); + runppr(rcx, dobj, PRP_DOBJCHECK, 4); + } - /* - * If there's a direct object, and the direct object doesn't - * directly define do, call dobj.dobjGen(actor, verb, iobj, - * prep) - */ - if (dobj != MCMONINV - && exegen(ctx, dobj, PRP_DOBJGEN, voctplvd(tpl), voctpldo(tpl))) - { - /* reset the run-time context if this is a top-level call */ - if (!recursive) - runrst(rcx); + /* + * If there's a direct object, and the direct object doesn't + * directly define do, call dobj.dobjGen(actor, verb, iobj, + * prep) + */ + if (dobj != MCMONINV + && exegen(ctx, dobj, PRP_DOBJGEN, voctplvd(tpl), voctpldo(tpl))) + { + /* reset the run-time context if this is a top-level call */ + if (!recursive) + runrst(rcx); - /* invoke dobjGen */ - runpobj(rcx, prep); - runpobj(rcx, iobj); - runpobj(rcx, verb); - runpobj(rcx, actor); - runppr(rcx, dobj, PRP_DOBJGEN, 4); - } + /* invoke dobjGen */ + runpobj(rcx, prep); + runpobj(rcx, iobj); + runpobj(rcx, verb); + runpobj(rcx, actor); + runppr(rcx, dobj, PRP_DOBJGEN, 4); + } - /* reset the hidden-text flag */ - tiohide(ctx->voccxtio); - tioshow(ctx->voccxtio); + /* reset the hidden-text flag */ + tiohide(ctx->voccxtio); + tioshow(ctx->voccxtio); - /* - * Now do what needs to be done, depending on the sentence structure: - * - * No objects ==> cmdVerb.action( cmdActor ) - * - * Direct object only ==> cmdDobj.verDo( actor ) - *. cmdDobj.do( actor ) - * - * Indirect + direct ==> cmdDobj.verDo( actor, cmdIobj ) - *. cmdIobj.verIo( actor, cmdDobj ) - *. cmdIobj.io( actor, cmdDobj ) - */ - if (dobj == MCMONINV) - { - /* reset the stack for top-level calls */ - if (!recursive) - runrst(rcx); + /* + * Now do what needs to be done, depending on the sentence structure: + * + * No objects ==> cmdVerb.action( cmdActor ) + * + * Direct object only ==> cmdDobj.verDo( actor ) + *. cmdDobj.do( actor ) + * + * Indirect + direct ==> cmdDobj.verDo( actor, cmdIobj ) + *. cmdIobj.verIo( actor, cmdDobj ) + *. cmdIobj.io( actor, cmdDobj ) + */ + if (dobj == MCMONINV) + { + /* reset the stack for top-level calls */ + if (!recursive) + runrst(rcx); - /* invoke verb.action */ - runpobj(rcx, actor); - runppr(rcx, verb, PRP_ACTION, 1); - } - else if (iobj == MCMONINV) - { - if (!objgetap(ctx->voccxmem, dobj, voctplvd(tpl), (objnum *)0, FALSE)) - { - /* display the error */ - exeperr(ctx, verb, dobj, MCMONINV, MCMONINV); + /* invoke verb.action */ + runpobj(rcx, actor); + runppr(rcx, verb, PRP_ACTION, 1); + } + else if (iobj == MCMONINV) + { + if (!objgetap(ctx->voccxmem, dobj, voctplvd(tpl), (objnum *)0, FALSE)) + { + /* display the error */ + exeperr(ctx, verb, dobj, MCMONINV, MCMONINV); - /* note that verDoVerb failed */ - err = ERR_PRS_NO_VERDO; + /* note that verDoVerb failed */ + err = ERR_PRS_NO_VERDO; - /* we're done with this command */ - goto skipToFuses; - } - - /* reset the stack for top-level calls */ - if (!recursive) - runrst(rcx); + /* we're done with this command */ + goto skipToFuses; + } + + /* reset the stack for top-level calls */ + if (!recursive) + runrst(rcx); - /* invoke dobj.verDoVerb */ - runpobj(rcx, actor); - runppr(rcx, dobj, voctplvd(tpl), 1); + /* invoke dobj.verDoVerb */ + runpobj(rcx, actor); + runppr(rcx, dobj, voctplvd(tpl), 1); - /* check for an error message from verDoVerb */ - if (!tioshow(ctx->voccxtio)) - { - /* reset the stack for top-level calls */ - if (!recursive) - runrst(rcx); + /* check for an error message from verDoVerb */ + if (!tioshow(ctx->voccxtio)) + { + /* reset the stack for top-level calls */ + if (!recursive) + runrst(rcx); - /* dobj.verDoVerb displayed no output - process dobj.doVerb */ - runpobj(rcx, actor); - runppr(rcx, dobj, voctpldo(tpl), 1); - } - else - { - /* note that verDoVerb failed */ - err = ERR_PRS_VERDO_FAIL; - } - } - else - { - /* check to see if the verDoVerb and verIoVerb methods exist */ - if (!objgetap(ctx->voccxmem, dobj, voctplvd(tpl), (objnum *)0, FALSE)) - { - /* no verDoVerb method - show a default message */ - exeperr(ctx, verb, dobj, MCMONINV, MCMONINV); + /* dobj.verDoVerb displayed no output - process dobj.doVerb */ + runpobj(rcx, actor); + runppr(rcx, dobj, voctpldo(tpl), 1); + } + else + { + /* note that verDoVerb failed */ + err = ERR_PRS_VERDO_FAIL; + } + } + else + { + /* check to see if the verDoVerb and verIoVerb methods exist */ + if (!objgetap(ctx->voccxmem, dobj, voctplvd(tpl), (objnum *)0, FALSE)) + { + /* no verDoVerb method - show a default message */ + exeperr(ctx, verb, dobj, MCMONINV, MCMONINV); - /* note the error */ - err = ERR_PRS_NO_VERDO; + /* note the error */ + err = ERR_PRS_NO_VERDO; - /* skip to the end of the turn */ - goto skipToFuses; - } - else if (!objgetap(ctx->voccxmem, iobj, voctplvi(tpl), (objnum *)0, - FALSE)) - { - /* no verIoVerb method - show a default mesage */ - exeperr(ctx, verb, MCMONINV, prep, iobj); + /* skip to the end of the turn */ + goto skipToFuses; + } + else if (!objgetap(ctx->voccxmem, iobj, voctplvi(tpl), (objnum *)0, + FALSE)) + { + /* no verIoVerb method - show a default mesage */ + exeperr(ctx, verb, MCMONINV, prep, iobj); - /* note the error */ - err = ERR_PRS_NO_VERIO; + /* note the error */ + err = ERR_PRS_NO_VERIO; - /* skip to the end of the turn */ - goto skipToFuses; - } + /* skip to the end of the turn */ + goto skipToFuses; + } - /* reset the stack for top-level calls */ - if (!recursive) - runrst(rcx); + /* reset the stack for top-level calls */ + if (!recursive) + runrst(rcx); - /* call verDoVerb(actor [,iobj]) */ - if (!dobj_first) - runpobj(rcx, iobj); - runpobj(rcx, actor); - runppr(rcx, dobj, voctplvd(tpl), (dobj_first ? 1 : 2)); + /* call verDoVerb(actor [,iobj]) */ + if (!dobj_first) + runpobj(rcx, iobj); + runpobj(rcx, actor); + runppr(rcx, dobj, voctplvd(tpl), (dobj_first ? 1 : 2)); - /* check for error output from verDoVerb */ - if (!tioshow(ctx->voccxtio)) - { - /* reset the stack for top-level calls */ - if (!recursive) - runrst(rcx); + /* check for error output from verDoVerb */ + if (!tioshow(ctx->voccxtio)) + { + /* reset the stack for top-level calls */ + if (!recursive) + runrst(rcx); - /* no error from verDoVerb - call verIoVerb(actor [,dobj]) */ - if (dobj_first) - runpobj(rcx, dobj); - runpobj(rcx, actor); - runppr(rcx, iobj, voctplvi(tpl), (dobj_first ? 2 : 1)); + /* no error from verDoVerb - call verIoVerb(actor [,dobj]) */ + if (dobj_first) + runpobj(rcx, dobj); + runpobj(rcx, actor); + runppr(rcx, iobj, voctplvi(tpl), (dobj_first ? 2 : 1)); - /* check for error output from verIoVerb */ - if (!tioshow(ctx->voccxtio)) - { - /* reset the stack for top-level calls */ - if (!recursive) - runrst(rcx); - - /* no error from verDoVerb or verIoVerb - call ioVerb */ - runpobj(rcx, dobj); - runpobj(rcx, actor); - runppr(rcx, iobj, voctplio(tpl), 2); - } - else - { - /* note the error */ - err = ERR_PRS_VERIO_FAIL; - } - } - else - { - /* note the error */ - err = ERR_PRS_VERDO_FAIL; - } - } - + /* check for error output from verIoVerb */ + if (!tioshow(ctx->voccxtio)) + { + /* reset the stack for top-level calls */ + if (!recursive) + runrst(rcx); + + /* no error from verDoVerb or verIoVerb - call ioVerb */ + runpobj(rcx, dobj); + runpobj(rcx, actor); + runppr(rcx, iobj, voctplio(tpl), 2); + } + else + { + /* note the error */ + err = ERR_PRS_VERIO_FAIL; + } + } + else + { + /* note the error */ + err = ERR_PRS_VERDO_FAIL; + } + } + skipToFuses: - ERRCATCH(ctx->voccxerr, err) - { - /* if askIo was invoked, get the preposition from the error stack */ - if (err == ERR_RUNASKI) - *prepptr = errargint(0); + ERRCATCH(ctx->voccxerr, err) + { + /* if askIo was invoked, get the preposition from the error stack */ + if (err == ERR_RUNASKI) + *prepptr = errargint(0); - /* - * If we executed 'abort', we'll skip straight to endCommand. - * - * If we executed askDo or askIo, we won't execute anything - * more, because the command is being interrupted. - * - * If 'exit' or 'exitobj' was executed, proceed through - * postAction and subsequent steps. - * - * If any error occurred other than 'exit' or 'exitobj' being - * invoked, resignal the error. - * - * We don't need to do anything more at this point if 'exit' was - * invoked, because 'exit' merely skips to the end-of-turn - * phase, which is where we'll go next from here. - * - * If 'exitobj' was invoked, we don't want to return an error at - * all, since we just want to skip the remainder of the normal - * processing for the current object and proceed to the next - * object (in a command with multiple direct objects). - */ - if (err == ERR_RUNABRT) - { - /* - * aborting - we're going to call postAction, but we're not - * going to execute fuses and daemons - */ - do_fuses = FALSE; - endturn = TRUE; - } - else if (err == ERR_RUNASKD || err == ERR_RUNASKI) - { - /* we're going to skip all end-of-turn action */ - do_fuses = FALSE; - do_postact = FALSE; - endturn = FALSE; - } - else if (err == ERR_RUNEXIT) - { - /* - * Proceed with the remainder of the processing for this - * turn, but retain the error code to return to our caller, - * so they know that the rest of the turn is to be skipped. - * - * In addition, set 'do_fuses' to true, since we want to go - * directly to the fuse and daemon processing for this turn, - * regardless of whether any other objects are present - * (because we'll skip any remaining objects). - */ - endturn = TRUE; - do_fuses = TRUE; - } - else if (err == ERR_RUNEXITPRECMD) - { - /* - * exited from preCommand - end the turn, but do not run the - * postAction routine - */ - do_fuses = TRUE; - do_postact = FALSE; - endturn = TRUE; - } - else if (err == ERR_RUNEXITOBJ) - { - /* - * Proceed with the remainder of processing for this turn - - * we want to proceed to the next object, if any, and - * process it as normal. We don't need to update 'endturn' - * or 'do_fuses', since we want to do all of those in the - * normal fashion. - */ - } - else - { - /* - * We can't handle any other errors. Restore the enclosing - * command context, and resignal the error. - */ + /* + * If we executed 'abort', we'll skip straight to endCommand. + * + * If we executed askDo or askIo, we won't execute anything + * more, because the command is being interrupted. + * + * If 'exit' or 'exitobj' was executed, proceed through + * postAction and subsequent steps. + * + * If any error occurred other than 'exit' or 'exitobj' being + * invoked, resignal the error. + * + * We don't need to do anything more at this point if 'exit' was + * invoked, because 'exit' merely skips to the end-of-turn + * phase, which is where we'll go next from here. + * + * If 'exitobj' was invoked, we don't want to return an error at + * all, since we just want to skip the remainder of the normal + * processing for the current object and proceed to the next + * object (in a command with multiple direct objects). + */ + if (err == ERR_RUNABRT) + { + /* + * aborting - we're going to call postAction, but we're not + * going to execute fuses and daemons + */ + do_fuses = FALSE; + endturn = TRUE; + } + else if (err == ERR_RUNASKD || err == ERR_RUNASKI) + { + /* we're going to skip all end-of-turn action */ + do_fuses = FALSE; + do_postact = FALSE; + endturn = FALSE; + } + else if (err == ERR_RUNEXIT) + { + /* + * Proceed with the remainder of the processing for this + * turn, but retain the error code to return to our caller, + * so they know that the rest of the turn is to be skipped. + * + * In addition, set 'do_fuses' to true, since we want to go + * directly to the fuse and daemon processing for this turn, + * regardless of whether any other objects are present + * (because we'll skip any remaining objects). + */ + endturn = TRUE; + do_fuses = TRUE; + } + else if (err == ERR_RUNEXITPRECMD) + { + /* + * exited from preCommand - end the turn, but do not run the + * postAction routine + */ + do_fuses = TRUE; + do_postact = FALSE; + endturn = TRUE; + } + else if (err == ERR_RUNEXITOBJ) + { + /* + * Proceed with the remainder of processing for this turn - + * we want to proceed to the next object, if any, and + * process it as normal. We don't need to update 'endturn' + * or 'do_fuses', since we want to do all of those in the + * normal fashion. + */ + } + else + { + /* + * We can't handle any other errors. Restore the enclosing + * command context, and resignal the error. + */ - /* restore the previous tio actor setting */ - tiosetactor(ctx->voccxtio, old_tio_actor); + /* restore the previous tio actor setting */ + tiosetactor(ctx->voccxtio, old_tio_actor); - /* restore the original context iobj and dobj settings */ - ctx->voccxdobj = old_ctx_dobj; - ctx->voccxiobj = old_ctx_iobj; + /* restore the original context iobj and dobj settings */ + ctx->voccxdobj = old_ctx_dobj; + ctx->voccxiobj = old_ctx_iobj; - /* restore the original context command objects */ - ctx->voccxactor = old_actor; - ctx->voccxverb = old_verb; - ctx->voccxprep = old_prep; + /* restore the original context command objects */ + ctx->voccxactor = old_actor; + ctx->voccxverb = old_verb; + ctx->voccxprep = old_prep; - /* resignal the error */ - errrse(ctx->voccxerr); - } - } - ERREND(ctx->voccxerr); + /* resignal the error */ + errrse(ctx->voccxerr); + } + } + ERREND(ctx->voccxerr); - /* - * If desired, call postAction(actor, verb, dobj, prep, iobj, - * error_status). - */ - if (do_postact && ctx->voccxpostact != MCMONINV) - { - int err2; - - ERRBEGIN(ctx->voccxerr) - { - /* push the arguments */ - runpnum(rcx, err); - runpobj(rcx, iobj); - runpobj(rcx, prep); - runpobj(rcx, dobj); - runpobj(rcx, verb); - runpobj(rcx, actor); + /* + * If desired, call postAction(actor, verb, dobj, prep, iobj, + * error_status). + */ + if (do_postact && ctx->voccxpostact != MCMONINV) + { + int err2; + + ERRBEGIN(ctx->voccxerr) + { + /* push the arguments */ + runpnum(rcx, err); + runpobj(rcx, iobj); + runpobj(rcx, prep); + runpobj(rcx, dobj); + runpobj(rcx, verb); + runpobj(rcx, actor); - /* invoke postAction */ - runfn(rcx, ctx->voccxpostact, 6); - } - ERRCATCH(ctx->voccxerr, err2) - { - /* remember the new error condition */ - err = err2; + /* invoke postAction */ + runfn(rcx, ctx->voccxpostact, 6); + } + ERRCATCH(ctx->voccxerr, err2) + { + /* remember the new error condition */ + err = err2; - /* if we're aborting, skip fuses and daemons */ - if (err == ERR_RUNABRT) - { - endturn = TRUE; - do_fuses = FALSE; - } - } - ERREND(ctx->voccxerr); - } - - /* restore the original context iobj and dobj settings */ - ctx->voccxdobj = old_ctx_dobj; - ctx->voccxiobj = old_ctx_iobj; + /* if we're aborting, skip fuses and daemons */ + if (err == ERR_RUNABRT) + { + endturn = TRUE; + do_fuses = FALSE; + } + } + ERREND(ctx->voccxerr); + } + + /* restore the original context iobj and dobj settings */ + ctx->voccxdobj = old_ctx_dobj; + ctx->voccxiobj = old_ctx_iobj; - /* restore the original context command objects */ - ctx->voccxverb = old_verb; - ctx->voccxprep = old_prep; + /* restore the original context command objects */ + ctx->voccxverb = old_verb; + ctx->voccxprep = old_prep; - /* reset the stack for top-level calls */ - if (!recursive) - runrst(rcx); + /* reset the stack for top-level calls */ + if (!recursive) + runrst(rcx); - /* - * If this is the end of the turn, execute fuses and daemons. Skip - * fuses on recursive calls, since we want to count them as part of - * the enclosing turn. - */ - if (endturn && !recursive) - { - /* catch errors so that we can restore the actor globals */ - ERRBEGIN(ctx->voccxerr) - { - /* run fuses, daemons, and endCommand */ - err = exe_fuses_and_daemons(ctx, err, do_fuses, actor, verb, - dobj_list, dobj_cnt, prep, iobj); - } - ERRCLEAN(ctx->voccxerr) - { - /* restore the previous actor globals */ - ctx->voccxactor = old_actor; - tiosetactor(ctx->voccxtio, old_tio_actor); - } - ERRENDCLN(ctx->voccxerr); - } + /* + * If this is the end of the turn, execute fuses and daemons. Skip + * fuses on recursive calls, since we want to count them as part of + * the enclosing turn. + */ + if (endturn && !recursive) + { + /* catch errors so that we can restore the actor globals */ + ERRBEGIN(ctx->voccxerr) + { + /* run fuses, daemons, and endCommand */ + err = exe_fuses_and_daemons(ctx, err, do_fuses, actor, verb, + dobj_list, dobj_cnt, prep, iobj); + } + ERRCLEAN(ctx->voccxerr) + { + /* restore the previous actor globals */ + ctx->voccxactor = old_actor; + tiosetactor(ctx->voccxtio, old_tio_actor); + } + ERRENDCLN(ctx->voccxerr); + } - /* restore the previous actor globals */ - ctx->voccxactor = old_actor; - tiosetactor(ctx->voccxtio, old_tio_actor); + /* restore the previous actor globals */ + ctx->voccxactor = old_actor; + tiosetactor(ctx->voccxtio, old_tio_actor); - /* success */ - return err; + /* success */ + return err; } @@ -1608,309 +1608,309 @@ static int exe1cmd(voccxdef *ctx, objnum actor, objnum verb, vocoldef *dobjv, */ static void exesaveit(voccxdef *ctx, vocoldef *dolist) { - int cnt; - int i; - int dbg = ctx->voccxflg & VOCCXFDBG; - runcxdef *rcx = ctx->voccxrun; + int cnt; + int i; + int dbg = ctx->voccxflg & VOCCXFDBG; + runcxdef *rcx = ctx->voccxrun; - cnt = voclistlen(dolist); - if (cnt == 1) - { - /* - * check to make sure they're not referring to a number or a - * string; if so, it doesn't make any sense to save it - */ - if (dolist[0].vocolflg == VOCS_STR - || dolist[0].vocolflg == VOCS_NUM) - { - /* - * As of 2.5.11, don't clear 'it' on a number or string; - * rather, just leave it as it was from the prior command. - * Players will almost never expect a number or string to have - * anything to do with pronoun antecedents, and in fact some - * players reported finding it confusing to have the antecedant - * implied by the second-most-recent command disappear when the - * most recent command used a number of string. - */ + cnt = voclistlen(dolist); + if (cnt == 1) + { + /* + * check to make sure they're not referring to a number or a + * string; if so, it doesn't make any sense to save it + */ + if (dolist[0].vocolflg == VOCS_STR + || dolist[0].vocolflg == VOCS_NUM) + { + /* + * As of 2.5.11, don't clear 'it' on a number or string; + * rather, just leave it as it was from the prior command. + * Players will almost never expect a number or string to have + * anything to do with pronoun antecedents, and in fact some + * players reported finding it confusing to have the antecedant + * implied by the second-most-recent command disappear when the + * most recent command used a number of string. + */ #if 0 - /* save a nil 'it' */ - ctx->voccxit = MCMONINV; - if (dbg) - tioputs(ctx->voccxtio, - ".. setting 'it' to nil (strObj/numObj)\\n"); + /* save a nil 'it' */ + ctx->voccxit = MCMONINV; + if (dbg) + tioputs(ctx->voccxtio, + ".. setting 'it' to nil (strObj/numObj)\\n"); #endif - /* we're done */ - return; - } + /* we're done */ + return; + } - /* save 'it' */ - ctx->voccxit = dolist[0].vocolobj; - ctx->voccxthc = 0; + /* save 'it' */ + ctx->voccxit = dolist[0].vocolobj; + ctx->voccxthc = 0; - if (dbg) - { - tioputs(ctx->voccxtio, ".. setting it: "); - runppr(rcx, ctx->voccxit, PRP_SDESC, 0); - tioputs(ctx->voccxtio, "\\n"); - } + if (dbg) + { + tioputs(ctx->voccxtio, ".. setting it: "); + runppr(rcx, ctx->voccxit, PRP_SDESC, 0); + tioputs(ctx->voccxtio, "\\n"); + } - /* set "him" if appropriate */ - runppr(rcx, ctx->voccxit, PRP_ISHIM, 0); - if (runtostyp(rcx) == DAT_TRUE) - { - ctx->voccxhim = ctx->voccxit; - if (dbg) - tioputs(ctx->voccxtio, - "... [setting \"him\" to same object]\\n"); - } - rundisc(rcx); + /* set "him" if appropriate */ + runppr(rcx, ctx->voccxit, PRP_ISHIM, 0); + if (runtostyp(rcx) == DAT_TRUE) + { + ctx->voccxhim = ctx->voccxit; + if (dbg) + tioputs(ctx->voccxtio, + "... [setting \"him\" to same object]\\n"); + } + rundisc(rcx); - /* set "her" if appropriate */ - runppr(rcx, ctx->voccxit, PRP_ISHER, 0); - if (runtostyp(rcx) == DAT_TRUE) - { - ctx->voccxher = ctx->voccxit; - if (dbg) - tioputs(ctx->voccxtio, - "... [setting \"her\" to same object]\\n"); - } - rundisc(rcx); - } - else if (cnt > 1) - { - ctx->voccxthc = cnt; - ctx->voccxit = MCMONINV; - if (dbg) tioputs(ctx->voccxtio, ".. setting \"them\": ["); - for (i = 0 ; i < cnt ; ++i) - { - ctx->voccxthm[i] = dolist[i].vocolobj; - if (dbg) - { - runppr(rcx, dolist[i].vocolobj, PRP_SDESC, 0); - tioputs(ctx->voccxtio, i+1 < cnt ? ", " : "]\\n"); - } - } - } + /* set "her" if appropriate */ + runppr(rcx, ctx->voccxit, PRP_ISHER, 0); + if (runtostyp(rcx) == DAT_TRUE) + { + ctx->voccxher = ctx->voccxit; + if (dbg) + tioputs(ctx->voccxtio, + "... [setting \"her\" to same object]\\n"); + } + rundisc(rcx); + } + else if (cnt > 1) + { + ctx->voccxthc = cnt; + ctx->voccxit = MCMONINV; + if (dbg) tioputs(ctx->voccxtio, ".. setting \"them\": ["); + for (i = 0 ; i < cnt ; ++i) + { + ctx->voccxthm[i] = dolist[i].vocolobj; + if (dbg) + { + runppr(rcx, dolist[i].vocolobj, PRP_SDESC, 0); + tioputs(ctx->voccxtio, i+1 < cnt ? ", " : "]\\n"); + } + } + } } /* display a multiple-object prefix */ void voc_multi_prefix(voccxdef *ctx, objnum objn, - int show_prefix, int multi_flags, - int cur_index, int count) + int show_prefix, int multi_flags, + int cur_index, int count) { - runcxdef *rcx = ctx->voccxrun; + runcxdef *rcx = ctx->voccxrun; - /* if the object is invalid, ignore it */ - if (objn == MCMONINV) - return; + /* if the object is invalid, ignore it */ + if (objn == MCMONINV) + return; - /* - * if there's a prefixdesc method defined, call it rather than the - * older multisdesc (or even older sdesc) approach - */ - if (objgetap(ctx->voccxmem, objn, PRP_PREFIXDESC, - (objnum *)0, FALSE) != 0) - { - runsdef val; + /* + * if there's a prefixdesc method defined, call it rather than the + * older multisdesc (or even older sdesc) approach + */ + if (objgetap(ctx->voccxmem, objn, PRP_PREFIXDESC, + (objnum *)0, FALSE) != 0) + { + runsdef val; - /* push the word flags */ - runpnum(rcx, multi_flags); + /* push the word flags */ + runpnum(rcx, multi_flags); - /* - * push the object count and the current index (adjusted to a - * 1-based value) - */ - runpnum(rcx, count); - runpnum(rcx, cur_index + 1); - - /* push the 'show' flag */ - val.runstyp = runclog(show_prefix); - runpush(rcx, val.runstyp, &val); + /* + * push the object count and the current index (adjusted to a + * 1-based value) + */ + runpnum(rcx, count); + runpnum(rcx, cur_index + 1); + + /* push the 'show' flag */ + val.runstyp = runclog(show_prefix); + runpush(rcx, val.runstyp, &val); - /* call the method */ - runppr(rcx, objn, PRP_PREFIXDESC, 4); + /* call the method */ + runppr(rcx, objn, PRP_PREFIXDESC, 4); - /* we're done */ - return; - } + /* we're done */ + return; + } - /* - * if we're not showing the prefix, don't use the multisdesc/sdesc - * display - */ - if (!show_prefix) - return; - - /* - * use multisdesc if defined (for compatibility with older games, - * use sdesc if multisdesc doesn't exist for this object) - */ - if (objgetap(ctx->voccxmem, objn, PRP_MULTISDESC, - (objnum *)0, FALSE) == 0) - { - /* there's no multisdesc defined - use the plain sdesc */ - runppr(rcx, objn, PRP_SDESC, 0); - } - else - { - /* multisdesc is defined - use it */ - runppr(rcx, objn, PRP_MULTISDESC, 0); - } + /* + * if we're not showing the prefix, don't use the multisdesc/sdesc + * display + */ + if (!show_prefix) + return; + + /* + * use multisdesc if defined (for compatibility with older games, + * use sdesc if multisdesc doesn't exist for this object) + */ + if (objgetap(ctx->voccxmem, objn, PRP_MULTISDESC, + (objnum *)0, FALSE) == 0) + { + /* there's no multisdesc defined - use the plain sdesc */ + runppr(rcx, objn, PRP_SDESC, 0); + } + else + { + /* multisdesc is defined - use it */ + runppr(rcx, objn, PRP_MULTISDESC, 0); + } - /* show the colon */ - vocerr_info(ctx, VOCERR(120), ": "); + /* show the colon */ + vocerr_info(ctx, VOCERR(120), ": "); } /* execute command for each object in direct object list */ static int exeloop(voccxdef *ctx, objnum actor, objnum verb, - vocoldef *dolist, objnum *prep, vocoldef *iobj, - int multi_flags, uchar *tpl, int newstyle) + vocoldef *dolist, objnum *prep, vocoldef *iobj, + int multi_flags, uchar *tpl, int newstyle) { - runcxdef *rcx = ctx->voccxrun; - int err; - int i; - int dobj_cnt; - int exec_cnt; - vocoldef *dobj; + runcxdef *rcx = ctx->voccxrun; + int err; + int i; + int dobj_cnt; + int exec_cnt; + vocoldef *dobj; - /* - * count the direct objects; we'll iterate over the direct objects, - * so we execute the command once per direct object - */ - exec_cnt = dobj_cnt = (dolist != 0 ? voclistlen(dolist) : 0); + /* + * count the direct objects; we'll iterate over the direct objects, + * so we execute the command once per direct object + */ + exec_cnt = dobj_cnt = (dolist != 0 ? voclistlen(dolist) : 0); - /* - * if there are no direct objects, we still must execute the command - * once - */ - if (exec_cnt < 1) - exec_cnt = 1; + /* + * if there are no direct objects, we still must execute the command + * once + */ + if (exec_cnt < 1) + exec_cnt = 1; - /* - * If we have multiple direct objects, or we're using "all" with - * just one direct object, check with the verb to see if multiple - * words are acceptable: call verb.rejectMultiDobj, and see what it - * returns; if it returns true, don't allow multiple words, and - * expect that rejectMultiDobj displayed an error message. - * Otherwise, proceed. - */ - if (((multi_flags & VOCS_ALL) != 0 || dobj_cnt > 1) - && dolist && dolist[0].vocolobj != MCMONINV) - { - int typ; + /* + * If we have multiple direct objects, or we're using "all" with + * just one direct object, check with the verb to see if multiple + * words are acceptable: call verb.rejectMultiDobj, and see what it + * returns; if it returns true, don't allow multiple words, and + * expect that rejectMultiDobj displayed an error message. + * Otherwise, proceed. + */ + if (((multi_flags & VOCS_ALL) != 0 || dobj_cnt > 1) + && dolist && dolist[0].vocolobj != MCMONINV) + { + int typ; - ERRBEGIN(ctx->voccxerr) - runrst(rcx); - if (!prep || *prep == MCMONINV) - runpnil(rcx); - else - runpobj(rcx, *prep); - runppr(rcx, verb, PRP_REJECTMDO, 1); - typ = runtostyp(rcx); - rundisc(rcx); - ERRCATCH(ctx->voccxerr, err) - if (err == ERR_RUNEXIT || err == ERR_RUNEXITOBJ - || err == ERR_RUNABRT) - return err; - else - errrse(ctx->voccxerr); - ERREND(ctx->voccxerr) + ERRBEGIN(ctx->voccxerr) + runrst(rcx); + if (!prep || *prep == MCMONINV) + runpnil(rcx); + else + runpobj(rcx, *prep); + runppr(rcx, verb, PRP_REJECTMDO, 1); + typ = runtostyp(rcx); + rundisc(rcx); + ERRCATCH(ctx->voccxerr, err) + if (err == ERR_RUNEXIT || err == ERR_RUNEXITOBJ + || err == ERR_RUNABRT) + return err; + else + errrse(ctx->voccxerr); + ERREND(ctx->voccxerr) - /* if they returned 'true', don't bother continuing */ - if (typ == DAT_TRUE) - return 0; - } + /* if they returned 'true', don't bother continuing */ + if (typ == DAT_TRUE) + return 0; + } - /* - * execute the command the required number of times - */ - for (i = 0 ; i < exec_cnt ; ++i) - { - int show_multi_prefix; + /* + * execute the command the required number of times + */ + for (i = 0 ; i < exec_cnt ; ++i) + { + int show_multi_prefix; - /* get the current direct object, if we have one */ - dobj = (dolist != 0 ? &dolist[i] : 0); + /* get the current direct object, if we have one */ + dobj = (dolist != 0 ? &dolist[i] : 0); - /* - * If we have a number or string, set the current one in - * numObj/strObj - */ - if (dolist != 0) - { - if (dolist[i].vocolflg == VOCS_STR) - { - /* it's a string - set strObj.value */ - vocsetobj(ctx, ctx->voccxstr, DAT_SSTRING, - dolist[i].vocolfst + 1, &dolist[i], &dolist[i]); - } - else if (dolist[i].vocolflg == VOCS_NUM) - { - long v1, v2; + /* + * If we have a number or string, set the current one in + * numObj/strObj + */ + if (dolist != 0) + { + if (dolist[i].vocolflg == VOCS_STR) + { + /* it's a string - set strObj.value */ + vocsetobj(ctx, ctx->voccxstr, DAT_SSTRING, + dolist[i].vocolfst + 1, &dolist[i], &dolist[i]); + } + else if (dolist[i].vocolflg == VOCS_NUM) + { + long v1, v2; - /* it's a number - set numObj.value */ - v1 = atol(dolist[i].vocolfst); - oswp4s(&v2, v1); - vocsetobj(ctx, ctx->voccxnum, DAT_NUMBER, &v2, - &dolist[i], &dolist[i]); - } - } + /* it's a number - set numObj.value */ + v1 = atol(dolist[i].vocolfst); + oswp4s(&v2, v1); + vocsetobj(ctx, ctx->voccxnum, DAT_NUMBER, &v2, + &dolist[i], &dolist[i]); + } + } - /* - * For cases where we have a bunch of direct objects (or even - * one when "all" was used), we want to preface the output from - * each iteration with the name of the object we're acting on - * currently. In other cases, there is no prefix. - */ - show_multi_prefix = ((multi_flags != 0 || dobj_cnt > 1) && dobj != 0); + /* + * For cases where we have a bunch of direct objects (or even + * one when "all" was used), we want to preface the output from + * each iteration with the name of the object we're acting on + * currently. In other cases, there is no prefix. + */ + show_multi_prefix = ((multi_flags != 0 || dobj_cnt > 1) && dobj != 0); - /* - * Execute the command for this object. For every object except - * the first, re-validate the direct and indirect objects. - * There's no need to re-validate the objects on the first - * object in a command, because that will already have been done - * during object resolution. - */ - err = exe1cmd(ctx, actor, verb, dobj, prep, iobj, - (i + 1 == exec_cnt), tpl, newstyle, FALSE, - i != 0, i != 0, dolist, i, dobj_cnt, - show_multi_prefix, multi_flags); + /* + * Execute the command for this object. For every object except + * the first, re-validate the direct and indirect objects. + * There's no need to re-validate the objects on the first + * object in a command, because that will already have been done + * during object resolution. + */ + err = exe1cmd(ctx, actor, verb, dobj, prep, iobj, + (i + 1 == exec_cnt), tpl, newstyle, FALSE, + i != 0, i != 0, dolist, i, dobj_cnt, + show_multi_prefix, multi_flags); - /* check the error - ignore any verification failures */ - switch(err) - { - case ERR_PRS_VERDO_FAIL: - case ERR_PRS_VERIO_FAIL: - case ERR_PRS_NO_VERDO: - case ERR_PRS_NO_VERIO: - case ERR_RUNEXITOBJ: - case ERR_RUNEXIT: - /* ignore the error and continue */ - err = 0; - break; + /* check the error - ignore any verification failures */ + switch(err) + { + case ERR_PRS_VERDO_FAIL: + case ERR_PRS_VERIO_FAIL: + case ERR_PRS_NO_VERDO: + case ERR_PRS_NO_VERIO: + case ERR_RUNEXITOBJ: + case ERR_RUNEXIT: + /* ignore the error and continue */ + err = 0; + break; - case ERR_RUNEXITPRECMD: - /* - * exited from preCommand - skip execution of subsequent - * objects, but return success - */ - return 0; + case ERR_RUNEXITPRECMD: + /* + * exited from preCommand - skip execution of subsequent + * objects, but return success + */ + return 0; - case 0: - /* no error; continue */ - break; + case 0: + /* no error; continue */ + break; - default: - /* anything else stops this command */ - return err; - } + default: + /* anything else stops this command */ + return err; + } - /* flush output */ - tioflush(ctx->voccxtio); - } + /* flush output */ + tioflush(ctx->voccxtio); + } - /* success */ - return 0; + /* success */ + return 0; } /* @@ -1920,139 +1920,139 @@ static int exeloop(voccxdef *ctx, objnum actor, objnum verb, * player had typed it. */ int execmd_recurs(voccxdef *ctx, objnum actor, objnum verb, - objnum dobj, objnum prep, objnum iobj, - int validate_dobj, int validate_iobj) + objnum dobj, objnum prep, objnum iobj, + int validate_dobj, int validate_iobj) { - int err; - int newstyle; - uchar tpl[VOCTPL2SIZ]; - vocoldef dobjv; - vocoldef iobjv; - voccxdef ctx_copy; - runsdef *orig_sp; - runsdef *orig_bp; + int err; + int newstyle; + uchar tpl[VOCTPL2SIZ]; + vocoldef dobjv; + vocoldef iobjv; + voccxdef ctx_copy; + runsdef *orig_sp; + runsdef *orig_bp; - /* - * Save the stack and base pointers as they are on entry. Since - * exe1cmd() is being called recursively, it won't automatically clear - * the stack after it's done as it would at the top level; this means - * that an aborted frame can be left on the stack if we throw an - * 'exit' or 'abort' in the course of executing the command. To make - * sure we don't leave any aborted frames on the stack before - * returning to our caller, we simply need to restore the stack and - * frame pointers on the way out as they were on the way in. - */ - orig_sp = ctx->voccxrun->runcxsp; - orig_bp = ctx->voccxrun->runcxbp; + /* + * Save the stack and base pointers as they are on entry. Since + * exe1cmd() is being called recursively, it won't automatically clear + * the stack after it's done as it would at the top level; this means + * that an aborted frame can be left on the stack if we throw an + * 'exit' or 'abort' in the course of executing the command. To make + * sure we don't leave any aborted frames on the stack before + * returning to our caller, we simply need to restore the stack and + * frame pointers on the way out as they were on the way in. + */ + orig_sp = ctx->voccxrun->runcxsp; + orig_bp = ctx->voccxrun->runcxbp; - /* make a copy of the voc context, so that changes aren't permanent */ - ctx_copy = *ctx; - ctx = &ctx_copy; + /* make a copy of the voc context, so that changes aren't permanent */ + ctx_copy = *ctx; + ctx = &ctx_copy; - /* - * there are no unknown words in the recursive command, since the - * command was prepared directly from resolved objects - */ - ctx->voccxunknown = 0; + /* + * there are no unknown words in the recursive command, since the + * command was prepared directly from resolved objects + */ + ctx->voccxunknown = 0; - /* set up the vocoldef structure for the direct object, if present */ - if (dobj != MCMONINV) - { - dobjv.vocolobj = dobj; - dobjv.vocolfst = dobjv.vocollst = ""; - dobjv.vocolflg = 0; - } + /* set up the vocoldef structure for the direct object, if present */ + if (dobj != MCMONINV) + { + dobjv.vocolobj = dobj; + dobjv.vocolfst = dobjv.vocollst = ""; + dobjv.vocolflg = 0; + } - /* set up the vocoldef structure for the indirect object, if present */ - if (iobj != MCMONINV) - { - iobjv.vocolobj = iobj; - iobjv.vocolfst = iobjv.vocollst = ""; - iobjv.vocolflg = 0; - } - - /* figure out which template we need, based on the objects provided */ - if (dobj == MCMONINV) - { - uint actofs; - uint tplofs; - - /* - * No objects were provided - use the verb's "action" method. - * Make sure that there is in fact an "action" method. - */ - exe_get_tpl(ctx, verb, &tplofs, &actofs); - if (actofs != 0) - { - /* execute the "action" method */ - err = exe1cmd(ctx, actor, verb, 0, &prep, 0, FALSE, - 0, FALSE, TRUE, validate_dobj, validate_iobj, - 0, 0, 0, FALSE, 0); - } - else - { - /* indicate that the sentence structure wasn't understood */ - err = ERR_PRS_SENT_UNK; - } - } - else if (iobj == MCMONINV) - { - /* - * No indirect object was provided, but a direct object is - * present - use the one-object template. First, look up the - * template. - */ - if (voctplfnd(ctx, verb, MCMONINV, tpl, &newstyle)) - { - /* execute the command */ - err = exe1cmd(ctx, actor, verb, &dobjv, &prep, 0, FALSE, - tpl, newstyle, TRUE, validate_dobj, validate_iobj, - &dobjv, 0, 1, FALSE, 0); - } - else - { - /* indicate that the sentence structure wasn't understood */ - err = ERR_PRS_SENT_UNK; - } - } - else - { - /* - * Both a direct and indirect object were provided - find the - * two-object template for the given preposition. - */ - if (voctplfnd(ctx, verb, prep, tpl, &newstyle)) - { - /* execute the command */ - err = exe1cmd(ctx, actor, verb, &dobjv, &prep, &iobjv, FALSE, - tpl, newstyle, TRUE, validate_dobj, validate_iobj, - &dobjv, 0, 1, FALSE, 0); - } - else - { - /* indicate that the sentence structure wasn't understood */ - err = ERR_PRS_SENT_UNK; - } - } + /* set up the vocoldef structure for the indirect object, if present */ + if (iobj != MCMONINV) + { + iobjv.vocolobj = iobj; + iobjv.vocolfst = iobjv.vocollst = ""; + iobjv.vocolflg = 0; + } + + /* figure out which template we need, based on the objects provided */ + if (dobj == MCMONINV) + { + uint actofs; + uint tplofs; + + /* + * No objects were provided - use the verb's "action" method. + * Make sure that there is in fact an "action" method. + */ + exe_get_tpl(ctx, verb, &tplofs, &actofs); + if (actofs != 0) + { + /* execute the "action" method */ + err = exe1cmd(ctx, actor, verb, 0, &prep, 0, FALSE, + 0, FALSE, TRUE, validate_dobj, validate_iobj, + 0, 0, 0, FALSE, 0); + } + else + { + /* indicate that the sentence structure wasn't understood */ + err = ERR_PRS_SENT_UNK; + } + } + else if (iobj == MCMONINV) + { + /* + * No indirect object was provided, but a direct object is + * present - use the one-object template. First, look up the + * template. + */ + if (voctplfnd(ctx, verb, MCMONINV, tpl, &newstyle)) + { + /* execute the command */ + err = exe1cmd(ctx, actor, verb, &dobjv, &prep, 0, FALSE, + tpl, newstyle, TRUE, validate_dobj, validate_iobj, + &dobjv, 0, 1, FALSE, 0); + } + else + { + /* indicate that the sentence structure wasn't understood */ + err = ERR_PRS_SENT_UNK; + } + } + else + { + /* + * Both a direct and indirect object were provided - find the + * two-object template for the given preposition. + */ + if (voctplfnd(ctx, verb, prep, tpl, &newstyle)) + { + /* execute the command */ + err = exe1cmd(ctx, actor, verb, &dobjv, &prep, &iobjv, FALSE, + tpl, newstyle, TRUE, validate_dobj, validate_iobj, + &dobjv, 0, 1, FALSE, 0); + } + else + { + /* indicate that the sentence structure wasn't understood */ + err = ERR_PRS_SENT_UNK; + } + } - /* - * if the error was EXITPRECMD, change it to EXIT - EXITPRECMD is a - * special flag indicating that we exited from a preCommand - * function, which is different than normal exiting internally but - * not to the game - */ - if (err == ERR_RUNEXITPRECMD) - err = ERR_RUNEXIT; + /* + * if the error was EXITPRECMD, change it to EXIT - EXITPRECMD is a + * special flag indicating that we exited from a preCommand + * function, which is different than normal exiting internally but + * not to the game + */ + if (err == ERR_RUNEXITPRECMD) + err = ERR_RUNEXIT; - /* - * restore the original stack and base pointers, to ensure that we - * don't leave any aborted frames on the stack - */ - ctx->voccxrun->runcxsp = orig_sp; - ctx->voccxrun->runcxbp = orig_bp; + /* + * restore the original stack and base pointers, to ensure that we + * don't leave any aborted frames on the stack + */ + ctx->voccxrun->runcxsp = orig_sp; + ctx->voccxrun->runcxbp = orig_bp; - /* return the result code */ - return err; + /* return the result code */ + return err; } @@ -2063,23 +2063,23 @@ int execmd_recurs(voccxdef *ctx, objnum actor, objnum verb, */ static int check_for_multi(vocoldef *dolist) { - int dolen; - int i; - int result; + int dolen; + int i; + int result; - /* presume we won't find any flags */ - result = 0; + /* presume we won't find any flags */ + result = 0; - /* - * scan the list for ALL, ANY, or THEM flags, combining any such - * flags we find into the result - */ - dolen = voclistlen(dolist); - for (i = 0 ; i < dolen ; ++i) - result |= (dolist[i].vocolflg & (VOCS_ALL | VOCS_ANY | VOCS_THEM)); + /* + * scan the list for ALL, ANY, or THEM flags, combining any such + * flags we find into the result + */ + dolen = voclistlen(dolist); + for (i = 0 ; i < dolen ; ++i) + result |= (dolist[i].vocolflg & (VOCS_ALL | VOCS_ANY | VOCS_THEM)); - /* return the result */ - return result; + /* return the result */ + return result; } /* ------------------------------------------------------------------------ */ @@ -2091,138 +2091,138 @@ static int check_for_multi(vocoldef *dolist) * command). */ int try_preparse_cmd(voccxdef *ctx, char **cmd, int wrdcnt, - uchar **preparse_list) + uchar **preparse_list) { - uchar listbuf[VOCBUFSIZ + 2 + 3*VOCBUFSIZ]; - int i; - uchar *p; - size_t len; - runsdef val; - int typ; - int err; + uchar listbuf[VOCBUFSIZ + 2 + 3*VOCBUFSIZ]; + int i; + uchar *p; + size_t len; + runsdef val; + int typ; + int err; - /* if there's no preparseCmd, keep processing */ - if (ctx->voccxppc == MCMONINV) - return 0; - - /* build a list of the words */ - for (p = listbuf + 2, i = 0 ; i < wrdcnt ; ++i) - { - char *src; - int add_quote; - - /* check for strings - they require special handling */ - if (cmd[i][0] == '"') - { - /* - * it's a string - what follows is a run-time style string, - * with a length prefix followed by the text of the string - */ - len = osrp2(cmd[i] + 1) - 2; - src = cmd[i] + 3; + /* if there's no preparseCmd, keep processing */ + if (ctx->voccxppc == MCMONINV) + return 0; + + /* build a list of the words */ + for (p = listbuf + 2, i = 0 ; i < wrdcnt ; ++i) + { + char *src; + int add_quote; + + /* check for strings - they require special handling */ + if (cmd[i][0] == '"') + { + /* + * it's a string - what follows is a run-time style string, + * with a length prefix followed by the text of the string + */ + len = osrp2(cmd[i] + 1) - 2; + src = cmd[i] + 3; - /* add quotes to the result */ - add_quote = TRUE; - } - else - { - /* ordinary word - copy directly */ - src = (char *)cmd[i]; + /* add quotes to the result */ + add_quote = TRUE; + } + else + { + /* ordinary word - copy directly */ + src = (char *)cmd[i]; - /* it's a null-terminated string */ - len = strlen(src); + /* it's a null-terminated string */ + len = strlen(src); - /* don't add quotes to the result */ - add_quote = FALSE; - } + /* don't add quotes to the result */ + add_quote = FALSE; + } - /* write the type prefix */ - *p++ = DAT_SSTRING; + /* write the type prefix */ + *p++ = DAT_SSTRING; - /* write the length prefix */ - oswp2(p, len + 2 + (add_quote ? 2 : 0)); - p += 2; + /* write the length prefix */ + oswp2(p, len + 2 + (add_quote ? 2 : 0)); + p += 2; - /* add an open quote if necessary */ - if (add_quote) - *p++ = '"'; + /* add an open quote if necessary */ + if (add_quote) + *p++ = '"'; - /* copy the text */ - memcpy(p, src, len); - p += len; + /* copy the text */ + memcpy(p, src, len); + p += len; - /* add the closing quote if necessary */ - if (add_quote) - *p++ = '"'; - } - - /* set the length of the whole list */ - len = p - listbuf; - oswp2(listbuf, len); - - /* push the list as the argument, and call the user's preparseCmd */ - val.runstyp = DAT_LIST; - val.runsv.runsvstr = listbuf; - runpush(ctx->voccxrun, DAT_LIST, &val); + /* add the closing quote if necessary */ + if (add_quote) + *p++ = '"'; + } + + /* set the length of the whole list */ + len = p - listbuf; + oswp2(listbuf, len); + + /* push the list as the argument, and call the user's preparseCmd */ + val.runstyp = DAT_LIST; + val.runsv.runsvstr = listbuf; + runpush(ctx->voccxrun, DAT_LIST, &val); - /* presume that no error will occur */ - err = 0; + /* presume that no error will occur */ + err = 0; - /* catch errors that occur within preparseCmd */ - ERRBEGIN(ctx->voccxerr) - { - /* call preparseCmd */ - runfn(ctx->voccxrun, ctx->voccxppc, 1); - } - ERRCATCH(ctx->voccxerr, err) - { - /* - * if it's abort/exit/exitobj, just return it; for any other - * errors, just re-throw the same error - */ - switch(err) - { - case ERR_RUNABRT: - case ERR_RUNEXIT: - case ERR_RUNEXITOBJ: - /* simply return these errors to the caller */ - break; + /* catch errors that occur within preparseCmd */ + ERRBEGIN(ctx->voccxerr) + { + /* call preparseCmd */ + runfn(ctx->voccxrun, ctx->voccxppc, 1); + } + ERRCATCH(ctx->voccxerr, err) + { + /* + * if it's abort/exit/exitobj, just return it; for any other + * errors, just re-throw the same error + */ + switch(err) + { + case ERR_RUNABRT: + case ERR_RUNEXIT: + case ERR_RUNEXITOBJ: + /* simply return these errors to the caller */ + break; - default: - /* re-throw anything else */ - errrse(ctx->voccxerr); - } - } - ERREND(ctx->voccxerr); + default: + /* re-throw anything else */ + errrse(ctx->voccxerr); + } + } + ERREND(ctx->voccxerr); - /* if an error occurred, return the error code */ - if (err != 0) - return err; + /* if an error occurred, return the error code */ + if (err != 0) + return err; - /* get the result */ - typ = runtostyp(ctx->voccxrun); - - /* if they returned a list, it's a new command to execute */ - if (typ == DAT_LIST) - { - /* get the list and give it to the caller */ - *preparse_list = runpoplst(ctx->voccxrun); - - /* - * indicate that the command is to be reparsed with the new word - * list - */ - return ERR_PREPRSCMDREDO; - } + /* get the result */ + typ = runtostyp(ctx->voccxrun); + + /* if they returned a list, it's a new command to execute */ + if (typ == DAT_LIST) + { + /* get the list and give it to the caller */ + *preparse_list = runpoplst(ctx->voccxrun); + + /* + * indicate that the command is to be reparsed with the new word + * list + */ + return ERR_PREPRSCMDREDO; + } - /* for any other type, we don't need the value, so discard it */ - rundisc(ctx->voccxrun); + /* for any other type, we don't need the value, so discard it */ + rundisc(ctx->voccxrun); - /* if the result is nil, don't process this command further */ - if (typ == DAT_NIL) - return ERR_PREPRSCMDCAN; - else - return 0; + /* if the result is nil, don't process this command further */ + if (typ == DAT_NIL) + return ERR_PREPRSCMDCAN; + else + return 0; } @@ -2231,203 +2231,203 @@ int try_preparse_cmd(voccxdef *ctx, char **cmd, int wrdcnt, * Call parseAskobjIndirect */ static void voc_askobj_indirect(voccxdef *ctx, vocoldef *dolist, - objnum actor, objnum verb, objnum prep) + objnum actor, objnum verb, objnum prep) { - int cnt; - int i; - size_t len; - uchar *lstp; - - /* - * Generate the direct object list argument. This argument is a - * list of lists. For each noun phrase, we generate one sublist in - * the main list. Each sublist itself consists of three - * sub-sublists: first, a list of strings giving the words in the - * noun phrase; second, a list of the objects matching the noun - * phrase; third, a list of the flags for the matching objects. - * - * So, if the player typed "put red box and blue ball", we might - * generate a list something like this: - * - * [ [ ['red', 'box'], [redBox1, redBox2], [0, 0] ], [ ['blue', - * 'ball'], [blueBall], [0, 0] ] ] - */ + int cnt; + int i; + size_t len; + uchar *lstp; + + /* + * Generate the direct object list argument. This argument is a + * list of lists. For each noun phrase, we generate one sublist in + * the main list. Each sublist itself consists of three + * sub-sublists: first, a list of strings giving the words in the + * noun phrase; second, a list of the objects matching the noun + * phrase; third, a list of the flags for the matching objects. + * + * So, if the player typed "put red box and blue ball", we might + * generate a list something like this: + * + * [ [ ['red', 'box'], [redBox1, redBox2], [0, 0] ], [ ['blue', + * 'ball'], [blueBall], [0, 0] ] ] + */ - /* - * First, figure out how much space we need for this list of lists - * of lists. Scan the direct object list for distinct noun phrases - * - we need one sublist for each distinct noun phrase. - */ - cnt = voclistlen(dolist); - for (len = 0, i = 0 ; i < cnt ; ) - { - const char *p; - size_t curlen; - int j; - - /* - * we need the sublist type prefix (one byte) plus the sublist - * length prefix (two bytes), plus the type and length prefixes - * (one plus two bytes) for each of the three sub-sublist - */ - len += (1+2) + 3*(1+2); + /* + * First, figure out how much space we need for this list of lists + * of lists. Scan the direct object list for distinct noun phrases + * - we need one sublist for each distinct noun phrase. + */ + cnt = voclistlen(dolist); + for (len = 0, i = 0 ; i < cnt ; ) + { + const char *p; + size_t curlen; + int j; + + /* + * we need the sublist type prefix (one byte) plus the sublist + * length prefix (two bytes), plus the type and length prefixes + * (one plus two bytes) for each of the three sub-sublist + */ + len += (1+2) + 3*(1+2); - /* - * we need space to store the strings for the words in this noun - * phrase - */ - for (p = dolist[i].vocolfst ; p != 0 && p <= dolist[i].vocollst ; - p += curlen + 1) - { - /* - * add in the space needed for this string element in the - * sub-sublist - we need one byte for the type prefix, two - * bytes for the length prefix, and the bytes for the string - * itself - */ - curlen = strlen(p); - len += (1+2) + curlen; - } + /* + * we need space to store the strings for the words in this noun + * phrase + */ + for (p = dolist[i].vocolfst ; p != 0 && p <= dolist[i].vocollst ; + p += curlen + 1) + { + /* + * add in the space needed for this string element in the + * sub-sublist - we need one byte for the type prefix, two + * bytes for the length prefix, and the bytes for the string + * itself + */ + curlen = strlen(p); + len += (1+2) + curlen; + } - /* - * scan each object for this same noun phrase (i.e., for which - * the vocabulary words are the same) - */ - for (j = i ; j < cnt && dolist[j].vocolfst == dolist[i].vocolfst ; - ++j) - { - /* - * Add in space for this object in the sub-sublist for the - * current noun phrase. If this object is nil, we need only - * one byte for the type; otherwise, we need one byte for - * the type prefix plus two bytes for the object ID. - */ - if (dolist[i].vocolobj == MCMONINV) - len += 1; - else - len += (1 + 2); - - /* - * Add in space for the flags sub-sublist for the current - * object. We need one byte for the type and four for the - * integer value. - */ - len += (1 + 4); - } + /* + * scan each object for this same noun phrase (i.e., for which + * the vocabulary words are the same) + */ + for (j = i ; j < cnt && dolist[j].vocolfst == dolist[i].vocolfst ; + ++j) + { + /* + * Add in space for this object in the sub-sublist for the + * current noun phrase. If this object is nil, we need only + * one byte for the type; otherwise, we need one byte for + * the type prefix plus two bytes for the object ID. + */ + if (dolist[i].vocolobj == MCMONINV) + len += 1; + else + len += (1 + 2); + + /* + * Add in space for the flags sub-sublist for the current + * object. We need one byte for the type and four for the + * integer value. + */ + len += (1 + 4); + } - /* skip to the next distinct noun phrase */ - i = j; - } + /* skip to the next distinct noun phrase */ + i = j; + } - /* allocate the list */ - lstp = voc_push_list_siz(ctx, len); + /* allocate the list */ + lstp = voc_push_list_siz(ctx, len); - /* - * Go through our object array again, and this time actually build - * the list. - */ - for (i = 0 ; i < cnt ; ) - { - const char *p; - uchar *subp; - uchar *subsubp; - size_t curlen; - int j; + /* + * Go through our object array again, and this time actually build + * the list. + */ + for (i = 0 ; i < cnt ; ) + { + const char *p; + uchar *subp; + uchar *subsubp; + size_t curlen; + int j; - /* start the sublist with the type prefix */ - *lstp++ = DAT_LIST; + /* start the sublist with the type prefix */ + *lstp++ = DAT_LIST; - /* leave a placeholder for our length prefix */ - subp = lstp; - lstp += 2; + /* leave a placeholder for our length prefix */ + subp = lstp; + lstp += 2; - /* start the sub-sublist with the word strings */ - *lstp++ = DAT_LIST; - subsubp = lstp; - lstp += 2; + /* start the sub-sublist with the word strings */ + *lstp++ = DAT_LIST; + subsubp = lstp; + lstp += 2; - /* store the word strings in the sub-sublist */ - for (p = dolist[i].vocolfst ; p != 0 && p <= dolist[i].vocollst ; - p += curlen + 1) - { - /* get this string's length */ - curlen = strlen(p); + /* store the word strings in the sub-sublist */ + for (p = dolist[i].vocolfst ; p != 0 && p <= dolist[i].vocollst ; + p += curlen + 1) + { + /* get this string's length */ + curlen = strlen(p); - /* store the type and length prefixes */ - *lstp++ = DAT_SSTRING; - oswp2(lstp, curlen + 2); - lstp += 2; + /* store the type and length prefixes */ + *lstp++ = DAT_SSTRING; + oswp2(lstp, curlen + 2); + lstp += 2; - /* store the string */ - memcpy(lstp, p, curlen); - lstp += curlen; - } + /* store the string */ + memcpy(lstp, p, curlen); + lstp += curlen; + } - /* fix up the string sub-sublist length */ - oswp2(subsubp, lstp - subsubp); + /* fix up the string sub-sublist length */ + oswp2(subsubp, lstp - subsubp); - /* start the second sub-sublist, for the objects */ - *lstp++ = DAT_LIST; - subsubp = lstp; - lstp += 2; + /* start the second sub-sublist, for the objects */ + *lstp++ = DAT_LIST; + subsubp = lstp; + lstp += 2; - /* write each object */ - for (j = i ; j < cnt && dolist[j].vocolfst == dolist[i].vocolfst ; - ++j) - { - /* - * if this object isn't nil, write it to the sub-sublist; - * otherwise, just put nil in the sub-sublist - */ - if (dolist[j].vocolobj != MCMONINV) - { - *lstp++ = DAT_OBJECT; - oswp2(lstp, dolist[j].vocolobj); - lstp += 2; - } - else - { - /* no object - just store nil */ - *lstp++ = DAT_NIL; - } - } + /* write each object */ + for (j = i ; j < cnt && dolist[j].vocolfst == dolist[i].vocolfst ; + ++j) + { + /* + * if this object isn't nil, write it to the sub-sublist; + * otherwise, just put nil in the sub-sublist + */ + if (dolist[j].vocolobj != MCMONINV) + { + *lstp++ = DAT_OBJECT; + oswp2(lstp, dolist[j].vocolobj); + lstp += 2; + } + else + { + /* no object - just store nil */ + *lstp++ = DAT_NIL; + } + } - /* fix up the object sub-sublist length */ - oswp2(subsubp, lstp - subsubp); + /* fix up the object sub-sublist length */ + oswp2(subsubp, lstp - subsubp); - /* start the third sub-sublist, for the flags */ - *lstp++ = DAT_LIST; - subsubp = lstp; - lstp += 2; + /* start the third sub-sublist, for the flags */ + *lstp++ = DAT_LIST; + subsubp = lstp; + lstp += 2; - /* write each object's flags */ - for (j = i ; j < cnt && dolist[j].vocolfst == dolist[i].vocolfst ; - ++j) - { - /* write the flags */ - *lstp++ = DAT_NUMBER; - oswp4s(lstp, dolist[j].vocolflg); - lstp += 4; - } + /* write each object's flags */ + for (j = i ; j < cnt && dolist[j].vocolfst == dolist[i].vocolfst ; + ++j) + { + /* write the flags */ + *lstp++ = DAT_NUMBER; + oswp4s(lstp, dolist[j].vocolflg); + lstp += 4; + } - /* fix up the flag sub-sublist length */ - oswp2(subsubp, lstp - subsubp); + /* fix up the flag sub-sublist length */ + oswp2(subsubp, lstp - subsubp); - /* skip to the start of the next distinct noun phrase */ - i = j; + /* skip to the start of the next distinct noun phrase */ + i = j; - /* fix up the sublist length */ - oswp2(subp, lstp - subp); - } + /* fix up the sublist length */ + oswp2(subp, lstp - subp); + } - /* push the prep, verb, and actor arguments */ - runpobj(ctx->voccxrun, prep); - runpobj(ctx->voccxrun, verb); - runpobj(ctx->voccxrun, - (objnum)(actor == MCMONINV ? ctx->voccxme : actor)); + /* push the prep, verb, and actor arguments */ + runpobj(ctx->voccxrun, prep); + runpobj(ctx->voccxrun, verb); + runpobj(ctx->voccxrun, + (objnum)(actor == MCMONINV ? ctx->voccxme : actor)); - /* call the function */ - runfn(ctx->voccxrun, ctx->voccxpask3, 4); + /* call the function */ + runfn(ctx->voccxrun, ctx->voccxpask3, 4); } @@ -2444,1240 +2444,1240 @@ static void voc_askobj_indirect(voccxdef *ctx, vocoldef *dolist, * understand the sentence and leave it at that. */ int execmd(voccxdef *ctx, objnum actor, objnum prep, - char *vverb, char *vprep, vocoldef *dolist, vocoldef *iolist, - char **cmd, int *typelist, - char *cmdbuf, int wrdcnt, uchar **preparse_list, int *next_word) + char *vverb, char *vprep, vocoldef *dolist, vocoldef *iolist, + char **cmd, int *typelist, + char *cmdbuf, int wrdcnt, uchar **preparse_list, int *next_word) { - objnum verb; - objnum iobj; - int multi_flags = 0; - vocwdef *n; - int cnt; - vocoldef *newnoun; - int next; - char *exenewcmd; - char *donewcmd; - char *ionewcmd; - char *exenewbuf; - char *donewbuf; - char *ionewbuf; - char **exenewlist; - char **donewlist; - char **ionewlist; - int *exenewtype; - int *donewtype; - int *ionewtype; - vocoldef *dolist1; - vocoldef *iolist1; - uchar tpl[VOCTPL2SIZ]; - int foundtpl; /* used to determine success of tpl searches */ - runcxdef *rcx = ctx->voccxrun; - uint tplofs; /* offset of template object */ - uint actofs; /* offset of 'action' property */ - int askflags; /* flag for what we need to ask user */ - int newstyle; /* flag indicating new-style template definitions */ - int tplflags; - int err; - uchar *save_sp; - - /* run preparseCmd */ - switch(try_preparse_cmd(ctx, cmd, wrdcnt, preparse_list)) - { - case 0: - /* proceed with the command */ - break; - - case ERR_PREPRSCMDCAN: - /* command cancelled */ - return 0; - - case ERR_RUNEXIT: - case ERR_RUNABRT: - case ERR_RUNEXITOBJ: - /* abort/exit/exitobj - treat this the same as command cancellation */ - return 0; - - case ERR_PREPRSCMDREDO: - /* redo the command - so indicate to the caller */ - return ERR_PREPRSCMDREDO; - } - - /* look up the verb based on the verb and verb-prep */ - n = vocffw(ctx, vverb, (int)strlen(vverb), - vprep, (vprep ? (int)strlen(vprep) : 0), PRP_VERB, - (vocseadef *)0); - - /* if we didn't find a verb template, we can't process the sentence */ - if (n == 0) - { - /* try parseUnknownVerb, and show an error if that doesn't handle it */ - if (try_unknown_verb(ctx, actor, cmd, typelist, wrdcnt, next_word, - TRUE, VOCERR(18), - "I don't understand that sentence.")) - { - /* they handled it successfully - end the command with success */ - return 0; - } - else - { - /* - * parseUnknownVerb failed or aborted - end the command with - * an error - */ - return 1; - } - } - - /* get the deepverb object */ - verb = n->vocwobj; - - /* default actor is "Me" */ - if (actor == MCMONINV) - actor = ctx->voccxme; - - /* set a savepoint, if we're keeping undo information */ - if (ctx->voccxundo) - objusav(ctx->voccxundo); - - /* - * Check that the room will allow this command -- it may not - * due to darkness or other ailment. We can find out with the - * roomCheck(verb) message, sent to the meobj. - */ - { - int t; - - /* call roomCheck */ - runrst(rcx); - runpobj(rcx, verb); - runppr(rcx, ctx->voccxme, PRP_ROOMCHECK, 1); - t = runpoplog(rcx); - - /* if they returned nil, stop the command, but indicate success */ - if (!t) - return 0; - } - - /* look for a new-style template first, then the old-style template */ - exe_get_tpl(ctx, verb, &tplofs, &actofs); - - /* make sure we found a verb */ - if (tplofs == 0 && actofs == 0 && verb != ctx->voccxvag) - { - /* try parseUnknownVerb, and show an error if that doesn't handle it */ - if (try_unknown_verb(ctx, actor, cmd, typelist, wrdcnt, next_word, - TRUE, VOCERR(23), - "internal error: verb has no action, doAction, or ioAction")) - return 0; - else - return 1; - } - - /* - * Check to see if we have an "all" - if we do, we'll need to - * display the direct object's name even if only one direct object - * comes of it. - */ - multi_flags = check_for_multi(dolist); - - /* - * set up dobj word list in case objwords is used in doDefault (the - * game may want to check for "all" and disallow it, for example) - */ - ctx->voccxdobj = dolist; - - /* set up our stack allocations, which we may need from now on */ - voc_enter(ctx, &save_sp); - VOC_STK_ARRAY(ctx, char, donewcmd, VOCBUFSIZ); - VOC_STK_ARRAY(ctx, char, ionewcmd, VOCBUFSIZ); - VOC_STK_ARRAY(ctx, char, donewbuf, 2*VOCBUFSIZ); - VOC_STK_ARRAY(ctx, char, ionewbuf, 2*VOCBUFSIZ); - VOC_STK_ARRAY(ctx, char *, donewlist, VOCBUFSIZ); - VOC_STK_ARRAY(ctx, char *, ionewlist, VOCBUFSIZ); - VOC_MAX_ARRAY(ctx, int, donewtype); - VOC_MAX_ARRAY(ctx, int, ionewtype); - VOC_MAX_ARRAY(ctx, vocoldef, dolist1); - VOC_MAX_ARRAY(ctx, vocoldef, iolist1); - - /* keep going until we're done with the sentence */ - for ( ;; ) - { - askflags = err = 0; - - ERRBEGIN(ctx->voccxerr) - - /* - * Now see what kind of sentence we have. If we have no - * objects and an action, use the action. If we have a direct - * object and a doAction, use the doAction. If we have an - * indirect object and an ioAction with a matching preposition, - * use the ioAction. If we have an indirect object and no - * matching ioAction, complain. If we have a direct object and - * no doAction or ioAction, complain. If we have fewer objects - * than we really want, ask the user for more of them. - */ - if (voclistlen(dolist) == 0 && voclistlen(iolist) == 0) - { - if (actofs || verb == ctx->voccxvag) - { - if ((err = exeloop(ctx, actor, verb, (vocoldef *)0, &prep, - (vocoldef *)0, multi_flags, - (uchar *)0, 0)) != 0) - goto exit_error; - } - else - { - /* - * The player has not specified any objects, but the - * verb seems to require one. See if there's a unique - * default. - */ - runrst(rcx); - runpnil(rcx); - runpobj(rcx, prep); - runpobj(rcx, actor); - runppr(rcx, verb, PRP_DODEFAULT, 3); - - if (runtostyp(rcx) == DAT_LIST) - { - uchar *l = runpoplst(rcx); - uint lstsiz; - objnum defobj = 0; - int objcnt; - objnum newprep; - runsdef val; - objnum o; - - /* push list back on stack, to keep in heap */ - val.runsv.runsvstr = l; - val.runstyp = DAT_LIST; - runrepush(rcx, &val); - - /* get list size out of list */ - lstsiz = osrp2(l) - 2; - l += 2; - - /* find default preposition for verb, if any */ - runppr(rcx, verb, PRP_PREPDEFAULT, 0); - if (runtostyp(rcx) == DAT_OBJECT) - newprep = runpopobj(rcx); - else - { - newprep = MCMONINV; - rundisc(rcx); - } - - if (!voctplfnd(ctx, verb, newprep, tpl, &newstyle)) - { - for (objcnt = 0 ; lstsiz && objcnt < 2 - ; lstadv(&l, &lstsiz)) - { - if (*l == DAT_OBJECT) - { - ++objcnt; - defobj = osrp2(l + 1); - } - } - } - else - { - int dobj_first; - - /* - * Get the template flags. If we must - * disambiguate the direct object first for this - * verb, do so now. - */ - tplflags = (newstyle ? voctplflg(tpl) : 0); - dobj_first = (tplflags & VOCTPLFLG_DOBJ_FIRST); - - for (objcnt = 0 ; lstsiz && objcnt < 2 - ; lstadv(&l, &lstsiz)) - { - if (*l == DAT_OBJECT) - { - o = osrp2(l + 1); - if (!objgetap(ctx->voccxmem, o, voctplvd(tpl), - (objnum *)0, FALSE)) - continue; - - tiohide(ctx->voccxtio); - if (newprep != MCMONINV && !dobj_first) - runpnil(rcx); - runpobj(rcx, actor); - runppr(rcx, o, voctplvd(tpl), - ((newprep != MCMONINV && !dobj_first) - ? 2 : 1)); - - if (!tioshow(ctx->voccxtio)) - { - ++objcnt; - defobj = o; - } - } - } - - /* no longer need list in heap, so discard it */ - rundisc(rcx); - - /* use default object if there's exactly one */ - if (objcnt == 1) - { - dolist[0].vocolobj = defobj; - dolist[0].vocolflg = 0; - dolist[0].vocolfst = dolist[0].vocollst = 0; - dolist[1].vocolobj = MCMONINV; - dolist[1].vocolflg = 0; - dolist[1].vocolfst = dolist[1].vocollst = 0; - - runrst(rcx); - if (ctx->voccxpdef2 != MCMONINV) - { - runpnil(rcx); - runpobj(rcx, defobj); - runpobj(rcx, verb); - runpobj(rcx, actor); - runfn(rcx, ctx->voccxpdef2, 4); - } - else if (ctx->voccxpdef != MCMONINV) - { - runpnil(rcx); - runpobj(rcx, defobj); - runfn(rcx, ctx->voccxpdef, 2); - } - else - { - /* tell the player what we're doing */ - vocerr_info(ctx, VOCERR(130), "("); - runppr(rcx, defobj, PRP_THEDESC, 0); - vocerr_info(ctx, VOCERR(131), ")"); - tioflush(ctx->voccxtio); - } - err = -2; /* "continue" */ - goto exit_error; - } - } - } - else - rundisc(rcx); - - /* - * No unique default; ask the player for a direct - * object, and try the command again if he is kind - * enough to provide one. - */ - askflags = ERR_RUNASKD; - } - } - else if (voclistlen(iolist) == 0) - { - /* direct object(s), but no indirect object -- find doAction */ - if (voctplfnd(ctx, verb, MCMONINV, tpl, &newstyle)) - { - /* disambiguate the direct object list, now that we can */ - if (vocdisambig(ctx, dolist1, dolist, PRP_DODEFAULT, - PRP_VALIDDO, voctplvd(tpl), cmd, MCMONINV, - actor, verb, prep, cmdbuf, FALSE)) - { - err = -1; - goto exit_error; - } - iobj = MCMONINV; - - /* - * save the disambiguated direct object list, in case - * we hit an askio in the course of processing it - */ - memcpy(dolist, dolist1, - (size_t)(voclistlen(dolist1) + 1)*sizeof(dolist[0])); - - /* re-check for multi-mode */ - if (multi_flags == 0) - multi_flags = check_for_multi(dolist1); - - /* save it/them/him/her, and execute the command */ - exesaveit(ctx, dolist1); - if ((err = exeloop(ctx, actor, verb, dolist1, &prep, - (vocoldef *)0, multi_flags, - tpl, newstyle)) != 0) - goto exit_error; - } - else - { - /* no doAction - we'll need to find an indirect object */ - runrst(rcx); - runppr(rcx, verb, PRP_PREPDEFAULT, 0); - if (runtostyp(rcx) != DAT_OBJECT) - { - /* discard the result */ - rundisc(rcx); - - /* call parseUnknownVerb to handle it */ - if (try_unknown_verb(ctx, actor, cmd, typelist, - wrdcnt, next_word, TRUE, VOCERR(24), - "I don't recognize that sentence.")) - { - /* handled - end the command successfully */ - err = 0; - } - else - { - /* not handled - indicate failure */ - err = -1; - } - goto exit_error; - } - prep = runpopobj(rcx); - - runrst(rcx); - runpobj(rcx, prep); - runpobj(rcx, actor); - runppr(rcx, verb, PRP_IODEFAULT, 2); - - if (runtostyp(rcx) == DAT_LIST) - { - uchar *l = runpoplst(rcx); - uint lstsiz; - objnum defobj = 0; - int objcnt; - runsdef val; - objnum o; - - /* push list back on stack, to keep in heap */ - val.runsv.runsvstr = l; - val.runstyp = DAT_LIST; - runrepush(rcx, &val); - - /* get list size out of list */ - lstsiz = osrp2(l) - 2; - l += 2; - - if (!voctplfnd(ctx, verb, prep, tpl, &newstyle)) - { - for (objcnt = 0 ; lstsiz && objcnt < 2 - ; lstadv(&l, &lstsiz)) - { - if (*l == DAT_OBJECT) - { - objcnt++; - defobj = osrp2(l + 1); - } - } - } - else - { - int dobj_first; - - /* - * Get the template flags. If we must - * disambiguate the direct object first for this - * verb, do so now. - */ - tplflags = (newstyle ? voctplflg(tpl) : 0); - dobj_first = (tplflags & VOCTPLFLG_DOBJ_FIRST); - if (dobj_first) - { - if (vocdisambig(ctx, dolist1, dolist, - PRP_DODEFAULT, PRP_VALIDDO, - voctplvd(tpl), cmd, MCMONINV, - actor, verb, prep, cmdbuf, - FALSE)) - { - err = -1; - goto exit_error; - } - - /* only one direct object is allowed here */ - if (voclistlen(dolist1) > 1) - { - vocerr(ctx, VOCERR(28), - "You can't use multiple objects with this command."); - err = -1; - goto exit_error; - } - - /* save the object in the original list */ - memcpy(dolist, dolist1, - (size_t)(2 * sizeof(dolist[0]))); - } - - for (objcnt = 0 ; lstsiz && objcnt < 2 - ; lstadv(&l, &lstsiz)) - { - if (*l == DAT_OBJECT) - { - o = osrp2(l + 1); - if (!objgetap(ctx->voccxmem, o, voctplvi(tpl), - (objnum *)0, FALSE)) - continue; - - tiohide(ctx->voccxtio); - if (dobj_first) - runpobj(rcx, dolist[0].vocolobj); - runpobj(rcx, actor); - runppr(rcx, o, voctplvi(tpl), - (dobj_first ? 2 : 1)); - if (!tioshow(ctx->voccxtio)) - { - objcnt++; - defobj = o; - } - } - } - } - - /* no longer need list in heap, so discard it */ - rundisc(rcx); - - /* if there's exactly one default object, use it */ - if (objcnt == 1) - { - iolist[0].vocolobj = defobj; - iolist[0].vocolflg = 0; - iolist[0].vocolfst = iolist[0].vocollst = 0; - iolist[1].vocolobj = MCMONINV; - iolist[1].vocolflg = 0; - iolist[1].vocolfst = iolist[1].vocollst = 0; - - /* tell the user what we're assuming */ - runrst(rcx); - if (ctx->voccxpdef2 != MCMONINV) - { - runpobj(rcx, prep); - runpobj(rcx, defobj); - runpobj(rcx, verb); - runpobj(rcx, actor); - runfn(rcx, ctx->voccxpdef2, 4); - } - else if (ctx->voccxpdef != MCMONINV) - { - runpobj(rcx, prep); - runpobj(rcx, defobj); - runfn(rcx, ctx->voccxpdef, 2); - } - else - { - vocerr_info(ctx, VOCERR(130), "("); - runppr(rcx, prep, PRP_SDESC, 0); - vocerr_info(ctx, VOCERR(132), " "); - runppr(rcx, defobj, PRP_THEDESC, 0); - vocerr_info(ctx, VOCERR(131), ")"); - } - tioflush(ctx->voccxtio); - err = -2; /* "continue" */ - goto exit_error; - } - } - else - rundisc(rcx); - - /* - * We didn't get a unique default indirect object, so - * we should ask the player for an indirct object, and - * repeat the command should he provide one. - */ - askflags = ERR_RUNASKI; - } - } - else - { - objnum otherobj; - - /* find the template for this verb/prep combination */ - if (!voctplfnd(ctx, verb, prep, tpl, &newstyle)) - { - vocoldef *np1; - - /* - * If we could have used the preposition in the first noun - * phrase rather than in the verb, and this would have - * yielded a valid verb phrase, the error is "I don't see - * any here". - * - * Otherwise, it's a verb phrasing error. In this case, - * call parseUnknownVerb to handle the error; the default - * error is "I don't recognize that sentence". - */ - np1 = dolist[0].vocolfst < iolist[0].vocolfst - ? dolist : iolist; - if ((np1->vocolflg & VOCS_TRIMPREP) != 0) - { - char namebuf[VOCBUFSIZ]; - - /* - * it's a trimmed prep phrase, so we actually have an - * unmatched object - report the error - */ - voc_make_obj_name_from_list( - ctx, namebuf, cmd, np1->vocolfst, np1->vocolhlst); - vocerr(ctx, VOCERR(9), "I don't see any %s here.", - namebuf); - - /* terminate the command with an error */ - err = -1; - } - else if (try_unknown_verb(ctx, actor, cmd, typelist, - wrdcnt, next_word, TRUE, - VOCERR(24), - "I don't recognize that sentence.")) - { - /* they handled it - terminate command successfully */ - err = 0; - } - else - { - /* that failed - terminate the command with an error */ - err = -1; - } - - /* terminate the command */ - goto exit_error; - } - - /* - * We have both direct and indirect objects. If we don't - * yet have the direct object, go ask for it - */ - if (voclistlen(dolist) == 0) - { - askflags = ERR_RUNASKD; - goto exit_error; - } - - /* get the flags (if old-style, flags are always zero) */ - tplflags = (newstyle ? voctplflg(tpl) : 0); - - /* - * the "other" object (dobj if doing iobj, iobj if doing - * dobj) is not known when the first object is disambiguated - */ - otherobj = MCMONINV; - - /* disambiguate the objects in the proper order */ - if (tplflags & VOCTPLFLG_DOBJ_FIRST) - { - /* disambiguate the direct object list */ - if (vocdisambig(ctx, dolist1, dolist, PRP_DODEFAULT, - PRP_VALIDDO, voctplvd(tpl), cmd, otherobj, - actor, verb, prep, cmdbuf, FALSE)) - { - err = -1; - goto exit_error; - } - - /* - * only one direct object is allowed if it's - * disambiguated first - */ - if (voclistlen(dolist1) > 1) - { - vocerr(ctx, VOCERR(28), - "You can't use multiple objects with this command."); - err = -1; - goto exit_error; - } - - /* the other object is now known for iboj disambiguation */ - otherobj = dolist1[0].vocolobj; - } - - /* disambiguate the indirect object list */ - if (vocdisambig(ctx, iolist1, iolist, PRP_IODEFAULT, - PRP_VALIDIO, voctplvi(tpl), cmd, otherobj, - actor, verb, prep, cmdbuf, FALSE)) - { - err = -1; - goto exit_error; - } - - /* only one indirect object is allowed */ - if (voclistlen(iolist1) > 1) - { - vocerr(ctx, VOCERR(25), - "You can't use multiple indirect objects."); - err = -1; - goto exit_error; - } - otherobj = iobj = iolist1[0].vocolobj; - - /* - * disambiguate the direct object list if we haven't - * already done so (we might have disambiguated it first due - * to the DisambigDobjFirst flag being set in the template) - */ - if (!(tplflags & VOCTPLFLG_DOBJ_FIRST) - && vocdisambig(ctx, dolist1, dolist, PRP_DODEFAULT, - PRP_VALIDDO, voctplvd(tpl), cmd, otherobj, - actor, verb, prep, cmdbuf, FALSE)) - { - err = -1; - goto exit_error; - } - - /* re-check for multi-mode */ - if (multi_flags == 0) - multi_flags = check_for_multi(dolist1); - - /* save it/them/him/her, and execute the command */ - exesaveit(ctx, dolist1); - if ((err = exeloop(ctx, actor, verb, dolist1, &prep, iolist1, - multi_flags, tpl, newstyle)) != 0) - goto exit_error; - } - - exit_error: ; - - ERRCATCH(ctx->voccxerr, err) - if (err == ERR_RUNASKI) prep = errargint(0); - if (err != ERR_RUNASKD && err != ERR_RUNASKI) - errrse(ctx->voccxerr); - ERREND(ctx->voccxerr) - - switch(err) - { - case 0: - break; - - case ERR_RUNABRT: - /* "abort" executed - return the ABORT code */ - VOC_RETVAL(ctx, save_sp, err); - - case ERR_RUNEXIT: - /* - * "exit" executed - terminate the command, but return - * success, since we want to process any additional commands - */ - VOC_RETVAL(ctx, save_sp, 0); - - case ERR_RUNEXITOBJ: - /* - * "exitobj" executed - indicate success, since this merely - * indicates that the game decided it was done processing an - * object early - */ - VOC_RETVAL(ctx, save_sp, 0); - - case ERR_RUNASKI: - case ERR_RUNASKD: - askflags = err; - break; - - case -2: /* special code: continue with main loop */ - continue; - - case -1: /* special code: return an error */ - default: - VOC_RETVAL(ctx, save_sp, 1); - } - - /* - * If we got this far, we probably want more information. The - * askflags can tell us what to do from here. - */ - if (askflags) - { - int old_unknown; - int exenewpos; - - /* - * if we had unknown words, don't ask for more information - * at this point; simply give up and report the unknown word - */ - if (ctx->voccxunknown != 0) - { - VOC_RETVAL(ctx, save_sp, 1); - } - - /* find new template indicated by the additional object */ - foundtpl = voctplfnd(ctx, verb, prep, tpl, &newstyle); - tplflags = (newstyle ? voctplflg(tpl) : 0); - - /* find a default object of the type requested */ - runrst(rcx); - if (askflags == ERR_RUNASKD) runpnil(rcx); - runpobj(rcx, prep); - runpobj(rcx, actor); - runppr(rcx, verb, - (prpnum)(askflags == ERR_RUNASKD - ? PRP_DODEFAULT : PRP_IODEFAULT), - (askflags == ERR_RUNASKD ? 3 : 2)); - - /* - * If we got a list back from ?oDefault, and we have a new - * template for the command, process the list normally with - * the object verification routine for this template. If we - * end up with exactly one object, we will assume it is the - * object to be used; otherwise, make no assumption and ask - * the user for guidance. - */ - if (runtostyp(rcx) == DAT_LIST && foundtpl) - { - uchar *l = runpoplst(rcx); - uint lstsiz; - int objcnt; - objnum defobj = 0; - objnum o; - runsdef val; - - /* push list back on stack, to keep it in the heap */ - val.runsv.runsvstr = l; - val.runstyp = DAT_LIST; - runrepush(rcx, &val); - - /* get list size out of list */ - lstsiz = osrp2(l) - 2; - l += 2; - - for (objcnt = 0 ; lstsiz && objcnt < 2 ; lstadv(&l, &lstsiz)) - { - if (*l == DAT_OBJECT) - { - prpnum verprop; - int argc = 1; - - o = osrp2(l + 1); - verprop = (askflags == ERR_RUNASKD ? voctplvd(tpl) - : voctplvi(tpl)); - - if (!objgetap(ctx->voccxmem, o, verprop, - (objnum *)0, FALSE)) - continue; - - tiohide(ctx->voccxtio); - - /* - * In the unlikely event that we have an - * indirect object but no direct object, push - * the iobj. This can happen when the player - * types a sentence such as "verb prep iobj". - */ - if (voclistlen(iolist) != 0 - && askflags == ERR_RUNASKD - && !(tplflags & VOCTPLFLG_DOBJ_FIRST)) - { - /* push the indirect object */ - runpobj(rcx, iolist[0].vocolobj); - - /* note the second argument */ - argc = 2; - } - - /* - * If this is a disambigDobjFirst verb, and - * we're validating an indirect object list, - * then we must push the direct object argument - * to the indirect object validation routine. - */ - if (askflags == ERR_RUNASKI - && (tplflags & VOCTPLFLG_DOBJ_FIRST) != 0) - { - /* push the diret object */ - runpobj(rcx, dolist[0].vocolobj); - - /* note the second argument */ - argc = 2; - } - - /* push the actor and call the verXoVerb routine */ - runpobj(rcx, actor); - runppr(rcx, o, verprop, argc); - if (!tioshow(ctx->voccxtio)) - { - ++objcnt; - defobj = o; - } - - } - } - - /* no longer need list in heap, so discard it */ - rundisc(rcx); - - /* if we found exactly one object, it's the default */ - if (objcnt == 1) - { - if (askflags == ERR_RUNASKD) - { - dolist[0].vocolobj = defobj; - dolist[0].vocolflg = 0; - dolist[0].vocolfst = dolist[0].vocollst = 0; - dolist[1].vocolobj = MCMONINV; - dolist[1].vocolflg = 0; - dolist[1].vocolfst = dolist[1].vocollst = 0; - } - else - { - iolist[0].vocolobj = defobj; - iolist[0].vocolflg = 0; - iolist[0].vocolfst = iolist[0].vocollst = 0; - iolist[1].vocolobj = MCMONINV; - iolist[1].vocolflg = 0; - iolist[1].vocolfst = iolist[1].vocollst = 0; - } - - /* tell the user what we're assuming */ - if (ctx->voccxpdef2 != MCMONINV) - { - if (askflags == ERR_RUNASKI) - runpobj(rcx, prep); - else - runpnil(rcx); - runpobj(rcx, defobj); - runpobj(rcx, verb); - runpobj(rcx, actor); - runfn(rcx, ctx->voccxpdef2, 4); - } - else if (ctx->voccxpdef != MCMONINV) - { - if (askflags == ERR_RUNASKI) - runpobj(rcx, prep); - else - runpnil(rcx); - runpobj(rcx, defobj); - runfn(rcx, ctx->voccxpdef, 2); - } - else - { - vocerr_info(ctx, VOCERR(130), "("); - if (askflags == ERR_RUNASKI) - { - runppr(rcx, prep, PRP_SDESC, 0); - vocerr_info(ctx, VOCERR(132), " "); - } - runppr(rcx, defobj, PRP_THEDESC, 0); - vocerr_info(ctx, VOCERR(131), ")"); - } - tioflush(ctx->voccxtio); - continue; /* try the command again */ - } - } - else - rundisc(rcx); - - /* make sure output capturing is off for the prompt */ - tiocapture(ctx->voccxtio, (mcmcxdef *)0, FALSE); - tioclrcapture(ctx->voccxtio); - - /* - * If we're asking for an indirect object, and we have a - * list of direct objects, and parseAskobjIndirect is - * defined, call it. Otherwise, if there's a - * parseAskobjActor routine, call it. Otherwise, if there's - * a parseAskobj routine, use that. Finally, if none of - * those are defined, generate the default phrasing. - */ - if (ctx->voccxpask3 != MCMONINV - && askflags == ERR_RUNASKI - && voclistlen(dolist) != 0) - { - /* call parseAskobjIndirect */ - voc_askobj_indirect(ctx, dolist, actor, verb, prep); - } - else if (ctx->voccxpask2 != MCMONINV) - { - if (askflags == ERR_RUNASKI) - runpobj(ctx->voccxrun, prep); - runpobj(ctx->voccxrun, verb); - runpobj(ctx->voccxrun, - (objnum)(actor == MCMONINV ? ctx->voccxme : actor)); - runfn(ctx->voccxrun, ctx->voccxpask2, - askflags == ERR_RUNASKI ? 3 : 2); - } - else if (ctx->voccxpask != MCMONINV) - { - if (askflags == ERR_RUNASKI) - runpobj(ctx->voccxrun, prep); - runpobj(ctx->voccxrun, verb); - runfn(ctx->voccxrun, ctx->voccxpask, - askflags == ERR_RUNASKI ? 2 : 1); - } - else - { - /* - * Phrase the question: askDo: "What do you want - * to ?" askIo: "What do you want - * to it ?" If the actor is Me, leave the - * actor out of it. - */ - if (actor != MCMONINV && actor != ctx->voccxme) - { - vocerr_info(ctx, VOCERR(148), "What do you want "); - runppr(rcx, actor, PRP_THEDESC, 0); - vocerr_info(ctx, VOCERR(149), " to "); - } - else - { - /* no actor - don't mention one */ - vocerr_info(ctx, VOCERR(140), "What do you want to "); - } - - /* add the verb */ - runppr(rcx, verb, PRP_SDESC, 0); - - /* - * add an appropriate pronoun for the direct object, - * and the preposition, if we're asking for an indirect - * object - */ - if (askflags == ERR_RUNASKI) - { - int i; - int vcnt; - int distinct; - const char *lastfst; - - /* - * If possible, tailor the pronoun to the situation - * rather than using "it"; if we have multiple - * objects, use "them", and if we have agreement - * with the possible single objects about "him" or - * "her", use that. Otherwise, use "it". If "all" - * was specified for any word, automatically assume - * multiple distinct objects were specified. - */ - vcnt = voclistlen(dolist); - for (distinct = 0, i = 0, lastfst = 0 ; i < vcnt ; ++i) - { - /* if the first word is different here, note it */ - if (lastfst != dolist[i].vocolfst) - { - /* this is a different word - count it */ - ++distinct; - lastfst = dolist[i].vocolfst; - } - - /* always assume multiple distinct objects on "all" */ - if (dolist[i].vocolflg & VOCS_ALL) - { - distinct = 2; - break; - } - } - - /* - * If we have multiple words, use "them"; - * otherwise, see if we can find agreement about - * using "him" or "her". - */ - if (distinct > 1) - { - /* multiple words specified by user - use "them" */ - vocerr_info(ctx, VOCERR(144), " them "); - } - else - { - int is_him = 0; - int is_her = 0; - int is_them = 0; - - /* run through the objects and check him/her */ - for (i = 0 ; i < vcnt ; ++i) - { - int him1, her1, them1; - - /* if it's special (number, string), use "it" */ - if (dolist[i].vocolobj == MCMONINV) - { - him1 = FALSE; - her1 = FALSE; - them1 = FALSE; - } - else - { - /* check for "him" */ - runppr(rcx, dolist[i].vocolobj, PRP_ISHIM, 0); - him1 = (runtostyp(rcx) == DAT_TRUE); - rundisc(rcx); - - /* check for "her" */ - runppr(rcx, dolist[i].vocolobj, PRP_ISHER, 0); - her1 = (runtostyp(rcx) == DAT_TRUE); - rundisc(rcx); - - /* check for "them" */ - runppr(rcx, dolist[i].vocolobj, - PRP_ISTHEM, 0); - them1 = (runtostyp(rcx) == DAT_TRUE); - rundisc(rcx); - } - - /* - * if this is the first object, it - * definitely agrees; otherwise, keep going - * only if it agrees with what we found on - * the last pass - */ - if (i == 0) - { - is_him = him1; - is_her = her1; - is_them = them1; - } - else - { - /* turn off either that is no longer true */ - if (!him1) is_him = FALSE; - if (!her1) is_her = FALSE; - if (!them1) is_them = FALSE; - } - - /* if all are false, stop now */ - if (!is_him && !is_her && !is_them) - break; - } - - /* - * If we could agree on "him", "her", or "them", - * use that pronoun; otherwise, use "it". If we - * found both "him" and "her" are acceptable for - * all objects, use "them". - */ - if ((is_him && is_her) || is_them) - vocerr_info(ctx, VOCERR(147), " them "); - else if (is_him) - vocerr_info(ctx, VOCERR(145), " him "); - else if (is_her) - vocerr_info(ctx, VOCERR(146), " her "); - else - vocerr_info(ctx, VOCERR(141), " it "); - } - - /* finish off the question with the prep and a "?" */ - if (prep != MCMONINV) - runppr(rcx, prep, PRP_SDESC, 0); - else - vocerr_info(ctx, VOCERR(142), "to"); - } - vocerr_info(ctx, VOCERR(143), "?"); - } - tioflush(ctx->voccxtio); - - /* - * Get a new command line. If the player gives us - * something that looks like a noun list, and nothing more, - * he anwered our question; otherwise, he's typing a new - * command, so we must return to the caller with the reparse - * flag set. - */ - if (askflags == ERR_RUNASKD) - { - exenewbuf = donewbuf; - exenewcmd = donewcmd; - exenewlist = donewlist; - exenewtype = donewtype; - } - else - { - exenewbuf = ionewbuf; - exenewcmd = ionewcmd; - exenewlist = ionewlist; - exenewtype = ionewtype; - } - - /* read the new command */ - if (vocread(ctx, actor, verb, exenewcmd, VOCBUFSIZ, - askflags == ERR_RUNASKD ? 3 : 4) == VOCREAD_REDO) - { - /* - * we got an input line, but we want to treat it as a brand - * new command line - copy the new text to the command - * buffer, set the 'redo' flag, and give up - */ - strcpy(cmdbuf, exenewcmd); - ctx->voccxredo = TRUE; - VOC_RETVAL(ctx, save_sp, 1); - } - - if (!(cnt = voctok(ctx, exenewcmd, exenewbuf, exenewlist, - TRUE, FALSE, TRUE))) - { - runrst(rcx); - runfn(rcx, ctx->voccxprd, 0); - VOC_RETVAL(ctx, save_sp, 1); - } - if (cnt < 0) - { - ctx->voccxunknown = 0; - VOC_RETVAL(ctx, save_sp, 1); - } - - /* - * Save the unknown word count while getting types, and set - * the count to a non-zero value - this will force the type - * checker to generate an error on an unknown word. This - * removes a little control from the game (since - * parseUnknownXobj won't be called), but there's not much - * else we can do here. - */ - old_unknown = ctx->voccxunknown; - ctx->voccxunknown = 1; - - /* get the types */ - exenewlist[cnt] = 0; - if (vocgtyp(ctx, exenewlist, exenewtype, cmdbuf)) - { - /* - * clear the unknown word count so that we fail with - * this error rather than trying to deal with unknown - * words - */ - ctx->voccxunknown = 0; - - /* return failure */ - VOC_RETVAL(ctx, save_sp, 1); - } - - /* restore the unknown word count */ - ctx->voccxunknown = old_unknown; - - /* start at the first word */ - exenewpos = 0; - - /* - * if we're asking for an indirect object, and the first - * word is a preposition, and matches the preposition that - * we supplied to precede the indirect object, skip the - * preposition - */ - if (askflags == ERR_RUNASKI - && prep != MCMONINV - && (exenewtype[0] & VOCT_PREP) != 0) - { - vocwdef *vp; - - /* get the preposition */ - vp = vocffw(ctx, exenewlist[0], (int)strlen(exenewlist[0]), - (char *)0, 0, PRP_PREP, (vocseadef *)0); - if (vp != 0 && vp->vocwobj == prep) - ++exenewpos; - } - - /* check for a noun */ - newnoun = (askflags == ERR_RUNASKD ? dolist : iolist); - cnt = vocchknoun(ctx, exenewlist, exenewtype, exenewpos, &next, - newnoun, FALSE); - - if (cnt < 0) { VOC_RETVAL(ctx, save_sp, 1); } /* invalid syntax */ - if (cnt == 0 - || (exenewlist[next] && !vocspec(exenewlist[next], VOCW_THEN) - && *exenewlist[next] != '\0')) - { - strcpy(cmdbuf, exenewcmd); - ctx->voccxredo = TRUE; - VOC_RETVAL(ctx, save_sp, 1); - } - - /* re-check the 'multi' flags */ - multi_flags = check_for_multi(newnoun); - - /* give it another go by going back to the top of the loop */ - } - else - { - /* normal exit flags - return success */ - VOC_RETVAL(ctx, save_sp, 0); - } - } + objnum verb; + objnum iobj; + int multi_flags = 0; + vocwdef *n; + int cnt; + vocoldef *newnoun; + int next; + char *exenewcmd; + char *donewcmd; + char *ionewcmd; + char *exenewbuf; + char *donewbuf; + char *ionewbuf; + char **exenewlist; + char **donewlist; + char **ionewlist; + int *exenewtype; + int *donewtype; + int *ionewtype; + vocoldef *dolist1; + vocoldef *iolist1; + uchar tpl[VOCTPL2SIZ]; + int foundtpl; /* used to determine success of tpl searches */ + runcxdef *rcx = ctx->voccxrun; + uint tplofs; /* offset of template object */ + uint actofs; /* offset of 'action' property */ + int askflags; /* flag for what we need to ask user */ + int newstyle; /* flag indicating new-style template definitions */ + int tplflags; + int err; + uchar *save_sp; + + /* run preparseCmd */ + switch(try_preparse_cmd(ctx, cmd, wrdcnt, preparse_list)) + { + case 0: + /* proceed with the command */ + break; + + case ERR_PREPRSCMDCAN: + /* command cancelled */ + return 0; + + case ERR_RUNEXIT: + case ERR_RUNABRT: + case ERR_RUNEXITOBJ: + /* abort/exit/exitobj - treat this the same as command cancellation */ + return 0; + + case ERR_PREPRSCMDREDO: + /* redo the command - so indicate to the caller */ + return ERR_PREPRSCMDREDO; + } + + /* look up the verb based on the verb and verb-prep */ + n = vocffw(ctx, vverb, (int)strlen(vverb), + vprep, (vprep ? (int)strlen(vprep) : 0), PRP_VERB, + (vocseadef *)0); + + /* if we didn't find a verb template, we can't process the sentence */ + if (n == 0) + { + /* try parseUnknownVerb, and show an error if that doesn't handle it */ + if (try_unknown_verb(ctx, actor, cmd, typelist, wrdcnt, next_word, + TRUE, VOCERR(18), + "I don't understand that sentence.")) + { + /* they handled it successfully - end the command with success */ + return 0; + } + else + { + /* + * parseUnknownVerb failed or aborted - end the command with + * an error + */ + return 1; + } + } + + /* get the deepverb object */ + verb = n->vocwobj; + + /* default actor is "Me" */ + if (actor == MCMONINV) + actor = ctx->voccxme; + + /* set a savepoint, if we're keeping undo information */ + if (ctx->voccxundo) + objusav(ctx->voccxundo); + + /* + * Check that the room will allow this command -- it may not + * due to darkness or other ailment. We can find out with the + * roomCheck(verb) message, sent to the meobj. + */ + { + int t; + + /* call roomCheck */ + runrst(rcx); + runpobj(rcx, verb); + runppr(rcx, ctx->voccxme, PRP_ROOMCHECK, 1); + t = runpoplog(rcx); + + /* if they returned nil, stop the command, but indicate success */ + if (!t) + return 0; + } + + /* look for a new-style template first, then the old-style template */ + exe_get_tpl(ctx, verb, &tplofs, &actofs); + + /* make sure we found a verb */ + if (tplofs == 0 && actofs == 0 && verb != ctx->voccxvag) + { + /* try parseUnknownVerb, and show an error if that doesn't handle it */ + if (try_unknown_verb(ctx, actor, cmd, typelist, wrdcnt, next_word, + TRUE, VOCERR(23), + "internal error: verb has no action, doAction, or ioAction")) + return 0; + else + return 1; + } + + /* + * Check to see if we have an "all" - if we do, we'll need to + * display the direct object's name even if only one direct object + * comes of it. + */ + multi_flags = check_for_multi(dolist); + + /* + * set up dobj word list in case objwords is used in doDefault (the + * game may want to check for "all" and disallow it, for example) + */ + ctx->voccxdobj = dolist; + + /* set up our stack allocations, which we may need from now on */ + voc_enter(ctx, &save_sp); + VOC_STK_ARRAY(ctx, char, donewcmd, VOCBUFSIZ); + VOC_STK_ARRAY(ctx, char, ionewcmd, VOCBUFSIZ); + VOC_STK_ARRAY(ctx, char, donewbuf, 2*VOCBUFSIZ); + VOC_STK_ARRAY(ctx, char, ionewbuf, 2*VOCBUFSIZ); + VOC_STK_ARRAY(ctx, char *, donewlist, VOCBUFSIZ); + VOC_STK_ARRAY(ctx, char *, ionewlist, VOCBUFSIZ); + VOC_MAX_ARRAY(ctx, int, donewtype); + VOC_MAX_ARRAY(ctx, int, ionewtype); + VOC_MAX_ARRAY(ctx, vocoldef, dolist1); + VOC_MAX_ARRAY(ctx, vocoldef, iolist1); + + /* keep going until we're done with the sentence */ + for ( ;; ) + { + askflags = err = 0; + + ERRBEGIN(ctx->voccxerr) + + /* + * Now see what kind of sentence we have. If we have no + * objects and an action, use the action. If we have a direct + * object and a doAction, use the doAction. If we have an + * indirect object and an ioAction with a matching preposition, + * use the ioAction. If we have an indirect object and no + * matching ioAction, complain. If we have a direct object and + * no doAction or ioAction, complain. If we have fewer objects + * than we really want, ask the user for more of them. + */ + if (voclistlen(dolist) == 0 && voclistlen(iolist) == 0) + { + if (actofs || verb == ctx->voccxvag) + { + if ((err = exeloop(ctx, actor, verb, (vocoldef *)0, &prep, + (vocoldef *)0, multi_flags, + (uchar *)0, 0)) != 0) + goto exit_error; + } + else + { + /* + * The player has not specified any objects, but the + * verb seems to require one. See if there's a unique + * default. + */ + runrst(rcx); + runpnil(rcx); + runpobj(rcx, prep); + runpobj(rcx, actor); + runppr(rcx, verb, PRP_DODEFAULT, 3); + + if (runtostyp(rcx) == DAT_LIST) + { + uchar *l = runpoplst(rcx); + uint lstsiz; + objnum defobj = 0; + int objcnt; + objnum newprep; + runsdef val; + objnum o; + + /* push list back on stack, to keep in heap */ + val.runsv.runsvstr = l; + val.runstyp = DAT_LIST; + runrepush(rcx, &val); + + /* get list size out of list */ + lstsiz = osrp2(l) - 2; + l += 2; + + /* find default preposition for verb, if any */ + runppr(rcx, verb, PRP_PREPDEFAULT, 0); + if (runtostyp(rcx) == DAT_OBJECT) + newprep = runpopobj(rcx); + else + { + newprep = MCMONINV; + rundisc(rcx); + } + + if (!voctplfnd(ctx, verb, newprep, tpl, &newstyle)) + { + for (objcnt = 0 ; lstsiz && objcnt < 2 + ; lstadv(&l, &lstsiz)) + { + if (*l == DAT_OBJECT) + { + ++objcnt; + defobj = osrp2(l + 1); + } + } + } + else + { + int dobj_first; + + /* + * Get the template flags. If we must + * disambiguate the direct object first for this + * verb, do so now. + */ + tplflags = (newstyle ? voctplflg(tpl) : 0); + dobj_first = (tplflags & VOCTPLFLG_DOBJ_FIRST); + + for (objcnt = 0 ; lstsiz && objcnt < 2 + ; lstadv(&l, &lstsiz)) + { + if (*l == DAT_OBJECT) + { + o = osrp2(l + 1); + if (!objgetap(ctx->voccxmem, o, voctplvd(tpl), + (objnum *)0, FALSE)) + continue; + + tiohide(ctx->voccxtio); + if (newprep != MCMONINV && !dobj_first) + runpnil(rcx); + runpobj(rcx, actor); + runppr(rcx, o, voctplvd(tpl), + ((newprep != MCMONINV && !dobj_first) + ? 2 : 1)); + + if (!tioshow(ctx->voccxtio)) + { + ++objcnt; + defobj = o; + } + } + } + + /* no longer need list in heap, so discard it */ + rundisc(rcx); + + /* use default object if there's exactly one */ + if (objcnt == 1) + { + dolist[0].vocolobj = defobj; + dolist[0].vocolflg = 0; + dolist[0].vocolfst = dolist[0].vocollst = 0; + dolist[1].vocolobj = MCMONINV; + dolist[1].vocolflg = 0; + dolist[1].vocolfst = dolist[1].vocollst = 0; + + runrst(rcx); + if (ctx->voccxpdef2 != MCMONINV) + { + runpnil(rcx); + runpobj(rcx, defobj); + runpobj(rcx, verb); + runpobj(rcx, actor); + runfn(rcx, ctx->voccxpdef2, 4); + } + else if (ctx->voccxpdef != MCMONINV) + { + runpnil(rcx); + runpobj(rcx, defobj); + runfn(rcx, ctx->voccxpdef, 2); + } + else + { + /* tell the player what we're doing */ + vocerr_info(ctx, VOCERR(130), "("); + runppr(rcx, defobj, PRP_THEDESC, 0); + vocerr_info(ctx, VOCERR(131), ")"); + tioflush(ctx->voccxtio); + } + err = -2; /* "continue" */ + goto exit_error; + } + } + } + else + rundisc(rcx); + + /* + * No unique default; ask the player for a direct + * object, and try the command again if he is kind + * enough to provide one. + */ + askflags = ERR_RUNASKD; + } + } + else if (voclistlen(iolist) == 0) + { + /* direct object(s), but no indirect object -- find doAction */ + if (voctplfnd(ctx, verb, MCMONINV, tpl, &newstyle)) + { + /* disambiguate the direct object list, now that we can */ + if (vocdisambig(ctx, dolist1, dolist, PRP_DODEFAULT, + PRP_VALIDDO, voctplvd(tpl), cmd, MCMONINV, + actor, verb, prep, cmdbuf, FALSE)) + { + err = -1; + goto exit_error; + } + iobj = MCMONINV; + + /* + * save the disambiguated direct object list, in case + * we hit an askio in the course of processing it + */ + memcpy(dolist, dolist1, + (size_t)(voclistlen(dolist1) + 1)*sizeof(dolist[0])); + + /* re-check for multi-mode */ + if (multi_flags == 0) + multi_flags = check_for_multi(dolist1); + + /* save it/them/him/her, and execute the command */ + exesaveit(ctx, dolist1); + if ((err = exeloop(ctx, actor, verb, dolist1, &prep, + (vocoldef *)0, multi_flags, + tpl, newstyle)) != 0) + goto exit_error; + } + else + { + /* no doAction - we'll need to find an indirect object */ + runrst(rcx); + runppr(rcx, verb, PRP_PREPDEFAULT, 0); + if (runtostyp(rcx) != DAT_OBJECT) + { + /* discard the result */ + rundisc(rcx); + + /* call parseUnknownVerb to handle it */ + if (try_unknown_verb(ctx, actor, cmd, typelist, + wrdcnt, next_word, TRUE, VOCERR(24), + "I don't recognize that sentence.")) + { + /* handled - end the command successfully */ + err = 0; + } + else + { + /* not handled - indicate failure */ + err = -1; + } + goto exit_error; + } + prep = runpopobj(rcx); + + runrst(rcx); + runpobj(rcx, prep); + runpobj(rcx, actor); + runppr(rcx, verb, PRP_IODEFAULT, 2); + + if (runtostyp(rcx) == DAT_LIST) + { + uchar *l = runpoplst(rcx); + uint lstsiz; + objnum defobj = 0; + int objcnt; + runsdef val; + objnum o; + + /* push list back on stack, to keep in heap */ + val.runsv.runsvstr = l; + val.runstyp = DAT_LIST; + runrepush(rcx, &val); + + /* get list size out of list */ + lstsiz = osrp2(l) - 2; + l += 2; + + if (!voctplfnd(ctx, verb, prep, tpl, &newstyle)) + { + for (objcnt = 0 ; lstsiz && objcnt < 2 + ; lstadv(&l, &lstsiz)) + { + if (*l == DAT_OBJECT) + { + objcnt++; + defobj = osrp2(l + 1); + } + } + } + else + { + int dobj_first; + + /* + * Get the template flags. If we must + * disambiguate the direct object first for this + * verb, do so now. + */ + tplflags = (newstyle ? voctplflg(tpl) : 0); + dobj_first = (tplflags & VOCTPLFLG_DOBJ_FIRST); + if (dobj_first) + { + if (vocdisambig(ctx, dolist1, dolist, + PRP_DODEFAULT, PRP_VALIDDO, + voctplvd(tpl), cmd, MCMONINV, + actor, verb, prep, cmdbuf, + FALSE)) + { + err = -1; + goto exit_error; + } + + /* only one direct object is allowed here */ + if (voclistlen(dolist1) > 1) + { + vocerr(ctx, VOCERR(28), + "You can't use multiple objects with this command."); + err = -1; + goto exit_error; + } + + /* save the object in the original list */ + memcpy(dolist, dolist1, + (size_t)(2 * sizeof(dolist[0]))); + } + + for (objcnt = 0 ; lstsiz && objcnt < 2 + ; lstadv(&l, &lstsiz)) + { + if (*l == DAT_OBJECT) + { + o = osrp2(l + 1); + if (!objgetap(ctx->voccxmem, o, voctplvi(tpl), + (objnum *)0, FALSE)) + continue; + + tiohide(ctx->voccxtio); + if (dobj_first) + runpobj(rcx, dolist[0].vocolobj); + runpobj(rcx, actor); + runppr(rcx, o, voctplvi(tpl), + (dobj_first ? 2 : 1)); + if (!tioshow(ctx->voccxtio)) + { + objcnt++; + defobj = o; + } + } + } + } + + /* no longer need list in heap, so discard it */ + rundisc(rcx); + + /* if there's exactly one default object, use it */ + if (objcnt == 1) + { + iolist[0].vocolobj = defobj; + iolist[0].vocolflg = 0; + iolist[0].vocolfst = iolist[0].vocollst = 0; + iolist[1].vocolobj = MCMONINV; + iolist[1].vocolflg = 0; + iolist[1].vocolfst = iolist[1].vocollst = 0; + + /* tell the user what we're assuming */ + runrst(rcx); + if (ctx->voccxpdef2 != MCMONINV) + { + runpobj(rcx, prep); + runpobj(rcx, defobj); + runpobj(rcx, verb); + runpobj(rcx, actor); + runfn(rcx, ctx->voccxpdef2, 4); + } + else if (ctx->voccxpdef != MCMONINV) + { + runpobj(rcx, prep); + runpobj(rcx, defobj); + runfn(rcx, ctx->voccxpdef, 2); + } + else + { + vocerr_info(ctx, VOCERR(130), "("); + runppr(rcx, prep, PRP_SDESC, 0); + vocerr_info(ctx, VOCERR(132), " "); + runppr(rcx, defobj, PRP_THEDESC, 0); + vocerr_info(ctx, VOCERR(131), ")"); + } + tioflush(ctx->voccxtio); + err = -2; /* "continue" */ + goto exit_error; + } + } + else + rundisc(rcx); + + /* + * We didn't get a unique default indirect object, so + * we should ask the player for an indirct object, and + * repeat the command should he provide one. + */ + askflags = ERR_RUNASKI; + } + } + else + { + objnum otherobj; + + /* find the template for this verb/prep combination */ + if (!voctplfnd(ctx, verb, prep, tpl, &newstyle)) + { + vocoldef *np1; + + /* + * If we could have used the preposition in the first noun + * phrase rather than in the verb, and this would have + * yielded a valid verb phrase, the error is "I don't see + * any here". + * + * Otherwise, it's a verb phrasing error. In this case, + * call parseUnknownVerb to handle the error; the default + * error is "I don't recognize that sentence". + */ + np1 = dolist[0].vocolfst < iolist[0].vocolfst + ? dolist : iolist; + if ((np1->vocolflg & VOCS_TRIMPREP) != 0) + { + char namebuf[VOCBUFSIZ]; + + /* + * it's a trimmed prep phrase, so we actually have an + * unmatched object - report the error + */ + voc_make_obj_name_from_list( + ctx, namebuf, cmd, np1->vocolfst, np1->vocolhlst); + vocerr(ctx, VOCERR(9), "I don't see any %s here.", + namebuf); + + /* terminate the command with an error */ + err = -1; + } + else if (try_unknown_verb(ctx, actor, cmd, typelist, + wrdcnt, next_word, TRUE, + VOCERR(24), + "I don't recognize that sentence.")) + { + /* they handled it - terminate command successfully */ + err = 0; + } + else + { + /* that failed - terminate the command with an error */ + err = -1; + } + + /* terminate the command */ + goto exit_error; + } + + /* + * We have both direct and indirect objects. If we don't + * yet have the direct object, go ask for it + */ + if (voclistlen(dolist) == 0) + { + askflags = ERR_RUNASKD; + goto exit_error; + } + + /* get the flags (if old-style, flags are always zero) */ + tplflags = (newstyle ? voctplflg(tpl) : 0); + + /* + * the "other" object (dobj if doing iobj, iobj if doing + * dobj) is not known when the first object is disambiguated + */ + otherobj = MCMONINV; + + /* disambiguate the objects in the proper order */ + if (tplflags & VOCTPLFLG_DOBJ_FIRST) + { + /* disambiguate the direct object list */ + if (vocdisambig(ctx, dolist1, dolist, PRP_DODEFAULT, + PRP_VALIDDO, voctplvd(tpl), cmd, otherobj, + actor, verb, prep, cmdbuf, FALSE)) + { + err = -1; + goto exit_error; + } + + /* + * only one direct object is allowed if it's + * disambiguated first + */ + if (voclistlen(dolist1) > 1) + { + vocerr(ctx, VOCERR(28), + "You can't use multiple objects with this command."); + err = -1; + goto exit_error; + } + + /* the other object is now known for iboj disambiguation */ + otherobj = dolist1[0].vocolobj; + } + + /* disambiguate the indirect object list */ + if (vocdisambig(ctx, iolist1, iolist, PRP_IODEFAULT, + PRP_VALIDIO, voctplvi(tpl), cmd, otherobj, + actor, verb, prep, cmdbuf, FALSE)) + { + err = -1; + goto exit_error; + } + + /* only one indirect object is allowed */ + if (voclistlen(iolist1) > 1) + { + vocerr(ctx, VOCERR(25), + "You can't use multiple indirect objects."); + err = -1; + goto exit_error; + } + otherobj = iobj = iolist1[0].vocolobj; + + /* + * disambiguate the direct object list if we haven't + * already done so (we might have disambiguated it first due + * to the DisambigDobjFirst flag being set in the template) + */ + if (!(tplflags & VOCTPLFLG_DOBJ_FIRST) + && vocdisambig(ctx, dolist1, dolist, PRP_DODEFAULT, + PRP_VALIDDO, voctplvd(tpl), cmd, otherobj, + actor, verb, prep, cmdbuf, FALSE)) + { + err = -1; + goto exit_error; + } + + /* re-check for multi-mode */ + if (multi_flags == 0) + multi_flags = check_for_multi(dolist1); + + /* save it/them/him/her, and execute the command */ + exesaveit(ctx, dolist1); + if ((err = exeloop(ctx, actor, verb, dolist1, &prep, iolist1, + multi_flags, tpl, newstyle)) != 0) + goto exit_error; + } + + exit_error: ; + + ERRCATCH(ctx->voccxerr, err) + if (err == ERR_RUNASKI) prep = errargint(0); + if (err != ERR_RUNASKD && err != ERR_RUNASKI) + errrse(ctx->voccxerr); + ERREND(ctx->voccxerr) + + switch(err) + { + case 0: + break; + + case ERR_RUNABRT: + /* "abort" executed - return the ABORT code */ + VOC_RETVAL(ctx, save_sp, err); + + case ERR_RUNEXIT: + /* + * "exit" executed - terminate the command, but return + * success, since we want to process any additional commands + */ + VOC_RETVAL(ctx, save_sp, 0); + + case ERR_RUNEXITOBJ: + /* + * "exitobj" executed - indicate success, since this merely + * indicates that the game decided it was done processing an + * object early + */ + VOC_RETVAL(ctx, save_sp, 0); + + case ERR_RUNASKI: + case ERR_RUNASKD: + askflags = err; + break; + + case -2: /* special code: continue with main loop */ + continue; + + case -1: /* special code: return an error */ + default: + VOC_RETVAL(ctx, save_sp, 1); + } + + /* + * If we got this far, we probably want more information. The + * askflags can tell us what to do from here. + */ + if (askflags) + { + int old_unknown; + int exenewpos; + + /* + * if we had unknown words, don't ask for more information + * at this point; simply give up and report the unknown word + */ + if (ctx->voccxunknown != 0) + { + VOC_RETVAL(ctx, save_sp, 1); + } + + /* find new template indicated by the additional object */ + foundtpl = voctplfnd(ctx, verb, prep, tpl, &newstyle); + tplflags = (newstyle ? voctplflg(tpl) : 0); + + /* find a default object of the type requested */ + runrst(rcx); + if (askflags == ERR_RUNASKD) runpnil(rcx); + runpobj(rcx, prep); + runpobj(rcx, actor); + runppr(rcx, verb, + (prpnum)(askflags == ERR_RUNASKD + ? PRP_DODEFAULT : PRP_IODEFAULT), + (askflags == ERR_RUNASKD ? 3 : 2)); + + /* + * If we got a list back from ?oDefault, and we have a new + * template for the command, process the list normally with + * the object verification routine for this template. If we + * end up with exactly one object, we will assume it is the + * object to be used; otherwise, make no assumption and ask + * the user for guidance. + */ + if (runtostyp(rcx) == DAT_LIST && foundtpl) + { + uchar *l = runpoplst(rcx); + uint lstsiz; + int objcnt; + objnum defobj = 0; + objnum o; + runsdef val; + + /* push list back on stack, to keep it in the heap */ + val.runsv.runsvstr = l; + val.runstyp = DAT_LIST; + runrepush(rcx, &val); + + /* get list size out of list */ + lstsiz = osrp2(l) - 2; + l += 2; + + for (objcnt = 0 ; lstsiz && objcnt < 2 ; lstadv(&l, &lstsiz)) + { + if (*l == DAT_OBJECT) + { + prpnum verprop; + int argc = 1; + + o = osrp2(l + 1); + verprop = (askflags == ERR_RUNASKD ? voctplvd(tpl) + : voctplvi(tpl)); + + if (!objgetap(ctx->voccxmem, o, verprop, + (objnum *)0, FALSE)) + continue; + + tiohide(ctx->voccxtio); + + /* + * In the unlikely event that we have an + * indirect object but no direct object, push + * the iobj. This can happen when the player + * types a sentence such as "verb prep iobj". + */ + if (voclistlen(iolist) != 0 + && askflags == ERR_RUNASKD + && !(tplflags & VOCTPLFLG_DOBJ_FIRST)) + { + /* push the indirect object */ + runpobj(rcx, iolist[0].vocolobj); + + /* note the second argument */ + argc = 2; + } + + /* + * If this is a disambigDobjFirst verb, and + * we're validating an indirect object list, + * then we must push the direct object argument + * to the indirect object validation routine. + */ + if (askflags == ERR_RUNASKI + && (tplflags & VOCTPLFLG_DOBJ_FIRST) != 0) + { + /* push the diret object */ + runpobj(rcx, dolist[0].vocolobj); + + /* note the second argument */ + argc = 2; + } + + /* push the actor and call the verXoVerb routine */ + runpobj(rcx, actor); + runppr(rcx, o, verprop, argc); + if (!tioshow(ctx->voccxtio)) + { + ++objcnt; + defobj = o; + } + + } + } + + /* no longer need list in heap, so discard it */ + rundisc(rcx); + + /* if we found exactly one object, it's the default */ + if (objcnt == 1) + { + if (askflags == ERR_RUNASKD) + { + dolist[0].vocolobj = defobj; + dolist[0].vocolflg = 0; + dolist[0].vocolfst = dolist[0].vocollst = 0; + dolist[1].vocolobj = MCMONINV; + dolist[1].vocolflg = 0; + dolist[1].vocolfst = dolist[1].vocollst = 0; + } + else + { + iolist[0].vocolobj = defobj; + iolist[0].vocolflg = 0; + iolist[0].vocolfst = iolist[0].vocollst = 0; + iolist[1].vocolobj = MCMONINV; + iolist[1].vocolflg = 0; + iolist[1].vocolfst = iolist[1].vocollst = 0; + } + + /* tell the user what we're assuming */ + if (ctx->voccxpdef2 != MCMONINV) + { + if (askflags == ERR_RUNASKI) + runpobj(rcx, prep); + else + runpnil(rcx); + runpobj(rcx, defobj); + runpobj(rcx, verb); + runpobj(rcx, actor); + runfn(rcx, ctx->voccxpdef2, 4); + } + else if (ctx->voccxpdef != MCMONINV) + { + if (askflags == ERR_RUNASKI) + runpobj(rcx, prep); + else + runpnil(rcx); + runpobj(rcx, defobj); + runfn(rcx, ctx->voccxpdef, 2); + } + else + { + vocerr_info(ctx, VOCERR(130), "("); + if (askflags == ERR_RUNASKI) + { + runppr(rcx, prep, PRP_SDESC, 0); + vocerr_info(ctx, VOCERR(132), " "); + } + runppr(rcx, defobj, PRP_THEDESC, 0); + vocerr_info(ctx, VOCERR(131), ")"); + } + tioflush(ctx->voccxtio); + continue; /* try the command again */ + } + } + else + rundisc(rcx); + + /* make sure output capturing is off for the prompt */ + tiocapture(ctx->voccxtio, (mcmcxdef *)0, FALSE); + tioclrcapture(ctx->voccxtio); + + /* + * If we're asking for an indirect object, and we have a + * list of direct objects, and parseAskobjIndirect is + * defined, call it. Otherwise, if there's a + * parseAskobjActor routine, call it. Otherwise, if there's + * a parseAskobj routine, use that. Finally, if none of + * those are defined, generate the default phrasing. + */ + if (ctx->voccxpask3 != MCMONINV + && askflags == ERR_RUNASKI + && voclistlen(dolist) != 0) + { + /* call parseAskobjIndirect */ + voc_askobj_indirect(ctx, dolist, actor, verb, prep); + } + else if (ctx->voccxpask2 != MCMONINV) + { + if (askflags == ERR_RUNASKI) + runpobj(ctx->voccxrun, prep); + runpobj(ctx->voccxrun, verb); + runpobj(ctx->voccxrun, + (objnum)(actor == MCMONINV ? ctx->voccxme : actor)); + runfn(ctx->voccxrun, ctx->voccxpask2, + askflags == ERR_RUNASKI ? 3 : 2); + } + else if (ctx->voccxpask != MCMONINV) + { + if (askflags == ERR_RUNASKI) + runpobj(ctx->voccxrun, prep); + runpobj(ctx->voccxrun, verb); + runfn(ctx->voccxrun, ctx->voccxpask, + askflags == ERR_RUNASKI ? 2 : 1); + } + else + { + /* + * Phrase the question: askDo: "What do you want + * to ?" askIo: "What do you want + * to it ?" If the actor is Me, leave the + * actor out of it. + */ + if (actor != MCMONINV && actor != ctx->voccxme) + { + vocerr_info(ctx, VOCERR(148), "What do you want "); + runppr(rcx, actor, PRP_THEDESC, 0); + vocerr_info(ctx, VOCERR(149), " to "); + } + else + { + /* no actor - don't mention one */ + vocerr_info(ctx, VOCERR(140), "What do you want to "); + } + + /* add the verb */ + runppr(rcx, verb, PRP_SDESC, 0); + + /* + * add an appropriate pronoun for the direct object, + * and the preposition, if we're asking for an indirect + * object + */ + if (askflags == ERR_RUNASKI) + { + int i; + int vcnt; + int distinct; + const char *lastfst; + + /* + * If possible, tailor the pronoun to the situation + * rather than using "it"; if we have multiple + * objects, use "them", and if we have agreement + * with the possible single objects about "him" or + * "her", use that. Otherwise, use "it". If "all" + * was specified for any word, automatically assume + * multiple distinct objects were specified. + */ + vcnt = voclistlen(dolist); + for (distinct = 0, i = 0, lastfst = 0 ; i < vcnt ; ++i) + { + /* if the first word is different here, note it */ + if (lastfst != dolist[i].vocolfst) + { + /* this is a different word - count it */ + ++distinct; + lastfst = dolist[i].vocolfst; + } + + /* always assume multiple distinct objects on "all" */ + if (dolist[i].vocolflg & VOCS_ALL) + { + distinct = 2; + break; + } + } + + /* + * If we have multiple words, use "them"; + * otherwise, see if we can find agreement about + * using "him" or "her". + */ + if (distinct > 1) + { + /* multiple words specified by user - use "them" */ + vocerr_info(ctx, VOCERR(144), " them "); + } + else + { + int is_him = 0; + int is_her = 0; + int is_them = 0; + + /* run through the objects and check him/her */ + for (i = 0 ; i < vcnt ; ++i) + { + int him1, her1, them1; + + /* if it's special (number, string), use "it" */ + if (dolist[i].vocolobj == MCMONINV) + { + him1 = FALSE; + her1 = FALSE; + them1 = FALSE; + } + else + { + /* check for "him" */ + runppr(rcx, dolist[i].vocolobj, PRP_ISHIM, 0); + him1 = (runtostyp(rcx) == DAT_TRUE); + rundisc(rcx); + + /* check for "her" */ + runppr(rcx, dolist[i].vocolobj, PRP_ISHER, 0); + her1 = (runtostyp(rcx) == DAT_TRUE); + rundisc(rcx); + + /* check for "them" */ + runppr(rcx, dolist[i].vocolobj, + PRP_ISTHEM, 0); + them1 = (runtostyp(rcx) == DAT_TRUE); + rundisc(rcx); + } + + /* + * if this is the first object, it + * definitely agrees; otherwise, keep going + * only if it agrees with what we found on + * the last pass + */ + if (i == 0) + { + is_him = him1; + is_her = her1; + is_them = them1; + } + else + { + /* turn off either that is no longer true */ + if (!him1) is_him = FALSE; + if (!her1) is_her = FALSE; + if (!them1) is_them = FALSE; + } + + /* if all are false, stop now */ + if (!is_him && !is_her && !is_them) + break; + } + + /* + * If we could agree on "him", "her", or "them", + * use that pronoun; otherwise, use "it". If we + * found both "him" and "her" are acceptable for + * all objects, use "them". + */ + if ((is_him && is_her) || is_them) + vocerr_info(ctx, VOCERR(147), " them "); + else if (is_him) + vocerr_info(ctx, VOCERR(145), " him "); + else if (is_her) + vocerr_info(ctx, VOCERR(146), " her "); + else + vocerr_info(ctx, VOCERR(141), " it "); + } + + /* finish off the question with the prep and a "?" */ + if (prep != MCMONINV) + runppr(rcx, prep, PRP_SDESC, 0); + else + vocerr_info(ctx, VOCERR(142), "to"); + } + vocerr_info(ctx, VOCERR(143), "?"); + } + tioflush(ctx->voccxtio); + + /* + * Get a new command line. If the player gives us + * something that looks like a noun list, and nothing more, + * he anwered our question; otherwise, he's typing a new + * command, so we must return to the caller with the reparse + * flag set. + */ + if (askflags == ERR_RUNASKD) + { + exenewbuf = donewbuf; + exenewcmd = donewcmd; + exenewlist = donewlist; + exenewtype = donewtype; + } + else + { + exenewbuf = ionewbuf; + exenewcmd = ionewcmd; + exenewlist = ionewlist; + exenewtype = ionewtype; + } + + /* read the new command */ + if (vocread(ctx, actor, verb, exenewcmd, VOCBUFSIZ, + askflags == ERR_RUNASKD ? 3 : 4) == VOCREAD_REDO) + { + /* + * we got an input line, but we want to treat it as a brand + * new command line - copy the new text to the command + * buffer, set the 'redo' flag, and give up + */ + strcpy(cmdbuf, exenewcmd); + ctx->voccxredo = TRUE; + VOC_RETVAL(ctx, save_sp, 1); + } + + if (!(cnt = voctok(ctx, exenewcmd, exenewbuf, exenewlist, + TRUE, FALSE, TRUE))) + { + runrst(rcx); + runfn(rcx, ctx->voccxprd, 0); + VOC_RETVAL(ctx, save_sp, 1); + } + if (cnt < 0) + { + ctx->voccxunknown = 0; + VOC_RETVAL(ctx, save_sp, 1); + } + + /* + * Save the unknown word count while getting types, and set + * the count to a non-zero value - this will force the type + * checker to generate an error on an unknown word. This + * removes a little control from the game (since + * parseUnknownXobj won't be called), but there's not much + * else we can do here. + */ + old_unknown = ctx->voccxunknown; + ctx->voccxunknown = 1; + + /* get the types */ + exenewlist[cnt] = 0; + if (vocgtyp(ctx, exenewlist, exenewtype, cmdbuf)) + { + /* + * clear the unknown word count so that we fail with + * this error rather than trying to deal with unknown + * words + */ + ctx->voccxunknown = 0; + + /* return failure */ + VOC_RETVAL(ctx, save_sp, 1); + } + + /* restore the unknown word count */ + ctx->voccxunknown = old_unknown; + + /* start at the first word */ + exenewpos = 0; + + /* + * if we're asking for an indirect object, and the first + * word is a preposition, and matches the preposition that + * we supplied to precede the indirect object, skip the + * preposition + */ + if (askflags == ERR_RUNASKI + && prep != MCMONINV + && (exenewtype[0] & VOCT_PREP) != 0) + { + vocwdef *vp; + + /* get the preposition */ + vp = vocffw(ctx, exenewlist[0], (int)strlen(exenewlist[0]), + (char *)0, 0, PRP_PREP, (vocseadef *)0); + if (vp != 0 && vp->vocwobj == prep) + ++exenewpos; + } + + /* check for a noun */ + newnoun = (askflags == ERR_RUNASKD ? dolist : iolist); + cnt = vocchknoun(ctx, exenewlist, exenewtype, exenewpos, &next, + newnoun, FALSE); + + if (cnt < 0) { VOC_RETVAL(ctx, save_sp, 1); } /* invalid syntax */ + if (cnt == 0 + || (exenewlist[next] && !vocspec(exenewlist[next], VOCW_THEN) + && *exenewlist[next] != '\0')) + { + strcpy(cmdbuf, exenewcmd); + ctx->voccxredo = TRUE; + VOC_RETVAL(ctx, save_sp, 1); + } + + /* re-check the 'multi' flags */ + multi_flags = check_for_multi(newnoun); + + /* give it another go by going back to the top of the loop */ + } + else + { + /* normal exit flags - return success */ + VOC_RETVAL(ctx, save_sp, 0); + } + } } } // End of namespace TADS2 diff --git a/engines/glk/tads/tads2/file_io.cpp b/engines/glk/tads/tads2/file_io.cpp index 5495c1b3d33..b498df66a20 100644 --- a/engines/glk/tads/tads2/file_io.cpp +++ b/engines/glk/tads/tads2/file_io.cpp @@ -45,114 +45,114 @@ namespace TADS2 { /* callback to load an object on demand */ void OS_LOADDS fioldobj(void *ctx0, mclhd handle, uchar *ptr, ushort siz) { - fiolcxdef *ctx = (fiolcxdef *)ctx0; - ulong seekpos = (ulong)handle; - osfildef *fp = ctx->fiolcxfp; - char buf[7]; - errcxdef *ec = ctx->fiolcxerr; - uint rdsiz = 0; - - /* figure out what type of object is to be loaded */ - osfseek(fp, seekpos + ctx->fiolcxst, OSFSK_SET); - if (osfrb(fp, buf, 7)) errsig(ec, ERR_LDGAM); - switch(buf[0]) - { - case TOKSTFUNC: - rdsiz = osrp2(buf + 3); - break; + fiolcxdef *ctx = (fiolcxdef *)ctx0; + ulong seekpos = (ulong)handle; + osfildef *fp = ctx->fiolcxfp; + char buf[7]; + errcxdef *ec = ctx->fiolcxerr; + uint rdsiz = 0; + + /* figure out what type of object is to be loaded */ + osfseek(fp, seekpos + ctx->fiolcxst, OSFSK_SET); + if (osfrb(fp, buf, 7)) errsig(ec, ERR_LDGAM); + switch(buf[0]) + { + case TOKSTFUNC: + rdsiz = osrp2(buf + 3); + break; - case TOKSTOBJ: - rdsiz = osrp2(buf + 5); - break; - - case TOKSTFWDOBJ: - case TOKSTFWDFN: - default: - errsig(ec, ERR_UNKOTYP); - } - - if (siz < rdsiz) errsig(ec, ERR_LDBIG); - if (osfrb(fp, ptr, rdsiz)) errsig(ec, ERR_LDGAM); - if (ctx->fiolcxflg & FIOFCRYPT) - fioxor(ptr, rdsiz, ctx->fiolcxseed, ctx->fiolcxinc); + case TOKSTOBJ: + rdsiz = osrp2(buf + 5); + break; + + case TOKSTFWDOBJ: + case TOKSTFWDFN: + default: + errsig(ec, ERR_UNKOTYP); + } + + if (siz < rdsiz) errsig(ec, ERR_LDBIG); + if (osfrb(fp, ptr, rdsiz)) errsig(ec, ERR_LDGAM); + if (ctx->fiolcxflg & FIOFCRYPT) + fioxor(ptr, rdsiz, ctx->fiolcxseed, ctx->fiolcxinc); } /* shut down load-on-demand subsystem (close load file) */ void fiorcls(fiolcxdef *ctx) { - if (ctx != 0 && ctx->fiolcxfp != 0) - { - /* close the file */ - osfcls(ctx->fiolcxfp); + if (ctx != 0 && ctx->fiolcxfp != 0) + { + /* close the file */ + osfcls(ctx->fiolcxfp); - /* forget the file object */ - ctx->fiolcxfp = 0; - } + /* forget the file object */ + ctx->fiolcxfp = 0; + } } /* * Read an HTMLRES resource map */ static void fiordhtml(errcxdef *ec, osfildef *fp, appctxdef *appctx, - int resfileno, const char *resfilename) + int resfileno, const char *resfilename) { - uchar buf[256]; + uchar buf[256]; - /* - * resource map - if the host system is interested, tell it about it - */ - if (appctx != 0) - { - ulong entry_cnt; - ulong i; - - /* read the index table header */ - if (osfrb(fp, buf, 8)) - errsig1(ec, ERR_RDRSC, ERRTSTR, - errstr(ec, resfilename, strlen(resfilename))); + /* + * resource map - if the host system is interested, tell it about it + */ + if (appctx != 0) + { + ulong entry_cnt; + ulong i; + + /* read the index table header */ + if (osfrb(fp, buf, 8)) + errsig1(ec, ERR_RDRSC, ERRTSTR, + errstr(ec, resfilename, strlen(resfilename))); - /* get the number of entries in the table */ - entry_cnt = osrp4(buf); - - /* read the index entries */ - for (i = 0 ; i < entry_cnt ; ++i) - { - ulong res_ofs; - ulong res_siz; - ushort res_namsiz; - - /* read this entry */ - if (osfrb(fp, buf, 10)) - errsig1(ec, ERR_RDRSC, ERRTSTR, - errstr(ec, resfilename, strlen(resfilename))); + /* get the number of entries in the table */ + entry_cnt = osrp4(buf); + + /* read the index entries */ + for (i = 0 ; i < entry_cnt ; ++i) + { + ulong res_ofs; + ulong res_siz; + ushort res_namsiz; + + /* read this entry */ + if (osfrb(fp, buf, 10)) + errsig1(ec, ERR_RDRSC, ERRTSTR, + errstr(ec, resfilename, strlen(resfilename))); - /* get the entry header */ - res_ofs = osrp4(buf); - res_siz = osrp4(buf + 4); - res_namsiz = osrp2(buf + 8); - - /* read this entry's name */ - if (osfrb(fp, buf, res_namsiz)) - errsig1(ec, ERR_RDRSC, ERRTSTR, - errstr(ec, resfilename, strlen(resfilename))); - - /* tell the host system about this entry */ - if (appctx->add_resource) - (*appctx->add_resource)(appctx->add_resource_ctx, - res_ofs, res_siz, - (char *)buf, - (size_t)res_namsiz, - resfileno); - } - - /* tell the host system where the resources start */ - if (appctx->set_resmap_seek != 0) - { - long pos = osfpos(fp); - (*appctx->set_resmap_seek)(appctx->set_resmap_seek_ctx, - pos, resfileno); - } - } + /* get the entry header */ + res_ofs = osrp4(buf); + res_siz = osrp4(buf + 4); + res_namsiz = osrp2(buf + 8); + + /* read this entry's name */ + if (osfrb(fp, buf, res_namsiz)) + errsig1(ec, ERR_RDRSC, ERRTSTR, + errstr(ec, resfilename, strlen(resfilename))); + + /* tell the host system about this entry */ + if (appctx->add_resource) + (*appctx->add_resource)(appctx->add_resource_ctx, + res_ofs, res_siz, + (char *)buf, + (size_t)res_namsiz, + resfileno); + } + + /* tell the host system where the resources start */ + if (appctx->set_resmap_seek != 0) + { + long pos = osfpos(fp); + (*appctx->set_resmap_seek)(appctx->set_resmap_seek_ctx, + pos, resfileno); + } + } } /* @@ -161,63 +161,63 @@ static void fiordhtml(errcxdef *ec, osfildef *fp, appctxdef *appctx, * files. */ static void fiordrscext(errcxdef *ec, osfildef *fp, appctxdef *appctx, - int resfileno, char *resfilename) + int resfileno, char *resfilename) { - uchar buf[TOKNAMMAX + 50]; - unsigned long endpos; - unsigned long startofs; + uchar buf[TOKNAMMAX + 50]; + unsigned long endpos; + unsigned long startofs; - /* note the starting offset */ - startofs = osfpos(fp); - - /* check file and version headers, and get flags and timestamp */ - if (osfrb(fp, buf, (int)(sizeof(FIOFILHDR) + sizeof(FIOVSNHDR) + 2))) - errsig1(ec, ERR_RDRSC, ERRTSTR, - errstr(ec, resfilename, strlen(resfilename))); - if (memcmp(buf, FIOFILHDRRSC, (size_t)sizeof(FIOFILHDRRSC))) - errsig1(ec, ERR_BADHDRRSC, ERRTSTR, - errstr(ec, resfilename, strlen(resfilename))); - if (memcmp(buf + sizeof(FIOFILHDR), FIOVSNHDR, - (size_t)sizeof(FIOVSNHDR)) - && memcmp(buf + sizeof(FIOFILHDR), FIOVSNHDR2, - (size_t)sizeof(FIOVSNHDR2)) - && memcmp(buf + sizeof(FIOFILHDR), FIOVSNHDR3, - (size_t)sizeof(FIOVSNHDR3))) - errsig(ec, ERR_BADVSN); - if (osfrb(fp, buf, (size_t)26)) - errsig1(ec, ERR_RDRSC, ERRTSTR, - errstr(ec, resfilename, strlen(resfilename))); + /* note the starting offset */ + startofs = osfpos(fp); + + /* check file and version headers, and get flags and timestamp */ + if (osfrb(fp, buf, (int)(sizeof(FIOFILHDR) + sizeof(FIOVSNHDR) + 2))) + errsig1(ec, ERR_RDRSC, ERRTSTR, + errstr(ec, resfilename, strlen(resfilename))); + if (memcmp(buf, FIOFILHDRRSC, (size_t)sizeof(FIOFILHDRRSC))) + errsig1(ec, ERR_BADHDRRSC, ERRTSTR, + errstr(ec, resfilename, strlen(resfilename))); + if (memcmp(buf + sizeof(FIOFILHDR), FIOVSNHDR, + (size_t)sizeof(FIOVSNHDR)) + && memcmp(buf + sizeof(FIOFILHDR), FIOVSNHDR2, + (size_t)sizeof(FIOVSNHDR2)) + && memcmp(buf + sizeof(FIOFILHDR), FIOVSNHDR3, + (size_t)sizeof(FIOVSNHDR3))) + errsig(ec, ERR_BADVSN); + if (osfrb(fp, buf, (size_t)26)) + errsig1(ec, ERR_RDRSC, ERRTSTR, + errstr(ec, resfilename, strlen(resfilename))); - /* now read resources from the file */ - for (;;) - { - /* read resource type and next-resource pointer */ - if (osfrb(fp, buf, 1) - || osfrb(fp, buf + 1, (int)(buf[0] + 4))) - errsig1(ec, ERR_RDRSC, ERRTSTR, - errstr(ec, resfilename, strlen(resfilename))); - endpos = osrp4(buf + 1 + buf[0]); + /* now read resources from the file */ + for (;;) + { + /* read resource type and next-resource pointer */ + if (osfrb(fp, buf, 1) + || osfrb(fp, buf + 1, (int)(buf[0] + 4))) + errsig1(ec, ERR_RDRSC, ERRTSTR, + errstr(ec, resfilename, strlen(resfilename))); + endpos = osrp4(buf + 1 + buf[0]); - /* check the resource type */ - if (fioisrsc(buf, "HTMLRES")) - { - /* read the HTML resource map */ - fiordhtml(ec, fp, appctx, resfileno, resfilename); + /* check the resource type */ + if (fioisrsc(buf, "HTMLRES")) + { + /* read the HTML resource map */ + fiordhtml(ec, fp, appctx, resfileno, resfilename); - /* - * skip the resources - they're entirely for the host - * application's use - */ - osfseek(fp, endpos + startofs, OSFSK_SET); - } - else if (fioisrsc(buf, "$EOF")) - { - /* we're done reading the file */ - break; - } - else - errsig(ec, ERR_UNKRSC); - } + /* + * skip the resources - they're entirely for the host + * application's use + */ + osfseek(fp, endpos + startofs, OSFSK_SET); + } + else if (fioisrsc(buf, "$EOF")) + { + /* we're done reading the file */ + break; + } + else + errsig(ec, ERR_UNKRSC); + } } /* @@ -228,901 +228,901 @@ static void fiordrscext(errcxdef *ec, osfildef *fp, appctxdef *appctx, * &2 ==> preload objects */ static void fiord1(mcmcxdef *mctx, voccxdef *vctx, tokcxdef *tctx, - osfildef *fp, const char *fname, - fiolcxdef *setupctx, ulong startofs, - objnum *preinit, uint *flagp, tokpdef *path, - uchar **fmtsp, uint *fmtlp, uint *pcntptr, int flags, - appctxdef *appctx, char *argv0) + osfildef *fp, const char *fname, + fiolcxdef *setupctx, ulong startofs, + objnum *preinit, uint *flagp, tokpdef *path, + uchar **fmtsp, uint *fmtlp, uint *pcntptr, int flags, + appctxdef *appctx, char *argv0) { - int i; - int siz; - uchar buf[TOKNAMMAX + 50]; - errcxdef *ec = vctx->voccxerr; - ulong endpos; - int obj; - ulong curpos; - runxdef *ex; - ulong eof_reset = 0; /* reset here at EOF if non-zero */ + int i; + int siz; + uchar buf[TOKNAMMAX + 50]; + errcxdef *ec = vctx->voccxerr; + ulong endpos; + int obj; + ulong curpos; + runxdef *ex; + ulong eof_reset = 0; /* reset here at EOF if non-zero */ #if 0 // XFCNs are obsolete - int xfcns_done = FALSE; /* already loaded XFCNs */ + int xfcns_done = FALSE; /* already loaded XFCNs */ #endif - ulong xfcn_pos = 0; /* location of XFCN's if preloadable */ - uint xor_seed = 17; /* seed value for fioxor */ - uint xor_inc = 29; /* increment value for fioxor */ + ulong xfcn_pos = 0; /* location of XFCN's if preloadable */ + uint xor_seed = 17; /* seed value for fioxor */ + uint xor_inc = 29; /* increment value for fioxor */ - /* set up loader callback context */ - setupctx->fiolcxfp = fp; - setupctx->fiolcxerr = ec; - setupctx->fiolcxst = startofs; - setupctx->fiolcxseed = xor_seed; - setupctx->fiolcxinc = xor_inc; + /* set up loader callback context */ + setupctx->fiolcxfp = fp; + setupctx->fiolcxerr = ec; + setupctx->fiolcxst = startofs; + setupctx->fiolcxseed = xor_seed; + setupctx->fiolcxinc = xor_inc; - /* check file and version headers, and get flags and timestamp */ - if (osfrb(fp, buf, (int)(sizeof(FIOFILHDR) + sizeof(FIOVSNHDR) + 2))) - errsig(ec, ERR_RDGAM); - if (memcmp(buf, FIOFILHDR, (size_t)sizeof(FIOFILHDR))) - errsig(ec, ERR_BADHDR); - if (memcmp(buf + sizeof(FIOFILHDR), FIOVSNHDR, - (size_t)sizeof(FIOVSNHDR)) - && memcmp(buf + sizeof(FIOFILHDR), FIOVSNHDR2, - (size_t)sizeof(FIOVSNHDR2)) - && memcmp(buf + sizeof(FIOFILHDR), FIOVSNHDR3, - (size_t)sizeof(FIOVSNHDR3))) - errsig(ec, ERR_BADVSN); - if (osfrb(fp, vctx->voccxtim, (size_t)26)) errsig(ec, ERR_RDGAM); + /* check file and version headers, and get flags and timestamp */ + if (osfrb(fp, buf, (int)(sizeof(FIOFILHDR) + sizeof(FIOVSNHDR) + 2))) + errsig(ec, ERR_RDGAM); + if (memcmp(buf, FIOFILHDR, (size_t)sizeof(FIOFILHDR))) + errsig(ec, ERR_BADHDR); + if (memcmp(buf + sizeof(FIOFILHDR), FIOVSNHDR, + (size_t)sizeof(FIOVSNHDR)) + && memcmp(buf + sizeof(FIOFILHDR), FIOVSNHDR2, + (size_t)sizeof(FIOVSNHDR2)) + && memcmp(buf + sizeof(FIOFILHDR), FIOVSNHDR3, + (size_t)sizeof(FIOVSNHDR3))) + errsig(ec, ERR_BADVSN); + if (osfrb(fp, vctx->voccxtim, (size_t)26)) errsig(ec, ERR_RDGAM); - /* - * if the game wasn't compiled with 2.2 or later, make a note, - * because we need to ignore certain property flags (due to a bug in - * the old compiler) - */ - if (memcmp(buf + sizeof(FIOFILHDR), FIOVSNHDR2, - (size_t)sizeof(FIOVSNHDR2)) == 0 - || memcmp(buf + sizeof(FIOFILHDR), FIOVSNHDR3, - (size_t)sizeof(FIOVSNHDR3)) == 0) - mctx->mcmcxflg |= MCMCXF_NO_PRP_DEL; + /* + * if the game wasn't compiled with 2.2 or later, make a note, + * because we need to ignore certain property flags (due to a bug in + * the old compiler) + */ + if (memcmp(buf + sizeof(FIOFILHDR), FIOVSNHDR2, + (size_t)sizeof(FIOVSNHDR2)) == 0 + || memcmp(buf + sizeof(FIOFILHDR), FIOVSNHDR3, + (size_t)sizeof(FIOVSNHDR3)) == 0) + mctx->mcmcxflg |= MCMCXF_NO_PRP_DEL; - setupctx->fiolcxflg = - *flagp = osrp2(buf + sizeof(FIOFILHDR) + sizeof(FIOVSNHDR)); - - /* now read resources from the file */ - for (;;) - { - /* read resource type and next-resource pointer */ - if (osfrb(fp, buf, 1) - || osfrb(fp, buf + 1, (int)(buf[0] + 4))) - errsig(ec, ERR_RDGAM); - endpos = osrp4(buf + 1 + buf[0]); - - if (fioisrsc(buf, "OBJ")) - { - /* skip regular objects if fast-load records are included */ - if (*flagp & FIOFFAST) - { - osfseek(fp, endpos + startofs, OSFSK_SET); - continue; - } + setupctx->fiolcxflg = + *flagp = osrp2(buf + sizeof(FIOFILHDR) + sizeof(FIOVSNHDR)); + + /* now read resources from the file */ + for (;;) + { + /* read resource type and next-resource pointer */ + if (osfrb(fp, buf, 1) + || osfrb(fp, buf + 1, (int)(buf[0] + 4))) + errsig(ec, ERR_RDGAM); + endpos = osrp4(buf + 1 + buf[0]); + + if (fioisrsc(buf, "OBJ")) + { + /* skip regular objects if fast-load records are included */ + if (*flagp & FIOFFAST) + { + osfseek(fp, endpos + startofs, OSFSK_SET); + continue; + } - curpos = osfpos(fp) - startofs; - while (curpos != endpos) - { - /* read type and object number */ - if (osfrb(fp, buf, 3)) errsig(ec, ERR_RDGAM); - obj = osrp2(buf+1); + curpos = osfpos(fp) - startofs; + while (curpos != endpos) + { + /* read type and object number */ + if (osfrb(fp, buf, 3)) errsig(ec, ERR_RDGAM); + obj = osrp2(buf+1); - switch(buf[0]) - { - case TOKSTFUNC: - case TOKSTOBJ: - if (osfrb(fp, buf + 3, 4)) errsig(ec, ERR_RDGAM); - mcmrsrv(mctx, (ushort)osrp2(buf + 3), (mcmon)obj, - (mclhd)curpos); - curpos += osrp2(buf + 5) + 7; - - /* load object if preloading */ - if (flags & 2) - { - (void)mcmlck(mctx, (mcmon)obj); - mcmunlck(mctx, (mcmon)obj); - } + switch(buf[0]) + { + case TOKSTFUNC: + case TOKSTOBJ: + if (osfrb(fp, buf + 3, 4)) errsig(ec, ERR_RDGAM); + mcmrsrv(mctx, (ushort)osrp2(buf + 3), (mcmon)obj, + (mclhd)curpos); + curpos += osrp2(buf + 5) + 7; + + /* load object if preloading */ + if (flags & 2) + { + (void)mcmlck(mctx, (mcmon)obj); + mcmunlck(mctx, (mcmon)obj); + } - /* seek past this object */ - osfseek(fp, curpos + startofs, OSFSK_SET); - break; - - case TOKSTFWDOBJ: - case TOKSTFWDFN: - { - ushort bsiz; - uchar *p; - - if (osfrb(fp, buf+3, 2)) errsig(ec, ERR_RDGAM); - bsiz = osrp2(buf+3); - p = mcmalonum(mctx, bsiz, (mcmon)obj); - if (osfrb(fp, p, bsiz)) errsig(ec, ERR_RDGAM); - mcmunlck(mctx, (mcmon)obj); - curpos += 5 + bsiz; - break; - } - - case TOKSTEXTERN: - if (!vctx->voccxrun->runcxext) - errsig(ec, ERR_UNXEXT); - ex = &vctx->voccxrun->runcxext[obj]; + /* seek past this object */ + osfseek(fp, curpos + startofs, OSFSK_SET); + break; + + case TOKSTFWDOBJ: + case TOKSTFWDFN: + { + ushort bsiz; + uchar *p; + + if (osfrb(fp, buf+3, 2)) errsig(ec, ERR_RDGAM); + bsiz = osrp2(buf+3); + p = mcmalonum(mctx, bsiz, (mcmon)obj); + if (osfrb(fp, p, bsiz)) errsig(ec, ERR_RDGAM); + mcmunlck(mctx, (mcmon)obj); + curpos += 5 + bsiz; + break; + } + + case TOKSTEXTERN: + if (!vctx->voccxrun->runcxext) + errsig(ec, ERR_UNXEXT); + ex = &vctx->voccxrun->runcxext[obj]; - if (osfrb(fp, buf + 3, 1) - || osfrb(fp, ex->runxnam, (int)buf[3])) - errsig(ec, ERR_RDGAM); - ex->runxnam[buf[3]] = '\0'; - curpos += buf[3] + 4; - break; - - default: - errsig(ec, ERR_UNKOTYP); - } - } - } - else if (fioisrsc(buf, "FST")) - { - uchar *p; - uchar *bufp; - ulong bsiz; - - if (!(*flagp & FIOFFAST)) - { - osfseek(fp, endpos + startofs, OSFSK_SET); - continue; - } - - curpos = osfpos(fp) - startofs; - bsiz = endpos - curpos; - if (bsiz && bsiz < OSMALMAX - && (bufp = p = (uchar *)osmalloc((size_t)bsiz)) != 0) - { - uchar *p1; - ulong siz2; - uint sizcur; + if (osfrb(fp, buf + 3, 1) + || osfrb(fp, ex->runxnam, (int)buf[3])) + errsig(ec, ERR_RDGAM); + ex->runxnam[buf[3]] = '\0'; + curpos += buf[3] + 4; + break; + + default: + errsig(ec, ERR_UNKOTYP); + } + } + } + else if (fioisrsc(buf, "FST")) + { + uchar *p; + uchar *bufp; + ulong bsiz; + + if (!(*flagp & FIOFFAST)) + { + osfseek(fp, endpos + startofs, OSFSK_SET); + continue; + } + + curpos = osfpos(fp) - startofs; + bsiz = endpos - curpos; + if (bsiz && bsiz < OSMALMAX + && (bufp = p = (uchar *)osmalloc((size_t)bsiz)) != 0) + { + uchar *p1; + ulong siz2; + uint sizcur; - for (p1 = p, siz2 = bsiz ; siz2 ; siz2 -= sizcur, p1 += sizcur) - { - sizcur = (siz2 > (uint)0xffff ? (uint)0xffff : siz2); - if (osfrb(fp, p1, sizcur)) errsig(ec, ERR_RDGAM); - } + for (p1 = p, siz2 = bsiz ; siz2 ; siz2 -= sizcur, p1 += sizcur) + { + sizcur = (siz2 > (uint)0xffff ? (uint)0xffff : siz2); + if (osfrb(fp, p1, sizcur)) errsig(ec, ERR_RDGAM); + } - while (bsiz) - { - obj = osrp2(p + 1); - switch(*p) - { - case TOKSTFUNC: - case TOKSTOBJ: - mcmrsrv(mctx, (ushort)osrp2(p + 3), (mcmon)obj, - (mclhd)osrp4(p + 7)); - p += 11; - bsiz -= 11; - - /* preload object if desired */ - if (flags & 2) - { - (void)mcmlck(mctx, (mcmon)obj); - mcmunlck(mctx, (mcmon)obj); - } - break; - - case TOKSTEXTERN: - if (!vctx->voccxrun->runcxext) - errsig(ec, ERR_UNXEXT); - ex = &vctx->voccxrun->runcxext[obj]; - - memcpy(ex->runxnam, p + 4, (size_t)p[3]); - ex->runxnam[p[3]] = '\0'; - bsiz -= p[3] + 4; - p += p[3] + 4; - break; - - default: - errsig(ec, ERR_UNKOTYP); - } - } - - /* done with temporary block; free it */ - osfree(bufp); - osfseek(fp, endpos + startofs, OSFSK_SET); - } - else - { - while (curpos != endpos) - { - if (osfrb(fp, buf, 3)) errsig(ec, ERR_RDGAM); - obj = osrp2(buf + 1); - switch(buf[0]) - { - case TOKSTFUNC: - case TOKSTOBJ: - if (osfrb(fp, buf + 3, 8)) errsig(ec, ERR_RDGAM); - mcmrsrv(mctx, (ushort)osrp2(buf + 3), (mcmon)obj, - (mclhd)osrp4(buf + 7)); - curpos += 11; - - /* preload object if desired */ - if (flags & 2) - { - (void)mcmlck(mctx, (mcmon)obj); - mcmunlck(mctx, (mcmon)obj); - osfseek(fp, curpos + startofs, OSFSK_SET); - } - break; - - case TOKSTEXTERN: - if (!vctx->voccxrun->runcxext) - errsig(ec, ERR_UNXEXT); - ex = &vctx->voccxrun->runcxext[obj]; - - if (osfrb(fp, buf + 3, 1) - || osfrb(fp, ex->runxnam, (int)buf[3])) - errsig(ec, ERR_RDGAM); - ex->runxnam[buf[3]] = '\0'; - curpos += buf[3] + 4; - break; - - default: - errsig(ec, ERR_UNKOTYP); - } - } - } + while (bsiz) + { + obj = osrp2(p + 1); + switch(*p) + { + case TOKSTFUNC: + case TOKSTOBJ: + mcmrsrv(mctx, (ushort)osrp2(p + 3), (mcmon)obj, + (mclhd)osrp4(p + 7)); + p += 11; + bsiz -= 11; + + /* preload object if desired */ + if (flags & 2) + { + (void)mcmlck(mctx, (mcmon)obj); + mcmunlck(mctx, (mcmon)obj); + } + break; + + case TOKSTEXTERN: + if (!vctx->voccxrun->runcxext) + errsig(ec, ERR_UNXEXT); + ex = &vctx->voccxrun->runcxext[obj]; + + memcpy(ex->runxnam, p + 4, (size_t)p[3]); + ex->runxnam[p[3]] = '\0'; + bsiz -= p[3] + 4; + p += p[3] + 4; + break; + + default: + errsig(ec, ERR_UNKOTYP); + } + } + + /* done with temporary block; free it */ + osfree(bufp); + osfseek(fp, endpos + startofs, OSFSK_SET); + } + else + { + while (curpos != endpos) + { + if (osfrb(fp, buf, 3)) errsig(ec, ERR_RDGAM); + obj = osrp2(buf + 1); + switch(buf[0]) + { + case TOKSTFUNC: + case TOKSTOBJ: + if (osfrb(fp, buf + 3, 8)) errsig(ec, ERR_RDGAM); + mcmrsrv(mctx, (ushort)osrp2(buf + 3), (mcmon)obj, + (mclhd)osrp4(buf + 7)); + curpos += 11; + + /* preload object if desired */ + if (flags & 2) + { + (void)mcmlck(mctx, (mcmon)obj); + mcmunlck(mctx, (mcmon)obj); + osfseek(fp, curpos + startofs, OSFSK_SET); + } + break; + + case TOKSTEXTERN: + if (!vctx->voccxrun->runcxext) + errsig(ec, ERR_UNXEXT); + ex = &vctx->voccxrun->runcxext[obj]; + + if (osfrb(fp, buf + 3, 1) + || osfrb(fp, ex->runxnam, (int)buf[3])) + errsig(ec, ERR_RDGAM); + ex->runxnam[buf[3]] = '\0'; + curpos += buf[3] + 4; + break; + + default: + errsig(ec, ERR_UNKOTYP); + } + } + } - /* if we can preload xfcn's, do so now */ - if (xfcn_pos) - { - eof_reset = endpos; /* remember to return here when done */ - osfseek(fp, xfcn_pos, OSFSK_SET); /* go to xfcn's */ - } - } - else if (fioisrsc(buf, "XFCN")) - { - if (!vctx->voccxrun->runcxext) errsig(ec, ERR_UNXEXT); + /* if we can preload xfcn's, do so now */ + if (xfcn_pos) + { + eof_reset = endpos; /* remember to return here when done */ + osfseek(fp, xfcn_pos, OSFSK_SET); /* go to xfcn's */ + } + } + else if (fioisrsc(buf, "XFCN")) + { + if (!vctx->voccxrun->runcxext) errsig(ec, ERR_UNXEXT); - /* read length and name of resource */ - if (osfrb(fp, buf, 3) || osfrb(fp, buf + 3, (int)buf[2])) - errsig(ec, ERR_RDGAM); - siz = osrp2(buf); + /* read length and name of resource */ + if (osfrb(fp, buf, 3) || osfrb(fp, buf + 3, (int)buf[2])) + errsig(ec, ERR_RDGAM); + siz = osrp2(buf); #if 0 /* * external functions are now obsolete - do not load */ - /* look for an external function with the same name */ - for (i = vctx->voccxrun->runcxexc, ex = vctx->voccxrun->runcxext - ; i ; ++ex, --i) - { - j = strlen(ex->runxnam); - if (j == buf[2] && !memcmp(buf + 3, ex->runxnam, (size_t)j)) - break; - } + /* look for an external function with the same name */ + for (i = vctx->voccxrun->runcxexc, ex = vctx->voccxrun->runcxext + ; i ; ++ex, --i) + { + j = strlen(ex->runxnam); + if (j == buf[2] && !memcmp(buf + 3, ex->runxnam, (size_t)j)) + break; + } - /* if we found an external function of this name, load it */ - if (i && !xfcns_done) - { - /* load the function */ - ex->runxptr = os_exfld(fp, (unsigned)siz); - } - else - { - /* this XFCN isn't used; don't bother loading it */ - osfseek(fp, endpos + startofs, OSFSK_SET); - } + /* if we found an external function of this name, load it */ + if (i && !xfcns_done) + { + /* load the function */ + ex->runxptr = os_exfld(fp, (unsigned)siz); + } + else + { + /* this XFCN isn't used; don't bother loading it */ + osfseek(fp, endpos + startofs, OSFSK_SET); + } #else - /* external functions are obsolete; simply skip the data */ - osfseek(fp, endpos + startofs, OSFSK_SET); + /* external functions are obsolete; simply skip the data */ + osfseek(fp, endpos + startofs, OSFSK_SET); #endif - } - else if (fioisrsc(buf, "HTMLRES")) - { - /* read the resources */ - fiordhtml(ec, fp, appctx, 0, fname); + } + else if (fioisrsc(buf, "HTMLRES")) + { + /* read the resources */ + fiordhtml(ec, fp, appctx, 0, fname); - /* - * skip the resources - they're entirely for the host - * application's use - */ - osfseek(fp, endpos + startofs, OSFSK_SET); - } - else if (fioisrsc(buf, "INH")) - { - uchar *p; - uchar *bufp; - ulong bsiz; - - /* do it in a single file read, if we can, for speed */ - curpos = osfpos(fp) - startofs; - bsiz = endpos - curpos; - if (bsiz && bsiz < OSMALMAX - && (bufp = p = (uchar *)osmalloc((size_t)bsiz)) != 0) - { - uchar *p1; - ulong siz2; - uint sizcur; + /* + * skip the resources - they're entirely for the host + * application's use + */ + osfseek(fp, endpos + startofs, OSFSK_SET); + } + else if (fioisrsc(buf, "INH")) + { + uchar *p; + uchar *bufp; + ulong bsiz; + + /* do it in a single file read, if we can, for speed */ + curpos = osfpos(fp) - startofs; + bsiz = endpos - curpos; + if (bsiz && bsiz < OSMALMAX + && (bufp = p = (uchar *)osmalloc((size_t)bsiz)) != 0) + { + uchar *p1; + ulong siz2; + uint sizcur; - for (p1 = p, siz2 = bsiz ; siz2 ; siz2 -= sizcur, p1 += sizcur) - { - sizcur = (siz2 > (uint)0xffff ? (uint)0xffff : siz2); - if (osfrb(fp, p1, sizcur)) errsig(ec, ERR_RDGAM); - } + for (p1 = p, siz2 = bsiz ; siz2 ; siz2 -= sizcur, p1 += sizcur) + { + sizcur = (siz2 > (uint)0xffff ? (uint)0xffff : siz2); + if (osfrb(fp, p1, sizcur)) errsig(ec, ERR_RDGAM); + } - while (bsiz) - { - i = osrp2(p + 7); - obj = osrp2(p + 1); - - vociadd(vctx, (objnum)obj, (objnum)osrp2(p+3), i, - (objnum *)(p + 9), p[0] | VOCIFXLAT); - vocinh(vctx, obj)->vociilc = osrp2(p + 5); - - p += 9 + (2 * i); - bsiz -= 9 + (2 * i); - } - - /* done with temporary block; free it */ - osfree(bufp); - } - else - { - while (curpos != endpos) - { - if (osfrb(fp, buf, 9)) errsig(ec, ERR_RDGAM); - i = osrp2(buf + 7); /* get number of superclasses */ - obj = osrp2(buf + 1); /* get object number */ - if (i && osfrb(fp, buf + 9, 2 * i)) errsig(ec, ERR_RDGAM); - - vociadd(vctx, (objnum)obj, (objnum)osrp2(buf+3), - i, (objnum *)(buf + 9), buf[0] | VOCIFXLAT); - vocinh(vctx, obj)->vociilc = osrp2(buf + 5); - - curpos += 9 + (2 * i); - } - } - } - else if (fioisrsc(buf, "REQ")) - { - curpos = osfpos(fp) - startofs; - siz = endpos - curpos; + while (bsiz) + { + i = osrp2(p + 7); + obj = osrp2(p + 1); + + vociadd(vctx, (objnum)obj, (objnum)osrp2(p+3), i, + (objnum *)(p + 9), p[0] | VOCIFXLAT); + vocinh(vctx, obj)->vociilc = osrp2(p + 5); + + p += 9 + (2 * i); + bsiz -= 9 + (2 * i); + } + + /* done with temporary block; free it */ + osfree(bufp); + } + else + { + while (curpos != endpos) + { + if (osfrb(fp, buf, 9)) errsig(ec, ERR_RDGAM); + i = osrp2(buf + 7); /* get number of superclasses */ + obj = osrp2(buf + 1); /* get object number */ + if (i && osfrb(fp, buf + 9, 2 * i)) errsig(ec, ERR_RDGAM); + + vociadd(vctx, (objnum)obj, (objnum)osrp2(buf+3), + i, (objnum *)(buf + 9), buf[0] | VOCIFXLAT); + vocinh(vctx, obj)->vociilc = osrp2(buf + 5); + + curpos += 9 + (2 * i); + } + } + } + else if (fioisrsc(buf, "REQ")) + { + curpos = osfpos(fp) - startofs; + siz = endpos - curpos; - if (osfrb(fp, buf, (uint)siz)) errsig(ec, ERR_RDGAM); - vctx->voccxme = vctx->voccxme_init = osrp2(buf); - vctx->voccxvtk = osrp2(buf+2); - vctx->voccxstr = osrp2(buf+4); - vctx->voccxnum = osrp2(buf+6); - vctx->voccxprd = osrp2(buf+8); - vctx->voccxvag = osrp2(buf+10); - vctx->voccxini = osrp2(buf+12); - vctx->voccxpre = osrp2(buf+14); - vctx->voccxper = osrp2(buf+16); - - /* if we have a cmdPrompt function, read it */ - if (siz >= 20) - vctx->voccxprom = osrp2(buf + 18); - else - vctx->voccxprom = MCMONINV; + if (osfrb(fp, buf, (uint)siz)) errsig(ec, ERR_RDGAM); + vctx->voccxme = vctx->voccxme_init = osrp2(buf); + vctx->voccxvtk = osrp2(buf+2); + vctx->voccxstr = osrp2(buf+4); + vctx->voccxnum = osrp2(buf+6); + vctx->voccxprd = osrp2(buf+8); + vctx->voccxvag = osrp2(buf+10); + vctx->voccxini = osrp2(buf+12); + vctx->voccxpre = osrp2(buf+14); + vctx->voccxper = osrp2(buf+16); + + /* if we have a cmdPrompt function, read it */ + if (siz >= 20) + vctx->voccxprom = osrp2(buf + 18); + else + vctx->voccxprom = MCMONINV; - /* if we have the NLS functions, read them */ - if (siz >= 26) - { - vctx->voccxpdis = osrp2(buf + 20); - vctx->voccxper2 = osrp2(buf + 22); - vctx->voccxpdef = osrp2(buf + 24); - } - else - { - /* the new NLS functions aren't defined in this file */ - vctx->voccxpdis = MCMONINV; - vctx->voccxper2 = MCMONINV; - vctx->voccxpdef = MCMONINV; - } + /* if we have the NLS functions, read them */ + if (siz >= 26) + { + vctx->voccxpdis = osrp2(buf + 20); + vctx->voccxper2 = osrp2(buf + 22); + vctx->voccxpdef = osrp2(buf + 24); + } + else + { + /* the new NLS functions aren't defined in this file */ + vctx->voccxpdis = MCMONINV; + vctx->voccxper2 = MCMONINV; + vctx->voccxpdef = MCMONINV; + } - /* test for parseAskobj separately, as it was added later */ - if (siz >= 28) - vctx->voccxpask = osrp2(buf + 26); - else - vctx->voccxpask = MCMONINV; + /* test for parseAskobj separately, as it was added later */ + if (siz >= 28) + vctx->voccxpask = osrp2(buf + 26); + else + vctx->voccxpask = MCMONINV; - /* test for preparseCmd separately - it's another late comer */ - if (siz >= 30) - vctx->voccxppc = osrp2(buf + 28); - else - vctx->voccxppc = MCMONINV; + /* test for preparseCmd separately - it's another late comer */ + if (siz >= 30) + vctx->voccxppc = osrp2(buf + 28); + else + vctx->voccxppc = MCMONINV; - /* check for parseAskobjActor separately - another late comer */ - if (siz >= 32) - vctx->voccxpask2 = osrp2(buf + 30); - else - vctx->voccxpask2 = MCMONINV; + /* check for parseAskobjActor separately - another late comer */ + if (siz >= 32) + vctx->voccxpask2 = osrp2(buf + 30); + else + vctx->voccxpask2 = MCMONINV; - /* if we have parseErrorParam, read it as well */ - if (siz >= 34) - { - vctx->voccxperp = osrp2(buf + 32); - } - else - { - /* parseErrorParam isn't defined in this file */ - vctx->voccxperp = MCMONINV; - } + /* if we have parseErrorParam, read it as well */ + if (siz >= 34) + { + vctx->voccxperp = osrp2(buf + 32); + } + else + { + /* parseErrorParam isn't defined in this file */ + vctx->voccxperp = MCMONINV; + } - /* - * if we have commandAfterRead and initRestore, read them as - * well - */ - if (siz >= 38) - { - vctx->voccxpostprom = osrp2(buf + 34); - vctx->voccxinitrestore = osrp2(buf + 36); - } - else - { - /* these new functions aren't defined in this game */ - vctx->voccxpostprom = MCMONINV; - vctx->voccxinitrestore = MCMONINV; - } + /* + * if we have commandAfterRead and initRestore, read them as + * well + */ + if (siz >= 38) + { + vctx->voccxpostprom = osrp2(buf + 34); + vctx->voccxinitrestore = osrp2(buf + 36); + } + else + { + /* these new functions aren't defined in this game */ + vctx->voccxpostprom = MCMONINV; + vctx->voccxinitrestore = MCMONINV; + } - /* check for and read parseUnknownVerb, parseNounPhrase */ - if (siz >= 42) - { - vctx->voccxpuv = osrp2(buf + 38); - vctx->voccxpnp = osrp2(buf + 40); - } - else - { - vctx->voccxpuv = MCMONINV; - vctx->voccxpnp = MCMONINV; - } + /* check for and read parseUnknownVerb, parseNounPhrase */ + if (siz >= 42) + { + vctx->voccxpuv = osrp2(buf + 38); + vctx->voccxpnp = osrp2(buf + 40); + } + else + { + vctx->voccxpuv = MCMONINV; + vctx->voccxpnp = MCMONINV; + } - /* check for postAction, endCommand */ - if (siz >= 48) - { - vctx->voccxpostact = osrp2(buf + 42); - vctx->voccxendcmd = osrp2(buf + 44); - vctx->voccxprecmd = osrp2(buf + 46); - } - else - { - vctx->voccxpostact = MCMONINV; - vctx->voccxendcmd = MCMONINV; - vctx->voccxprecmd = MCMONINV; - } + /* check for postAction, endCommand */ + if (siz >= 48) + { + vctx->voccxpostact = osrp2(buf + 42); + vctx->voccxendcmd = osrp2(buf + 44); + vctx->voccxprecmd = osrp2(buf + 46); + } + else + { + vctx->voccxpostact = MCMONINV; + vctx->voccxendcmd = MCMONINV; + vctx->voccxprecmd = MCMONINV; + } - /* check for parseAskobjIndirect */ - if (siz >= 50) - vctx->voccxpask3 = osrp2(buf + 48); - else - vctx->voccxpask3 = MCMONINV; + /* check for parseAskobjIndirect */ + if (siz >= 50) + vctx->voccxpask3 = osrp2(buf + 48); + else + vctx->voccxpask3 = MCMONINV; - /* check for preparseExt and parseDefaultExt */ - if (siz >= 54) - { - vctx->voccxpre2 = osrp2(buf + 50); - vctx->voccxpdef2 = osrp2(buf + 52); - } - else - { - vctx->voccxpre2 = MCMONINV; - vctx->voccxpdef2 = MCMONINV; - } - } - else if (fioisrsc(buf, "VOC")) - { - uchar *p; - uchar *bufp; - ulong bsiz; - int len1 = 0; - int len2 = 0; - - /* do it in a single file read, if we can, for speed */ - curpos = osfpos(fp) - startofs; - bsiz = endpos - curpos; - if (bsiz && bsiz < OSMALMAX - && (bufp = p = (uchar *)osmalloc((size_t)bsiz)) != 0) - { - uchar *p1; - ulong siz2; - uint sizcur; + /* check for preparseExt and parseDefaultExt */ + if (siz >= 54) + { + vctx->voccxpre2 = osrp2(buf + 50); + vctx->voccxpdef2 = osrp2(buf + 52); + } + else + { + vctx->voccxpre2 = MCMONINV; + vctx->voccxpdef2 = MCMONINV; + } + } + else if (fioisrsc(buf, "VOC")) + { + uchar *p; + uchar *bufp; + ulong bsiz; + int len1 = 0; + int len2 = 0; + + /* do it in a single file read, if we can, for speed */ + curpos = osfpos(fp) - startofs; + bsiz = endpos - curpos; + if (bsiz && bsiz < OSMALMAX + && (bufp = p = (uchar *)osmalloc((size_t)bsiz)) != 0) + { + uchar *p1; + ulong siz2; + uint sizcur; - for (p1 = p, siz2 = bsiz ; siz2 ; siz2 -= sizcur, p1 += sizcur) - { - sizcur = (siz2 > (uint)0xffff ? (uint)0xffff : siz2); - if (osfrb(fp, p1, sizcur)) errsig(ec, ERR_RDGAM); - } - - while (bsiz) - { - len1 = osrp2(p); - len2 = osrp2(p + 2); - if (*flagp & FIOFCRYPT) - fioxor(p + 10, (uint)(len1 + len2), - xor_seed, xor_inc); - vocadd2(vctx, (prpnum)osrp2(p+4), (objnum)osrp2(p+6), - osrp2(p+8), p + 10, len1, - (len2 ? p + 10 + len1 : (uchar*)0), len2); - - p += 10 + len1 + len2; - bsiz -= 10 + len1 + len2; - } - - /* done with the temporary block; free it up */ - osfree(bufp); - } - else - { - /* can't do it in one file read; do it the slow way */ - while (curpos != endpos) - { - if (osfrb(fp, buf, 10) - || osfrb(fp, buf + 10, - (len1 = osrp2(buf)) + (len2 = osrp2(buf + 2)))) - errsig(ec, ERR_RDGAM); - - if (*flagp & FIOFCRYPT) - fioxor(buf + 10, (uint)(len1 + len2), - xor_seed, xor_inc); - vocadd2(vctx, (prpnum)osrp2(buf+4), (objnum)osrp2(buf+6), - osrp2(buf+8), buf + 10, len1, - (len2 ? buf + 10 + len1 : (uchar*)0), len2); - curpos += 10 + len1 + len2; - } - } - } - else if (fioisrsc(buf, "FMTSTR")) - { - uchar *fmts; - uint fmtl; - - if (osfrb(fp, buf, 2)) errsig(ec, ERR_RDGAM); - fmtl = osrp2(buf); - fmts = mchalo(vctx->voccxerr, fmtl, "fiord1"); - if (osfrb(fp, fmts, fmtl)) errsig(ec, ERR_RDGAM); - if (*flagp & FIOFCRYPT) fioxor(fmts, fmtl, xor_seed, xor_inc); - tiosetfmt(vctx->voccxtio, vctx->voccxrun, fmts, fmtl); - - if (fmtsp) *fmtsp = fmts; - if (fmtlp) *fmtlp = fmtl; - } - else if (fioisrsc(buf, "CMPD")) - { - if (osfrb(fp, buf, 2)) errsig(ec, ERR_RDGAM); - vctx->voccxcpl = osrp2(buf); - vctx->voccxcpp = (char *)mchalo(vctx->voccxerr, - vctx->voccxcpl, "fiord1"); - if (osfrb(fp, vctx->voccxcpp, (uint)vctx->voccxcpl)) - errsig(ec, ERR_RDGAM); - if (*flagp & FIOFCRYPT) - fioxor((uchar *)vctx->voccxcpp, (uint)vctx->voccxcpl, - xor_seed, xor_inc); - } - else if (fioisrsc(buf, "SPECWORD")) - { - if (osfrb(fp, buf, 2)) errsig(ec, ERR_RDGAM); - vctx->voccxspl = osrp2(buf); - vctx->voccxspp = (char *)mchalo(vctx->voccxerr, - vctx->voccxspl, "fiord1"); - if (osfrb(fp, vctx->voccxspp, (uint)vctx->voccxspl)) - errsig(ec, ERR_RDGAM); - if (*flagp & FIOFCRYPT) - fioxor((uchar *)vctx->voccxspp, (uint)vctx->voccxspl, - xor_seed, xor_inc); - } - else if (fioisrsc(buf, "SYMTAB")) - { - tokthdef *symtab; - - /* if there's no debugger context, don't bother with this */ - if (!vctx->voccxrun->runcxdbg) - { - osfseek(fp, endpos + startofs, OSFSK_SET); - continue; - } - - if (!(symtab = vctx->voccxrun->runcxdbg->dbgcxtab)) - { - symtab = (tokthdef *)mchalo(ec, sizeof(tokthdef), - "fiord:symtab"); - tokthini(ec, mctx, (toktdef *)symtab); - vctx->voccxrun->runcxdbg->dbgcxtab = symtab; - } - - /* read symbols until we find a zero-length symbol */ - for (;;) - { - int hash; - - if (osfrb(fp, buf, 4)) errsig(ec, ERR_RDGAM); - if (buf[0] == 0) break; - if (osfrb(fp, buf + 4, (int)buf[0])) errsig(ec, ERR_RDGAM); - buf[4 + buf[0]] = '\0'; - hash = tokhsh((char *)buf + 4); - - (*symtab->tokthsc.toktfadd)((toktdef *)symtab, - (char *)buf + 4, - (int)buf[0], (int)buf[1], - osrp2(buf + 2), hash); - } - } - else if (fioisrsc(buf, "SRC")) - { - /* skip source file id's if there's no debugger context */ - if (vctx->voccxrun->runcxdbg == 0) - { - osfseek(fp, endpos + startofs, OSFSK_SET); - continue; - } - - while ((osfpos(fp) - startofs) != endpos) - { - /* the only thing we know how to read is linfdef's */ - if (linfload(fp, vctx->voccxrun->runcxdbg, ec, path)) - errsig(ec, ERR_RDGAM); - } - } - else if (fioisrsc(buf, "SRC2")) - { - /* - * this is simply a marker indicating that we have new-style - * (line-number-based) source debugging information in the - * file -- set the new-style debug info flag - */ - if (vctx->voccxrun->runcxdbg != 0) - vctx->voccxrun->runcxdbg->dbgcxflg |= DBGCXFLIN2; + for (p1 = p, siz2 = bsiz ; siz2 ; siz2 -= sizcur, p1 += sizcur) + { + sizcur = (siz2 > (uint)0xffff ? (uint)0xffff : siz2); + if (osfrb(fp, p1, sizcur)) errsig(ec, ERR_RDGAM); + } + + while (bsiz) + { + len1 = osrp2(p); + len2 = osrp2(p + 2); + if (*flagp & FIOFCRYPT) + fioxor(p + 10, (uint)(len1 + len2), + xor_seed, xor_inc); + vocadd2(vctx, (prpnum)osrp2(p+4), (objnum)osrp2(p+6), + osrp2(p+8), p + 10, len1, + (len2 ? p + 10 + len1 : (uchar*)0), len2); + + p += 10 + len1 + len2; + bsiz -= 10 + len1 + len2; + } + + /* done with the temporary block; free it up */ + osfree(bufp); + } + else + { + /* can't do it in one file read; do it the slow way */ + while (curpos != endpos) + { + if (osfrb(fp, buf, 10) + || osfrb(fp, buf + 10, + (len1 = osrp2(buf)) + (len2 = osrp2(buf + 2)))) + errsig(ec, ERR_RDGAM); + + if (*flagp & FIOFCRYPT) + fioxor(buf + 10, (uint)(len1 + len2), + xor_seed, xor_inc); + vocadd2(vctx, (prpnum)osrp2(buf+4), (objnum)osrp2(buf+6), + osrp2(buf+8), buf + 10, len1, + (len2 ? buf + 10 + len1 : (uchar*)0), len2); + curpos += 10 + len1 + len2; + } + } + } + else if (fioisrsc(buf, "FMTSTR")) + { + uchar *fmts; + uint fmtl; + + if (osfrb(fp, buf, 2)) errsig(ec, ERR_RDGAM); + fmtl = osrp2(buf); + fmts = mchalo(vctx->voccxerr, fmtl, "fiord1"); + if (osfrb(fp, fmts, fmtl)) errsig(ec, ERR_RDGAM); + if (*flagp & FIOFCRYPT) fioxor(fmts, fmtl, xor_seed, xor_inc); + tiosetfmt(vctx->voccxtio, vctx->voccxrun, fmts, fmtl); + + if (fmtsp) *fmtsp = fmts; + if (fmtlp) *fmtlp = fmtl; + } + else if (fioisrsc(buf, "CMPD")) + { + if (osfrb(fp, buf, 2)) errsig(ec, ERR_RDGAM); + vctx->voccxcpl = osrp2(buf); + vctx->voccxcpp = (char *)mchalo(vctx->voccxerr, + vctx->voccxcpl, "fiord1"); + if (osfrb(fp, vctx->voccxcpp, (uint)vctx->voccxcpl)) + errsig(ec, ERR_RDGAM); + if (*flagp & FIOFCRYPT) + fioxor((uchar *)vctx->voccxcpp, (uint)vctx->voccxcpl, + xor_seed, xor_inc); + } + else if (fioisrsc(buf, "SPECWORD")) + { + if (osfrb(fp, buf, 2)) errsig(ec, ERR_RDGAM); + vctx->voccxspl = osrp2(buf); + vctx->voccxspp = (char *)mchalo(vctx->voccxerr, + vctx->voccxspl, "fiord1"); + if (osfrb(fp, vctx->voccxspp, (uint)vctx->voccxspl)) + errsig(ec, ERR_RDGAM); + if (*flagp & FIOFCRYPT) + fioxor((uchar *)vctx->voccxspp, (uint)vctx->voccxspl, + xor_seed, xor_inc); + } + else if (fioisrsc(buf, "SYMTAB")) + { + tokthdef *symtab; + + /* if there's no debugger context, don't bother with this */ + if (!vctx->voccxrun->runcxdbg) + { + osfseek(fp, endpos + startofs, OSFSK_SET); + continue; + } + + if (!(symtab = vctx->voccxrun->runcxdbg->dbgcxtab)) + { + symtab = (tokthdef *)mchalo(ec, sizeof(tokthdef), + "fiord:symtab"); + tokthini(ec, mctx, (toktdef *)symtab); + vctx->voccxrun->runcxdbg->dbgcxtab = symtab; + } + + /* read symbols until we find a zero-length symbol */ + for (;;) + { + int hash; + + if (osfrb(fp, buf, 4)) errsig(ec, ERR_RDGAM); + if (buf[0] == 0) break; + if (osfrb(fp, buf + 4, (int)buf[0])) errsig(ec, ERR_RDGAM); + buf[4 + buf[0]] = '\0'; + hash = tokhsh((char *)buf + 4); + + (*symtab->tokthsc.toktfadd)((toktdef *)symtab, + (char *)buf + 4, + (int)buf[0], (int)buf[1], + osrp2(buf + 2), hash); + } + } + else if (fioisrsc(buf, "SRC")) + { + /* skip source file id's if there's no debugger context */ + if (vctx->voccxrun->runcxdbg == 0) + { + osfseek(fp, endpos + startofs, OSFSK_SET); + continue; + } + + while ((osfpos(fp) - startofs) != endpos) + { + /* the only thing we know how to read is linfdef's */ + if (linfload(fp, vctx->voccxrun->runcxdbg, ec, path)) + errsig(ec, ERR_RDGAM); + } + } + else if (fioisrsc(buf, "SRC2")) + { + /* + * this is simply a marker indicating that we have new-style + * (line-number-based) source debugging information in the + * file -- set the new-style debug info flag + */ + if (vctx->voccxrun->runcxdbg != 0) + vctx->voccxrun->runcxdbg->dbgcxflg |= DBGCXFLIN2; - /* the contents are empty - skip the block */ - osfseek(fp, endpos + startofs, OSFSK_SET); - } - else if (fioisrsc(buf, "PREINIT")) - { - if (osfrb(fp, buf, 2)) errsig(ec, ERR_RDGAM); - *preinit = osrp2(buf); - } - else if (fioisrsc(buf, "ERRMSG")) - { - errini(ec, fp); - osfseek(fp, endpos + startofs, OSFSK_SET); - } - else if (fioisrsc(buf, "EXTCNT")) - { - uchar *p; - ushort len; - ulong bsiz; + /* the contents are empty - skip the block */ + osfseek(fp, endpos + startofs, OSFSK_SET); + } + else if (fioisrsc(buf, "PREINIT")) + { + if (osfrb(fp, buf, 2)) errsig(ec, ERR_RDGAM); + *preinit = osrp2(buf); + } + else if (fioisrsc(buf, "ERRMSG")) + { + errini(ec, fp); + osfseek(fp, endpos + startofs, OSFSK_SET); + } + else if (fioisrsc(buf, "EXTCNT")) + { + uchar *p; + ushort len; + ulong bsiz; - curpos = osfpos(fp) - startofs; - bsiz = endpos - curpos; - if (osfrb(fp, buf, 2)) errsig(ec, ERR_RDGAM); - i = osrp2(buf); + curpos = osfpos(fp) - startofs; + bsiz = endpos - curpos; + if (osfrb(fp, buf, 2)) errsig(ec, ERR_RDGAM); + i = osrp2(buf); - len = i * sizeof(runxdef); - p = mchalo(ec, len, "fiord:runxdef"); - memset(p, 0, (size_t)len); + len = i * sizeof(runxdef); + p = mchalo(ec, len, "fiord:runxdef"); + memset(p, 0, (size_t)len); - vctx->voccxrun->runcxext = (runxdef *)p; - vctx->voccxrun->runcxexc = i; + vctx->voccxrun->runcxext = (runxdef *)p; + vctx->voccxrun->runcxexc = i; - /* see if start-of-XFCN information is present */ - if (bsiz >= 6) - { - /* get location of first XFCN, and seek there */ - if (osfrb(fp, buf, 4)) errsig(ec, ERR_RDGAM); - xfcn_pos = osrp4(buf); - } + /* see if start-of-XFCN information is present */ + if (bsiz >= 6) + { + /* get location of first XFCN, and seek there */ + if (osfrb(fp, buf, 4)) errsig(ec, ERR_RDGAM); + xfcn_pos = osrp4(buf); + } - /* seek past this resource */ - osfseek(fp, endpos + startofs, OSFSK_SET); - } - else if (fioisrsc(buf, "PRPCNT")) - { - if (osfrb(fp, buf, 2)) errsig(ec, ERR_RDGAM); - if (pcntptr) *pcntptr = osrp2(buf); - } - else if (fioisrsc(buf, "TADSPP") && tctx != 0) - { - tok_read_defines(tctx, fp, ec); - } - else if (fioisrsc(buf, "XSI")) - { - if (osfrb(fp, buf, 2)) errsig(ec, ERR_RDGAM); - setupctx->fiolcxseed = xor_seed = buf[0]; - setupctx->fiolcxinc = xor_inc = buf[1]; - osfseek(fp, endpos + startofs, OSFSK_SET); - } - else if (fioisrsc(buf, "CHRSET")) - { - size_t len; - - /* read the character set ID and LDESC */ - if (osfrb(fp, buf, 6) - || (len = osrp2(buf+4)) > CMAP_LDESC_MAX_LEN - || osfrb(fp, buf+6, len)) - errsig(ec, ERR_RDGAM); + /* seek past this resource */ + osfseek(fp, endpos + startofs, OSFSK_SET); + } + else if (fioisrsc(buf, "PRPCNT")) + { + if (osfrb(fp, buf, 2)) errsig(ec, ERR_RDGAM); + if (pcntptr) *pcntptr = osrp2(buf); + } + else if (fioisrsc(buf, "TADSPP") && tctx != 0) + { + tok_read_defines(tctx, fp, ec); + } + else if (fioisrsc(buf, "XSI")) + { + if (osfrb(fp, buf, 2)) errsig(ec, ERR_RDGAM); + setupctx->fiolcxseed = xor_seed = buf[0]; + setupctx->fiolcxinc = xor_inc = buf[1]; + osfseek(fp, endpos + startofs, OSFSK_SET); + } + else if (fioisrsc(buf, "CHRSET")) + { + size_t len; + + /* read the character set ID and LDESC */ + if (osfrb(fp, buf, 6) + || (len = osrp2(buf+4)) > CMAP_LDESC_MAX_LEN + || osfrb(fp, buf+6, len)) + errsig(ec, ERR_RDGAM); - /* establish this character set mapping */ - buf[4] = '\0'; - cmap_set_game_charset(ec, (char *)buf, (char *)buf + 6, argv0); - } - else if (fioisrsc(buf, "$EOF")) - { - if (eof_reset) - { - osfseek(fp, eof_reset, OSFSK_SET); /* back after EXTCNT */ - eof_reset = 0; /* really done at next EOF */ + /* establish this character set mapping */ + buf[4] = '\0'; + cmap_set_game_charset(ec, (char *)buf, (char *)buf + 6, argv0); + } + else if (fioisrsc(buf, "$EOF")) + { + if (eof_reset) + { + osfseek(fp, eof_reset, OSFSK_SET); /* back after EXTCNT */ + eof_reset = 0; /* really done at next EOF */ #if 0 // XFCNs are obsolete - xfcns_done = TRUE; /* don't do XFCNs again */ + xfcns_done = TRUE; /* don't do XFCNs again */ #endif - } - else - break; - } - else - errsig(ec, ERR_UNKRSC); - } + } + else + break; + } + else + errsig(ec, ERR_UNKRSC); + } } /* read binary file */ void fiord(mcmcxdef *mctx, voccxdef *vctx, tokcxdef *tctx, const char *fname, - const char *exename, fiolcxdef *setupctx, objnum *preinit, uint *flagp, - tokpdef *path, uchar **fmtsp, uint *fmtlp, uint *pcntptr, - int flags, struct appctxdef *appctx, char *argv0) + const char *exename, fiolcxdef *setupctx, objnum *preinit, uint *flagp, + tokpdef *path, uchar **fmtsp, uint *fmtlp, uint *pcntptr, + int flags, struct appctxdef *appctx, char *argv0) { - osfildef *fp; - ulong startofs; - const char *display_fname; - - /* presume there will be no need to run preinit */ - *preinit = MCMONINV; + osfildef *fp; + ulong startofs; + const char *display_fname; + + /* presume there will be no need to run preinit */ + *preinit = MCMONINV; - /* - * get the display filename - use the real filename if one is - * provided, otherwise use the name of the executable file itself - */ - display_fname = (fname != 0 ? fname : exename); + /* + * get the display filename - use the real filename if one is + * provided, otherwise use the name of the executable file itself + */ + display_fname = (fname != 0 ? fname : exename); - /* save the filename in G_os_gamename */ - if (display_fname != 0) - { - size_t copylen; + /* save the filename in G_os_gamename */ + if (display_fname != 0) + { + size_t copylen; - /* limit the copy to the buffer size */ - if ((copylen = strlen(display_fname)) > sizeof(G_os_gamename) - 1) - copylen = sizeof(G_os_gamename) - 1; + /* limit the copy to the buffer size */ + if ((copylen = strlen(display_fname)) > sizeof(G_os_gamename) - 1) + copylen = sizeof(G_os_gamename) - 1; - /* save it */ - memcpy(G_os_gamename, display_fname, copylen); - G_os_gamename[copylen] = '\0'; - } - else - G_os_gamename[0] = '\0'; - - /* open the file and read and check file header */ - fp = (fname != 0 ? osfoprb(fname, OSFTGAME) - : os_exeseek(exename, "TGAM")); - if (fp == 0) - errsig(vctx->voccxerr, ERR_OPRGAM); + /* save it */ + memcpy(G_os_gamename, display_fname, copylen); + G_os_gamename[copylen] = '\0'; + } + else + G_os_gamename[0] = '\0'; + + /* open the file and read and check file header */ + fp = (fname != 0 ? osfoprb(fname, OSFTGAME) + : os_exeseek(exename, "TGAM")); + if (fp == 0) + errsig(vctx->voccxerr, ERR_OPRGAM); - /* - * we've identified the .GAM file source - tell the host system - * about it, if it's interested - */ - if (appctx != 0 && appctx->set_game_name != 0) - (*appctx->set_game_name)(appctx->set_game_name_ctx, display_fname); + /* + * we've identified the .GAM file source - tell the host system + * about it, if it's interested + */ + if (appctx != 0 && appctx->set_game_name != 0) + (*appctx->set_game_name)(appctx->set_game_name_ctx, display_fname); - /* remember starting location in file */ - startofs = osfpos(fp); + /* remember starting location in file */ + startofs = osfpos(fp); - ERRBEGIN(vctx->voccxerr) + ERRBEGIN(vctx->voccxerr) - /* - * Read the game file. Note that the .GAM file always has resource - * file number zero. - */ - fiord1(mctx, vctx, tctx, fp, display_fname, - setupctx, startofs, preinit, flagp, path, - fmtsp, fmtlp, pcntptr, flags, appctx, argv0); + /* + * Read the game file. Note that the .GAM file always has resource + * file number zero. + */ + fiord1(mctx, vctx, tctx, fp, display_fname, + setupctx, startofs, preinit, flagp, path, + fmtsp, fmtlp, pcntptr, flags, appctx, argv0); - /* - * If the host system accepts additional resource files, look for - * additional resource files. These are files in the same directory - * as the .GAM file, with the .GAM suffix replaced by suffixes from - *. RS0 to .RS9. - */ - if (appctx != 0 && appctx->add_resfile != 0) - { - char suffix_lc[4]; - char suffix_uc[4]; - int i; - const char *base_name; + /* + * If the host system accepts additional resource files, look for + * additional resource files. These are files in the same directory + * as the .GAM file, with the .GAM suffix replaced by suffixes from + *. RS0 to .RS9. + */ + if (appctx != 0 && appctx->add_resfile != 0) + { + char suffix_lc[4]; + char suffix_uc[4]; + int i; + const char *base_name; - /* use the game or executable filename, as appropriate */ - base_name = display_fname; + /* use the game or executable filename, as appropriate */ + base_name = display_fname; - /* build the initial suffixes - try both upper- and lower-case */ - suffix_uc[0] = 'R'; - suffix_uc[1] = 'S'; - suffix_uc[3] = '\0'; - suffix_lc[0] = 'r'; - suffix_lc[1] = 's'; - suffix_lc[3] = '\0'; + /* build the initial suffixes - try both upper- and lower-case */ + suffix_uc[0] = 'R'; + suffix_uc[1] = 'S'; + suffix_uc[3] = '\0'; + suffix_lc[0] = 'r'; + suffix_lc[1] = 's'; + suffix_lc[3] = '\0'; - /* loop through each possible suffix (.RS0 through .RS9) */ - for (i = 0 ; i < 9 ; ++i) - { - char resname[OSFNMAX]; - osfildef *fpres; - int resfileno; + /* loop through each possible suffix (.RS0 through .RS9) */ + for (i = 0 ; i < 9 ; ++i) + { + char resname[OSFNMAX]; + osfildef *fpres; + int resfileno; - /* - * Build the next resource filename. If there's an explicit - * resource path, use it, otherwise use the same directory - * that contains the .GAM file. - */ - if (appctx->ext_res_path != 0) - { - /* - * There's an explicit resource path - append the root - * (filename-only, minus path) portion of the .GAM file - * name to the resource path. - */ - os_build_full_path(resname, sizeof(resname), - appctx->ext_res_path, - os_get_root_name(base_name)); - } - else - { - /* - * there's no resource path - use the entire .GAM - * filename, including directory, so that we look in the - * same directory that contains the .GAM file - */ - if (base_name != 0) - strcpy(resname, base_name); - else - resname[0] = '\0'; - } + /* + * Build the next resource filename. If there's an explicit + * resource path, use it, otherwise use the same directory + * that contains the .GAM file. + */ + if (appctx->ext_res_path != 0) + { + /* + * There's an explicit resource path - append the root + * (filename-only, minus path) portion of the .GAM file + * name to the resource path. + */ + os_build_full_path(resname, sizeof(resname), + appctx->ext_res_path, + os_get_root_name(base_name)); + } + else + { + /* + * there's no resource path - use the entire .GAM + * filename, including directory, so that we look in the + * same directory that contains the .GAM file + */ + if (base_name != 0) + strcpy(resname, base_name); + else + resname[0] = '\0'; + } - /* add the current extension (replacing any current extension) */ - os_remext(resname); - suffix_lc[2] = suffix_uc[2] = '0' + i; - os_addext(resname, suffix_lc); + /* add the current extension (replacing any current extension) */ + os_remext(resname); + suffix_lc[2] = suffix_uc[2] = '0' + i; + os_addext(resname, suffix_lc); - /* try opening the file */ - fpres = osfoprb(resname, OSFTGAME); + /* try opening the file */ + fpres = osfoprb(resname, OSFTGAME); - /* if that didn't work, try the upper-case name */ - if (fpres == 0) - { - /* replace the suffix with the upper-case version */ - os_remext(resname); - os_addext(resname, suffix_uc); + /* if that didn't work, try the upper-case name */ + if (fpres == 0) + { + /* replace the suffix with the upper-case version */ + os_remext(resname); + os_addext(resname, suffix_uc); - /* try again with the new name */ - fpres = osfoprb(resname, OSFTGAME); - } + /* try again with the new name */ + fpres = osfoprb(resname, OSFTGAME); + } - /* if we opened it successfully, read it */ - if (fpres != 0) - { - /* tell the host system about it */ - resfileno = (*appctx->add_resfile) - (appctx->add_resfile_ctx, resname); + /* if we opened it successfully, read it */ + if (fpres != 0) + { + /* tell the host system about it */ + resfileno = (*appctx->add_resfile) + (appctx->add_resfile_ctx, resname); - /* read the file */ - fiordrscext(vctx->voccxerr, fpres, appctx, - resfileno, resname); + /* read the file */ + fiordrscext(vctx->voccxerr, fpres, appctx, + resfileno, resname); - /* we're done with the file, so close it */ - osfcls(fpres); - } - } - } + /* we're done with the file, so close it */ + osfcls(fpres); + } + } + } - ERRCLEAN(vctx->voccxerr) - /* if an error occurs during read, clean up by closing the file */ - osfcls(fp); - ERRENDCLN(vctx->voccxerr); + ERRCLEAN(vctx->voccxerr) + /* if an error occurs during read, clean up by closing the file */ + osfcls(fp); + ERRENDCLN(vctx->voccxerr); } /* save game header */ @@ -1146,41 +1146,41 @@ void fiord(mcmcxdef *mctx, voccxdef *vctx, tokcxdef *tctx, const char *fname, /* read fuse/daemon/alarm record */ static int fiorfda(osfildef *fp, vocddef *p, uint cnt) { - vocddef *q; - uint i; - uchar buf[14]; - - /* start by clearing out entire record */ - for (i = 0, q = p ; i < cnt ; ++q, ++i) - q->vocdfn = MCMONINV; - - /* now restore all the records from the file */ - for (;;) - { - /* read a record, and quit if it's the last one */ - if (osfrb(fp, buf, 13)) return(TRUE); - if ((i = osrp2(buf)) == 0xffff) return(FALSE); - - /* restore this record */ - q = p + i; - q->vocdfn = osrp2(buf+2); - q->vocdarg.runstyp = buf[4]; - switch(buf[4]) - { - case DAT_NUMBER: - q->vocdarg.runsv.runsvnum = osrp4s(buf+5); - break; - case DAT_OBJECT: - case DAT_FNADDR: - q->vocdarg.runsv.runsvobj = osrp2(buf+5); - break; - case DAT_PROPNUM: - q->vocdarg.runsv.runsvprp = osrp2(buf+5); - break; - } - q->vocdprp = osrp2(buf+9); - q->vocdtim = osrp2(buf+11); - } + vocddef *q; + uint i; + uchar buf[14]; + + /* start by clearing out entire record */ + for (i = 0, q = p ; i < cnt ; ++q, ++i) + q->vocdfn = MCMONINV; + + /* now restore all the records from the file */ + for (;;) + { + /* read a record, and quit if it's the last one */ + if (osfrb(fp, buf, 13)) return(TRUE); + if ((i = osrp2(buf)) == 0xffff) return(FALSE); + + /* restore this record */ + q = p + i; + q->vocdfn = osrp2(buf+2); + q->vocdarg.runstyp = buf[4]; + switch(buf[4]) + { + case DAT_NUMBER: + q->vocdarg.runsv.runsvnum = osrp4s(buf+5); + break; + case DAT_OBJECT: + case DAT_FNADDR: + q->vocdarg.runsv.runsvobj = osrp2(buf+5); + break; + case DAT_PROPNUM: + q->vocdarg.runsv.runsvprp = osrp2(buf+5); + break; + } + q->vocdprp = osrp2(buf+9); + q->vocdtim = osrp2(buf+11); + } } /* @@ -1191,367 +1191,367 @@ static int fiorfda(osfildef *fp, vocddef *p, uint cnt) */ int fiorso_getgame(char *saved_file, char *fnamebuf, size_t buflen) { - osfildef *fp; - uint namelen; - char buf[sizeof(FIOSAVHDR_PREFIX) + 2]; + osfildef *fp; + uint namelen; + char buf[sizeof(FIOSAVHDR_PREFIX) + 2]; - /* open the input file */ - if (!(fp = osfoprb(saved_file, OSFTSAVE))) - return FALSE; + /* open the input file */ + if (!(fp = osfoprb(saved_file, OSFTSAVE))) + return FALSE; - /* read the prefix header and check */ - if (osfrb(fp, buf, (int)(sizeof(FIOSAVHDR_PREFIX) + 2)) - || memcmp(buf, FIOSAVHDR_PREFIX, sizeof(FIOSAVHDR_PREFIX)) != 0) - { - /* - * there's no game file information - close the file and - * indicate that we have no information - */ - osfcls(fp); - return FALSE; - } + /* read the prefix header and check */ + if (osfrb(fp, buf, (int)(sizeof(FIOSAVHDR_PREFIX) + 2)) + || memcmp(buf, FIOSAVHDR_PREFIX, sizeof(FIOSAVHDR_PREFIX)) != 0) + { + /* + * there's no game file information - close the file and + * indicate that we have no information + */ + osfcls(fp); + return FALSE; + } - /* get the length of the filename */ - namelen = osrp2(buf + sizeof(FIOSAVHDR_PREFIX)); - if (namelen > buflen - 1) - namelen = buflen - 1; + /* get the length of the filename */ + namelen = osrp2(buf + sizeof(FIOSAVHDR_PREFIX)); + if (namelen > buflen - 1) + namelen = buflen - 1; - /* read the filename */ - if (osfrb(fp, fnamebuf, namelen)) - { - osfcls(fp); - return FALSE; - } + /* read the filename */ + if (osfrb(fp, fnamebuf, namelen)) + { + osfcls(fp); + return FALSE; + } - /* null-terminate the string */ - fnamebuf[namelen] = '\0'; + /* null-terminate the string */ + fnamebuf[namelen] = '\0'; - /* done with the file */ - osfcls(fp); + /* done with the file */ + osfcls(fp); - /* indicate that we found the information */ - return TRUE; + /* indicate that we found the information */ + return TRUE; } /* restore game: returns TRUE on failure */ int fiorso(voccxdef *vctx, char *fname) { - osfildef *fp; - objnum obj; - uchar *p; - uchar *mut; - uint mutsiz; - uint oldmutsiz; - int propcnt; - mcmcxdef *mctx = vctx->voccxmem; - uchar buf[sizeof(FIOSAVHDR) + sizeof(FIOSAVVSN)]; - ushort newsiz; - int err = FALSE; - char timestamp[26]; - int version = 0; /* version ID - 0 = current version */ - int result; + osfildef *fp; + objnum obj; + uchar *p; + uchar *mut; + uint mutsiz; + uint oldmutsiz; + int propcnt; + mcmcxdef *mctx = vctx->voccxmem; + uchar buf[sizeof(FIOSAVHDR) + sizeof(FIOSAVVSN)]; + ushort newsiz; + int err = FALSE; + char timestamp[26]; + int version = 0; /* version ID - 0 = current version */ + int result; - /* presume success */ - result = FIORSO_SUCCESS; + /* presume success */ + result = FIORSO_SUCCESS; - /* open the input file */ - if (!(fp = osfoprb(fname, OSFTSAVE))) - return FIORSO_FILE_NOT_FOUND; + /* open the input file */ + if (!(fp = osfoprb(fname, OSFTSAVE))) + return FIORSO_FILE_NOT_FOUND; - /* check for a prefix header - if it's there, skip it */ - if (!osfrb(fp, buf, (int)(sizeof(FIOSAVHDR_PREFIX) + 2)) - && memcmp(buf, FIOSAVHDR_PREFIX, sizeof(FIOSAVHDR_PREFIX)) == 0) - { - ulong skip_len; - - /* - * The prefix header is present - skip it. The 2-byte value - * following the header is the length of the prefix data block - * (not including the header), so simply skip the additional - * number of bytes specified. - */ - skip_len = (ulong)osrp2(buf + sizeof(FIOSAVHDR_PREFIX)); - osfseek(fp, skip_len, OSFSK_CUR); - } - else - { - /* - * there's no prefix header - seek back to the start of the file - * and read the standard header information - */ - osfseek(fp, 0, OSFSK_SET); - } + /* check for a prefix header - if it's there, skip it */ + if (!osfrb(fp, buf, (int)(sizeof(FIOSAVHDR_PREFIX) + 2)) + && memcmp(buf, FIOSAVHDR_PREFIX, sizeof(FIOSAVHDR_PREFIX)) == 0) + { + ulong skip_len; + + /* + * The prefix header is present - skip it. The 2-byte value + * following the header is the length of the prefix data block + * (not including the header), so simply skip the additional + * number of bytes specified. + */ + skip_len = (ulong)osrp2(buf + sizeof(FIOSAVHDR_PREFIX)); + osfseek(fp, skip_len, OSFSK_CUR); + } + else + { + /* + * there's no prefix header - seek back to the start of the file + * and read the standard header information + */ + osfseek(fp, 0, OSFSK_SET); + } - - /* read headers and check */ - if (osfrb(fp, buf, (int)(sizeof(FIOSAVHDR) + sizeof(FIOSAVVSN))) - || memcmp(buf, FIOSAVHDR, (size_t)sizeof(FIOSAVHDR))) - { - /* it's not a saved game file */ - result = FIORSO_NOT_SAVE_FILE; - goto ret_error; - } + + /* read headers and check */ + if (osfrb(fp, buf, (int)(sizeof(FIOSAVHDR) + sizeof(FIOSAVVSN))) + || memcmp(buf, FIOSAVHDR, (size_t)sizeof(FIOSAVHDR))) + { + /* it's not a saved game file */ + result = FIORSO_NOT_SAVE_FILE; + goto ret_error; + } - /* check the version string */ - if (memcmp(buf + sizeof(FIOSAVHDR), FIOSAVVSN, - (size_t)sizeof(FIOSAVVSN)) == 0) - { - /* it's the current version */ - version = 0; - } - else if (memcmp(buf + sizeof(FIOSAVHDR), FIOSAVVSN1, - (size_t)sizeof(FIOSAVVSN1)) == 0) - { - /* it's old version #1 */ - version = 1; - } - else - { - /* - * this isn't a recognized version - the file must have been - * saved by a newer version of the system, so we can't assume we - * will be able to parse the format - */ - result = FIORSO_BAD_FMT_VSN; - goto ret_error; - } - - /* - * Read timestamp and check - the game must have been saved by the - * same .GAM file that we are now running, because the .SAV file is - * written entirely in terms of the contents of the .GAM file; any - * change in the .GAM file invalidates the .SAV file. - */ - if (osfrb(fp, timestamp, 26) - || memcmp(timestamp, vctx->voccxtim, (size_t)26)) - { - result = FIORSO_BAD_GAME_VSN; - goto ret_error; - } - - /* first revert every object to original (post-compilation) state */ - vocrevert(vctx); + /* check the version string */ + if (memcmp(buf + sizeof(FIOSAVHDR), FIOSAVVSN, + (size_t)sizeof(FIOSAVVSN)) == 0) + { + /* it's the current version */ + version = 0; + } + else if (memcmp(buf + sizeof(FIOSAVHDR), FIOSAVVSN1, + (size_t)sizeof(FIOSAVVSN1)) == 0) + { + /* it's old version #1 */ + version = 1; + } + else + { + /* + * this isn't a recognized version - the file must have been + * saved by a newer version of the system, so we can't assume we + * will be able to parse the format + */ + result = FIORSO_BAD_FMT_VSN; + goto ret_error; + } + + /* + * Read timestamp and check - the game must have been saved by the + * same .GAM file that we are now running, because the .SAV file is + * written entirely in terms of the contents of the .GAM file; any + * change in the .GAM file invalidates the .SAV file. + */ + if (osfrb(fp, timestamp, 26) + || memcmp(timestamp, vctx->voccxtim, (size_t)26)) + { + result = FIORSO_BAD_GAME_VSN; + goto ret_error; + } + + /* first revert every object to original (post-compilation) state */ + vocrevert(vctx); - /* - * the most common error from here on is simply a file read error, - * so presume that this is what will happen; if we are successful or - * encounter a different error, we'll change the status at that - * point - */ - result = FIORSO_READ_ERROR; + /* + * the most common error from here on is simply a file read error, + * so presume that this is what will happen; if we are successful or + * encounter a different error, we'll change the status at that + * point + */ + result = FIORSO_READ_ERROR; - /* go through file and load changed objects */ - for (;;) - { - /* get the header */ - if (osfrb(fp, buf, 7)) - goto ret_error; + /* go through file and load changed objects */ + for (;;) + { + /* get the header */ + if (osfrb(fp, buf, 7)) + goto ret_error; - /* get the object number from the header, and stop if we're done */ - obj = osrp2(buf+1); - if (obj == MCMONINV) - break; + /* get the object number from the header, and stop if we're done */ + obj = osrp2(buf+1); + if (obj == MCMONINV) + break; - /* if the object was dynamically allocated, recreate it */ - if (buf[0] == 1) - { - int sccnt; - objnum sc; - - /* create the object */ - mutsiz = osrp2(buf + 3); - p = mcmalonum(mctx, (ushort)mutsiz, (mcmon)obj); + /* if the object was dynamically allocated, recreate it */ + if (buf[0] == 1) + { + int sccnt; + objnum sc; + + /* create the object */ + mutsiz = osrp2(buf + 3); + p = mcmalonum(mctx, (ushort)mutsiz, (mcmon)obj); - /* read the object's contents */ - if (osfrb(fp, p, mutsiz)) - goto ret_error; + /* read the object's contents */ + if (osfrb(fp, p, mutsiz)) + goto ret_error; - /* get the superclass data (at most one superclass) */ - sccnt = objnsc(p); - if (sccnt) sc = osrp2(objsc(p)); + /* get the superclass data (at most one superclass) */ + sccnt = objnsc(p); + if (sccnt) sc = osrp2(objsc(p)); - /* create inheritance records for the object */ - vociadd(vctx, obj, MCMONINV, sccnt, &sc, VOCIFNEW | VOCIFVOC); + /* create inheritance records for the object */ + vociadd(vctx, obj, MCMONINV, sccnt, &sc, VOCIFNEW | VOCIFVOC); #if 0 - { - int wrdcnt; + { + int wrdcnt; - /* read the object's vocabulary and add it back */ - if (osfrb(fp, buf, 2)) - goto ret_error; - wrdcnt = osrp2(buf); - while (wrdcnt--) - { - int len1; - int len2; - char wrd[80]; - - /* read the header */ - if (osfrb(fp, buf, 6)) - goto ret_error; - len1 = osrp2(buf+2); - len2 = osrp2(buf+4); - - /* read the word text */ - if (osfrb(fp, wrd, len1 + len2)) - goto ret_error; - - /* add the word */ - vocadd2(vctx, buf[0], obj, buf[1], wrd, len1, - wrd + len1, len2); - } - } + /* read the object's vocabulary and add it back */ + if (osfrb(fp, buf, 2)) + goto ret_error; + wrdcnt = osrp2(buf); + while (wrdcnt--) + { + int len1; + int len2; + char wrd[80]; + + /* read the header */ + if (osfrb(fp, buf, 6)) + goto ret_error; + len1 = osrp2(buf+2); + len2 = osrp2(buf+4); + + /* read the word text */ + if (osfrb(fp, wrd, len1 + len2)) + goto ret_error; + + /* add the word */ + vocadd2(vctx, buf[0], obj, buf[1], wrd, len1, + wrd + len1, len2); + } + } #endif - } - else - { - /* get the remaining data from the header */ - propcnt = osrp2(buf + 3); - mutsiz = osrp2(buf + 5); - - /* expand object if it's not big enough for mutsiz */ - p = mcmlck(mctx, (mcmon)obj); - oldmutsiz = mcmobjsiz(mctx, (mcmon)obj) - objrst(p); - if (oldmutsiz < mutsiz) - { - newsiz = mutsiz - oldmutsiz; - p = (uchar *)objexp(mctx, obj, &newsiz); - } - - /* reset statistics, and read mutable part from file */ - mut = p + objrst(p); - objsnp(p, propcnt); - objsfree(p, mutsiz + objrst(p)); - if (osfrb(fp, mut, mutsiz)) - err = TRUE; - - /* reset ignore flags as needed */ - objsetign(mctx, obj); - } + } + else + { + /* get the remaining data from the header */ + propcnt = osrp2(buf + 3); + mutsiz = osrp2(buf + 5); + + /* expand object if it's not big enough for mutsiz */ + p = mcmlck(mctx, (mcmon)obj); + oldmutsiz = mcmobjsiz(mctx, (mcmon)obj) - objrst(p); + if (oldmutsiz < mutsiz) + { + newsiz = mutsiz - oldmutsiz; + p = (uchar *)objexp(mctx, obj, &newsiz); + } + + /* reset statistics, and read mutable part from file */ + mut = p + objrst(p); + objsnp(p, propcnt); + objsfree(p, mutsiz + objrst(p)); + if (osfrb(fp, mut, mutsiz)) + err = TRUE; + + /* reset ignore flags as needed */ + objsetign(mctx, obj); + } - /* touch and unlock the object */ - mcmtch(mctx, (mcmon)obj); - mcmunlck(mctx, (mcmon)obj); - if (err) - goto ret_error; - } - - /* read fuses/daemons/alarms */ - if (fiorfda(fp, vctx->voccxdmn, vctx->voccxdmc) - || fiorfda(fp, vctx->voccxfus, vctx->voccxfuc) - || fiorfda(fp, vctx->voccxalm, vctx->voccxalc)) - goto ret_error; + /* touch and unlock the object */ + mcmtch(mctx, (mcmon)obj); + mcmunlck(mctx, (mcmon)obj); + if (err) + goto ret_error; + } + + /* read fuses/daemons/alarms */ + if (fiorfda(fp, vctx->voccxdmn, vctx->voccxdmc) + || fiorfda(fp, vctx->voccxfus, vctx->voccxfuc) + || fiorfda(fp, vctx->voccxalm, vctx->voccxalc)) + goto ret_error; - /* read the dynamically added and deleted vocabulary */ - for (;;) - { - int len1; - int len2; - char wrd[80]; - int flags; - int typ; - - /* read the header */ - if (osfrb(fp, buf, 8)) - goto ret_error; + /* read the dynamically added and deleted vocabulary */ + for (;;) + { + int len1; + int len2; + char wrd[80]; + int flags; + int typ; + + /* read the header */ + if (osfrb(fp, buf, 8)) + goto ret_error; - typ = buf[0]; - flags = buf[1]; - len1 = osrp2(buf+2); - len2 = osrp2(buf+4); - obj = osrp2(buf+6); + typ = buf[0]; + flags = buf[1]; + len1 = osrp2(buf+2); + len2 = osrp2(buf+4); + obj = osrp2(buf+6); - /* check to see if this is the end marker */ - if (obj == MCMONINV) break; - - /* read the word text */ - if (osfrb(fp, wrd+2, len1)) - goto ret_error; - if (len2) - { - wrd[len1 + 2] = ' '; - if (osfrb(fp, &wrd[len1 + 3], len2)) - goto ret_error; - oswp2(wrd, len1 + len2 + 3); - } - else - oswp2(wrd, len1 + 2); - - /* add or delete the word as appropriate */ - if (flags & VOCFDEL) - vocdel1(vctx, obj, (char *)wrd, (prpnum)typ, FALSE, FALSE, FALSE); - else - vocadd2(vctx, buf[0], obj, buf[1], (uchar *)wrd+2, len1, - (uchar *)wrd+len1, len2); - } + /* check to see if this is the end marker */ + if (obj == MCMONINV) break; + + /* read the word text */ + if (osfrb(fp, wrd+2, len1)) + goto ret_error; + if (len2) + { + wrd[len1 + 2] = ' '; + if (osfrb(fp, &wrd[len1 + 3], len2)) + goto ret_error; + oswp2(wrd, len1 + len2 + 3); + } + else + oswp2(wrd, len1 + 2); + + /* add or delete the word as appropriate */ + if (flags & VOCFDEL) + vocdel1(vctx, obj, (char *)wrd, (prpnum)typ, FALSE, FALSE, FALSE); + else + vocadd2(vctx, buf[0], obj, buf[1], (uchar *)wrd+2, len1, + (uchar *)wrd+len1, len2); + } - /* - * the following was added in save format version "v2.2.1", so skip - * it if the save version is older than that - */ - if (version != 1) - { - /* read the current "Me" object */ - if (osfrb(fp, buf, 2)) - goto ret_error; - vctx->voccxme = osrp2(buf); - } + /* + * the following was added in save format version "v2.2.1", so skip + * it if the save version is older than that + */ + if (version != 1) + { + /* read the current "Me" object */ + if (osfrb(fp, buf, 2)) + goto ret_error; + vctx->voccxme = osrp2(buf); + } - /* done - close file and return success indication */ - osfcls(fp); - return FIORSO_SUCCESS; + /* done - close file and return success indication */ + osfcls(fp); + return FIORSO_SUCCESS; - /* come here on failure - close file and return error indication */ + /* come here on failure - close file and return error indication */ ret_error: - osfcls(fp); - return result; + osfcls(fp); + return result; } /* write fuse/daemon/alarm block */ static int fiowfda(osfildef *fp, vocddef *p, uint cnt) { - uchar buf[14]; - uint i; - - for (i = 0 ; i < cnt ; ++i, ++p) - { - if (p->vocdfn == MCMONINV) continue; /* not set - ignore */ - - oswp2(buf, i); /* element in array to be set */ - oswp2(buf+2, p->vocdfn); /* object number for function/target */ - buf[4] = p->vocdarg.runstyp; /* type of argument */ - switch(buf[4]) - { - case DAT_NUMBER: - oswp4s(buf+5, p->vocdarg.runsv.runsvnum); - break; - case DAT_OBJECT: - case DAT_FNADDR: - oswp2(buf+5, p->vocdarg.runsv.runsvobj); - break; - case DAT_PROPNUM: - oswp2(buf+5, p->vocdarg.runsv.runsvprp); - break; - } - oswp2(buf+9, p->vocdprp); - oswp2(buf+11, p->vocdtim); - - /* write this record to file */ - if (osfwb(fp, buf, 13)) return(TRUE); - } - - /* write end record - -1 for array element number */ - oswp2(buf, 0xffff); - return(osfwb(fp, buf, 13)); + uchar buf[14]; + uint i; + + for (i = 0 ; i < cnt ; ++i, ++p) + { + if (p->vocdfn == MCMONINV) continue; /* not set - ignore */ + + oswp2(buf, i); /* element in array to be set */ + oswp2(buf+2, p->vocdfn); /* object number for function/target */ + buf[4] = p->vocdarg.runstyp; /* type of argument */ + switch(buf[4]) + { + case DAT_NUMBER: + oswp4s(buf+5, p->vocdarg.runsv.runsvnum); + break; + case DAT_OBJECT: + case DAT_FNADDR: + oswp2(buf+5, p->vocdarg.runsv.runsvobj); + break; + case DAT_PROPNUM: + oswp2(buf+5, p->vocdarg.runsv.runsvprp); + break; + } + oswp2(buf+9, p->vocdprp); + oswp2(buf+11, p->vocdtim); + + /* write this record to file */ + if (osfwb(fp, buf, 13)) return(TRUE); + } + + /* write end record - -1 for array element number */ + oswp2(buf, 0xffff); + return(osfwb(fp, buf, 13)); } /* context for vocabulary saver callback function */ struct fiosav_cb_ctx { - int err; - osfildef *fp; + int err; + osfildef *fp; }; #ifdef NEVER @@ -1561,20 +1561,20 @@ struct fiosav_cb_ctx * attached to a dynamically allocated object to the save file */ static void fiosav_cb(struct fiosav_cb_ctx *ctx, - vocdef *voc, vocwdef *vocw) + vocdef *voc, vocwdef *vocw) { - char buf[10]; - - /* write the part of speech, flags, and word lengths */ - buf[0] = vocw->vocwtyp; - buf[1] = vocw->vocwflg; - oswp2(buf+2, voc->voclen); - oswp2(buf+4, voc->vocln2); - if (osfwb(ctx->fp, buf, 6)) ctx->err = TRUE; + char buf[10]; + + /* write the part of speech, flags, and word lengths */ + buf[0] = vocw->vocwtyp; + buf[1] = vocw->vocwflg; + oswp2(buf+2, voc->voclen); + oswp2(buf+4, voc->vocln2); + if (osfwb(ctx->fp, buf, 6)) ctx->err = TRUE; - /* write the words */ - if (osfwb(ctx->fp, voc->voctxt, voc->voclen + voc->vocln2)) - ctx->err = TRUE; + /* write the words */ + if (osfwb(ctx->fp, voc->voctxt, voc->voclen + voc->vocln2)) + ctx->err = TRUE; } #endif @@ -1585,188 +1585,188 @@ static void fiosav_cb(struct fiosav_cb_ctx *ctx, */ static void fiosav_voc_cb(void *ctx0, vocdef *voc, vocwdef *vocw) { - struct fiosav_cb_ctx *ctx = (struct fiosav_cb_ctx *)ctx0; - char buf[10]; - - /* if the word was dynamically allocated or deleted, save it */ - if ((vocw->vocwflg & VOCFNEW) || (vocw->vocwflg & VOCFDEL)) - { - /* write the header information */ - buf[0] = vocw->vocwtyp; - buf[1] = vocw->vocwflg; - oswp2(buf+2, voc->voclen); - oswp2(buf+4, voc->vocln2); - oswp2(buf+6, vocw->vocwobj); - if (osfwb(ctx->fp, buf, 8)) ctx->err = TRUE; + struct fiosav_cb_ctx *ctx = (struct fiosav_cb_ctx *)ctx0; + char buf[10]; + + /* if the word was dynamically allocated or deleted, save it */ + if ((vocw->vocwflg & VOCFNEW) || (vocw->vocwflg & VOCFDEL)) + { + /* write the header information */ + buf[0] = vocw->vocwtyp; + buf[1] = vocw->vocwflg; + oswp2(buf+2, voc->voclen); + oswp2(buf+4, voc->vocln2); + oswp2(buf+6, vocw->vocwobj); + if (osfwb(ctx->fp, buf, 8)) ctx->err = TRUE; - /* write the words */ - if (osfwb(ctx->fp, voc->voctxt, voc->voclen + voc->vocln2)) - ctx->err = TRUE; - } + /* write the words */ + if (osfwb(ctx->fp, voc->voctxt, voc->voclen + voc->vocln2)) + ctx->err = TRUE; + } } /* save game; returns TRUE on failure */ int fiosav(voccxdef *vctx, char *fname, char *game_fname) { - osfildef *fp; - vocidef ***vpg; - vocidef **v; - int i; - int j; - objnum obj; - uchar *p; - uchar *mut; - uint mutsiz; - int propcnt; - mcmcxdef *mctx = vctx->voccxmem; - uchar buf[8]; - int err = FALSE; - struct fiosav_cb_ctx fnctx; + osfildef *fp; + vocidef ***vpg; + vocidef **v; + int i; + int j; + objnum obj; + uchar *p; + uchar *mut; + uint mutsiz; + int propcnt; + mcmcxdef *mctx = vctx->voccxmem; + uchar buf[8]; + int err = FALSE; + struct fiosav_cb_ctx fnctx; - /* open the output file */ - if ((fp = osfopwb(fname, OSFTSAVE)) == 0) - return TRUE; + /* open the output file */ + if ((fp = osfopwb(fname, OSFTSAVE)) == 0) + return TRUE; - /* - * If we have game file information, save the game file information - * with the saved game file. This lets the player start the - * run-time and restore the game by specifying only the saved game - * file. - */ - if (game_fname != 0) - { - size_t len; - - /* write the prefix header */ - len = strlen(game_fname); - oswp2(buf, len); - if (osfwb(fp, FIOSAVHDR_PREFIX, (int)sizeof(FIOSAVHDR_PREFIX)) - || osfwb(fp, buf, 2) - || osfwb(fp, game_fname, (int)len)) - goto ret_error; - } - - /* write save game header and timestamp */ - if (osfwb(fp, FIOSAVHDR, (int)sizeof(FIOSAVHDR)) - || osfwb(fp, FIOSAVVSN, (int)sizeof(FIOSAVVSN)) - || osfwb(fp, vctx->voccxtim, 26)) - goto ret_error; + /* + * If we have game file information, save the game file information + * with the saved game file. This lets the player start the + * run-time and restore the game by specifying only the saved game + * file. + */ + if (game_fname != 0) + { + size_t len; + + /* write the prefix header */ + len = strlen(game_fname); + oswp2(buf, len); + if (osfwb(fp, FIOSAVHDR_PREFIX, (int)sizeof(FIOSAVHDR_PREFIX)) + || osfwb(fp, buf, 2) + || osfwb(fp, game_fname, (int)len)) + goto ret_error; + } + + /* write save game header and timestamp */ + if (osfwb(fp, FIOSAVHDR, (int)sizeof(FIOSAVHDR)) + || osfwb(fp, FIOSAVVSN, (int)sizeof(FIOSAVVSN)) + || osfwb(fp, vctx->voccxtim, 26)) + goto ret_error; - /* go through each object, and write if it's been changed */ - for (vpg = vctx->voccxinh, i = 0 ; i < VOCINHMAX ; ++vpg, ++i) - { - if (!*vpg) continue; - for (v = *vpg, obj = (i << 8), j = 0 ; j < 256 ; ++v, ++obj, ++j) - { - if (*v != 0) - { - /* write object if it's dirty */ - if (mcmobjdirty(mctx, (mcmon)obj)) - { - p = mcmlck(mctx, (mcmon)obj); - mut = p + objrst(p); - propcnt = objnprop(p); - mutsiz = objfree(p) - objrst(p); - if ((objflg(p) & OBJFINDEX) != 0) - mutsiz += propcnt * 4; + /* go through each object, and write if it's been changed */ + for (vpg = vctx->voccxinh, i = 0 ; i < VOCINHMAX ; ++vpg, ++i) + { + if (!*vpg) continue; + for (v = *vpg, obj = (i << 8), j = 0 ; j < 256 ; ++v, ++obj, ++j) + { + if (*v != 0) + { + /* write object if it's dirty */ + if (mcmobjdirty(mctx, (mcmon)obj)) + { + p = mcmlck(mctx, (mcmon)obj); + mut = p + objrst(p); + propcnt = objnprop(p); + mutsiz = objfree(p) - objrst(p); + if ((objflg(p) & OBJFINDEX) != 0) + mutsiz += propcnt * 4; - /* - * If the object was dynamically allocated, write - * the whole object. Otherwise, write just the - * mutable part. - */ - if ((*v)->vociflg & VOCIFNEW) - { - /* indicate that the object is dynamic */ - buf[0] = 1; - oswp2(buf + 1, obj); + /* + * If the object was dynamically allocated, write + * the whole object. Otherwise, write just the + * mutable part. + */ + if ((*v)->vociflg & VOCIFNEW) + { + /* indicate that the object is dynamic */ + buf[0] = 1; + oswp2(buf + 1, obj); - /* write the entire object */ - mutsiz = objfree(p); - oswp2(buf + 3, mutsiz); - if (osfwb(fp, buf, 7) - || osfwb(fp, p, mutsiz)) - err = TRUE; + /* write the entire object */ + mutsiz = objfree(p); + oswp2(buf + 3, mutsiz); + if (osfwb(fp, buf, 7) + || osfwb(fp, p, mutsiz)) + err = TRUE; #ifdef NEVER - { - int wrdcnt; - - /* count the words, and write the count */ - voc_count(vctx, obj, 0, &wrdcnt, (int *)0); - oswp2(buf, wrdcnt); - if (osfwb(fp, buf, 2)) - err = TRUE; - - /* write the words */ - fnctx.err = 0; - fnctx.fp = fp; - voc_iterate(vctx, obj, fiosav_cb, &fnctx); - if (fnctx.err != 0) - err = TRUE; - } + { + int wrdcnt; + + /* count the words, and write the count */ + voc_count(vctx, obj, 0, &wrdcnt, (int *)0); + oswp2(buf, wrdcnt); + if (osfwb(fp, buf, 2)) + err = TRUE; + + /* write the words */ + fnctx.err = 0; + fnctx.fp = fp; + voc_iterate(vctx, obj, fiosav_cb, &fnctx); + if (fnctx.err != 0) + err = TRUE; + } #endif - } - else if (mutsiz) - { - /* write number of properties, size of mut, and mut */ - buf[0] = 0; /* indicate that the object is static */ - oswp2(buf + 1, obj); - oswp2(buf + 3, propcnt); - oswp2(buf + 5, mutsiz); - if (osfwb(fp, buf, 7) - || osfwb(fp, mut, mutsiz)) - err = TRUE; - } - - mcmunlck(mctx, (mcmon)obj); - if (err != 0) - goto ret_error; - } - } - } - } + } + else if (mutsiz) + { + /* write number of properties, size of mut, and mut */ + buf[0] = 0; /* indicate that the object is static */ + oswp2(buf + 1, obj); + oswp2(buf + 3, propcnt); + oswp2(buf + 5, mutsiz); + if (osfwb(fp, buf, 7) + || osfwb(fp, mut, mutsiz)) + err = TRUE; + } + + mcmunlck(mctx, (mcmon)obj); + if (err != 0) + goto ret_error; + } + } + } + } - /* write end-of-objects indication */ - buf[0] = 0; - oswp2(buf + 1, MCMONINV); - oswp4(buf + 3, 0); - if (osfwb(fp, buf, 7)) - goto ret_error; + /* write end-of-objects indication */ + buf[0] = 0; + oswp2(buf + 1, MCMONINV); + oswp4(buf + 3, 0); + if (osfwb(fp, buf, 7)) + goto ret_error; - /* write fuses/daemons/alarms */ - if (fiowfda(fp, vctx->voccxdmn, vctx->voccxdmc) - || fiowfda(fp, vctx->voccxfus, vctx->voccxfuc) - || fiowfda(fp, vctx->voccxalm, vctx->voccxalc)) - goto ret_error; + /* write fuses/daemons/alarms */ + if (fiowfda(fp, vctx->voccxdmn, vctx->voccxdmc) + || fiowfda(fp, vctx->voccxfus, vctx->voccxfuc) + || fiowfda(fp, vctx->voccxalm, vctx->voccxalc)) + goto ret_error; - /* write run-time vocabulary additions and deletions */ - fnctx.fp = fp; - fnctx.err = 0; - voc_iterate(vctx, MCMONINV, fiosav_voc_cb, &fnctx); - if (fnctx.err) - goto ret_error; + /* write run-time vocabulary additions and deletions */ + fnctx.fp = fp; + fnctx.err = 0; + voc_iterate(vctx, MCMONINV, fiosav_voc_cb, &fnctx); + if (fnctx.err) + goto ret_error; - /* write end marker for vocabulary additions and deletions */ - oswp2(buf+6, MCMONINV); - if (osfwb(fp, buf, 8)) - goto ret_error; + /* write end marker for vocabulary additions and deletions */ + oswp2(buf+6, MCMONINV); + if (osfwb(fp, buf, 8)) + goto ret_error; - /* write the current "Me" object */ - oswp2(buf, vctx->voccxme); - if (osfwb(fp, buf, 2)) - goto ret_error; + /* write the current "Me" object */ + oswp2(buf, vctx->voccxme); + if (osfwb(fp, buf, 2)) + goto ret_error; - /* done - close file and return success indication */ - osfcls(fp); - os_settype(fname, OSFTSAVE); - return FALSE; + /* done - close file and return success indication */ + osfcls(fp); + os_settype(fname, OSFTSAVE); + return FALSE; - /* come here on failure - close file and return error indication */ + /* come here on failure - close file and return error indication */ ret_error: - osfcls(fp); - return TRUE; + osfcls(fp); + return TRUE; } void fioxor(uchar *p, uint siz, uint seed, uint inc) diff --git a/engines/glk/tads/tads2/file_io.h b/engines/glk/tads/tads2/file_io.h index 464a1f93e82..02d0754aee2 100644 --- a/engines/glk/tads/tads2/file_io.h +++ b/engines/glk/tads/tads2/file_io.h @@ -43,19 +43,19 @@ struct tokcxdef; /* load-on-demand context (passed in by mcm in load callback) */ struct fiolcxdef { - osfildef *fiolcxfp; /* file pointer of load file */ - errcxdef *fiolcxerr; /* error handling context */ - ulong fiolcxst; /* starting offset in file */ - uint fiolcxflg; /* flags from original load file */ - uint fiolcxseed; /* fioxor seed */ - uint fiolcxinc; /* fioxor increment */ + osfildef *fiolcxfp; /* file pointer of load file */ + errcxdef *fiolcxerr; /* error handling context */ + ulong fiolcxst; /* starting offset in file */ + uint fiolcxflg; /* flags from original load file */ + uint fiolcxseed; /* fioxor seed */ + uint fiolcxinc; /* fioxor increment */ }; /* write game to binary file */ void fiowrt(struct mcmcxdef *mctx, voccxdef *vctx, - struct tokcxdef *tokctx, struct tokthdef *tab, - uchar *fmts, uint fmtl, char *fname, uint flags, objnum preinit, - int extc, uint prpcnt, char *filever); + struct tokcxdef *tokctx, struct tokthdef *tab, + uchar *fmts, uint fmtl, char *fname, uint flags, objnum preinit, + int extc, uint prpcnt, char *filever); /* flag values for use with fiowrt */ #define FIOFSYM 0x01 /* include symbol table in output file */ diff --git a/engines/glk/tads/tads2/get_string.cpp b/engines/glk/tads/tads2/get_string.cpp index 624b8d95da9..55aa0937f2b 100644 --- a/engines/glk/tads/tads2/get_string.cpp +++ b/engines/glk/tads/tads2/get_string.cpp @@ -58,114 +58,114 @@ extern int scrquiet; */ int getstring(const char *prompt, char *buf, int bufl) { - char *result; - int savemoremode; + char *result; + int savemoremode; int retval = 0; - /* show prompt if one was given and flush output */ - savemoremode = setmore(0); - if (prompt != 0) - { - /* display the prompt text */ - outformat(prompt); + /* show prompt if one was given and flush output */ + savemoremode = setmore(0); + if (prompt != 0) + { + /* display the prompt text */ + outformat(prompt); - /* make sure it shows up in the log file as well */ - out_logfile_print(prompt, FALSE); - } - outflushn(0); - outreset(); + /* make sure it shows up in the log file as well */ + out_logfile_print(prompt, FALSE); + } + outflushn(0); + outreset(); - /* read from the command input file if we have one */ - if (scrfp != 0) - { - int quiet = scrquiet; - - /* try reading from command input file */ - if ((result = qasgets(buf, bufl)) == 0) - { - /* - * End of command input file; return to reading the - * keyboard. If we didn't already show the prompt, show it - * now. - * - * Note that qasgets() will have closed the script file - * before returning eof, so we won't directly read the - * command here but instead handle it later when we check to - * see if we need to read from the keyboard. - */ - if (quiet && prompt != 0) - outformat(prompt); - outflushn(0); - outreset(); + /* read from the command input file if we have one */ + if (scrfp != 0) + { + int quiet = scrquiet; + + /* try reading from command input file */ + if ((result = qasgets(buf, bufl)) == 0) + { + /* + * End of command input file; return to reading the + * keyboard. If we didn't already show the prompt, show it + * now. + * + * Note that qasgets() will have closed the script file + * before returning eof, so we won't directly read the + * command here but instead handle it later when we check to + * see if we need to read from the keyboard. + */ + if (quiet && prompt != 0) + outformat(prompt); + outflushn(0); + outreset(); - /* - * Guarantee that moremode is turned back on. (moremode can - * be turned off for one of two reasons: we're printing the - * prompt, or we're reading from a script with no pauses. - * In either case, moremode should be turned back on at this - * point. -CDN) - */ - savemoremode = 1; + /* + * Guarantee that moremode is turned back on. (moremode can + * be turned off for one of two reasons: we're printing the + * prompt, or we're reading from a script with no pauses. + * In either case, moremode should be turned back on at this + * point. -CDN) + */ + savemoremode = 1; - /* turn off NONSTOP mode now that we're done with the script */ - os_nonstop_mode(FALSE); - } + /* turn off NONSTOP mode now that we're done with the script */ + os_nonstop_mode(FALSE); + } - /* success */ - retval = 0; - } + /* success */ + retval = 0; + } - /* if we don't have a script file, read from the keyboard */ - if (scrfp == 0) - { - /* update the status line */ - runstat(); - - /* read a line from the keyboard */ - result = (char *)os_gets((uchar *)buf, bufl); - - /* - * if the result is null, we're at eof, so return a non-zero - * value; otherwise, we successfully read a command, so return - * zero - */ - retval = (result == 0); - } + /* if we don't have a script file, read from the keyboard */ + if (scrfp == 0) + { + /* update the status line */ + runstat(); + + /* read a line from the keyboard */ + result = (char *)os_gets((uchar *)buf, bufl); + + /* + * if the result is null, we're at eof, so return a non-zero + * value; otherwise, we successfully read a command, so return + * zero + */ + retval = (result == 0); + } - /* restore the original "more" mode */ - setmore(savemoremode); + /* restore the original "more" mode */ + setmore(savemoremode); - /* check the result */ - if (retval != 0) - { - /* we got an error reading the command - return the error */ - return retval; - } - else - { - char *p; - - /* - * we got a command, or at least a partial command (if we timed - * out, we may still have a partial line in the buffer) - write - * the input line to the log and/or command files, as - * appropriate - */ - out_logfile_print(buf, TRUE); - if (cmdfile != 0) - { - os_fprintz(cmdfile, ">"); - os_fprintz(cmdfile, buf); - os_fprintz(cmdfile, "\n"); - } + /* check the result */ + if (retval != 0) + { + /* we got an error reading the command - return the error */ + return retval; + } + else + { + char *p; + + /* + * we got a command, or at least a partial command (if we timed + * out, we may still have a partial line in the buffer) - write + * the input line to the log and/or command files, as + * appropriate + */ + out_logfile_print(buf, TRUE); + if (cmdfile != 0) + { + os_fprintz(cmdfile, ">"); + os_fprintz(cmdfile, buf); + os_fprintz(cmdfile, "\n"); + } - /* translate the input to the internal character set */ - for (p = buf ; *p != '\0' ; ++p) - *p = cmap_n2i(*p); + /* translate the input to the internal character set */ + for (p = buf ; *p != '\0' ; ++p) + *p = cmap_n2i(*p); - /* success */ - return retval; - } + /* success */ + return retval; + } } } // End of namespace TADS2 diff --git a/engines/glk/tads/tads2/lib.h b/engines/glk/tads/tads2/lib.h index 596a66d57da..3df447518a6 100644 --- a/engines/glk/tads/tads2/lib.h +++ b/engines/glk/tads/tads2/lib.h @@ -123,7 +123,7 @@ void varused(); * anything outside of the normal ASCII set as spaces. */ #define t_isspace(c) \ - (((unsigned char)(c)) <= 127 && Common::isSpace((unsigned char)(c))) + (((unsigned char)(c)) <= 127 && Common::isSpace((unsigned char)(c))) } // End of namespace TADS2 } // End of namespace TADS diff --git a/engines/glk/tads/tads2/line_source.h b/engines/glk/tads/tads2/line_source.h index a7e5454c602..61bfe6ff205 100644 --- a/engines/glk/tads/tads2/line_source.h +++ b/engines/glk/tads/tads2/line_source.h @@ -43,49 +43,49 @@ namespace TADS2 { * Line source superclass structure */ struct lindef { - int (*lingetp)(lindef *lin); /* get next line */ - void (*linclsp)(lindef *lin); /* close line source */ - void (*linppos)(lindef *lin, char *buf, uint buflen); - /* write printable rep of position to buf (for error reporting) */ - void (*linglop)(lindef *lin, uchar *buf); - /* generate a line record for an OPCLINE instruction */ - int (*linwrtp)(lindef *lin, osfildef *fp); - /* write line source information to binary file; TRUE ==> error */ - void (*lincmpp)(lindef *lin, uchar *buf); - /* give location of compiled code for current line to line source */ - void (*linactp)(lindef *lin); /* activate for dbg */ - void (*lindisp)(lindef *lin); /* disactivate */ - void (*lintellp)(lindef *lin, uchar *pos); /* get position */ - void (*linseekp)(lindef *lin, uchar *pos); /* seek */ - int (*linreadp)(lindef *lin, uchar *buf, uint siz); /* fread */ - void (*linpaddp)(lindef *lin, uchar *pos, long delta); - /* add an offset to a position value */ - int (*linqtopp)(lindef *lin, uchar *pos); /* at top? */ - int (*lingetsp)(lindef *lin, uchar *buf, uint siz); /* get line */ - void (*linnamp)(lindef *lin, char *buf); /* get source name */ - void (*linfindp)(lindef *lin, char *buf, objnum *objp, - uint *ofsp); /* find nearest line record */ - void (*lingotop)(lindef *lin, int where); /* seek global */ - long (*linofsp)(lindef *lin); /* byte offset in line source */ - void (*linrenp)(lindef *lin, objnum oldnum, objnum newnum); - /* renumber an object (for "modify") */ - void (*lindelp)(lindef *lin, objnum objn); - /* delete an object (for "replace") */ - ulong (*linlnump)(lindef *lin); /* get the current line number */ + int (*lingetp)(lindef *lin); /* get next line */ + void (*linclsp)(lindef *lin); /* close line source */ + void (*linppos)(lindef *lin, char *buf, uint buflen); + /* write printable rep of position to buf (for error reporting) */ + void (*linglop)(lindef *lin, uchar *buf); + /* generate a line record for an OPCLINE instruction */ + int (*linwrtp)(lindef *lin, osfildef *fp); + /* write line source information to binary file; TRUE ==> error */ + void (*lincmpp)(lindef *lin, uchar *buf); + /* give location of compiled code for current line to line source */ + void (*linactp)(lindef *lin); /* activate for dbg */ + void (*lindisp)(lindef *lin); /* disactivate */ + void (*lintellp)(lindef *lin, uchar *pos); /* get position */ + void (*linseekp)(lindef *lin, uchar *pos); /* seek */ + int (*linreadp)(lindef *lin, uchar *buf, uint siz); /* fread */ + void (*linpaddp)(lindef *lin, uchar *pos, long delta); + /* add an offset to a position value */ + int (*linqtopp)(lindef *lin, uchar *pos); /* at top? */ + int (*lingetsp)(lindef *lin, uchar *buf, uint siz); /* get line */ + void (*linnamp)(lindef *lin, char *buf); /* get source name */ + void (*linfindp)(lindef *lin, char *buf, objnum *objp, + uint *ofsp); /* find nearest line record */ + void (*lingotop)(lindef *lin, int where); /* seek global */ + long (*linofsp)(lindef *lin); /* byte offset in line source */ + void (*linrenp)(lindef *lin, objnum oldnum, objnum newnum); + /* renumber an object (for "modify") */ + void (*lindelp)(lindef *lin, objnum objn); + /* delete an object (for "replace") */ + ulong (*linlnump)(lindef *lin); /* get the current line number */ #define LINGOTOP OSFSK_SET /* go to top of line source */ #define LINGOEND OSFSK_END /* go to end of line source */ - lindef *linpar; /* parent of current line source */ - lindef *linnxt; /* next line in line source chain */ - int linid; /* serial number of line source (for debugger) */ - char *linbuf; /* pointer to current line */ - ushort linflg; /* flags */ + lindef *linpar; /* parent of current line source */ + lindef *linnxt; /* next line in line source chain */ + int linid; /* serial number of line source (for debugger) */ + char *linbuf; /* pointer to current line */ + ushort linflg; /* flags */ #define LINFEOF 0x01 /* line source is at end of file */ #define LINFMORE 0x02 /* there's more to the line than linlen */ #define LINFDBG 0x04 /* debug record already generated for line */ #define LINFNOINC 0x08 /* ignore # directives from this line source */ #define LINFCMODE 0x10 /* line source is parsed in C-mode */ - ushort linlen; /* length of the line */ - ushort linlln; /* length of line record generated by lingloc */ + ushort linlen; /* length of the line */ + ushort linlln; /* length of line record generated by lingloc */ }; /** diff --git a/engines/glk/tads/tads2/line_source_file.cpp b/engines/glk/tads/tads2/line_source_file.cpp index 67ad66b628d..67a18ddd830 100644 --- a/engines/glk/tads/tads2/line_source_file.cpp +++ b/engines/glk/tads/tads2/line_source_file.cpp @@ -35,44 +35,44 @@ enum { BYTE_MAX = 0xff }; /* initialize a pre-allocated linfdef, skipping debugger page setup */ void linfini2(mcmcxdef *mctx, linfdef *linf, - const char *filename, int flen, osfildef *fp, int new_line_records) + const char *filename, int flen, osfildef *fp, int new_line_records) { - /* set up method pointers */ - linf->linflin.lingetp = linfget; - linf->linflin.linclsp = linfcls; - linf->linflin.linppos = linfppos; - linf->linflin.linglop = (new_line_records ? linfglop2 : linfglop); - linf->linflin.linwrtp = linfwrt; - linf->linflin.lincmpp = linfcmp; - linf->linflin.linactp = linfact; - linf->linflin.lindisp = linfdis; - linf->linflin.lintellp = linftell; - linf->linflin.linseekp = linfseek; - linf->linflin.linreadp = linfread; - linf->linflin.linpaddp = linfpadd; - linf->linflin.linqtopp = linfqtop; - linf->linflin.lingetsp = linfgets; - linf->linflin.linnamp = linfnam; - linf->linflin.linlnump = linflnum; - linf->linflin.linfindp = linffind; - linf->linflin.lingotop = linfgoto; - linf->linflin.linofsp = linfofs; - linf->linflin.linrenp = linfren; - linf->linflin.lindelp = linfdelnum; + /* set up method pointers */ + linf->linflin.lingetp = linfget; + linf->linflin.linclsp = linfcls; + linf->linflin.linppos = linfppos; + linf->linflin.linglop = (new_line_records ? linfglop2 : linfglop); + linf->linflin.linwrtp = linfwrt; + linf->linflin.lincmpp = linfcmp; + linf->linflin.linactp = linfact; + linf->linflin.lindisp = linfdis; + linf->linflin.lintellp = linftell; + linf->linflin.linseekp = linfseek; + linf->linflin.linreadp = linfread; + linf->linflin.linpaddp = linfpadd; + linf->linflin.linqtopp = linfqtop; + linf->linflin.lingetsp = linfgets; + linf->linflin.linnamp = linfnam; + linf->linflin.linlnump = linflnum; + linf->linflin.linfindp = linffind; + linf->linflin.lingotop = linfgoto; + linf->linflin.linofsp = linfofs; + linf->linflin.linrenp = linfren; + linf->linflin.lindelp = linfdelnum; - /* set up instance data */ - linf->linflin.linbuf = linf->linfbuf; - linf->linflin.linflg = 0; - memcpy(linf->linfnam, filename, (size_t)flen); - linf->linfnam[flen] = '\0'; - linf->linfbuf[0] = '\0'; - linf->linfbufnxt = 0; - linf->linfnxtlen = 0; - linf->linffp = fp; - linf->linfnum = 0; - linf->linflin.linlln = 4; /* OPCLINE operand is seek offset in file */ - linf->linfmem = mctx; /* save memory manager context */ - linf->linfcrec = 0; /* no debugger records written yet */ + /* set up instance data */ + linf->linflin.linbuf = linf->linfbuf; + linf->linflin.linflg = 0; + memcpy(linf->linfnam, filename, (size_t)flen); + linf->linfnam[flen] = '\0'; + linf->linfbuf[0] = '\0'; + linf->linfbufnxt = 0; + linf->linfnxtlen = 0; + linf->linffp = fp; + linf->linfnum = 0; + linf->linflin.linlln = 4; /* OPCLINE operand is seek offset in file */ + linf->linfmem = mctx; /* save memory manager context */ + linf->linfcrec = 0; /* no debugger records written yet */ } /* @@ -82,294 +82,294 @@ void linfini2(mcmcxdef *mctx, linfdef *linf, * for its path name to be filled in later. */ linfdef *linfini(mcmcxdef *mctx, errcxdef *ec, const char *filename, - int flen, tokpdef *path, int must_find_file, - int new_line_records) + int flen, tokpdef *path, int must_find_file, + int new_line_records) { - int i; - objnum *objp; - linfdef *linf; - osfildef *fp = nullptr; - char fbuf[OSFNMAX + 1]; - tokpdef fakepath; - int len; - - if (!path) - { - path = &fakepath; - fakepath.tokpnxt = (tokpdef *)0; - fakepath.tokplen = 0; - } + int i; + objnum *objp; + linfdef *linf; + osfildef *fp = nullptr; + char fbuf[OSFNMAX + 1]; + tokpdef fakepath; + int len; + + if (!path) + { + path = &fakepath; + fakepath.tokpnxt = (tokpdef *)0; + fakepath.tokplen = 0; + } - /* search through the path list */ - for ( ; path ; path = path->tokpnxt) - { - char last; + /* search through the path list */ + for ( ; path ; path = path->tokpnxt) + { + char last; - /* prefix the current path */ - if ((len = path->tokplen) != 0) - { - memcpy(fbuf, path->tokpdir, (size_t)len); - last = fbuf[len - 1]; - if (last == OSPATHCHAR || - (OSPATHALT && strchr(OSPATHALT, last))) - /* do nothing */ ; - else - { - /* append path separator character */ - fbuf[len++] = OSPATHCHAR; - } - } + /* prefix the current path */ + if ((len = path->tokplen) != 0) + { + memcpy(fbuf, path->tokpdir, (size_t)len); + last = fbuf[len - 1]; + if (last == OSPATHCHAR || + (OSPATHALT && strchr(OSPATHALT, last))) + /* do nothing */ ; + else + { + /* append path separator character */ + fbuf[len++] = OSPATHCHAR; + } + } - /* add the filename and null-terminate */ - memcpy(fbuf + len, filename, (size_t)flen); - fbuf[len + flen] = '\0'; - - /* attempt to open this file */ - if ((fp = osfoprs(fbuf, OSFTTEXT)) != 0) - break; - } + /* add the filename and null-terminate */ + memcpy(fbuf + len, filename, (size_t)flen); + fbuf[len + flen] = '\0'; + + /* attempt to open this file */ + if ((fp = osfoprs(fbuf, OSFTTEXT)) != 0) + break; + } - /* - * If no file opened yet, search tads path; if that doesn't work, - * let the debugger UI try to find the file. If nothing works, give - * up and return failure. - */ - if (fp == 0 - && (!os_locate(filename, flen, (char *)0, fbuf, sizeof(fbuf)) - || (fp = osfoprs(fbuf, OSFTTEXT)) == 0)) - { - /* - * Ask the debugger UI for advice. If the debugger isn't - * present, we'll get a failure code from this routine. - */ - if (!dbgu_find_src(filename, flen, fbuf, sizeof(fbuf), - must_find_file)) - return 0; + /* + * If no file opened yet, search tads path; if that doesn't work, + * let the debugger UI try to find the file. If nothing works, give + * up and return failure. + */ + if (fp == 0 + && (!os_locate(filename, flen, (char *)0, fbuf, sizeof(fbuf)) + || (fp = osfoprs(fbuf, OSFTTEXT)) == 0)) + { + /* + * Ask the debugger UI for advice. If the debugger isn't + * present, we'll get a failure code from this routine. + */ + if (!dbgu_find_src(filename, flen, fbuf, sizeof(fbuf), + must_find_file)) + return 0; - /* try opening the file */ - if (fbuf[0] == '\0') - { - /* - * we didn't get a filename - the UI wants to defer finding - * the file until later - */ - fp = 0; - } - else - { - /* we got a filename from the UI - try opening it */ - fp = osfoprs(fbuf, OSFTTEXT); - } + /* try opening the file */ + if (fbuf[0] == '\0') + { + /* + * we didn't get a filename - the UI wants to defer finding + * the file until later + */ + fp = 0; + } + else + { + /* we got a filename from the UI - try opening it */ + fp = osfoprs(fbuf, OSFTTEXT); + } - /* - * if the file isn't present, and we're required to find it, - * return failure - */ - if (fp == 0 && must_find_file) - return 0; - } - - /* figure out how much space we need for the file's full name */ - if (fp == 0) - { - /* - * we didn't find the file, so we don't yet know its name - use - * the maximum possible filename length for the buffer size, so - * that we can store the final filename if we should figure out - * where the file is later on - */ - fbuf[0] = '\0'; - len = sizeof(fbuf); - } - else - { - /* - * we found the file, so we have its final name - allocate space - * for the known name - */ - len = (int)strlen(fbuf); - } + /* + * if the file isn't present, and we're required to find it, + * return failure + */ + if (fp == 0 && must_find_file) + return 0; + } + + /* figure out how much space we need for the file's full name */ + if (fp == 0) + { + /* + * we didn't find the file, so we don't yet know its name - use + * the maximum possible filename length for the buffer size, so + * that we can store the final filename if we should figure out + * where the file is later on + */ + fbuf[0] = '\0'; + len = sizeof(fbuf); + } + else + { + /* + * we found the file, so we have its final name - allocate space + * for the known name + */ + len = (int)strlen(fbuf); + } - /* allocate the linfdef */ - linf = (linfdef *)mchalo(ec, (ushort)(sizeof(linfdef) + flen - + len + 1), "linfini"); + /* allocate the linfdef */ + linf = (linfdef *)mchalo(ec, (ushort)(sizeof(linfdef) + flen + + len + 1), "linfini"); - /* do the basic initialization */ - linfini2(mctx, linf, filename, flen, fp, new_line_records); + /* do the basic initialization */ + linfini2(mctx, linf, filename, flen, fp, new_line_records); - memcpy(linf->linfnam + flen + 1, fbuf, (size_t)len); - linf->linfnam[flen + 1 + len] = '\0'; - - /* set all debugger pages to not-yet-allocated */ - for (i = LINFPGMAX, objp = linf->linfpg ; i ; ++objp, --i) - *objp = MCMONINV; + memcpy(linf->linfnam + flen + 1, fbuf, (size_t)len); + linf->linfnam[flen + 1 + len] = '\0'; + + /* set all debugger pages to not-yet-allocated */ + for (i = LINFPGMAX, objp = linf->linfpg ; i ; ++objp, --i) + *objp = MCMONINV; - /* return the new line source object */ - return linf; + /* return the new line source object */ + return linf; } int linfget(lindef *lin) { # define linf ((linfdef *)lin) - char *p; - size_t rdlen; - int nl_len; + char *p; + size_t rdlen; + int nl_len; - /* remember seek position of start of current line */ - linf->linfseek = osfpos(linf->linffp); + /* remember seek position of start of current line */ + linf->linfseek = osfpos(linf->linffp); - /* - * if we have data left in the buffer after the end of this line, - * move it to the start of the buffer - */ - if (linf->linfnxtlen != 0) - { - /* move the data down */ - memmove(linf->linfbuf, linf->linfbuf + linf->linfbufnxt, - linf->linfnxtlen); + /* + * if we have data left in the buffer after the end of this line, + * move it to the start of the buffer + */ + if (linf->linfnxtlen != 0) + { + /* move the data down */ + memmove(linf->linfbuf, linf->linfbuf + linf->linfbufnxt, + linf->linfnxtlen); - /* - * adjust the seek position to account for the fact that we've - * read ahead in the file - */ - linf->linfseek -= linf->linfnxtlen; + /* + * adjust the seek position to account for the fact that we've + * read ahead in the file + */ + linf->linfseek -= linf->linfnxtlen; - /* - * Fill up the rest of the buffer. Leave one byte for a null - * terminator and one byte for a possible extra newline pair - * character (see below), hence fill to sizeof(buf)-2. - */ - rdlen = osfrbc(linf->linffp, linf->linfbuf + linf->linfnxtlen, - sizeof(linf->linfbuf) - linf->linfnxtlen - 2); + /* + * Fill up the rest of the buffer. Leave one byte for a null + * terminator and one byte for a possible extra newline pair + * character (see below), hence fill to sizeof(buf)-2. + */ + rdlen = osfrbc(linf->linffp, linf->linfbuf + linf->linfnxtlen, + sizeof(linf->linfbuf) - linf->linfnxtlen - 2); - /* - * the total space is the amount we had left over plus the - * amount we just read - */ - rdlen += linf->linfnxtlen; - } - else - { - /* - * We have nothing in the buffer - fill it up. Fill to - * sizeof(buf)-2 to leave room for a null terminator plus a - * possible extra newline pair character (see below). - */ - rdlen = osfrbc(linf->linffp, linf->linfbuf, - sizeof(linf->linfbuf) - 2); - } + /* + * the total space is the amount we had left over plus the + * amount we just read + */ + rdlen += linf->linfnxtlen; + } + else + { + /* + * We have nothing in the buffer - fill it up. Fill to + * sizeof(buf)-2 to leave room for a null terminator plus a + * possible extra newline pair character (see below). + */ + rdlen = osfrbc(linf->linffp, linf->linfbuf, + sizeof(linf->linfbuf) - 2); + } - /* - * if there's nothing in the buffer at this point, we've reached the - * end of the file - */ - if (rdlen == 0) - return TRUE; + /* + * if there's nothing in the buffer at this point, we've reached the + * end of the file + */ + if (rdlen == 0) + return TRUE; - /* - * if the last line was not a continuation line, increment the line - * counter for the start of a new line - */ - if (!(lin->linflg & LINFMORE)) - ++(linf->linfnum); + /* + * if the last line was not a continuation line, increment the line + * counter for the start of a new line + */ + if (!(lin->linflg & LINFMORE)) + ++(linf->linfnum); - /* null-terminate the buffer contents */ - linf->linfbuf[rdlen] = '\0'; + /* null-terminate the buffer contents */ + linf->linfbuf[rdlen] = '\0'; - /* perform character mapping on th new part only */ - for (p = linf->linfbuf + linf->linfnxtlen ; *p != '\0' ; ++p) - *p = cmap_n2i(*p); + /* perform character mapping on th new part only */ + for (p = linf->linfbuf + linf->linfnxtlen ; *p != '\0' ; ++p) + *p = cmap_n2i(*p); - /* - * scan the for the first newline in the buffer, allowing newline - * conventions that involve either CR or LF - */ - for (p = linf->linfbuf ; *p != '\n' && *p != '\r' && *p != '\0' ; ++p) ; + /* + * scan the for the first newline in the buffer, allowing newline + * conventions that involve either CR or LF + */ + for (p = linf->linfbuf ; *p != '\n' && *p != '\r' && *p != '\0' ; ++p) ; - /* - * Check to see if this character is followed by its newline pair - * complement, to allow for either CR-LF or LF-CR sequences, as well - * as plain single-byte newline (CR or LF) sequences. - * - * First, though, one weird special case: if this character is at - * the read limit in the buffer, the complementary character might - * be lurking in the next byte that we haven't read. In this case, - * use that one-byte reserve we have left (we filled the buffer only - * to length-2 so far) and read the next byte. - */ - if (*p != '\0' && p + 1 == linf->linfbuf + sizeof(linf->linfbuf) - 2) - { - /* - * we've filled the buffer to but not including the reserve for - * just this case - fetch the extra character - */ - if (osfrbc(linf->linffp, p + 1, 1) == 1) - { - /* increase the total read length for the extra byte */ - ++rdlen; - *(p+2) = '\0'; - } - } + /* + * Check to see if this character is followed by its newline pair + * complement, to allow for either CR-LF or LF-CR sequences, as well + * as plain single-byte newline (CR or LF) sequences. + * + * First, though, one weird special case: if this character is at + * the read limit in the buffer, the complementary character might + * be lurking in the next byte that we haven't read. In this case, + * use that one-byte reserve we have left (we filled the buffer only + * to length-2 so far) and read the next byte. + */ + if (*p != '\0' && p + 1 == linf->linfbuf + sizeof(linf->linfbuf) - 2) + { + /* + * we've filled the buffer to but not including the reserve for + * just this case - fetch the extra character + */ + if (osfrbc(linf->linffp, p + 1, 1) == 1) + { + /* increase the total read length for the extra byte */ + ++rdlen; + *(p+2) = '\0'; + } + } - /* - * now we can check for the newline type, since we have definitely - * read the full paired sequence - */ - if (*p == '\0') - { - /* there's no newline in the buffer - we'll return a partial line */ - nl_len = 0; + /* + * now we can check for the newline type, since we have definitely + * read the full paired sequence + */ + if (*p == '\0') + { + /* there's no newline in the buffer - we'll return a partial line */ + nl_len = 0; - /* set the partial line flag */ - lin->linflg |= LINFMORE; + /* set the partial line flag */ + lin->linflg |= LINFMORE; - /* return the entire buffer */ - lin->linlen = rdlen; + /* return the entire buffer */ + lin->linlen = rdlen; - /* there's nothing left for the next time through */ - linf->linfnxtlen = 0; - } - else - { - /* check for a complementary pair */ - if ((*p == '\n' && *(p+1) == '\r') || (*p == '\r' && *(p+1) == '\n')) - { - /* we have a paired newline */ - nl_len = 2; - } - else - { - /* we have but a single-character newline sequence */ - nl_len = 1; - } + /* there's nothing left for the next time through */ + linf->linfnxtlen = 0; + } + else + { + /* check for a complementary pair */ + if ((*p == '\n' && *(p+1) == '\r') || (*p == '\r' && *(p+1) == '\n')) + { + /* we have a paired newline */ + nl_len = 2; + } + else + { + /* we have but a single-character newline sequence */ + nl_len = 1; + } - /* this is the end of a line */ - lin->linflg &= ~LINFMORE; + /* this is the end of a line */ + lin->linflg &= ~LINFMORE; - /* - * return only the part of the buffer up to, but not including, - * the newline - */ - lin->linlen = (p - linf->linfbuf); + /* + * return only the part of the buffer up to, but not including, + * the newline + */ + lin->linlen = (p - linf->linfbuf); - /* null-terminate the buffer at the newline */ - *p = '\0'; + /* null-terminate the buffer at the newline */ + *p = '\0'; - /* - * anything remaining after the newline sequence is available - * for reading the next time through - */ - linf->linfbufnxt = ((p + nl_len) - linf->linfbuf); - linf->linfnxtlen = rdlen - linf->linfbufnxt; - } + /* + * anything remaining after the newline sequence is available + * for reading the next time through + */ + linf->linfbufnxt = ((p + nl_len) - linf->linfbuf); + linf->linfnxtlen = rdlen - linf->linfbufnxt; + } - /* make sure buffer pointer is correct */ - lin->linbuf = linf->linfbuf; + /* make sure buffer pointer is correct */ + lin->linbuf = linf->linfbuf; - LINFDEBUG(debug(10, "%s\n", linf->linfbuf)); + LINFDEBUG(debug(10, "%s\n", linf->linfbuf)); - /* success */ - return FALSE; + /* success */ + return FALSE; # undef linf } @@ -377,61 +377,61 @@ int linfget(lindef *lin) /* make printable string from position in file (for error reporting) */ void linfppos(lindef *lin, char *buf, uint buflen) { - VARUSED(buflen); - - sprintf(buf, "%s(%lu): ", ((linfdef *)lin)->linfnam, - ((linfdef *)lin)->linfnum); + VARUSED(buflen); + + sprintf(buf, "%s(%lu): ", ((linfdef *)lin)->linfnam, + ((linfdef *)lin)->linfnum); } /* close line source */ void linfcls(lindef *lin) { - osfcls(((linfdef *)lin)->linffp); + osfcls(((linfdef *)lin)->linffp); } /* generate operand of OPCLINE (source-line debug) instruction */ void linfglop(lindef *lin, uchar *buf) { - oswp4(buf, ((linfdef *)lin)->linfseek); /* save seek position of line */ + oswp4(buf, ((linfdef *)lin)->linfseek); /* save seek position of line */ } /* generate new-style operand of OPCLINE instruction */ void linfglop2(lindef *lin, uchar *buf) { - oswp4(buf, ((linfdef *)lin)->linfnum); /* save seek position of line */ + oswp4(buf, ((linfdef *)lin)->linfnum); /* save seek position of line */ } /* save line source information to binary (.gam) file; TRUE ==> error */ int linfwrt(lindef *lin, osfildef *fp) { #define linf ((linfdef *)lin) - uchar buf[BYTE_MAX + 6]; - size_t len; - uint pgcnt; - uchar *objp; - mcmon *objn; + uchar buf[BYTE_MAX + 6]; + size_t len; + uint pgcnt; + uchar *objp; + mcmon *objn; - buf[0] = lin->linid; - len = strlen(linf->linfnam); - if (len > BYTE_MAX) - return FALSE; - buf[1] = (uchar)len; - oswp4(buf + 2, linf->linfcrec); - memcpy(buf + 6, linf->linfnam, (size_t)buf[1]); - if (osfwb(fp, buf, (int)(buf[1] + 6))) return(TRUE); - - /* write the debug source pages */ - if (!linf->linfcrec) return(FALSE); /* no debug records at all */ - pgcnt = 1 + ((linf->linfcrec - 1) >> 10); /* figure number of pages */ - - for (objn = linf->linfpg ; pgcnt ; ++objn, --pgcnt) - { - objp = mcmlck(linf->linfmem, *objn); - if (osfwb(fp, objp, (1024 * DBGLINFSIZ))) return(TRUE); - mcmunlck(linf->linfmem, *objn); - } - - return(FALSE); + buf[0] = lin->linid; + len = strlen(linf->linfnam); + if (len > BYTE_MAX) + return FALSE; + buf[1] = (uchar)len; + oswp4(buf + 2, linf->linfcrec); + memcpy(buf + 6, linf->linfnam, (size_t)buf[1]); + if (osfwb(fp, buf, (int)(buf[1] + 6))) return(TRUE); + + /* write the debug source pages */ + if (!linf->linfcrec) return(FALSE); /* no debug records at all */ + pgcnt = 1 + ((linf->linfcrec - 1) >> 10); /* figure number of pages */ + + for (objn = linf->linfpg ; pgcnt ; ++objn, --pgcnt) + { + objp = mcmlck(linf->linfmem, *objn); + if (osfwb(fp, objp, (1024 * DBGLINFSIZ))) return(TRUE); + mcmunlck(linf->linfmem, *objn); + } + + return(FALSE); # undef linf } @@ -439,90 +439,90 @@ int linfwrt(lindef *lin, osfildef *fp) /* load a file-line-source from binary (.gam) file */ int linfload(osfildef *fp, dbgcxdef *dbgctx, errcxdef *ec, tokpdef *path) { - linfdef *linf; - uchar buf[BYTE_MAX + 6]; - uint pgcnt; - uchar *objp; - mcmon *objn; - - /* read the source's description from the file */ - if (osfrb(fp, buf, 6) - || osfrb(fp, buf + 6, (int)buf[1])) - return TRUE; - - /* initialize the linfdef */ - if (!(linf = linfini(dbgctx->dbgcxmem, ec, (char *)buf + 6, - (int)buf[1], path, FALSE, FALSE))) - { - errlog1(ec, ERR_NOSOURC, ERRTSTR, - errstr(ec, (char *)buf+6, (int)buf[1])); - return TRUE; - } - - /* if we opened the file, close it - don't hold all files open */ - if (linf->linffp != 0) - { - osfcls(linf->linffp); - linf->linffp = 0; - } - - /* link into debug line source chain */ - linf->linflin.linnxt = dbgctx->dbgcxlin; - dbgctx->dbgcxlin = &linf->linflin; - linf->linflin.linid = buf[0]; - linf->linfcrec = osrp4(buf + 2); - - /* make sure the max line id is set above current line */ - if (buf[0] >= dbgctx->dbgcxfid) - dbgctx->dbgcxfid = buf[0] + 1; - - /* make sure we have some debug records */ - if (!linf->linfcrec) - return FALSE; + linfdef *linf; + uchar buf[BYTE_MAX + 6]; + uint pgcnt; + uchar *objp; + mcmon *objn; + + /* read the source's description from the file */ + if (osfrb(fp, buf, 6) + || osfrb(fp, buf + 6, (int)buf[1])) + return TRUE; + + /* initialize the linfdef */ + if (!(linf = linfini(dbgctx->dbgcxmem, ec, (char *)buf + 6, + (int)buf[1], path, FALSE, FALSE))) + { + errlog1(ec, ERR_NOSOURC, ERRTSTR, + errstr(ec, (char *)buf+6, (int)buf[1])); + return TRUE; + } + + /* if we opened the file, close it - don't hold all files open */ + if (linf->linffp != 0) + { + osfcls(linf->linffp); + linf->linffp = 0; + } + + /* link into debug line source chain */ + linf->linflin.linnxt = dbgctx->dbgcxlin; + dbgctx->dbgcxlin = &linf->linflin; + linf->linflin.linid = buf[0]; + linf->linfcrec = osrp4(buf + 2); + + /* make sure the max line id is set above current line */ + if (buf[0] >= dbgctx->dbgcxfid) + dbgctx->dbgcxfid = buf[0] + 1; + + /* make sure we have some debug records */ + if (!linf->linfcrec) + return FALSE; - /* figure number of pages */ - pgcnt = 1 + ((linf->linfcrec - 1) >> 10); - - /* allocate and read the debug source pages */ - for (objn = linf->linfpg ; pgcnt ; ++objn, --pgcnt) - { - objp = mcmalo(linf->linfmem, (ushort)(1024 * DBGLINFSIZ), objn); - if (osfrb(fp, objp, (1024 * DBGLINFSIZ))) return(TRUE); - mcmunlck(linf->linfmem, *objn); - } + /* figure number of pages */ + pgcnt = 1 + ((linf->linfcrec - 1) >> 10); + + /* allocate and read the debug source pages */ + for (objn = linf->linfpg ; pgcnt ; ++objn, --pgcnt) + { + objp = mcmalo(linf->linfmem, (ushort)(1024 * DBGLINFSIZ), objn); + if (osfrb(fp, objp, (1024 * DBGLINFSIZ))) return(TRUE); + mcmunlck(linf->linfmem, *objn); + } - /* success */ - return FALSE; + /* success */ + return FALSE; } /* add a debugger line record for the current line being compiled */ void linfcmp(lindef *lin, uchar *buf) { - uint pg; - uchar *objptr; + uint pg; + uchar *objptr; # define linf ((linfdef *)lin) - /* figure out which page to use, and lock it */ - pg = linf->linfcrec >> 10; /* 2^10 records per page */ - if (pg >= LINFPGMAX) - errsig(linf->linfmem->mcmcxgl->mcmcxerr, ERR_MANYDBG); - if (linf->linfpg[pg] == MCMONINV) - objptr = mcmalo(linf->linfmem, (ushort)(1024 * DBGLINFSIZ), - &linf->linfpg[pg]); - else - objptr = mcmlck(linf->linfmem, linf->linfpg[pg]); - - /* write the record to the appropriate offset within the page */ - memcpy(objptr + (linf->linfcrec & 1023) * DBGLINFSIZ, buf, - (size_t)DBGLINFSIZ); - - /* increment counter of line records so far */ - ++(linf->linfcrec); - - /* done with page - touch it and unlock it */ - mcmtch(linf->linfmem, linf->linfpg[pg]); - mcmunlck(linf->linfmem, linf->linfpg[pg]); - + /* figure out which page to use, and lock it */ + pg = linf->linfcrec >> 10; /* 2^10 records per page */ + if (pg >= LINFPGMAX) + errsig(linf->linfmem->mcmcxgl->mcmcxerr, ERR_MANYDBG); + if (linf->linfpg[pg] == MCMONINV) + objptr = mcmalo(linf->linfmem, (ushort)(1024 * DBGLINFSIZ), + &linf->linfpg[pg]); + else + objptr = mcmlck(linf->linfmem, linf->linfpg[pg]); + + /* write the record to the appropriate offset within the page */ + memcpy(objptr + (linf->linfcrec & 1023) * DBGLINFSIZ, buf, + (size_t)DBGLINFSIZ); + + /* increment counter of line records so far */ + ++(linf->linfcrec); + + /* done with page - touch it and unlock it */ + mcmtch(linf->linfmem, linf->linfpg[pg]); + mcmunlck(linf->linfmem, linf->linfpg[pg]); + # undef linf } @@ -534,45 +534,45 @@ void linfcmp(lindef *lin, uchar *buf) void linfren(lindef *lin, objnum oldnum, objnum newnum) { # define linf ((linfdef *)lin) - uint pgcnt; - uchar *objp; - mcmon *pgobjn; - int i; - int pgtot; - int tot; + uint pgcnt; + uchar *objp; + mcmon *pgobjn; + int i; + int pgtot; + int tot; - /* figure the number of pages - if no lines, stop now */ - tot = linf->linfcrec; - if (tot == 0) - return; + /* figure the number of pages - if no lines, stop now */ + tot = linf->linfcrec; + if (tot == 0) + return; - /* calculate the number of pages to check */ - pgcnt = 1 + ((tot - 1) >> 10); + /* calculate the number of pages to check */ + pgcnt = 1 + ((tot - 1) >> 10); - /* scan each page */ - for (pgobjn = linf->linfpg ; pgcnt ; ++pgobjn, --pgcnt, tot -= 1024) - { - /* lock the page */ - objp = mcmlck(linf->linfmem, *pgobjn); + /* scan each page */ + for (pgobjn = linf->linfpg ; pgcnt ; ++pgobjn, --pgcnt, tot -= 1024) + { + /* lock the page */ + objp = mcmlck(linf->linfmem, *pgobjn); - /* figure the number on this page */ - pgtot = (tot > 1024 ? 1024 : tot); + /* figure the number on this page */ + pgtot = (tot > 1024 ? 1024 : tot); - /* scan each record on this page */ - for (i = 0 ; i < pgtot ; ++i, objp += DBGLINFSIZ) - { - /* check this one */ - if (osrp2(objp) == oldnum) - { - /* it matches - renumber it */ - oswp2(objp, newnum); - } - } + /* scan each record on this page */ + for (i = 0 ; i < pgtot ; ++i, objp += DBGLINFSIZ) + { + /* check this one */ + if (osrp2(objp) == oldnum) + { + /* it matches - renumber it */ + oswp2(objp, newnum); + } + } - /* done with the page - touch it and unlock it */ - mcmtch(linf->linfmem, *pgobjn); - mcmunlck(linf->linfmem, *pgobjn); - } + /* done with the page - touch it and unlock it */ + mcmtch(linf->linfmem, *pgobjn); + mcmunlck(linf->linfmem, *pgobjn); + } # undef linf } @@ -585,143 +585,143 @@ void linfren(lindef *lin, objnum oldnum, objnum newnum) void linfdelnum(lindef *lin, objnum objn) { # define linf ((linfdef *)lin) - uint pgcnt; - uchar *objp; - uchar *objp_orig; - mcmon *pgobjn; - int i; - int pgtot; - int tot; + uint pgcnt; + uchar *objp; + uchar *objp_orig; + mcmon *pgobjn; + int i; + int pgtot; + int tot; - /* figure the number of pages - if no lines, stop now */ - tot = linf->linfcrec; - if (tot == 0) - return; + /* figure the number of pages - if no lines, stop now */ + tot = linf->linfcrec; + if (tot == 0) + return; - /* calculate the number of pages to check */ - pgcnt = 1 + ((tot - 1) >> 10); + /* calculate the number of pages to check */ + pgcnt = 1 + ((tot - 1) >> 10); - /* scan each page */ - for (pgobjn = linf->linfpg ; pgcnt ; ++pgobjn, --pgcnt, tot -= 1024) - { - /* lock the page */ - objp = objp_orig = mcmlck(linf->linfmem, *pgobjn); + /* scan each page */ + for (pgobjn = linf->linfpg ; pgcnt ; ++pgobjn, --pgcnt, tot -= 1024) + { + /* lock the page */ + objp = objp_orig = mcmlck(linf->linfmem, *pgobjn); - /* figure the number on this page */ - pgtot = (tot > 1024 ? 1024 : tot); + /* figure the number on this page */ + pgtot = (tot > 1024 ? 1024 : tot); - /* scan each record on this page */ - for (i = 0 ; i < pgtot ; ++i, objp += DBGLINFSIZ) - { - int j; - - /* check this one */ - if (osrp2(objp) == objn) - { - uchar *nxtp; - uint pg; - int delcnt; - int totrem; - - /* - * it matches - delete it, along with any subsequent - * contiguous entries that also match it - */ - for (delcnt = 1, j = i + 1 ; j < pgtot ; ++j, ++delcnt) - { - /* - * if this one doesn't match, we've found the end of - * the contiguous records for this object - */ - if (osrp2(objp + (j - i)*DBGLINFSIZ) != objn) - break; - } + /* scan each record on this page */ + for (i = 0 ; i < pgtot ; ++i, objp += DBGLINFSIZ) + { + int j; + + /* check this one */ + if (osrp2(objp) == objn) + { + uchar *nxtp; + uint pg; + int delcnt; + int totrem; + + /* + * it matches - delete it, along with any subsequent + * contiguous entries that also match it + */ + for (delcnt = 1, j = i + 1 ; j < pgtot ; ++j, ++delcnt) + { + /* + * if this one doesn't match, we've found the end of + * the contiguous records for this object + */ + if (osrp2(objp + (j - i)*DBGLINFSIZ) != objn) + break; + } - /* close up the gap on this page */ - if (j < pgtot) - memmove(objp, objp + delcnt*DBGLINFSIZ, - (pgtot - j)*DBGLINFSIZ); + /* close up the gap on this page */ + if (j < pgtot) + memmove(objp, objp + delcnt*DBGLINFSIZ, + (pgtot - j)*DBGLINFSIZ); - /* - * if this isn't the last page, copy the bottom of the - * next page to the gap at the top of this page - */ - if (pgcnt > 1) - { - /* lock the next page */ - nxtp = mcmlck(linf->linfmem, *(pgobjn + 1)); + /* + * if this isn't the last page, copy the bottom of the + * next page to the gap at the top of this page + */ + if (pgcnt > 1) + { + /* lock the next page */ + nxtp = mcmlck(linf->linfmem, *(pgobjn + 1)); - /* - * copy from the beginning of the next page to the - * end of this page - */ - memcpy(objp_orig + (pgtot - delcnt)*DBGLINFSIZ, - nxtp, delcnt*DBGLINFSIZ); + /* + * copy from the beginning of the next page to the + * end of this page + */ + memcpy(objp_orig + (pgtot - delcnt)*DBGLINFSIZ, + nxtp, delcnt*DBGLINFSIZ); - /* done with the page */ - mcmunlck(linf->linfmem, *(pgobjn + 1)); - } - else - { - /* - * this is the last page, so there's no next page to - * copy items from - reduce the count of items on - * this page accordingly - */ - pgtot -= delcnt; - } + /* done with the page */ + mcmunlck(linf->linfmem, *(pgobjn + 1)); + } + else + { + /* + * this is the last page, so there's no next page to + * copy items from - reduce the count of items on + * this page accordingly + */ + pgtot -= delcnt; + } - /* - * Now rearrange all subsequent pages to accommodate the - * gap we just created - */ - for (totrem = tot, pg = 1 ; pg < pgcnt ; - totrem -= 1024, ++pg) - { - uchar *curp; - int curtot; + /* + * Now rearrange all subsequent pages to accommodate the + * gap we just created + */ + for (totrem = tot, pg = 1 ; pg < pgcnt ; + totrem -= 1024, ++pg) + { + uchar *curp; + int curtot; - /* figure how many we have on this page */ - curtot = (totrem > 1024 ? 1024 : totrem); - - /* lock this page */ - curp = mcmlck(linf->linfmem, *(pgobjn + pg)); + /* figure how many we have on this page */ + curtot = (totrem > 1024 ? 1024 : totrem); + + /* lock this page */ + curp = mcmlck(linf->linfmem, *(pgobjn + pg)); - /* delete from the start of this page */ - memmove(curp, curp + delcnt*DBGLINFSIZ, - (curtot - delcnt)*DBGLINFSIZ); + /* delete from the start of this page */ + memmove(curp, curp + delcnt*DBGLINFSIZ, + (curtot - delcnt)*DBGLINFSIZ); - /* if there's another page, copy from it */ - if (pg + 1 < pgcnt) - { - /* lock the next page */ - nxtp = mcmlck(linf->linfmem, *(pgobjn + pg + 1)); + /* if there's another page, copy from it */ + if (pg + 1 < pgcnt) + { + /* lock the next page */ + nxtp = mcmlck(linf->linfmem, *(pgobjn + pg + 1)); - /* - * copy from the start of the next page to the - * end of this page - */ - memcpy(curp + (curtot - delcnt)*DBGLINFSIZ, - nxtp, delcnt*DBGLINFSIZ); + /* + * copy from the start of the next page to the + * end of this page + */ + memcpy(curp + (curtot - delcnt)*DBGLINFSIZ, + nxtp, delcnt*DBGLINFSIZ); - /* unlock it */ - mcmunlck(linf->linfmem, *(pgobjn + pg + 1)); - } + /* unlock it */ + mcmunlck(linf->linfmem, *(pgobjn + pg + 1)); + } - /* done with the page - touch it and unlock it */ - mcmtch(linf->linfmem, *(pgobjn + pg)); - mcmunlck(linf->linfmem, *(pgobjn + pg)); - } + /* done with the page - touch it and unlock it */ + mcmtch(linf->linfmem, *(pgobjn + pg)); + mcmunlck(linf->linfmem, *(pgobjn + pg)); + } - /* deduct the removed records from the total */ - linf->linfcrec -= delcnt; - } - } + /* deduct the removed records from the total */ + linf->linfcrec -= delcnt; + } + } - /* done with the page - touch it and unlock it */ - mcmtch(linf->linfmem, *pgobjn); - mcmunlck(linf->linfmem, *pgobjn); - } + /* done with the page - touch it and unlock it */ + mcmtch(linf->linfmem, *pgobjn); + mcmunlck(linf->linfmem, *pgobjn); + } # undef linf } @@ -731,73 +731,73 @@ void linfdelnum(lindef *lin, objnum objn) void linffind(lindef *lin, char *buf, objnum *objp, uint *ofsp) { # define linf ((linfdef *)lin) - uint pg; - uchar *objptr; - uchar *bufptr; - long first; - long last; - long cur; - ulong seekpos; + uint pg; + uchar *objptr; + uchar *bufptr; + long first; + long last; + long cur; + ulong seekpos; ulong curpos = 0; - objnum objn; - uint ofs; + objnum objn; + uint ofs; - /* get desired seek position out of buffer */ - seekpos = osrp4(buf); + /* get desired seek position out of buffer */ + seekpos = osrp4(buf); - /* we haven't traversed any records yet */ - objn = MCMONINV; - ofs = 0; - - /* run a binary search for the indicated line record */ - first = 0; - last = linf->linfcrec - 1; - for (;;) - { - /* make sure we're not out of records entirely */ - if (first > last) - { - /* return the most recent record found - it's closest */ - *objp = objn; - *ofsp = ofs; + /* we haven't traversed any records yet */ + objn = MCMONINV; + ofs = 0; + + /* run a binary search for the indicated line record */ + first = 0; + last = linf->linfcrec - 1; + for (;;) + { + /* make sure we're not out of records entirely */ + if (first > last) + { + /* return the most recent record found - it's closest */ + *objp = objn; + *ofsp = ofs; - /* set the position to that of the line we actually found */ - oswp4(buf, curpos); - return; - } + /* set the position to that of the line we actually found */ + oswp4(buf, curpos); + return; + } - /* split the difference */ - cur = first + (last - first)/2; + /* split the difference */ + cur = first + (last - first)/2; - /* calculate the page containing this item */ - pg = cur >> 10; - - /* get object + offset corresponding to current source line */ - objptr = mcmlck(linf->linfmem, linf->linfpg[pg]); - bufptr = objptr + ((cur & 1023) * DBGLINFSIZ); - objn = osrp2(bufptr); - ofs = osrp2(bufptr + 2); - mcmunlck(linf->linfmem, linf->linfpg[pg]); + /* calculate the page containing this item */ + pg = cur >> 10; + + /* get object + offset corresponding to current source line */ + objptr = mcmlck(linf->linfmem, linf->linfpg[pg]); + bufptr = objptr + ((cur & 1023) * DBGLINFSIZ); + objn = osrp2(bufptr); + ofs = osrp2(bufptr + 2); + mcmunlck(linf->linfmem, linf->linfpg[pg]); - /* read user data out of the object's OPCLINE record */ - objptr = mcmlck(linf->linfmem, (mcmon)objn); - bufptr = objptr + ofs + 5; - curpos = osrp4(bufptr); - mcmunlck(linf->linfmem, (mcmon)objn); + /* read user data out of the object's OPCLINE record */ + objptr = mcmlck(linf->linfmem, (mcmon)objn); + bufptr = objptr + ofs + 5; + curpos = osrp4(bufptr); + mcmunlck(linf->linfmem, (mcmon)objn); - /* see what we have */ - if (curpos == seekpos) - { - *objp = objn; - *ofsp = ofs; - return; - } - else if (curpos < seekpos) - first = (cur == first ? first + 1 : cur); - else - last = (cur == last ? last - 1 : cur); - } - + /* see what we have */ + if (curpos == seekpos) + { + *objp = objn; + *ofsp = ofs; + return; + } + else if (curpos < seekpos) + first = (cur == first ? first + 1 : cur); + else + last = (cur == last ? last - 1 : cur); + } + # undef linf } @@ -806,60 +806,60 @@ void linffind(lindef *lin, char *buf, objnum *objp, uint *ofsp) */ void linf_copy_linerecs(linfdef *linf, struct linfinfo *info) { - uint pg; - uint prvpg; - uchar *objptr; - uchar *bufptr; - long last; - long cur; + uint pg; + uint prvpg; + uchar *objptr; + uchar *bufptr; + long last; + long cur; - /* note the last element */ - last = linf->linfcrec; + /* note the last element */ + last = linf->linfcrec; - /* if there are no records, there's nothing to do */ - if (last == 0) - return; + /* if there are no records, there's nothing to do */ + if (last == 0) + return; - /* load the first page of records */ - prvpg = 0; - pg = 0; - objptr = mcmlck(linf->linfmem, linf->linfpg[0]); + /* load the first page of records */ + prvpg = 0; + pg = 0; + objptr = mcmlck(linf->linfmem, linf->linfpg[0]); - /* scan the records */ - for (cur = 0 ; cur < last ; ++cur, ++info) - { - uchar *codeptr; - - /* calculate the page containing this item */ - pg = cur >> 10; + /* scan the records */ + for (cur = 0 ; cur < last ; ++cur, ++info) + { + uchar *codeptr; + + /* calculate the page containing this item */ + pg = cur >> 10; - /* if it's different than the last page, load the next page */ - if (pg != prvpg) - { - /* unlock the previous page */ - mcmunlck(linf->linfmem, linf->linfpg[prvpg]); + /* if it's different than the last page, load the next page */ + if (pg != prvpg) + { + /* unlock the previous page */ + mcmunlck(linf->linfmem, linf->linfpg[prvpg]); - /* load the next page */ - objptr = mcmlck(linf->linfmem, linf->linfpg[pg]); + /* load the next page */ + objptr = mcmlck(linf->linfmem, linf->linfpg[pg]); - /* this is now the previous page */ - prvpg = pg; - } - - /* get object + offset corresponding to current source line */ - bufptr = objptr + ((cur & 1023) * DBGLINFSIZ); - info->objn = osrp2(bufptr); - info->ofs = osrp2(bufptr + 2); + /* this is now the previous page */ + prvpg = pg; + } + + /* get object + offset corresponding to current source line */ + bufptr = objptr + ((cur & 1023) * DBGLINFSIZ); + info->objn = osrp2(bufptr); + info->ofs = osrp2(bufptr + 2); - /* read source location data out of the object's OPCLINE record */ - codeptr = mcmlck(linf->linfmem, (mcmon)info->objn); - bufptr = codeptr + info->ofs + 5; - info->fpos = osrp4(bufptr); - mcmunlck(linf->linfmem, (mcmon)info->objn); - } + /* read source location data out of the object's OPCLINE record */ + codeptr = mcmlck(linf->linfmem, (mcmon)info->objn); + bufptr = codeptr + info->ofs + 5; + info->fpos = osrp4(bufptr); + mcmunlck(linf->linfmem, (mcmon)info->objn); + } - /* unlock the last page */ - mcmunlck(linf->linfmem, linf->linfpg[prvpg]); + /* unlock the last page */ + mcmunlck(linf->linfmem, linf->linfpg[prvpg]); } /* disactivate line source under debugger - close file */ @@ -867,43 +867,43 @@ void linfdis(lindef *lin) { # define linf ((linfdef *)lin) - if (linf->linffp) - { - osfcls(linf->linffp); - linf->linffp = (osfildef *)0; - } - + if (linf->linffp) + { + osfcls(linf->linffp); + linf->linffp = (osfildef *)0; + } + # undef linf } /* activate line source under debugger - open file */ void linfact(lindef *lin) { - char *fname; + char *fname; # define linf ((linfdef *)lin) - /* get the name buffer, and advance to the full path name portion */ - fname = linf->linfnam; - fname += strlen(fname) + 1; + /* get the name buffer, and advance to the full path name portion */ + fname = linf->linfnam; + fname += strlen(fname) + 1; - /* - * If the full path name is empty, it means that the UI told us to - * defer searching for the file until we actually need the file. At - * this point, we actually need the file. Ask the UI again to find - * the file. - */ - if (fname[0] != '\0' - || dbgu_find_src(linf->linfnam, strlen(linf->linfnam), - fname, OSFNMAX, TRUE)) - { - /* open the file */ - linf->linffp = osfoprs(fname, OSFTTEXT); - } - else - { - /* there's no file to open */ - linf->linffp = 0; - } + /* + * If the full path name is empty, it means that the UI told us to + * defer searching for the file until we actually need the file. At + * this point, we actually need the file. Ask the UI again to find + * the file. + */ + if (fname[0] != '\0' + || dbgu_find_src(linf->linfnam, strlen(linf->linfnam), + fname, OSFNMAX, TRUE)) + { + /* open the file */ + linf->linffp = osfoprs(fname, OSFTTEXT); + } + else + { + /* there's no file to open */ + linf->linffp = 0; + } # undef linf } @@ -912,10 +912,10 @@ void linfact(lindef *lin) void linftell(lindef *lin, uchar *pos) { # define linf ((linfdef *)lin) - long seekpos; + long seekpos; - seekpos = osfpos(linf->linffp); - oswp4(pos, seekpos); + seekpos = osfpos(linf->linffp); + oswp4(pos, seekpos); # undef linf } @@ -924,10 +924,10 @@ void linftell(lindef *lin, uchar *pos) void linfseek(lindef *lin, uchar *pos) { # define linf ((linfdef *)lin) - long seekpos; - - seekpos = osrp4(pos); - osfseek(linf->linffp, seekpos, OSFSK_SET); + long seekpos; + + seekpos = osrp4(pos); + osfseek(linf->linffp, seekpos, OSFSK_SET); # undef linf } @@ -937,7 +937,7 @@ int linfread(lindef *lin, uchar *buf, uint siz) { # define linf ((linfdef *)lin) - return osfrbc(linf->linffp, buf, siz); + return osfrbc(linf->linffp, buf, siz); # undef linf } @@ -946,12 +946,12 @@ int linfread(lindef *lin, uchar *buf, uint siz) void linfpadd(lindef *lin, uchar *pos, long delta) { # define linf ((linfdef *)lin) - long seekpos; + long seekpos; - seekpos = osrp4(pos); - seekpos += delta; - if (seekpos < 0) seekpos = 0; - oswp4(pos, seekpos); + seekpos = osrp4(pos); + seekpos += delta; + if (seekpos < 0) seekpos = 0; + oswp4(pos, seekpos); # undef linf } @@ -961,7 +961,7 @@ int linfqtop(lindef *lin, uchar *pos) { # define linf ((linfdef *)lin) - return(osrp4(pos) == 0); + return(osrp4(pos) == 0); # undef linf } @@ -969,59 +969,59 @@ int linfqtop(lindef *lin, uchar *pos) /* read one line at current position - fgets-style interface */ int linfgets(lindef *lin, uchar *buf, uint siz) { - int ret; - long startpos; - uchar *p; + int ret; + long startpos; + uchar *p; # define linf ((linfdef *)lin) - /* note the seek offset at the start of the line */ - startpos = osfpos(linf->linffp); + /* note the seek offset at the start of the line */ + startpos = osfpos(linf->linffp); - /* read the next line */ - ret = (osfgets((char *)buf, siz, linf->linffp) != 0); - if (!ret) - return ret; + /* read the next line */ + ret = (osfgets((char *)buf, siz, linf->linffp) != 0); + if (!ret) + return ret; - /* scan for non-standard line endings */ - for (p = buf ; *p != '\0' && *p != '\r' && *p != '\n' ; ++p) ; - if (*p != '\0') - { - uchar *nxt; - - /* - * Scan for non-line-ending characters after this line-ending - * character. If we find any, we must have non-standard newline - * conventions in this file. To be tolerant of these, seek back - * to the start of the next line in these cases and read the - * next line from the new location. - */ - for (nxt = p + 1 ; *nxt == '\r' || *nxt == '\n' ; ++nxt) ; - if (*nxt == '\0') - { - /* - * we had only line-ending characters after the first - * line-ending character -- simply end the line after the - * first line-ending character - */ - *(p+1) = '\0'; - } - else - { - /* - * We had a line-ending character in the middle of other - * text, so we must have a file that doesn't conform to - * local newline conventions. Seek back to the next - * character following the last line-ending character so - * that we start the next line here, and end the current - * line after the first line-ending character. - */ - *(p+1) = '\0'; - osfseek(linf->linffp, startpos + (nxt - buf), OSFSK_SET); - } - } + /* scan for non-standard line endings */ + for (p = buf ; *p != '\0' && *p != '\r' && *p != '\n' ; ++p) ; + if (*p != '\0') + { + uchar *nxt; + + /* + * Scan for non-line-ending characters after this line-ending + * character. If we find any, we must have non-standard newline + * conventions in this file. To be tolerant of these, seek back + * to the start of the next line in these cases and read the + * next line from the new location. + */ + for (nxt = p + 1 ; *nxt == '\r' || *nxt == '\n' ; ++nxt) ; + if (*nxt == '\0') + { + /* + * we had only line-ending characters after the first + * line-ending character -- simply end the line after the + * first line-ending character + */ + *(p+1) = '\0'; + } + else + { + /* + * We had a line-ending character in the middle of other + * text, so we must have a file that doesn't conform to + * local newline conventions. Seek back to the next + * character following the last line-ending character so + * that we start the next line here, and end the current + * line after the first line-ending character. + */ + *(p+1) = '\0'; + osfseek(linf->linffp, startpos + (nxt - buf), OSFSK_SET); + } + } - /* return the result */ - return ret; + /* return the result */ + return ret; # undef linf } @@ -1031,7 +1031,7 @@ void linfnam(lindef *lin, char *buf) { # define linf ((linfdef *)lin) - strcpy(buf, linf->linfnam); + strcpy(buf, linf->linfnam); # undef linf } @@ -1041,7 +1041,7 @@ ulong linflnum(lindef *lin) { # define linf ((linfdef *)lin) - return linf->linfnum; + return linf->linfnum; # undef linf } @@ -1051,7 +1051,7 @@ void linfgoto(lindef *lin, int where) { # define linf ((linfdef *)lin) - osfseek(linf->linffp, 0L, where); + osfseek(linf->linffp, 0L, where); # undef linf } @@ -1061,8 +1061,8 @@ long linfofs(lindef *lin) { # define linf ((linfdef *)lin) - return(osfpos(linf->linffp)); - + return(osfpos(linf->linffp)); + # undef linf } diff --git a/engines/glk/tads/tads2/line_source_file.h b/engines/glk/tads/tads2/line_source_file.h index 91b31277a28..6658387f7b9 100644 --- a/engines/glk/tads/tads2/line_source_file.h +++ b/engines/glk/tads/tads2/line_source_file.h @@ -43,45 +43,45 @@ struct tokpdef; * in the object of the p-code for the start of the line */ struct linfinfo { - /* - * OPCLINE data (file seek position or line number, depending on how - * the game was compiled: -ds -> file seek offset, -ds2 -> line - * number) - */ - ulong fpos; - - /* object number */ - objnum objn; + /* + * OPCLINE data (file seek position or line number, depending on how + * the game was compiled: -ds -> file seek offset, -ds2 -> line + * number) + */ + ulong fpos; + + /* object number */ + objnum objn; - /* offset from start of code */ - uint ofs; + /* offset from start of code */ + uint ofs; }; /* * file line source */ struct linfdef { - lindef linflin; /* superclass data */ - osfildef *linffp; /* file pointer for this line source */ - char linfbuf[100]; /* buffer for the line contents */ - int linfbufnxt; /* offset in buffer of start of next line */ - int linfnxtlen; /* length of data after linfbufnxt */ - ulong linfnum; /* current line number */ - ulong linfseek; /* seek position of current line */ - mcmcxdef *linfmem; /* memory manager context */ - mcmon linfpg[LINFPGMAX]; /* pages for debugging records */ - ulong linfcrec; /* number of debugger records written so far */ - char linfnam[1]; /* name of file being read */ + lindef linflin; /* superclass data */ + osfildef *linffp; /* file pointer for this line source */ + char linfbuf[100]; /* buffer for the line contents */ + int linfbufnxt; /* offset in buffer of start of next line */ + int linfnxtlen; /* length of data after linfbufnxt */ + ulong linfnum; /* current line number */ + ulong linfseek; /* seek position of current line */ + mcmcxdef *linfmem; /* memory manager context */ + mcmon linfpg[LINFPGMAX]; /* pages for debugging records */ + ulong linfcrec; /* number of debugger records written so far */ + char linfnam[1]; /* name of file being read */ }; /* initialize a file line source, opening the file for the line source */ linfdef *linfini(mcmcxdef *mctx, errcxdef *errctx, const char *filename, - int flen, tokpdef *path, int must_find_file, - int new_line_records); + int flen, tokpdef *path, int must_find_file, + int new_line_records); /* initialize a pre-allocated linfdef, skipping debugger page setup */ void linfini2(mcmcxdef *mctx, linfdef *linf, - const char *filename, int flen, osfildef *fp, int new_line_records); + const char *filename, int flen, osfildef *fp, int new_line_records); /* get next line from line source */ int linfget(lindef *lin); @@ -103,7 +103,7 @@ int linfwrt(lindef *lin, osfildef *fp); /* load a file-line-source from binary (.gam) file */ int linfload(osfildef *fp, dbgcxdef *dbgctx, errcxdef *ec, - tokpdef *path); + tokpdef *path); /* add a debugger line record for the current line */ void linfcmp(lindef *lin, uchar *buf); diff --git a/engines/glk/tads/tads2/ltk.cpp b/engines/glk/tads/tads2/ltk.cpp index 6961f216aed..6e32359312a 100644 --- a/engines/glk/tads/tads2/ltk.cpp +++ b/engines/glk/tads/tads2/ltk.cpp @@ -64,8 +64,8 @@ void *ltk_sigsuballoc(errcxdef *errcx, size_t siz) { /* allocate the memory */ if (!(ptr = ltk_suballoc(siz))) { - /* signal an error */ - errsigf(errcx, "LTK", 0); + /* signal an error */ + errsigf(errcx, "LTK", 0); } /* return the memory */ @@ -106,8 +106,8 @@ void *ltk_sigalloc(errcxdef *errcx, size_t siz) { void *ptr; /* pointer to allocated memory */ if (!(ptr = ltk_alloc(siz))) { - /* signal error */ - errsigf(errcx, "LTK", 0); + /* signal error */ + errsigf(errcx, "LTK", 0); } /* return a ptr to the allocated memory */ diff --git a/engines/glk/tads/tads2/memory_cache.cpp b/engines/glk/tads/tads2/memory_cache.cpp index d6f2e3cbcc3..8e26dd303f6 100644 --- a/engines/glk/tads/tads2/memory_cache.cpp +++ b/engines/glk/tads/tads2/memory_cache.cpp @@ -92,134 +92,134 @@ static int mcmtoss(mcmcx1def *ctx, mcmon objnum); /* initialize a new client context */ mcmcxdef *mcmcini(mcmcx1def *globalctx, uint pages, - void (*loadfn)(void *, mclhd, uchar *, ushort), - void *loadctx, - void (*revertfn)(void *, mcmon), void *revertctx) + void (*loadfn)(void *, mclhd, uchar *, ushort), + void *loadctx, + void (*revertfn)(void *, mcmon), void *revertctx) { - mcmcxdef *ret; - ushort siz; - - siz = sizeof(mcmcxdef) + sizeof(mcmon *) * (pages - 1); - IF_DEBUG(siz += sizeof(ulong)); - - ret = (mcmcxdef *)mchalo(globalctx->mcmcxerr, siz, "mcm client context"); - IF_DEBUG((*(ulong *)ret = 0x02020202, - ret = (mcmcxdef *)((uchar *)ret + sizeof(ulong)))); + mcmcxdef *ret; + ushort siz; + + siz = sizeof(mcmcxdef) + sizeof(mcmon *) * (pages - 1); + IF_DEBUG(siz += sizeof(ulong)); + + ret = (mcmcxdef *)mchalo(globalctx->mcmcxerr, siz, "mcm client context"); + IF_DEBUG((*(ulong *)ret = 0x02020202, + ret = (mcmcxdef *)((uchar *)ret + sizeof(ulong)))); - ret->mcmcxmsz = pages; - ret->mcmcxgl = globalctx; - ret->mcmcxldf = loadfn; - ret->mcmcxldc = loadctx; - ret->mcmcxrvf = revertfn; - ret->mcmcxrvc = revertctx; - ret->mcmcxflg = 0; - memset(ret->mcmcxmtb, 0, (size_t)(pages * sizeof(mcmon *))); - return(ret); + ret->mcmcxmsz = pages; + ret->mcmcxgl = globalctx; + ret->mcmcxldf = loadfn; + ret->mcmcxldc = loadctx; + ret->mcmcxrvf = revertfn; + ret->mcmcxrvc = revertctx; + ret->mcmcxflg = 0; + memset(ret->mcmcxmtb, 0, (size_t)(pages * sizeof(mcmon *))); + return(ret); } /* uninitialize a client context */ void mcmcterm(mcmcxdef *ctx) { - /* delete the context memory */ - mchfre(ctx); + /* delete the context memory */ + mchfre(ctx); } /* initialize a new global context */ mcmcx1def *mcmini(ulong max, uint pages, ulong swapsize, - osfildef *swapfp, char *swapfilename, errcxdef *errctx) + osfildef *swapfp, char *swapfilename, errcxdef *errctx) { - mcmcx1def *ctx; /* newly-allocated cache manager context */ - uchar *noreg chunk;/* 1st chunk of memory managed by this cache mgr */ - mcmodef *obj; /* pointer to a cache object entry */ - ushort siz; /* size of current thing being allocated */ - ushort rem; /* bytes remaining in chunk */ - int err; - - NOREG((&chunk)) - - /* make sure 'max' is big enough - must be at least one chunk */ - if (max < (ulong)MCMCHUNK) max = (ulong)MCMCHUNK; - - /* allocate space for control structures from low-level heap */ - rem = MCMCHUNK; - - IF_DEBUG(rem += sizeof(long)); - chunk = mchalo(errctx, rem, "mcmini"); - IF_DEBUG((*(ulong *)chunk = 0x01010101, chunk += sizeof(ulong), - rem -= sizeof(ulong))); - - ctx = (mcmcx1def *)chunk; /* put context at start of chunk */ - - /* initialize swapper; clean up if it fails */ - ERRBEGIN(errctx) - mcsini(&ctx->mcmcxswc, ctx, swapsize, swapfp, swapfilename, errctx); - ERRCATCH(errctx, err) - mcsclose(&ctx->mcmcxswc); - mchfre(chunk); - errsig(errctx, err); - ERREND(errctx) - - chunk += sizeof(mcmcx1def); /* rest of chunk is after context */ - rem -= sizeof(mcmcx1def); /* remove from remaining size counter */ + mcmcx1def *ctx; /* newly-allocated cache manager context */ + uchar *noreg chunk;/* 1st chunk of memory managed by this cache mgr */ + mcmodef *obj; /* pointer to a cache object entry */ + ushort siz; /* size of current thing being allocated */ + ushort rem; /* bytes remaining in chunk */ + int err; + + NOREG((&chunk)) + + /* make sure 'max' is big enough - must be at least one chunk */ + if (max < (ulong)MCMCHUNK) max = (ulong)MCMCHUNK; + + /* allocate space for control structures from low-level heap */ + rem = MCMCHUNK; + + IF_DEBUG(rem += sizeof(long)); + chunk = mchalo(errctx, rem, "mcmini"); + IF_DEBUG((*(ulong *)chunk = 0x01010101, chunk += sizeof(ulong), + rem -= sizeof(ulong))); + + ctx = (mcmcx1def *)chunk; /* put context at start of chunk */ + + /* initialize swapper; clean up if it fails */ + ERRBEGIN(errctx) + mcsini(&ctx->mcmcxswc, ctx, swapsize, swapfp, swapfilename, errctx); + ERRCATCH(errctx, err) + mcsclose(&ctx->mcmcxswc); + mchfre(chunk); + errsig(errctx, err); + ERREND(errctx) + + chunk += sizeof(mcmcx1def); /* rest of chunk is after context */ + rem -= sizeof(mcmcx1def); /* remove from remaining size counter */ - /* allocate the page table (an array of pointers to pages) */ - ctx->mcmcxtab = (mcmodef **)chunk; /* put at bottom of chunk */ - siz = pages * sizeof(mcmodef *); /* calcuate size of table */ + /* allocate the page table (an array of pointers to pages) */ + ctx->mcmcxtab = (mcmodef **)chunk; /* put at bottom of chunk */ + siz = pages * sizeof(mcmodef *); /* calcuate size of table */ - memset(ctx->mcmcxtab, 0, (size_t)siz); /* clear entire table */ - chunk += siz; /* reflect size of table */ - rem -= siz; /* take it out of the remaining count */ + memset(ctx->mcmcxtab, 0, (size_t)siz); /* clear entire table */ + chunk += siz; /* reflect size of table */ + rem -= siz; /* take it out of the remaining count */ - /* here we begin normal heap marking with object references */ - ctx->mcmcxhpch = (mcmhdef *)chunk; /* set start of heap chain */ - chunk += sizeof(mcmhdef); - rem -= sizeof(mcmhdef); - ctx->mcmcxhpch->mcmhnxt = (mcmhdef *)0; /* no next heap in chain yet */ - - /* allocate the first page */ - *(mcmon *)chunk = 0; /* set object number header in chunk */ - chunk += osrndsz(sizeof(mcmon)); - rem -= osrndsz(sizeof(mcmon)); + /* here we begin normal heap marking with object references */ + ctx->mcmcxhpch = (mcmhdef *)chunk; /* set start of heap chain */ + chunk += sizeof(mcmhdef); + rem -= sizeof(mcmhdef); + ctx->mcmcxhpch->mcmhnxt = (mcmhdef *)0; /* no next heap in chain yet */ + + /* allocate the first page */ + *(mcmon *)chunk = 0; /* set object number header in chunk */ + chunk += osrndsz(sizeof(mcmon)); + rem -= osrndsz(sizeof(mcmon)); - ctx->mcmcxtab[0] = (mcmodef *)chunk; /* put at bottom of chunk */ - memset(ctx->mcmcxtab[0], 0, (size_t)MCMPAGESIZE); - chunk += MCMPAGESIZE; /* reflect size of page */ - rem -= MCMPAGESIZE; /* take it out of the remainder */ - - /* set up the first page with an entry for itself */ - obj = mcmgobje(ctx, (mcmon)0); /* point to first page entry */ - obj->mcmoflg = MCMOFPRES | MCMOFNODISC | MCMOFPAGE | MCMOFNOSWAP; - obj->mcmoptr = (uchar *)ctx->mcmcxtab[0]; - obj->mcmosiz = MCMPAGESIZE; - - /* set up the rest of the context */ - ctx->mcmcxlru = ctx->mcmcxmru = MCMONINV; /* no mru/lru list yet */ - ctx->mcmcxmax = max - (ulong)MCMCHUNK; - ctx->mcmcxpage = 1; /* next page slot to be allocated will be #1 */ - ctx->mcmcxpgmx = pages; /* max number of pages we can allocate */ - ctx->mcmcxerr = errctx; - ctx->mcmcxcsw = mcmcswf; - - /* set up the free list with the remainder of the chunk */ - ctx->mcmcxfre = 1; /* we've allocated object 0; obj 1 is free space */ - obj = mcmgobje(ctx, ctx->mcmcxfre); /* point to free object entry */ - obj->mcmonxt = obj->mcmoprv = MCMONINV; /* end of free list */ - obj->mcmoflg = MCMOFFREE; /* mark the free block as such */ - *(mcmon *)chunk = ctx->mcmcxfre; /* set free list header */ + ctx->mcmcxtab[0] = (mcmodef *)chunk; /* put at bottom of chunk */ + memset(ctx->mcmcxtab[0], 0, (size_t)MCMPAGESIZE); + chunk += MCMPAGESIZE; /* reflect size of page */ + rem -= MCMPAGESIZE; /* take it out of the remainder */ + + /* set up the first page with an entry for itself */ + obj = mcmgobje(ctx, (mcmon)0); /* point to first page entry */ + obj->mcmoflg = MCMOFPRES | MCMOFNODISC | MCMOFPAGE | MCMOFNOSWAP; + obj->mcmoptr = (uchar *)ctx->mcmcxtab[0]; + obj->mcmosiz = MCMPAGESIZE; + + /* set up the rest of the context */ + ctx->mcmcxlru = ctx->mcmcxmru = MCMONINV; /* no mru/lru list yet */ + ctx->mcmcxmax = max - (ulong)MCMCHUNK; + ctx->mcmcxpage = 1; /* next page slot to be allocated will be #1 */ + ctx->mcmcxpgmx = pages; /* max number of pages we can allocate */ + ctx->mcmcxerr = errctx; + ctx->mcmcxcsw = mcmcswf; + + /* set up the free list with the remainder of the chunk */ + ctx->mcmcxfre = 1; /* we've allocated object 0; obj 1 is free space */ + obj = mcmgobje(ctx, ctx->mcmcxfre); /* point to free object entry */ + obj->mcmonxt = obj->mcmoprv = MCMONINV; /* end of free list */ + obj->mcmoflg = MCMOFFREE; /* mark the free block as such */ + *(mcmon *)chunk = ctx->mcmcxfre; /* set free list header */ - chunk += osrndsz(sizeof(mcmon)); - rem -= osrndsz(sizeof(mcmon)); - obj->mcmoptr = chunk; /* rest of chunk */ + chunk += osrndsz(sizeof(mcmon)); + rem -= osrndsz(sizeof(mcmon)); + obj->mcmoptr = chunk; /* rest of chunk */ - obj->mcmosiz = rem - osrndsz(sizeof(mcmon)); /* remaining size in chunk */ + obj->mcmosiz = rem - osrndsz(sizeof(mcmon)); /* remaining size in chunk */ - /* set flag for end of chunk (invalid object header) */ - *((mcmon *)(chunk + rem - osrndsz(sizeof(mcmon)))) = MCMONINV; - - /* set up the unused entry list with the remaining headers in the page */ - mcmadpg(ctx, 0, 2); - - return(ctx); + /* set flag for end of chunk (invalid object header) */ + *((mcmon *)(chunk + rem - osrndsz(sizeof(mcmon)))) = MCMONINV; + + /* set up the unused entry list with the remaining headers in the page */ + mcmadpg(ctx, 0, 2); + + return(ctx); } /* @@ -228,32 +228,32 @@ mcmcx1def *mcmini(ulong max, uint pages, ulong swapsize, */ void mcmterm(mcmcx1def *ctx) { - mcmhdef *cur, *nxt; - - /* - * Free each chunk in the cache block list, *except* the last one. The - * last one is special: it's actually the first chunk allocated, since - * we build the list in reverse order, and the first chunk pointer - * points into the middle of the actual allocation block, since we - * sub-allocated the context structure itself and the page table out of - * that memory. - */ - for (cur = ctx->mcmcxhpch ; cur != 0 && cur->mcmhnxt != 0 ; cur = nxt) - { - /* remember the next chunk, and delete this one */ - nxt = cur->mcmhnxt; - mchfre(cur); - } + mcmhdef *cur, *nxt; + + /* + * Free each chunk in the cache block list, *except* the last one. The + * last one is special: it's actually the first chunk allocated, since + * we build the list in reverse order, and the first chunk pointer + * points into the middle of the actual allocation block, since we + * sub-allocated the context structure itself and the page table out of + * that memory. + */ + for (cur = ctx->mcmcxhpch ; cur != 0 && cur->mcmhnxt != 0 ; cur = nxt) + { + /* remember the next chunk, and delete this one */ + nxt = cur->mcmhnxt; + mchfre(cur); + } - /* - * As described above, the last chunk in the list is the first - * allocated, and it points into the middle of the actual allocated - * memory block. Luckily, we do have a handy pointer to the start of - * the memory block, namely the context pointer - it's the first thing - * allocated out of the block, so it's the same as the block pointer. - * Freeing the context frees this last/first chunk. - */ - mchfre(ctx); + /* + * As described above, the last chunk in the list is the first + * allocated, and it points into the middle of the actual allocated + * memory block. Luckily, we do have a handy pointer to the start of + * the memory block, namely the context pointer - it's the first thing + * allocated out of the block, so it's the same as the block pointer. + * Freeing the context frees this last/first chunk. + */ + mchfre(ctx); } /* @@ -263,280 +263,280 @@ void mcmterm(mcmcx1def *ctx) */ static uchar *mcmalo1(mcmcx1def *ctx, ushort siz, mcmon *nump) { - mcmon n; - mcmodef *o; - uchar *chunk; - - MCMGLBCTX(ctx); + mcmon n; + mcmodef *o; + uchar *chunk; + + MCMGLBCTX(ctx); - /* round size to appropriate multiple */ - siz = osrndsz(siz); + /* round size to appropriate multiple */ + siz = osrndsz(siz); - /* if it's bigger than the chunk size, we can't allocate it */ - if (siz > MCMCHUNK) - errsig(ctx->mcmcxerr, ERR_BIGOBJ); + /* if it's bigger than the chunk size, we can't allocate it */ + if (siz > MCMCHUNK) + errsig(ctx->mcmcxerr, ERR_BIGOBJ); startover: - /* look in the free block chain for a fit to the request */ - o = mcmffb(ctx, siz, &n); - if (n != MCMONINV) - { - mcmsplt(ctx, n, siz); /* split the block if necessary */ - mcmgobje(ctx, n)->mcmoflg = MCMOFNODISC | MCMOFLOCK | MCMOFPRES; - mcmgobje(ctx, n)->mcmolcnt = 1; /* one locker so far */ - *nump = n; - return(o->mcmoptr); - } - - /* nothing found; we must get space out of the heap if possible */ - chunk = mcmhalo(ctx); /* get space from heap */ - if (!chunk) goto error; /* can't get any more space from heap */ - o = mcmoal(ctx, &n); /* set up cache entry for free space */ - if (n == MCMONINV) - { - mcmhdef *chunk_hdr = ((mcmhdef *)chunk) - 1; - ctx->mcmcxhpch = chunk_hdr->mcmhnxt; - mchfre(chunk_hdr); - goto error; /* any error means we can't allocate the memory */ - } - - *(mcmon *)chunk = n; /* set object header */ - chunk += osrndsz(sizeof(mcmon)); - o->mcmoptr = chunk; - o->mcmosiz = MCMCHUNK - osrndsz(sizeof(mcmon)); - o->mcmoflg = MCMOFFREE; - mcmlnkhd(ctx, &ctx->mcmcxfre, n); - goto startover; /* try again, now that we have some memory */ - + /* look in the free block chain for a fit to the request */ + o = mcmffb(ctx, siz, &n); + if (n != MCMONINV) + { + mcmsplt(ctx, n, siz); /* split the block if necessary */ + mcmgobje(ctx, n)->mcmoflg = MCMOFNODISC | MCMOFLOCK | MCMOFPRES; + mcmgobje(ctx, n)->mcmolcnt = 1; /* one locker so far */ + *nump = n; + return(o->mcmoptr); + } + + /* nothing found; we must get space out of the heap if possible */ + chunk = mcmhalo(ctx); /* get space from heap */ + if (!chunk) goto error; /* can't get any more space from heap */ + o = mcmoal(ctx, &n); /* set up cache entry for free space */ + if (n == MCMONINV) + { + mcmhdef *chunk_hdr = ((mcmhdef *)chunk) - 1; + ctx->mcmcxhpch = chunk_hdr->mcmhnxt; + mchfre(chunk_hdr); + goto error; /* any error means we can't allocate the memory */ + } + + *(mcmon *)chunk = n; /* set object header */ + chunk += osrndsz(sizeof(mcmon)); + o->mcmoptr = chunk; + o->mcmosiz = MCMCHUNK - osrndsz(sizeof(mcmon)); + o->mcmoflg = MCMOFFREE; + mcmlnkhd(ctx, &ctx->mcmcxfre, n); + goto startover; /* try again, now that we have some memory */ + error: - *nump = MCMONINV; - return((uchar *)0); + *nump = MCMONINV; + return((uchar *)0); } static void mcmcliexp(mcmcxdef *cctx, mcmon clinum) { - /* add global number to client mapping table at client number */ - if (cctx->mcmcxmtb[clinum >> 8] == (mcmon *)0) - { - mcmcx1def *ctx = cctx->mcmcxgl; - int i; - mcmon *p; - - /* this page is not allocated - allocate it */ - p = (mcmon *)mchalo(ctx->mcmcxerr, (256 * sizeof(mcmon)), - "client mapping page"); - cctx->mcmcxmtb[clinum >> 8] = p; - for (i = 0 ; i < 256 ; ++i) *p++ = MCMONINV; - } + /* add global number to client mapping table at client number */ + if (cctx->mcmcxmtb[clinum >> 8] == (mcmon *)0) + { + mcmcx1def *ctx = cctx->mcmcxgl; + int i; + mcmon *p; + + /* this page is not allocated - allocate it */ + p = (mcmon *)mchalo(ctx->mcmcxerr, (256 * sizeof(mcmon)), + "client mapping page"); + cctx->mcmcxmtb[clinum >> 8] = p; + for (i = 0 ; i < 256 ; ++i) *p++ = MCMONINV; + } } /* high-level allocate: try, collect garbage, then try again */ uchar *mcmalo0(mcmcxdef *cctx, ushort siz, mcmon *nump, - mcmon clinum, int noclitrans) + mcmon clinum, int noclitrans) { - uchar *ret; - mcmcx1def *ctx = cctx->mcmcxgl; /* global context */ - mcmon glb; /* global object number allocated */ - - MCMCLICTX(cctx); - MCMGLBCTX(ctx); - - /* try once */ - if ((ret = mcmalo1(ctx, siz, &glb)) != 0) - goto done; + uchar *ret; + mcmcx1def *ctx = cctx->mcmcxgl; /* global context */ + mcmon glb; /* global object number allocated */ + + MCMCLICTX(cctx); + MCMGLBCTX(ctx); + + /* try once */ + if ((ret = mcmalo1(ctx, siz, &glb)) != 0) + goto done; - /* collect some garbage */ - mcmgarb(ctx); - - /* try swapping until we get the memory or have nothing left to swap */ - for ( ;; ) - { - /* try again */ - if ((ret = mcmalo1(ctx, siz, &glb)) != 0) - goto done; + /* collect some garbage */ + mcmgarb(ctx); + + /* try swapping until we get the memory or have nothing left to swap */ + for ( ;; ) + { + /* try again */ + if ((ret = mcmalo1(ctx, siz, &glb)) != 0) + goto done; - /* nothing left to swap? */ - if (!mcmswap(ctx, siz)) - break; + /* nothing left to swap? */ + if (!mcmswap(ctx, siz)) + break; - /* try yet again */ - if ((ret = mcmalo1(ctx, siz, &glb)) != 0) - goto done; + /* try yet again */ + if ((ret = mcmalo1(ctx, siz, &glb)) != 0) + goto done; - /* collect garbage once again */ - mcmgarb(ctx); - } - - /* try again */ - if ((ret = mcmalo1(ctx, siz, &glb)) != 0) - goto done; - - /* we have no other way of getting more memory, so signal an error */ - errsig(ctx->mcmcxerr, ERR_NOMEM1); - NOTREACHEDV(uchar *); - + /* collect garbage once again */ + mcmgarb(ctx); + } + + /* try again */ + if ((ret = mcmalo1(ctx, siz, &glb)) != 0) + goto done; + + /* we have no other way of getting more memory, so signal an error */ + errsig(ctx->mcmcxerr, ERR_NOMEM1); + NOTREACHEDV(uchar *); + done: - if (noclitrans) - { - *nump = glb; - return(ret); - } - - /* we have an object - generate client number */ - if (clinum == MCMONINV) - { - /* find a free number */ - mcmon **p; - uint i; - mcmon j = 0; - mcmon *q; - int found = FALSE; - int unused = -1; - - for (i = 0, p = cctx->mcmcxmtb ; i < cctx->mcmcxmsz ; ++i, ++p) - { - if (*p) - { - for (j = 0, q = *p ; j < 256 ; ++j, ++q) - { - if (*q == MCMONINV) - { - found = TRUE; - break; - } - } - } - else if (unused == -1) - unused = i; /* note an unused page mapping table */ + if (noclitrans) + { + *nump = glb; + return(ret); + } + + /* we have an object - generate client number */ + if (clinum == MCMONINV) + { + /* find a free number */ + mcmon **p; + uint i; + mcmon j = 0; + mcmon *q; + int found = FALSE; + int unused = -1; + + for (i = 0, p = cctx->mcmcxmtb ; i < cctx->mcmcxmsz ; ++i, ++p) + { + if (*p) + { + for (j = 0, q = *p ; j < 256 ; ++j, ++q) + { + if (*q == MCMONINV) + { + found = TRUE; + break; + } + } + } + else if (unused == -1) + unused = i; /* note an unused page mapping table */ - if (found) break; - } - - if (found) - clinum = (i << 8) + j; - else if (unused != -1) - clinum = (unused << 8); - else - errsig(ctx->mcmcxerr, ERR_CLIFULL); - } + if (found) break; + } + + if (found) + clinum = (i << 8) + j; + else if (unused != -1) + clinum = (unused << 8); + else + errsig(ctx->mcmcxerr, ERR_CLIFULL); + } - /* expand client mapping table if necessary */ - mcmcliexp(cctx, clinum); + /* expand client mapping table if necessary */ + mcmcliexp(cctx, clinum); - /* make sure the entry isn't already in use */ - if (mcmc2g(cctx, clinum) != MCMONINV) - errsig(ctx->mcmcxerr, ERR_CLIUSE); + /* make sure the entry isn't already in use */ + if (mcmc2g(cctx, clinum) != MCMONINV) + errsig(ctx->mcmcxerr, ERR_CLIUSE); - cctx->mcmcxmtb[clinum >> 8][clinum & 255] = glb; - if (nump) *nump = clinum; - return(ret); + cctx->mcmcxmtb[clinum >> 8][clinum & 255] = glb; + if (nump) *nump = clinum; + return(ret); } /* reserve space for an object at a client object number */ void mcmrsrv(mcmcxdef *cctx, ushort siz, mcmon clinum, mclhd loadhd) { - mcmcx1def *ctx = cctx->mcmcxgl; /* global context */ - mcmon glb; /* global object number allocated */ - mcmodef *o; - - MCMCLICTX(cctx); - MCMGLBCTX(ctx); - - o = mcmoal(ctx, &glb); /* get a new object header */ - if (!o) errsig(ctx->mcmcxerr, ERR_NOHDR); /* can't get a new header */ - - o->mcmoldh = loadhd; - o->mcmoflg = 0; - o->mcmosiz = siz; - - mcmcliexp(cctx, clinum); - if (mcmc2g(cctx, clinum) != MCMONINV) - errsig(ctx->mcmcxerr, ERR_CLIUSE); - - cctx->mcmcxmtb[clinum >> 8][clinum & 255] = glb; + mcmcx1def *ctx = cctx->mcmcxgl; /* global context */ + mcmon glb; /* global object number allocated */ + mcmodef *o; + + MCMCLICTX(cctx); + MCMGLBCTX(ctx); + + o = mcmoal(ctx, &glb); /* get a new object header */ + if (!o) errsig(ctx->mcmcxerr, ERR_NOHDR); /* can't get a new header */ + + o->mcmoldh = loadhd; + o->mcmoflg = 0; + o->mcmosiz = siz; + + mcmcliexp(cctx, clinum); + if (mcmc2g(cctx, clinum) != MCMONINV) + errsig(ctx->mcmcxerr, ERR_CLIUSE); + + cctx->mcmcxmtb[clinum >> 8][clinum & 255] = glb; } /* resize an existing object */ uchar *mcmrealo(mcmcxdef *cctx, mcmon cliobj, ushort newsize) { - mcmcx1def *ctx = cctx->mcmcxgl; /* global context */ - mcmon obj = mcmc2g(cctx, cliobj); - mcmodef *o = mcmgobje(ctx, obj); - mcmon nxt; - mcmodef *nxto; - uchar *p; - int local_lock; - - MCMCLICTX(cctx); - MCMGLBCTX(ctx); - - newsize = osrndsz(newsize); - - /* make sure the object is locked, and note if we locked it */ - if ((local_lock = !(o->mcmoflg & MCMOFLOCK)) != 0) - (void)mcmlck(cctx, cliobj); - - ERRBEGIN(ctx->mcmcxerr) - - if (newsize < o->mcmosiz) - mcmsplt(ctx, obj, newsize); /* smaller; just split block */ - else - { - /* see if there's a free block after this block */ - p = o->mcmoptr; - nxt = *(mcmon *)(p + o->mcmosiz); - nxto = (nxt == MCMONINV) ? (mcmodef *)0 : mcmgobje(ctx, nxt); - - if (nxto && ((nxto->mcmoflg & MCMOFFREE) - && nxto->mcmosiz >= newsize - o->mcmosiz)) - { - /* sanity check - make sure heap and page table agree */ - assert(nxto->mcmoptr == p + o->mcmosiz + osrndsz(sizeof(mcmon))); - /* annex the free block */ - o->mcmosiz += nxto->mcmosiz + osrndsz(sizeof(mcmon)); - /* move the free block to the unused list */ - mcmunl(ctx, nxt, &ctx->mcmcxfre); - nxto->mcmonxt = ctx->mcmcxunu; - ctx->mcmcxunu = nxt; - nxto->mcmoflg = 0; - - /* split the newly grown block if necessary */ - mcmsplt(ctx, obj, newsize); - } - else - { - /* can't annex; allocate new memory and copy */ - - if (o->mcmolcnt != 1) /* if anyone else has a lock... */ - errsig(ctx->mcmcxerr, ERR_REALCK); /* we can't move it */ - - p = mcmalo0(cctx, newsize, &nxt, MCMONINV, TRUE); - if (nxt == MCMONINV) errsig(ctx->mcmcxerr, ERR_NOMEM2); - memcpy(p, o->mcmoptr, (size_t)o->mcmosiz); - - /* adjust the object entries */ - nxto = mcmgobje(ctx, nxt); /* get pointer to new entry */ - newsize = nxto->mcmosiz; /* get actual size of new block */ - nxto->mcmoptr = o->mcmoptr; /* copy current block info to new */ - nxto->mcmosiz = o->mcmosiz; - o->mcmoptr = p; /* copy new block info to original entry */ - o->mcmosiz = newsize; - - /* now fix up the heap pointers, and free the temp object */ - *(mcmon *)(p - osrndsz(sizeof(mcmon))) = obj; - *(mcmon *)(nxto->mcmoptr - osrndsz(sizeof(mcmon))) = nxt; - mcmgunlck(ctx, nxt); - mcmgfre(ctx, nxt); - } - } - - ERRCLEAN(ctx->mcmcxerr) - /* release our lock, if we had to obtain one */ - if (local_lock) mcmunlck(cctx, cliobj); - ERRENDCLN(ctx->mcmcxerr) - - /* return the address of the object */ - return(o->mcmoptr); + mcmcx1def *ctx = cctx->mcmcxgl; /* global context */ + mcmon obj = mcmc2g(cctx, cliobj); + mcmodef *o = mcmgobje(ctx, obj); + mcmon nxt; + mcmodef *nxto; + uchar *p; + int local_lock; + + MCMCLICTX(cctx); + MCMGLBCTX(ctx); + + newsize = osrndsz(newsize); + + /* make sure the object is locked, and note if we locked it */ + if ((local_lock = !(o->mcmoflg & MCMOFLOCK)) != 0) + (void)mcmlck(cctx, cliobj); + + ERRBEGIN(ctx->mcmcxerr) + + if (newsize < o->mcmosiz) + mcmsplt(ctx, obj, newsize); /* smaller; just split block */ + else + { + /* see if there's a free block after this block */ + p = o->mcmoptr; + nxt = *(mcmon *)(p + o->mcmosiz); + nxto = (nxt == MCMONINV) ? (mcmodef *)0 : mcmgobje(ctx, nxt); + + if (nxto && ((nxto->mcmoflg & MCMOFFREE) + && nxto->mcmosiz >= newsize - o->mcmosiz)) + { + /* sanity check - make sure heap and page table agree */ + assert(nxto->mcmoptr == p + o->mcmosiz + osrndsz(sizeof(mcmon))); + /* annex the free block */ + o->mcmosiz += nxto->mcmosiz + osrndsz(sizeof(mcmon)); + /* move the free block to the unused list */ + mcmunl(ctx, nxt, &ctx->mcmcxfre); + nxto->mcmonxt = ctx->mcmcxunu; + ctx->mcmcxunu = nxt; + nxto->mcmoflg = 0; + + /* split the newly grown block if necessary */ + mcmsplt(ctx, obj, newsize); + } + else + { + /* can't annex; allocate new memory and copy */ + + if (o->mcmolcnt != 1) /* if anyone else has a lock... */ + errsig(ctx->mcmcxerr, ERR_REALCK); /* we can't move it */ + + p = mcmalo0(cctx, newsize, &nxt, MCMONINV, TRUE); + if (nxt == MCMONINV) errsig(ctx->mcmcxerr, ERR_NOMEM2); + memcpy(p, o->mcmoptr, (size_t)o->mcmosiz); + + /* adjust the object entries */ + nxto = mcmgobje(ctx, nxt); /* get pointer to new entry */ + newsize = nxto->mcmosiz; /* get actual size of new block */ + nxto->mcmoptr = o->mcmoptr; /* copy current block info to new */ + nxto->mcmosiz = o->mcmosiz; + o->mcmoptr = p; /* copy new block info to original entry */ + o->mcmosiz = newsize; + + /* now fix up the heap pointers, and free the temp object */ + *(mcmon *)(p - osrndsz(sizeof(mcmon))) = obj; + *(mcmon *)(nxto->mcmoptr - osrndsz(sizeof(mcmon))) = nxt; + mcmgunlck(ctx, nxt); + mcmgfre(ctx, nxt); + } + } + + ERRCLEAN(ctx->mcmcxerr) + /* release our lock, if we had to obtain one */ + if (local_lock) mcmunlck(cctx, cliobj); + ERRENDCLN(ctx->mcmcxerr) + + /* return the address of the object */ + return(o->mcmoptr); } /* @@ -544,19 +544,19 @@ uchar *mcmrealo(mcmcxdef *cctx, mcmon cliobj, ushort newsize) */ void mcmgfre(mcmcx1def *ctx, mcmon obj) { - mcmodef *o = mcmgobje(ctx, obj); - - MCMGLBCTX(ctx); - - /* signal an error if the object is locked */ - if (o->mcmolcnt) errsig(ctx->mcmcxerr, ERR_LCKFRE); + mcmodef *o = mcmgobje(ctx, obj); + + MCMGLBCTX(ctx); + + /* signal an error if the object is locked */ + if (o->mcmolcnt) errsig(ctx->mcmcxerr, ERR_LCKFRE); - /* take out of LRU chain if it's in the chain */ - if (o->mcmoflg & MCMOFLRU) mcmunl(ctx, obj, &ctx->mcmcxlru); - - /* put it in the free list */ - mcmlnkhd(ctx, &ctx->mcmcxfre, obj); - o->mcmoflg = MCMOFFREE; + /* take out of LRU chain if it's in the chain */ + if (o->mcmoflg & MCMOFLRU) mcmunl(ctx, obj, &ctx->mcmcxlru); + + /* put it in the free list */ + mcmlnkhd(ctx, &ctx->mcmcxfre, obj); + o->mcmoflg = MCMOFFREE; } /* @@ -564,58 +564,58 @@ void mcmgfre(mcmcx1def *ctx, mcmon obj) */ uchar *mcmload(mcmcxdef *cctx, mcmon cnum) { - mcmcx1def *ctx = cctx->mcmcxgl; - mcmodef *o = mcmobje(cctx, cnum); - mcmodef *newdef; - mcmon newn; - mcmon num = mcmc2g(cctx, cnum); - - MCMCLICTX(cctx); - MCMGLBCTX(ctx); + mcmcx1def *ctx = cctx->mcmcxgl; + mcmodef *o = mcmobje(cctx, cnum); + mcmodef *newdef; + mcmon newn; + mcmon num = mcmc2g(cctx, cnum); + + MCMCLICTX(cctx); + MCMGLBCTX(ctx); - /* we first need to obtain some memory for this object */ - (void)mcmalo0(cctx, o->mcmosiz, &newn, MCMONINV, TRUE); - newdef = mcmgobje(ctx, newn); - - /* use memory block from our new object */ - o->mcmoptr = newdef->mcmoptr; - o->mcmosiz = newdef->mcmosiz; + /* we first need to obtain some memory for this object */ + (void)mcmalo0(cctx, o->mcmosiz, &newn, MCMONINV, TRUE); + newdef = mcmgobje(ctx, newn); + + /* use memory block from our new object */ + o->mcmoptr = newdef->mcmoptr; + o->mcmosiz = newdef->mcmosiz; - /* load or swap the object in */ - ERRBEGIN(ctx->mcmcxerr) - if (o->mcmoflg & (MCMOFNODISC | MCMOFDIRTY)) - mcsin(&ctx->mcmcxswc, o->mcmoswh, o->mcmoptr, o->mcmosiz); - else if (cctx->mcmcxldf) - (*cctx->mcmcxldf)(cctx->mcmcxldc, o->mcmoldh, o->mcmoptr, - o->mcmosiz); - else - errsig(ctx->mcmcxerr, ERR_NOLOAD); - ERRCLEAN(ctx->mcmcxerr) - mcmgunlck(ctx, newn); /* unlock the object */ - mcmgfre(ctx, newn); /* don't need new memory after all */ - ERRENDCLN(ctx->mcmcxerr) + /* load or swap the object in */ + ERRBEGIN(ctx->mcmcxerr) + if (o->mcmoflg & (MCMOFNODISC | MCMOFDIRTY)) + mcsin(&ctx->mcmcxswc, o->mcmoswh, o->mcmoptr, o->mcmosiz); + else if (cctx->mcmcxldf) + (*cctx->mcmcxldf)(cctx->mcmcxldc, o->mcmoldh, o->mcmoptr, + o->mcmosiz); + else + errsig(ctx->mcmcxerr, ERR_NOLOAD); + ERRCLEAN(ctx->mcmcxerr) + mcmgunlck(ctx, newn); /* unlock the object */ + mcmgfre(ctx, newn); /* don't need new memory after all */ + ERRENDCLN(ctx->mcmcxerr) - /* unuse the new cache entry we obtained (we just wanted the memory) */ + /* unuse the new cache entry we obtained (we just wanted the memory) */ /* @@@ */ - *(mcmon *)(o->mcmoptr - osrndsz(sizeof(mcmon))) = num; /* set obj# */ - newdef->mcmoflg = 0; /* mark new block as unused */ - newdef->mcmonxt = ctx->mcmcxunu; /* link to unused chain */ - ctx->mcmcxunu = newn; + *(mcmon *)(o->mcmoptr - osrndsz(sizeof(mcmon))) = num; /* set obj# */ + newdef->mcmoflg = 0; /* mark new block as unused */ + newdef->mcmonxt = ctx->mcmcxunu; /* link to unused chain */ + ctx->mcmcxunu = newn; - /* set flags in the newly loaded object and return */ - o->mcmoflg |= MCMOFPRES | MCMOFLOCK; /* object is now present in memory */ - o->mcmoflg &= ~MCMOFDIRTY; /* not written since last swapped in */ - o->mcmoflg |= MCMOFNODISC; /* don't discard once it's been to swap file */ - o->mcmolcnt = 1; /* one locker so far */ - - /* if the object is to be reverted upon loading, revert it now */ - if (o->mcmoflg & MCMOFREVRT) - { - (*cctx->mcmcxrvf)(cctx->mcmcxrvc, cnum); - o->mcmoflg &= ~MCMOFREVRT; - } + /* set flags in the newly loaded object and return */ + o->mcmoflg |= MCMOFPRES | MCMOFLOCK; /* object is now present in memory */ + o->mcmoflg &= ~MCMOFDIRTY; /* not written since last swapped in */ + o->mcmoflg |= MCMOFNODISC; /* don't discard once it's been to swap file */ + o->mcmolcnt = 1; /* one locker so far */ + + /* if the object is to be reverted upon loading, revert it now */ + if (o->mcmoflg & MCMOFREVRT) + { + (*cctx->mcmcxrvf)(cctx->mcmcxrvc, cnum); + o->mcmoflg &= ~MCMOFREVRT; + } - return(o->mcmoptr); + return(o->mcmoptr); } /* @@ -624,88 +624,88 @@ uchar *mcmload(mcmcxdef *cctx, mcmon cnum) */ static mcmodef *mcmoal(mcmcx1def *ctx, mcmon *nump) { - mcmodef *ret; - uint pagenum; - - MCMGLBCTX(ctx); - - /* look first in list of unused headers */ + mcmodef *ret; + uint pagenum; + + MCMGLBCTX(ctx); + + /* look first in list of unused headers */ startover: - if (ctx->mcmcxunu != MCMONINV) - { - /* we have something in the unused list; return it */ - *nump = ctx->mcmcxunu; - ret = mcmgobje(ctx, *nump); - ctx->mcmcxunu = ret->mcmonxt; - ret->mcmoswh = MCSSEGINV; - return(ret); - } - - /* - * No unused entries: we must create a new page. To do so, we - * simply allocate memory for a new page. Allocate the memory - * ourselves, to avoid deadlocking with the allocator (which can - * try to get a new entry to satisfy our request for memory). - */ - if (ctx->mcmcxpage == ctx->mcmcxpgmx) goto error; /* no more pages */ - pagenum = ctx->mcmcxpage++; /* get a new page slot */ - - ctx->mcmcxtab[pagenum] = - (mcmodef *)mchalo(ctx->mcmcxerr, MCMPAGESIZE, "mcmoal"); - mcmadpg(ctx, pagenum, MCMONINV); - goto startover; + if (ctx->mcmcxunu != MCMONINV) + { + /* we have something in the unused list; return it */ + *nump = ctx->mcmcxunu; + ret = mcmgobje(ctx, *nump); + ctx->mcmcxunu = ret->mcmonxt; + ret->mcmoswh = MCSSEGINV; + return(ret); + } + + /* + * No unused entries: we must create a new page. To do so, we + * simply allocate memory for a new page. Allocate the memory + * ourselves, to avoid deadlocking with the allocator (which can + * try to get a new entry to satisfy our request for memory). + */ + if (ctx->mcmcxpage == ctx->mcmcxpgmx) goto error; /* no more pages */ + pagenum = ctx->mcmcxpage++; /* get a new page slot */ + + ctx->mcmcxtab[pagenum] = + (mcmodef *)mchalo(ctx->mcmcxerr, MCMPAGESIZE, "mcmoal"); + mcmadpg(ctx, pagenum, MCMONINV); + goto startover; error: - *nump = MCMONINV; - return((mcmodef *)0); + *nump = MCMONINV; + return((mcmodef *)0); } /* find free block: find a block from the free pool to satisfy allocation */ static mcmodef *mcmffb(mcmcx1def *ctx, ushort siz, mcmon *nump) { - mcmon n; - mcmodef *o; - mcmon minn; - mcmodef *mino; - ushort min = 0; - - MCMGLBCTX(ctx); + mcmon n; + mcmodef *o; + mcmon minn; + mcmodef *mino; + ushort min = 0; + + MCMGLBCTX(ctx); - for (minn = MCMONINV, mino = 0, n = ctx->mcmcxfre ; n != MCMONINV ; - n = o->mcmonxt) - { - o = mcmgobje(ctx, n); - if (o->mcmosiz == siz) - { - /* found exact match - use it immediately */ - minn = n; - min = siz; - mino = o; - break; - } - else if (o->mcmosiz > siz) - { - /* found something at least as big; is it smallest yet? */ - if (minn == MCMONINV || o->mcmosiz < min) - { - /* yes, best fit so far, use it; but keep looking */ - minn = n; - mino = o; - min = o->mcmosiz; - } - } - } - - /* if we found something, remove from the free list */ - if (minn != MCMONINV) - { - mcmunl(ctx, minn, &ctx->mcmcxfre); - mino->mcmoflg &= ~MCMOFFREE; - mino->mcmoswh = MCSSEGINV; - } - - *nump = minn; - return mino; + for (minn = MCMONINV, mino = 0, n = ctx->mcmcxfre ; n != MCMONINV ; + n = o->mcmonxt) + { + o = mcmgobje(ctx, n); + if (o->mcmosiz == siz) + { + /* found exact match - use it immediately */ + minn = n; + min = siz; + mino = o; + break; + } + else if (o->mcmosiz > siz) + { + /* found something at least as big; is it smallest yet? */ + if (minn == MCMONINV || o->mcmosiz < min) + { + /* yes, best fit so far, use it; but keep looking */ + minn = n; + mino = o; + min = o->mcmosiz; + } + } + } + + /* if we found something, remove from the free list */ + if (minn != MCMONINV) + { + mcmunl(ctx, minn, &ctx->mcmcxfre); + mino->mcmoflg &= ~MCMOFFREE; + mino->mcmoswh = MCSSEGINV; + } + + *nump = minn; + return mino; } /* @@ -713,66 +713,66 @@ static mcmodef *mcmffb(mcmcx1def *ctx, ushort siz, mcmon *nump) */ static void mcmunl(mcmcx1def *ctx, mcmon n, mcmon *lst) { - mcmodef *o = mcmgobje(ctx, n); - mcmodef *nxt; - mcmodef *prv; - - MCMGLBCTX(ctx); + mcmodef *o = mcmgobje(ctx, n); + mcmodef *nxt; + mcmodef *prv; + + MCMGLBCTX(ctx); - /* see if this is LRU chain - must deal with MRU pointer if so */ - if (lst == &ctx->mcmcxlru) - { - /* if it's at MRU, set MRU pointer to previous object in list */ - if (ctx->mcmcxmru == n) - { - ctx->mcmcxmru = o->mcmoprv; /* set MRU to previous in chain */ - if (ctx->mcmcxmru != MCMONINV) /* set nxt for new MRU */ - mcmgobje(ctx, ctx->mcmcxmru)->mcmonxt = MCMONINV; - else - ctx->mcmcxlru = MCMONINV; /* nothing in list; clear LRU */ - } - o->mcmoflg &= ~MCMOFLRU; - } - - nxt = o->mcmonxt == MCMONINV ? (mcmodef *)0 : mcmgobje(ctx, o->mcmonxt); - prv = o->mcmoprv == MCMONINV ? (mcmodef *)0 : mcmgobje(ctx, o->mcmoprv); - - /* set back link for next object, if there is a next object */ - if (nxt) nxt->mcmoprv = o->mcmoprv; - - /* set forward link for previous object, or head if no previous object */ - if (prv) prv->mcmonxt = o->mcmonxt; - else *lst = o->mcmonxt; - - o->mcmonxt = o->mcmoprv = MCMONINV; + /* see if this is LRU chain - must deal with MRU pointer if so */ + if (lst == &ctx->mcmcxlru) + { + /* if it's at MRU, set MRU pointer to previous object in list */ + if (ctx->mcmcxmru == n) + { + ctx->mcmcxmru = o->mcmoprv; /* set MRU to previous in chain */ + if (ctx->mcmcxmru != MCMONINV) /* set nxt for new MRU */ + mcmgobje(ctx, ctx->mcmcxmru)->mcmonxt = MCMONINV; + else + ctx->mcmcxlru = MCMONINV; /* nothing in list; clear LRU */ + } + o->mcmoflg &= ~MCMOFLRU; + } + + nxt = o->mcmonxt == MCMONINV ? (mcmodef *)0 : mcmgobje(ctx, o->mcmonxt); + prv = o->mcmoprv == MCMONINV ? (mcmodef *)0 : mcmgobje(ctx, o->mcmoprv); + + /* set back link for next object, if there is a next object */ + if (nxt) nxt->mcmoprv = o->mcmoprv; + + /* set forward link for previous object, or head if no previous object */ + if (prv) prv->mcmonxt = o->mcmonxt; + else *lst = o->mcmonxt; + + o->mcmonxt = o->mcmoprv = MCMONINV; } /* link an item to the head of a doubly-linked list */ static void mcmlnkhd(mcmcx1def *ctx, mcmon *lst, mcmon n) { - MCMGLBCTX(ctx); + MCMGLBCTX(ctx); - if (*lst != MCMONINV) mcmgobje(ctx, *lst)->mcmoprv = n; - mcmgobje(ctx, n)->mcmonxt = *lst; /* next is previous head of list */ - *lst = n; /* make object new head of list */ - mcmgobje(ctx, n)->mcmoprv = MCMONINV; /* there is no previous entry */ + if (*lst != MCMONINV) mcmgobje(ctx, *lst)->mcmoprv = n; + mcmgobje(ctx, n)->mcmonxt = *lst; /* next is previous head of list */ + *lst = n; /* make object new head of list */ + mcmgobje(ctx, n)->mcmoprv = MCMONINV; /* there is no previous entry */ } /* add page pagenum, initializing entries after firstunu to unused */ static void mcmadpg(mcmcx1def *ctx, uint pagenum, mcmon firstunu) { - mcmon unu; - mcmodef *obj; - mcmon lastunu; - - MCMGLBCTX(ctx); + mcmon unu; + mcmodef *obj; + mcmon lastunu; + + MCMGLBCTX(ctx); - unu = (firstunu == MCMONINV ? pagenum * MCMPAGECNT : firstunu); - ctx->mcmcxunu = unu; - lastunu = (pagenum * MCMPAGECNT) + MCMPAGECNT - 1; - for (obj = mcmgobje(ctx, unu) ; unu < lastunu ; ++obj) - obj->mcmonxt = ++unu; - obj->mcmonxt = MCMONINV; + unu = (firstunu == MCMONINV ? pagenum * MCMPAGECNT : firstunu); + ctx->mcmcxunu = unu; + lastunu = (pagenum * MCMPAGECNT) + MCMPAGECNT - 1; + for (obj = mcmgobje(ctx, unu) ; unu < lastunu ; ++obj) + obj->mcmonxt = ++unu; + obj->mcmonxt = MCMONINV; } /* @@ -781,52 +781,52 @@ static void mcmadpg(mcmcx1def *ctx, uint pagenum, mcmon firstunu) */ static void mcmsplt(mcmcx1def *ctx, mcmon n, ushort siz) { - mcmodef *o = mcmgobje(ctx, n); - mcmon newn; - mcmodef *newp; - - MCMGLBCTX(ctx); + mcmodef *o = mcmgobje(ctx, n); + mcmon newn; + mcmodef *newp; + + MCMGLBCTX(ctx); - if (o->mcmosiz < siz + MCMSPLIT) return; /* don't split; we're done */ + if (o->mcmosiz < siz + MCMSPLIT) return; /* don't split; we're done */ - newp = mcmoal(ctx, &newn); - if (newn == MCMONINV) return; /* ignore error - just skip split */ + newp = mcmoal(ctx, &newn); + if (newn == MCMONINV) return; /* ignore error - just skip split */ - /* set up the new entry, and link into free list */ - *(mcmon *)(o->mcmoptr + siz) = newn; - newp->mcmoptr = o->mcmoptr + siz + osrndsz(sizeof(mcmon)); - newp->mcmosiz = o->mcmosiz - siz - osrndsz(sizeof(mcmon)); - newp->mcmoflg = MCMOFFREE; - mcmlnkhd(ctx, &ctx->mcmcxfre, newn); - - o->mcmosiz = siz; /* size of new object is now exactly as request */ + /* set up the new entry, and link into free list */ + *(mcmon *)(o->mcmoptr + siz) = newn; + newp->mcmoptr = o->mcmoptr + siz + osrndsz(sizeof(mcmon)); + newp->mcmosiz = o->mcmosiz - siz - osrndsz(sizeof(mcmon)); + newp->mcmoflg = MCMOFFREE; + mcmlnkhd(ctx, &ctx->mcmcxfre, newn); + + o->mcmosiz = siz; /* size of new object is now exactly as request */ } /* allocate a new chunk from the heap if possible */ static uchar *mcmhalo(mcmcx1def *ctx) { - uchar *chunk; - int err; + uchar *chunk; + int err; #define size (MCMCHUNK + sizeof(mcmhdef) + 2*osrndsz(sizeof(mcmon))) - MCMGLBCTX(ctx); + MCMGLBCTX(ctx); - if (ctx->mcmcxmax < MCMCHUNK) return((uchar *)0); + if (ctx->mcmcxmax < MCMCHUNK) return((uchar *)0); - ERRBEGIN(ctx->mcmcxerr) - chunk = mchalo(ctx->mcmcxerr, size, "mcmhalo"); - ERRCATCH(ctx->mcmcxerr, err) - ctx->mcmcxmax = 0; /* remember we can't allocate anything more */ - return((uchar *)0); /* return no memory */ - ERREND(ctx->mcmcxerr) + ERRBEGIN(ctx->mcmcxerr) + chunk = mchalo(ctx->mcmcxerr, size, "mcmhalo"); + ERRCATCH(ctx->mcmcxerr, err) + ctx->mcmcxmax = 0; /* remember we can't allocate anything more */ + return((uchar *)0); /* return no memory */ + ERREND(ctx->mcmcxerr) - ctx->mcmcxmax -= MCMCHUNK; - - /* link into heap chain */ - ((mcmhdef *)chunk)->mcmhnxt = ctx->mcmcxhpch; - ctx->mcmcxhpch = (mcmhdef *)chunk; + ctx->mcmcxmax -= MCMCHUNK; + + /* link into heap chain */ + ((mcmhdef *)chunk)->mcmhnxt = ctx->mcmcxhpch; + ctx->mcmcxhpch = (mcmhdef *)chunk; /*@@@@*/ - *(mcmon *)(chunk + osrndsz(sizeof(mcmhdef) + MCMCHUNK)) = MCMONINV; + *(mcmon *)(chunk + osrndsz(sizeof(mcmhdef) + MCMCHUNK)) = MCMONINV; VARUSED(err); return(chunk + sizeof(mcmhdef)); @@ -837,265 +837,265 @@ static uchar *mcmhalo(mcmcx1def *ctx) /* "use" an object - move to most-recent position in LRU chain */ void mcmuse(mcmcx1def *ctx, mcmon obj) { - mcmodef *o = mcmgobje(ctx, obj); - - MCMGLBCTX(ctx); + mcmodef *o = mcmgobje(ctx, obj); + + MCMGLBCTX(ctx); - if (ctx->mcmcxmru == obj) return; /* already MRU; nothing to do */ - - /* remove from LRU chain if it's in it */ - if (o->mcmoflg & MCMOFLRU) mcmunl(ctx, obj, &ctx->mcmcxlru); + if (ctx->mcmcxmru == obj) return; /* already MRU; nothing to do */ + + /* remove from LRU chain if it's in it */ + if (o->mcmoflg & MCMOFLRU) mcmunl(ctx, obj, &ctx->mcmcxlru); - /* set forward pointer of last block, if there is one */ - if (ctx->mcmcxmru != MCMONINV) - mcmgobje(ctx, ctx->mcmcxmru)->mcmonxt = obj; - - o->mcmoprv = ctx->mcmcxmru; /* point back to previous MRU */ - o->mcmonxt = MCMONINV; /* nothing in list after this one */ - ctx->mcmcxmru = obj; /* point MRU to new block */ - - /* if there's nothing in the chain at all, set LRU to this block, too */ - if (ctx->mcmcxlru == MCMONINV) ctx->mcmcxlru = obj; + /* set forward pointer of last block, if there is one */ + if (ctx->mcmcxmru != MCMONINV) + mcmgobje(ctx, ctx->mcmcxmru)->mcmonxt = obj; + + o->mcmoprv = ctx->mcmcxmru; /* point back to previous MRU */ + o->mcmonxt = MCMONINV; /* nothing in list after this one */ + ctx->mcmcxmru = obj; /* point MRU to new block */ + + /* if there's nothing in the chain at all, set LRU to this block, too */ + if (ctx->mcmcxlru == MCMONINV) ctx->mcmcxlru = obj; - /* note that object is in LRU chain */ - o->mcmoflg |= MCMOFLRU; + /* note that object is in LRU chain */ + o->mcmoflg |= MCMOFLRU; } /* find next free block in a heap, starting with pointer */ static uchar *mcmffh(mcmcx1def *ctx, uchar *p) { - mcmodef *o; + mcmodef *o; - MCMGLBCTX(ctx); + MCMGLBCTX(ctx); - while (*(mcmon *)p != MCMONINV) - { - o = mcmgobje(ctx, *(mcmon *)p); - assert(o->mcmoptr == p + osrndsz(sizeof(mcmon))); - if (o->mcmoflg & MCMOFFREE) return(p); - p += osrndsz(sizeof(mcmon)) + o->mcmosiz; /* move on to next chunk */ - } - return((uchar *)0); /* no more free blocks in heap */ + while (*(mcmon *)p != MCMONINV) + { + o = mcmgobje(ctx, *(mcmon *)p); + assert(o->mcmoptr == p + osrndsz(sizeof(mcmon))); + if (o->mcmoflg & MCMOFFREE) return(p); + p += osrndsz(sizeof(mcmon)) + o->mcmosiz; /* move on to next chunk */ + } + return((uchar *)0); /* no more free blocks in heap */ } #ifdef NEVER static void mcmmove(mcmcx1def *ctx, mcmodef *o, uchar *newpage) { - mcmodef **page; - - MCMGLBCTX(ctx); + mcmodef **page; + + MCMGLBCTX(ctx); - /* see if we need to update page table (we do if moving a page) */ - if (o->mcmoflg & MCMOFPAGE) - { - for (page = ctx->mcmcxtab ; *page ; ++page) - { - if (*page == (mcmodef *)(o->mcmoptr)) - { - *page = (mcmodef *)newpag; - break; - } - } - if (!*page) printf("\n*** internal error - relocating page\n"); - } - o->mcmoptr = newpage; + /* see if we need to update page table (we do if moving a page) */ + if (o->mcmoflg & MCMOFPAGE) + { + for (page = ctx->mcmcxtab ; *page ; ++page) + { + if (*page == (mcmodef *)(o->mcmoptr)) + { + *page = (mcmodef *)newpag; + break; + } + } + if (!*page) printf("\n*** internal error - relocating page\n"); + } + o->mcmoptr = newpage; } #endif /* NEVER */ /* relocate blocks from p to (but not including) q */ static uchar *mcmreloc(mcmcx1def *ctx, uchar *p, uchar *q) { - mcmodef *o; - ushort dist; - mcmon objnum; + mcmodef *o; + ushort dist; + mcmon objnum; - MCMGLBCTX(ctx); + MCMGLBCTX(ctx); - objnum = *(mcmon *)p; /* get number of free block being bubbled up */ - o = mcmgobje(ctx, objnum); /* get pointer to free object */ - assert(o->mcmoptr == p + osrndsz(sizeof(mcmon))); - dist = osrndsz(sizeof(mcmon)) + o->mcmosiz; /* compute distance to move */ - mcmmove(ctx, o, q - dist + osrndsz(sizeof(mcmon))); /* move obj to top */ + objnum = *(mcmon *)p; /* get number of free block being bubbled up */ + o = mcmgobje(ctx, objnum); /* get pointer to free object */ + assert(o->mcmoptr == p + osrndsz(sizeof(mcmon))); + dist = osrndsz(sizeof(mcmon)) + o->mcmosiz; /* compute distance to move */ + mcmmove(ctx, o, q - dist + osrndsz(sizeof(mcmon))); /* move obj to top */ - memmove(p, p+dist, (size_t)(q - p - o->mcmosiz)); /* move memory */ + memmove(p, p+dist, (size_t)(q - p - o->mcmosiz)); /* move memory */ - /* update cache entries for the blocks we moved */ - while (p != q - dist) - { - mcmmove(ctx, mcmgobje(ctx, *(mcmon *)p), p + osrndsz(sizeof(mcmon))); - p = mcmnxh(ctx, p); - } + /* update cache entries for the blocks we moved */ + while (p != q - dist) + { + mcmmove(ctx, mcmgobje(ctx, *(mcmon *)p), p + osrndsz(sizeof(mcmon))); + p = mcmnxh(ctx, p); + } - *(mcmon *)(q - dist) = objnum; /* set bubbled num */ - return(q - dist); /* return new location of bubbled block */ + *(mcmon *)(q - dist) = objnum; /* set bubbled num */ + return(q - dist); /* return new location of bubbled block */ } /* consolidate the two (free) blocks starting at p into one block */ static void mcmconsol(mcmcx1def *ctx, uchar *p) { - uchar *q; - mcmodef *obj1, *obj2; - - MCMGLBCTX(ctx); + uchar *q; + mcmodef *obj1, *obj2; + + MCMGLBCTX(ctx); - q = mcmnxh(ctx, p); - obj1 = mcmgobje(ctx, *(mcmon *)p); - obj2 = mcmgobje(ctx, *(mcmon *)q); - - assert(obj1->mcmoptr == p + osrndsz(sizeof(mcmon))); - assert(obj2->mcmoptr == q + osrndsz(sizeof(mcmon))); + q = mcmnxh(ctx, p); + obj1 = mcmgobje(ctx, *(mcmon *)p); + obj2 = mcmgobje(ctx, *(mcmon *)q); + + assert(obj1->mcmoptr == p + osrndsz(sizeof(mcmon))); + assert(obj2->mcmoptr == q + osrndsz(sizeof(mcmon))); - obj1->mcmosiz += osrndsz(sizeof(mcmon)) + obj2->mcmosiz; - mcmunl(ctx, *(mcmon *)q, &ctx->mcmcxfre); - - /* add second object entry to unused list */ - obj2->mcmonxt = ctx->mcmcxunu; - ctx->mcmcxunu = *(mcmon *)q; - obj2->mcmoflg = 0; + obj1->mcmosiz += osrndsz(sizeof(mcmon)) + obj2->mcmosiz; + mcmunl(ctx, *(mcmon *)q, &ctx->mcmcxfre); + + /* add second object entry to unused list */ + obj2->mcmonxt = ctx->mcmcxunu; + ctx->mcmcxunu = *(mcmon *)q; + obj2->mcmoflg = 0; } /* attempt to compact all heaps by consolidating free space */ static void mcmgarb(mcmcx1def *ctx) { - mcmhdef *h; - uchar *p; - uchar *q; - uchar *nxt; - ushort flags; - - MCMGLBCTX(ctx); + mcmhdef *h; + uchar *p; + uchar *q; + uchar *nxt; + ushort flags; + + MCMGLBCTX(ctx); - for (h = ctx->mcmcxhpch ; h ; h = h->mcmhnxt) - { - p = (uchar *)(h+1); /* get pointer to actual heap */ - p = mcmffh(ctx, p); /* get first free block in heap */ - if (!p) continue; /* can't do anything - no free blocks */ - nxt = mcmnxh(ctx, p); /* remember immediate next block */ - - for (q=p ;; ) - { - q = mcmnxh(ctx, q); /* find next chunk in heap */ - if (*(mcmon *)q == MCMONINV) break; /* reached end of heap */ - assert(mcmgobje(ctx, *(mcmon *)q)->mcmoptr - == q + osrndsz(sizeof(mcmon))); - flags = mcmgobje(ctx, *(mcmon *)q)->mcmoflg; /* get flags */ + for (h = ctx->mcmcxhpch ; h ; h = h->mcmhnxt) + { + p = (uchar *)(h+1); /* get pointer to actual heap */ + p = mcmffh(ctx, p); /* get first free block in heap */ + if (!p) continue; /* can't do anything - no free blocks */ + nxt = mcmnxh(ctx, p); /* remember immediate next block */ + + for (q=p ;; ) + { + q = mcmnxh(ctx, q); /* find next chunk in heap */ + if (*(mcmon *)q == MCMONINV) break; /* reached end of heap */ + assert(mcmgobje(ctx, *(mcmon *)q)->mcmoptr + == q + osrndsz(sizeof(mcmon))); + flags = mcmgobje(ctx, *(mcmon *)q)->mcmoflg; /* get flags */ - /* if the block is locked, p can't be relocated */ - if (flags & MCMOFLOCK) - { - p = mcmffh(ctx, q); /* find next free block after p */ - q = p; - if (p) continue; /* try again; start with next free block */ - else break; /* no more free blocks - done with heap */ - } + /* if the block is locked, p can't be relocated */ + if (flags & MCMOFLOCK) + { + p = mcmffh(ctx, q); /* find next free block after p */ + q = p; + if (p) continue; /* try again; start with next free block */ + else break; /* no more free blocks - done with heap */ + } - /* if the block is free, we can relocate between p and q */ - if (flags & MCMOFFREE) - { - if (q != nxt) p = mcmreloc(ctx, p, q); /* relocate */ - mcmconsol(ctx, p); /* consolidate two free blocks */ - - /* resume looking, starting with consolidated block */ - nxt = mcmnxh(ctx, p); - q = p; - continue; - } - } - } + /* if the block is free, we can relocate between p and q */ + if (flags & MCMOFFREE) + { + if (q != nxt) p = mcmreloc(ctx, p, q); /* relocate */ + mcmconsol(ctx, p); /* consolidate two free blocks */ + + /* resume looking, starting with consolidated block */ + nxt = mcmnxh(ctx, p); + q = p; + continue; + } + } + } } /* toss out a particular object */ static int mcmtoss(mcmcx1def *ctx, mcmon n) { - mcmodef *o = mcmgobje(ctx, n); - mcmodef *newp; - mcmon newn; + mcmodef *o = mcmgobje(ctx, n); + mcmodef *newp; + mcmon newn; - MCMGLBCTX(ctx); + MCMGLBCTX(ctx); - /* make a new block for the free space */ - newp = mcmoal(ctx, &newn); - if (newn == MCMONINV) - return(FALSE); /* ignore the error, but can't toss it out */ + /* make a new block for the free space */ + newp = mcmoal(ctx, &newn); + if (newn == MCMONINV) + return(FALSE); /* ignore the error, but can't toss it out */ - /* write object to swap file if not discardable */ - if (o->mcmoflg & (MCMOFNODISC | MCMOFDIRTY)) - { - mcsseg old_swap_seg; - - /* - * If this object was last loaded out of the load file, rather - * than the swap file, don't attempt to find it in the swap file - * -- so note by setting the old swap segment parameter to null. - */ - if (!(o->mcmoflg & MCMOFNODISC)) - old_swap_seg = o->mcmoswh; - else - old_swap_seg = MCSSEGINV; - - o->mcmoswh = mcsout(&ctx->mcmcxswc, (uint)n, o->mcmoptr, o->mcmosiz, - old_swap_seg, o->mcmoflg & MCMOFDIRTY); - } - - /* give the object's space to the newly created block */ - newp->mcmoptr = o->mcmoptr; - newp->mcmosiz = o->mcmosiz; - newp->mcmoflg = MCMOFFREE; + /* write object to swap file if not discardable */ + if (o->mcmoflg & (MCMOFNODISC | MCMOFDIRTY)) + { + mcsseg old_swap_seg; + + /* + * If this object was last loaded out of the load file, rather + * than the swap file, don't attempt to find it in the swap file + * -- so note by setting the old swap segment parameter to null. + */ + if (!(o->mcmoflg & MCMOFNODISC)) + old_swap_seg = o->mcmoswh; + else + old_swap_seg = MCSSEGINV; + + o->mcmoswh = mcsout(&ctx->mcmcxswc, (uint)n, o->mcmoptr, o->mcmosiz, + old_swap_seg, o->mcmoflg & MCMOFDIRTY); + } + + /* give the object's space to the newly created block */ + newp->mcmoptr = o->mcmoptr; + newp->mcmosiz = o->mcmosiz; + newp->mcmoflg = MCMOFFREE; /*@@@*/ - *(mcmon *)(o->mcmoptr - osrndsz(sizeof(mcmon))) = newn; - mcmlnkhd(ctx, &ctx->mcmcxfre, newn); - - o->mcmoflg &= ~MCMOFPRES; /* object is no longer in memory */ - mcmunl(ctx, n, &ctx->mcmcxlru); /* remove from LRU list */ - return(TRUE); /* successful, so return TRUE */ + *(mcmon *)(o->mcmoptr - osrndsz(sizeof(mcmon))) = newn; + mcmlnkhd(ctx, &ctx->mcmcxfre, newn); + + o->mcmoflg &= ~MCMOFPRES; /* object is no longer in memory */ + mcmunl(ctx, n, &ctx->mcmcxlru); /* remove from LRU list */ + return(TRUE); /* successful, so return TRUE */ } /* swap or discard to make room for siz; return 0 if nothing swapped */ static int mcmswap(mcmcx1def *ctx, ushort siz) { - mcmon n; - mcmodef *o; - mcmon nxt; - int pass; /* pass 1: swap one piece big enough */ - /* pass 2: swap enough pieces to add up to right size */ - ushort tot; + mcmon n; + mcmodef *o; + mcmon nxt; + int pass; /* pass 1: swap one piece big enough */ + /* pass 2: swap enough pieces to add up to right size */ + ushort tot; - MCMGLBCTX(ctx); + MCMGLBCTX(ctx); - for (pass = 1, tot = 0 ; pass < 3 && tot < siz ; ++pass) - { - for (n = ctx->mcmcxlru ; n != MCMONINV && tot < siz ; n = nxt) - { - o = mcmgobje(ctx, n); - nxt = o->mcmonxt; /* get next now, as we may unlink */ - if (!(o->mcmoflg & (MCMOFLOCK | MCMOFNOSWAP | MCMOFPAGE)) - && (pass == 2 || o->mcmosiz >= siz)) - { - /* toss out, and add into size if successful */ - if (mcmtoss(ctx, n)) tot += o->mcmosiz; - } - } - } - - /* if we managed to remove anything, return TRUE, otherwise FALSE */ - return(tot != 0); + for (pass = 1, tot = 0 ; pass < 3 && tot < siz ; ++pass) + { + for (n = ctx->mcmcxlru ; n != MCMONINV && tot < siz ; n = nxt) + { + o = mcmgobje(ctx, n); + nxt = o->mcmonxt; /* get next now, as we may unlink */ + if (!(o->mcmoflg & (MCMOFLOCK | MCMOFNOSWAP | MCMOFPAGE)) + && (pass == 2 || o->mcmosiz >= siz)) + { + /* toss out, and add into size if successful */ + if (mcmtoss(ctx, n)) tot += o->mcmosiz; + } + } + } + + /* if we managed to remove anything, return TRUE, otherwise FALSE */ + return(tot != 0); } /* compute size of cache */ ulong mcmcsiz(mcmcxdef *cctx) { - mcmcx1def *ctx = cctx->mcmcxgl; - mcmhdef *p; - ulong tot; - - MCMCLICTX(cctx); - MCMGLBCTX(ctx); - - /* count number of heaps, adding in chunk size for each */ - for (tot = 0, p = ctx->mcmcxhpch ; p ; p = p->mcmhnxt) - tot += MCMCHUNK; - - return(tot); + mcmcx1def *ctx = cctx->mcmcxgl; + mcmhdef *p; + ulong tot; + + MCMCLICTX(cctx); + MCMGLBCTX(ctx); + + /* count number of heaps, adding in chunk size for each */ + for (tot = 0, p = ctx->mcmcxhpch ; p ; p = p->mcmhnxt) + tot += MCMCHUNK; + + return(tot); } #ifdef MCM_NO_MACRO @@ -1103,49 +1103,49 @@ ulong mcmcsiz(mcmcxdef *cctx) uchar *mcmlck(mcmcxdef *ctx, mcmon objnum) { - mcmodef *o = mcmobje(ctx, objnum); + mcmodef *o = mcmobje(ctx, objnum); - if ((o->mcmoflg & MCMOFFREE) != 0 || mcmc2g(ctx, objnum) == MCMONINV) - { - errsig(ctx->mcmcxgl->mcmcxerr, ERR_INVOBJ); - return 0; - } - else if (o->mcmoflg & MCMOFPRES) - { - o->mcmoflg |= MCMOFLOCK; - ++(o->mcmolcnt); - return(o->mcmoptr); - } - else - return(mcmload(ctx, objnum)); + if ((o->mcmoflg & MCMOFFREE) != 0 || mcmc2g(ctx, objnum) == MCMONINV) + { + errsig(ctx->mcmcxgl->mcmcxerr, ERR_INVOBJ); + return 0; + } + else if (o->mcmoflg & MCMOFPRES) + { + o->mcmoflg |= MCMOFLOCK; + ++(o->mcmolcnt); + return(o->mcmoptr); + } + else + return(mcmload(ctx, objnum)); } void mcmunlck(mcmcxdef *ctx, mcmon obj) { - mcmodef *o = mcmobje(ctx, obj); - - if (o->mcmoflg & MCMOFLOCK) - { - if (!(--(o->mcmolcnt))) - { - o->mcmoflg &= ~MCMOFLOCK; - mcmuse(ctx->mcmcxgl, mcmc2g(ctx, obj)); - } - } + mcmodef *o = mcmobje(ctx, obj); + + if (o->mcmoflg & MCMOFLOCK) + { + if (!(--(o->mcmolcnt))) + { + o->mcmoflg &= ~MCMOFLOCK; + mcmuse(ctx->mcmcxgl, mcmc2g(ctx, obj)); + } + } } void mcmgunlck(mcmcx1def *ctx, mcmon obj) { - mcmodef *o = mcmgobje(ctx, obj); - - if (o->mcmoflg & MCMOFLOCK) - { - if (!(--(o->mcmolcnt))) - { - o->mcmoflg &= ~MCMOFLOCK; - mcmuse(ctx, obj); - } - } + mcmodef *o = mcmgobje(ctx, obj); + + if (o->mcmoflg & MCMOFLOCK) + { + if (!(--(o->mcmolcnt))) + { + o->mcmoflg &= ~MCMOFLOCK; + mcmuse(ctx, obj); + } + } } #endif /* MCM_NO_MACRO */ @@ -1157,29 +1157,29 @@ void mcmgunlck(mcmcx1def *ctx, mcmon obj) */ void mcmcswf(mcmcx1def *ctx, mcmon objn, mcsseg swapn, mcsseg oldswapn) { - mcmodef *o = mcmgobje(ctx, objn); - - MCMGLBCTX(ctx); - - /* - * Reset the swap number only if the object is swapped out and its - * swap file number matches the old one, or the object is currently - * present (in which case the swap file number is irrelevant and can - * be replaced). - */ - if (((o->mcmoflg & (MCMOFDIRTY | MCMOFNODISC)) && o->mcmoswh == oldswapn) - || (o->mcmoflg & MCMOFPRES)) - o->mcmoswh = swapn; + mcmodef *o = mcmgobje(ctx, objn); + + MCMGLBCTX(ctx); + + /* + * Reset the swap number only if the object is swapped out and its + * swap file number matches the old one, or the object is currently + * present (in which case the swap file number is irrelevant and can + * be replaced). + */ + if (((o->mcmoflg & (MCMOFDIRTY | MCMOFNODISC)) && o->mcmoswh == oldswapn) + || (o->mcmoflg & MCMOFPRES)) + o->mcmoswh = swapn; } void mcmfre(mcmcxdef *ctx, mcmon obj) { - /* free the actual object */ - mcmgfre(ctx->mcmcxgl, mcmc2g(ctx, obj)); + /* free the actual object */ + mcmgfre(ctx->mcmcxgl, mcmc2g(ctx, obj)); - /* unmap the client object number */ - mcmc2g(ctx, obj) = MCMONINV; + /* unmap the client object number */ + mcmc2g(ctx, obj) = MCMONINV; } } // End of namespace TADS2 diff --git a/engines/glk/tads/tads2/memory_cache.h b/engines/glk/tads/tads2/memory_cache.h index 26159aebadf..0eb1626acdf 100644 --- a/engines/glk/tads/tads2/memory_cache.h +++ b/engines/glk/tads/tads2/memory_cache.h @@ -69,13 +69,13 @@ union mcmodefloc { * objects that are unloaded). */ struct mcmodef { - uchar *mcmoptr; /* memory pointer (if object is present) */ + uchar *mcmoptr; /* memory pointer (if object is present) */ mcmodefloc mcmoloc; /* object's external location */ #define mcmoswh mcmoloc.mcmolocs #define mcmoldh mcmoloc.mcmolocl - mcmon mcmonxt; /* next object in this list */ - mcmon mcmoprv; /* previous object in this list */ - ushort mcmoflg; /* flags for this cache object */ + mcmon mcmonxt; /* next object in this list */ + mcmon mcmoprv; /* previous object in this list */ + ushort mcmoflg; /* flags for this cache object */ #define MCMOFDIRTY 0x01 /* object has been written */ #define MCMOFNODISC 0x02 /* not in load file (can't be discarded) */ #define MCMOFLOCK 0x04 /* object is locked */ @@ -85,44 +85,44 @@ struct mcmodef { #define MCMOFNOSWAP 0x40 /* object cannot be swapped out */ #define MCMOFFREE 0x80 /* entry refers to a free block of memory */ #define MCMOFREVRT 0x100 /* call revert callback upon loading */ - uchar mcmolcnt; /* lock count */ - ushort mcmosiz; /* size of the object */ + uchar mcmolcnt; /* lock count */ + ushort mcmosiz; /* size of the object */ }; /* heap header - allocate one of these in each heap */ struct mcmhdef { - mcmhdef *mcmhnxt; /* next heap in this chain */ + mcmhdef *mcmhnxt; /* next heap in this chain */ }; /* GLOBAL cache manager context: tracks cache manager state */ struct mcmcx1def { - mcmodef **mcmcxtab; /* page table for the cache */ - errcxdef *mcmcxerr; /* error handling context */ - mcmhdef *mcmcxhpch; /* heap chain pointer */ - mcscxdef mcmcxswc; /* swap manager context */ - mclcxdef mcmcxldc; /* loader context */ - ulong mcmcxmax; /* maximum amount of actual heap we can ever alloc */ - mcmon mcmcxlru; /* least recently used object still in memory */ - mcmon mcmcxmru; /* most recently used object */ - mcmon mcmcxfre; /* head of free list */ - mcmon mcmcxunu; /* head of unused list */ - ushort mcmcxpage; /* last page table slot used */ - ushort mcmcxpgmx; /* maximum number of pages we can allocate */ - void (*mcmcxcsw)(mcmcx1def *, mcmon, mcsseg, mcsseg); - /* change swap handle in object to new swap handle */ + mcmodef **mcmcxtab; /* page table for the cache */ + errcxdef *mcmcxerr; /* error handling context */ + mcmhdef *mcmcxhpch; /* heap chain pointer */ + mcscxdef mcmcxswc; /* swap manager context */ + mclcxdef mcmcxldc; /* loader context */ + ulong mcmcxmax; /* maximum amount of actual heap we can ever alloc */ + mcmon mcmcxlru; /* least recently used object still in memory */ + mcmon mcmcxmru; /* most recently used object */ + mcmon mcmcxfre; /* head of free list */ + mcmon mcmcxunu; /* head of unused list */ + ushort mcmcxpage; /* last page table slot used */ + ushort mcmcxpgmx; /* maximum number of pages we can allocate */ + void (*mcmcxcsw)(mcmcx1def *, mcmon, mcsseg, mcsseg); + /* change swap handle in object to new swap handle */ }; /* CLIENT cache manager context: used by client to request mcm services */ struct mcmcxdef { - mcmcx1def *mcmcxgl; /* global cache manager context */ - uint mcmcxflg; /* flags */ - uint mcmcxmsz; /* maximum size of mapping table */ - void (*mcmcxldf)(void *ctx, mclhd handle, uchar *ptr, - ushort siz); /* callback to load objects */ - void *mcmcxldc; /* context for load callback */ - void (*mcmcxrvf)(void *ctx, mcmon objn); /* revert object */ - void *mcmcxrvc; /* context for revert callback */ - mcmon *mcmcxmtb[1]; /* mapping table */ + mcmcx1def *mcmcxgl; /* global cache manager context */ + uint mcmcxflg; /* flags */ + uint mcmcxmsz; /* maximum size of mapping table */ + void (*mcmcxldf)(void *ctx, mclhd handle, uchar *ptr, + ushort siz); /* callback to load objects */ + void *mcmcxldc; /* context for load callback */ + void (*mcmcxrvf)(void *ctx, mcmon objn); /* revert object */ + void *mcmcxrvc; /* context for revert callback */ + mcmon *mcmcxmtb[1]; /* mapping table */ }; /* context flags */ @@ -169,16 +169,16 @@ struct mcmcxdef { * minimum. */ mcmcx1def *mcmini(ulong max, uint pages, ulong swapsize, - osfildef *swapfp, char *swapfilename, errcxdef *errctx); + osfildef *swapfp, char *swapfilename, errcxdef *errctx); /* terminate the cache manager - frees the structure and all cache memory */ void mcmterm(mcmcx1def *ctx); /* allocate a client context */ mcmcxdef *mcmcini(mcmcx1def *globalctx, uint pages, - void (*loadfn)(void *, mclhd, uchar *, ushort), - void *loadctx, - void (*revertfn)(void *, mcmon), void *revertctx); + void (*loadfn)(void *, mclhd, uchar *, ushort), + void *loadctx, + void (*revertfn)(void *, mcmon), void *revertctx); /* terminate a client context - frees the structure memory */ void mcmcterm(mcmcxdef *ctx); @@ -227,7 +227,7 @@ void mcmunlck(mcmcxdef *ctx, mcmon objnum); ((mcmobje(ctx,obj)->mcmoflg & MCMOFLOCK) ? \ (--(mcmobje(ctx,obj)->mcmolcnt) ? (void)0 : \ ((mcmobje(ctx,obj)->mcmoflg&=(~MCMOFLOCK)), \ - mcmuse((ctx)->mcmcxgl,mcmc2g(ctx,obj)))) : (void)0) + mcmuse((ctx)->mcmcxgl,mcmc2g(ctx,obj)))) : (void)0) #endif /* MCM_NO_MACRO */ @@ -330,14 +330,14 @@ void mcmgunlck(mcmcx1def *ctx, mcmon objnum); #define mcmgunlck(ctx,obj) \ ((mcmgobje(ctx,obj)->mcmoflg & MCMOFLOCK) ? \ (--(mcmgobje(ctx,obj)->mcmolcnt) ? (void)0 : \ - ((mcmgobje(ctx,obj)->mcmoflg&=(~MCMOFLOCK)), mcmuse(ctx,obj))) : \ + ((mcmgobje(ctx,obj)->mcmoflg&=(~MCMOFLOCK)), mcmuse(ctx,obj))) : \ (void)0) #endif /* MCM_NO_MACRO */ /* real memory allocator; clients use cover macros */ uchar *mcmalo0(mcmcxdef *ctx, ushort siz, mcmon *nump, mcmon clinum, - int noclitrans); + int noclitrans); /* free an object by global object number */ void mcmgfre(mcmcx1def *ctx, mcmon obj); diff --git a/engines/glk/tads/tads2/memory_cache_heap.cpp b/engines/glk/tads/tads2/memory_cache_heap.cpp index 5704f46a484..b64b18a9d67 100644 --- a/engines/glk/tads/tads2/memory_cache_heap.cpp +++ b/engines/glk/tads/tads2/memory_cache_heap.cpp @@ -31,19 +31,19 @@ namespace TADS2 { IF_DEBUG(ulong mchtotmem;) uchar *mchalo(errcxdef *ctx, size_t siz, const char *comment) { - uchar *ret; + uchar *ret; - VARUSED(comment); - IF_DEBUG(mchtotmem += siz;) + VARUSED(comment); + IF_DEBUG(mchtotmem += siz;) - ret = (uchar *)osmalloc(siz); - if (ret) - return(ret); - else { - errsig(ctx, ERR_NOMEM); - NOTREACHEDV(uchar *); - return 0; - } + ret = (uchar *)osmalloc(siz); + if (ret) + return(ret); + else { + errsig(ctx, ERR_NOMEM); + NOTREACHEDV(uchar *); + return 0; + } } } // End of namespace TADS2 diff --git a/engines/glk/tads/tads2/memory_cache_loader.h b/engines/glk/tads/tads2/memory_cache_loader.h index c7ec22db571..d81d3a2127c 100644 --- a/engines/glk/tads/tads2/memory_cache_loader.h +++ b/engines/glk/tads/tads2/memory_cache_loader.h @@ -42,7 +42,7 @@ namespace TADS2 { * Loader context */ struct mclcxdef { - errcxdef *mclcxerr; /* error handling context */ + errcxdef *mclcxerr; /* error handling context */ }; /** diff --git a/engines/glk/tads/tads2/memory_cache_swap.cpp b/engines/glk/tads/tads2/memory_cache_swap.cpp index cdb1aad6be6..81b7574b87f 100644 --- a/engines/glk/tads/tads2/memory_cache_swap.cpp +++ b/engines/glk/tads/tads2/memory_cache_swap.cpp @@ -31,7 +31,7 @@ namespace TADS2 { /* initialize swapper: allocate memory for swap page table */ void mcsini(mcscxdef *ctx, mcmcx1def *gmemctx, ulong maxsiz, - osfildef *fp, char *swapfilename, errcxdef *errctx) { + osfildef *fp, char *swapfilename, errcxdef *errctx) { uchar *p; ctx->mcscxtab = (mcsdsdef **)0; /* anticipate failure */ @@ -54,15 +54,15 @@ void mcsini(mcscxdef *ctx, mcmcx1def *gmemctx, ulong maxsiz, ctx->mcscxmem = gmemctx; /* - * store the swap filename - make a copy so that the caller doesn't - * have to retain the original copy (in case it's on the stack) - */ + * store the swap filename - make a copy so that the caller doesn't + * have to retain the original copy (in case it's on the stack) + */ if (swapfilename != 0) { ctx->mcscxfname = (char *)mchalo(errctx, (strlen(swapfilename) + 1), "mcsini"); strcpy(ctx->mcscxfname, swapfilename); } else { ctx->mcscxfname = 0; - } + } } /* close the swapper */ @@ -95,11 +95,11 @@ static void mcscompact(mcscxdef *ctx) { desc_in = mcsdsc(ctx, cur_in); /* - * If the present descriptor's address is wrong, and the swap - * segment is in use, move the swap segment. If it's not in - * use, we don't need to move it, because we're going to throw - * away the segment entirely. - */ + * If the present descriptor's address is wrong, and the swap + * segment is in use, move the swap segment. If it's not in + * use, we don't need to move it, because we're going to throw + * away the segment entirely. + */ if (desc_in->mcsdsptr != max && (desc_in->mcsdsflg & MCSDSFINUSE)) { /* ptr_in is the old location, ptr_out is the new location */ ptr_in = desc_in->mcsdsptr; @@ -128,9 +128,9 @@ static void mcscompact(mcscxdef *ctx) { desc_in->mcsdsptr = max; /* - * Make current object's size exact if it's in use. If it's - * not in use, delete the segment altogether. - */ + * Make current object's size exact if it's in use. If it's + * not in use, delete the segment altogether. + */ if (desc_in->mcsdsflg & MCSDSFINUSE) { desc_in->mcsdssiz = desc_in->mcsdsosz; max += desc_in->mcsdssiz; @@ -149,19 +149,19 @@ static void mcscompact(mcscxdef *ctx) { ++cur_out; } else { /* - * We need to renumber the corresponding object so that it - * knows there is no swap segment for it any more. - */ + * We need to renumber the corresponding object so that it + * knows there is no swap segment for it any more. + */ mcmcsw(ctx->mcscxmem, (mcmon)desc_in->mcsdsobj, MCSSEGINV, cur_in); } } /* - * Adjust the top of the file for our new size, and add the savings - * into the available space counter. Also, adjust the total handle - * count to reflect any descriptors that we've deleted. - */ + * Adjust the top of the file for our new size, and add the savings + * into the available space counter. Also, adjust the total handle + * count to reflect any descriptors that we've deleted. + */ ctx->mcscxmax += (ctx->mcscxtop - max); ctx->mcscxtop = max; ctx->mcscxmsg = cur_out; @@ -169,7 +169,7 @@ static void mcscompact(mcscxdef *ctx) { /* swap an object out to the swap file */ mcsseg mcsout(mcscxdef *ctx, uint objid, uchar *ptr, ushort siz, - mcsseg oldseg, int dirty) { + mcsseg oldseg, int dirty) { mcsdsdef *desc; mcsdsdef **pagep; uint i; diff --git a/engines/glk/tads/tads2/memory_cache_swap.h b/engines/glk/tads/tads2/memory_cache_swap.h index 5a7ac7da4fe..950291fa983 100644 --- a/engines/glk/tads/tads2/memory_cache_swap.h +++ b/engines/glk/tads/tads2/memory_cache_swap.h @@ -46,11 +46,11 @@ struct mcmcx1def; * swap segment descriptor */ struct mcsdsdef { - ulong mcsdsptr; /* seek pointer in swap file */ - ushort mcsdssiz; /* size of this swap segment */ - ushort mcsdsosz; /* size of object written to segment */ - uint mcsdsobj; /* client object ID */ - ushort mcsdsflg; /* flags */ + ulong mcsdsptr; /* seek pointer in swap file */ + ushort mcsdssiz; /* size of this swap segment */ + ushort mcsdsosz; /* size of object written to segment */ + uint mcsdsobj; /* client object ID */ + ushort mcsdsflg; /* flags */ #define MCSDSFINUSE 0x01 /* segment is in use */ }; @@ -64,21 +64,21 @@ typedef ushort mcsseg; * Swap manager context */ struct mcscxdef { - osfildef *mcscxfp; /* swap file handle */ - char *mcscxfname; /* name of swap file */ - errcxdef *mcscxerr; /* error handling context */ - ulong mcscxtop; /* top of swap file allocated so far */ - ulong mcscxmax; /* maximum size of swap file we're allowed */ - mcsdsdef **mcscxtab; /* swap descriptor page table */ - mcsseg mcscxmsg; /* maximum segment allocated so far */ - mcmcx1def *mcscxmem; /* memory manager context */ + osfildef *mcscxfp; /* swap file handle */ + char *mcscxfname; /* name of swap file */ + errcxdef *mcscxerr; /* error handling context */ + ulong mcscxtop; /* top of swap file allocated so far */ + ulong mcscxmax; /* maximum size of swap file we're allowed */ + mcsdsdef **mcscxtab; /* swap descriptor page table */ + mcsseg mcscxmsg; /* maximum segment allocated so far */ + mcmcx1def *mcscxmem; /* memory manager context */ }; #define MCSSEGINV ((mcsseg)~0) /* invalid segment ID - error indicator */ /* initialize swapper - returns 0 for success, other for error */ void mcsini(struct mcscxdef *ctx, struct mcmcx1def *gmemctx, ulong maxsiz, - osfildef *fp, char *swapfilename, struct errcxdef *errctx); + osfildef *fp, char *swapfilename, struct errcxdef *errctx); /* close swapper (release memory areas) */ void mcsclose(struct mcscxdef *ctx); @@ -97,8 +97,8 @@ void mcsclose(struct mcscxdef *ctx); * dirty == TRUE, which will force a write regardless of the object ID. */ mcsseg mcsout(struct mcscxdef *ctx, uint objid, uchar *objptr, - ushort objsize, mcsseg oldswapseg, int dirty); - + ushort objsize, mcsseg oldswapseg, int dirty); + /* Swap an object in */ void mcsin(struct mcscxdef *ctx, mcsseg swapseg, uchar *objptr, ushort size); diff --git a/engines/glk/tads/tads2/object.cpp b/engines/glk/tads/tads2/object.cpp index 7bd2f3a279b..4d2f83a0ee6 100644 --- a/engines/glk/tads/tads2/object.cpp +++ b/engines/glk/tads/tads2/object.cpp @@ -36,142 +36,142 @@ namespace TADS2 { */ uint objgetp(mcmcxdef *mctx, objnum objn, prpnum prop, dattyp *typptr) { - objdef *objptr; - prpdef *p; - int cnt; - uint retval; /* property offset, if we find it */ - uint ignprop; /* ignored property - use if real property isn't found */ - uchar pbuf[2]; /* property number in portable format */ - uchar *indp = nullptr; - uchar *indbase; - int last; - int first; - int cur = 0; - - oswp2(pbuf, prop); /* get property number in portable foramt */ - objptr = (objdef *)mcmlck(mctx, objn); /* get a lock on the object */ - ignprop = 0; /* assume we won't find ignored property */ - cnt = objnprop(objptr); /* get number of properties defined */ - retval = 0; /* presume failure */ - - if (objflg(objptr) & OBJFINDEX) - { - /* there's an index -> do a binary search through the index */ - indbase = (uchar *)objpfre(objptr); /* find index */ - first = 0; - last = cnt - 1; - for (;;) - { - if (first > last) break; /* crossed over -> not found */ - cur = first + (last - first)/2; /* split the difference */ - indp = indbase + cur*4; /* get pointer to this entry */ - if (indp[0] == pbuf[0] && indp[1] == pbuf[1]) - { - retval = osrp2(indp + 2); - break; - } - else if (indp[0] < pbuf[0] - || (indp[0] == pbuf[0] && indp[1] < pbuf[1])) - first = (cur == first ? first + 1 : cur); - else - last = (cur == last ? last - 1 : cur); - } + objdef *objptr; + prpdef *p; + int cnt; + uint retval; /* property offset, if we find it */ + uint ignprop; /* ignored property - use if real property isn't found */ + uchar pbuf[2]; /* property number in portable format */ + uchar *indp = nullptr; + uchar *indbase; + int last; + int first; + int cur = 0; + + oswp2(pbuf, prop); /* get property number in portable foramt */ + objptr = (objdef *)mcmlck(mctx, objn); /* get a lock on the object */ + ignprop = 0; /* assume we won't find ignored property */ + cnt = objnprop(objptr); /* get number of properties defined */ + retval = 0; /* presume failure */ + + if (objflg(objptr) & OBJFINDEX) + { + /* there's an index -> do a binary search through the index */ + indbase = (uchar *)objpfre(objptr); /* find index */ + first = 0; + last = cnt - 1; + for (;;) + { + if (first > last) break; /* crossed over -> not found */ + cur = first + (last - first)/2; /* split the difference */ + indp = indbase + cur*4; /* get pointer to this entry */ + if (indp[0] == pbuf[0] && indp[1] == pbuf[1]) + { + retval = osrp2(indp + 2); + break; + } + else if (indp[0] < pbuf[0] + || (indp[0] == pbuf[0] && indp[1] < pbuf[1])) + first = (cur == first ? first + 1 : cur); + else + last = (cur == last ? last - 1 : cur); + } - /* ignore ignored and deleted properties if possible */ - while (retval - && ((prpflg(objptr + retval) & PRPFIGN) != 0 - || ((prpflg(objptr + retval) & PRPFDEL) != 0 - && (mctx->mcmcxflg & MCMCXF_NO_PRP_DEL) == 0)) - && cur < cnt && indp[0] == indp[4] && indp[1] == indp[5]) - { - indp += 4; - retval = osrp2(indp + 2); - } - if (retval && osrp2(objptr + retval) != prop) - assert(FALSE); - } - else - { - /* there's no index -> do sequential search through properties */ - for (p = objprp(objptr) ; cnt ; p = objpnxt(p), --cnt) - { - /* if this is the property, and it's not being ignored, use it */ - if (*(uchar *)p == pbuf[0] && *(((uchar *)p) + 1) == pbuf[1]) - { - if (prpflg(p) & PRPFIGN) /* this is ignored */ - ignprop = objpofs(objptr, p); /* ... make a note of it */ - else if ((prpflg(p) & PRPFDEL) != 0 /* it's deleted */ - && (mctx->mcmcxflg & MCMCXF_NO_PRP_DEL) == 0) - /* simply skip it */ ; - else - { - retval = objpofs(objptr, p); /* this is the one */ - break; /* we're done */ - } - } - } - } + /* ignore ignored and deleted properties if possible */ + while (retval + && ((prpflg(objptr + retval) & PRPFIGN) != 0 + || ((prpflg(objptr + retval) & PRPFDEL) != 0 + && (mctx->mcmcxflg & MCMCXF_NO_PRP_DEL) == 0)) + && cur < cnt && indp[0] == indp[4] && indp[1] == indp[5]) + { + indp += 4; + retval = osrp2(indp + 2); + } + if (retval && osrp2(objptr + retval) != prop) + assert(FALSE); + } + else + { + /* there's no index -> do sequential search through properties */ + for (p = objprp(objptr) ; cnt ; p = objpnxt(p), --cnt) + { + /* if this is the property, and it's not being ignored, use it */ + if (*(uchar *)p == pbuf[0] && *(((uchar *)p) + 1) == pbuf[1]) + { + if (prpflg(p) & PRPFIGN) /* this is ignored */ + ignprop = objpofs(objptr, p); /* ... make a note of it */ + else if ((prpflg(p) & PRPFDEL) != 0 /* it's deleted */ + && (mctx->mcmcxflg & MCMCXF_NO_PRP_DEL) == 0) + /* simply skip it */ ; + else + { + retval = objpofs(objptr, p); /* this is the one */ + break; /* we're done */ + } + } + } + } - if (!retval) retval = ignprop; /* use ignored value if nothing else */ - if (retval && typptr) *typptr = prptype(objofsp(objptr, retval)); - - mcmunlck(mctx, objn); /* done with object, so unlock it */ - return(retval); + if (!retval) retval = ignprop; /* use ignored value if nothing else */ + if (retval && typptr) *typptr = prptype(objofsp(objptr, retval)); + + mcmunlck(mctx, objn); /* done with object, so unlock it */ + return(retval); } /* get the offset of the end of a property in an object */ uint objgetp_end(mcmcxdef *ctx, objnum objn, prpnum prop) { - objdef *objp; - prpdef *propptr; - uint ofs; - uint valsiz; - - /* get the start of the object */ - ofs = objgetp(ctx, objn, prop, 0); - if (ofs == 0) - return 0; + objdef *objp; + prpdef *propptr; + uint ofs; + uint valsiz; + + /* get the start of the object */ + ofs = objgetp(ctx, objn, prop, 0); + if (ofs == 0) + return 0; - /* get the object */ - objp = mcmlck(ctx, (mcmon)objn); + /* get the object */ + objp = mcmlck(ctx, (mcmon)objn); - /* get the property */ - propptr = objofsp(objp, ofs); + /* get the property */ + propptr = objofsp(objp, ofs); - /* get the data size */ - valsiz = prpsize(propptr); + /* get the data size */ + valsiz = prpsize(propptr); - /* done with the object */ - mcmunlck(ctx, (mcmon)objn); + /* done with the object */ + mcmunlck(ctx, (mcmon)objn); - /* - * return the ending offset - it's the starting offset plus the - * property header size plus the size of the property data - */ - return ofs + PRPHDRSIZ + valsiz; + /* + * return the ending offset - it's the starting offset plus the + * property header size plus the size of the property data + */ + return ofs + PRPHDRSIZ + valsiz; } /* determine whether an object is a descendant of another object */ static int objisd(mcmcxdef *ctx, objdef *objptr, objnum parentnum) { - uchar *sc; - int cnt; - - for (sc = objsc(objptr), cnt = objnsc(objptr) ; cnt ; - sc += 2, --cnt) - { - int cursc = osrp2(sc); - int ret; - objdef *curptr; - - if (cursc == parentnum) return(TRUE); - - curptr = (objdef *)mcmlck(ctx, (mcmon)cursc); - ret = objisd(ctx, curptr, parentnum); - mcmunlck(ctx, (mcmon)cursc); - if (ret) return(TRUE); - } - return(FALSE); + uchar *sc; + int cnt; + + for (sc = objsc(objptr), cnt = objnsc(objptr) ; cnt ; + sc += 2, --cnt) + { + int cursc = osrp2(sc); + int ret; + objdef *curptr; + + if (cursc == parentnum) return(TRUE); + + curptr = (objdef *)mcmlck(ctx, (mcmon)cursc); + ret = objisd(ctx, curptr, parentnum); + mcmunlck(ctx, (mcmon)cursc); + if (ret) return(TRUE); + } + return(FALSE); } /* @@ -188,95 +188,95 @@ static int objisd(mcmcxdef *ctx, objdef *objptr, objnum parentnum) * except by objgetap(). */ static uint objgetap0(mcmcxdef *ctx, noreg objnum obj, prpnum prop, - objnum *orn, int inh, dattyp *ortyp) + objnum *orn, int inh, dattyp *ortyp) { - uchar *sc; - ushort sccnt; - ushort psav = 0; - dattyp typsav = DAT_NIL; - objnum osavn = MCMONINV; - uchar *o1; - objnum o1n; - ushort poff; - int found; - uint retval; - dattyp typ; - uchar sclist[100]; /* up to 50 superclasses */ - objdef *objptr; - - NOREG((&obj)) - - /* see if the property is in the current object first */ - if (!inh && (retval = objgetp(ctx, obj, prop, &typ)) != 0) - { - /* - * tell the caller which object this came from, if the caller - * wants to know - */ - if (orn != 0) - *orn = obj; + uchar *sc; + ushort sccnt; + ushort psav = 0; + dattyp typsav = DAT_NIL; + objnum osavn = MCMONINV; + uchar *o1; + objnum o1n; + ushort poff; + int found; + uint retval; + dattyp typ; + uchar sclist[100]; /* up to 50 superclasses */ + objdef *objptr; + + NOREG((&obj)) + + /* see if the property is in the current object first */ + if (!inh && (retval = objgetp(ctx, obj, prop, &typ)) != 0) + { + /* + * tell the caller which object this came from, if the caller + * wants to know + */ + if (orn != 0) + *orn = obj; - /* if the caller wants to know the type, return it */ - if (ortyp != 0) - *ortyp = typ; + /* if the caller wants to know the type, return it */ + if (ortyp != 0) + *ortyp = typ; - /* return the property offset */ - return retval; - } - - /* lock the object, cache its superclass list, and unlock it */ - objptr = (objdef *)mcmlck(ctx, (mcmon)obj); - sccnt = objnsc(objptr); - memcpy(sclist, objsc(objptr), (size_t)(sccnt << 1)); - sc = sclist; - mcmunlck(ctx, (mcmon)obj); - - /* try to inherit the property */ - for (found = FALSE ; sccnt != 0 ; sc += 2, --sccnt) - { - /* recursively look up the property in this superclass */ - poff = objgetap0(ctx, (objnum)osrp2(sc), prop, &o1n, FALSE, &typ); + /* return the property offset */ + return retval; + } + + /* lock the object, cache its superclass list, and unlock it */ + objptr = (objdef *)mcmlck(ctx, (mcmon)obj); + sccnt = objnsc(objptr); + memcpy(sclist, objsc(objptr), (size_t)(sccnt << 1)); + sc = sclist; + mcmunlck(ctx, (mcmon)obj); + + /* try to inherit the property */ + for (found = FALSE ; sccnt != 0 ; sc += 2, --sccnt) + { + /* recursively look up the property in this superclass */ + poff = objgetap0(ctx, (objnum)osrp2(sc), prop, &o1n, FALSE, &typ); - /* if we found the property, remember it */ - if (poff != 0) - { - int isdesc = 0; - - /* if we have a previous object, determine lineage */ - if (found) - { - o1 = mcmlck(ctx, o1n); - isdesc = objisd(ctx, o1, osavn); - mcmunlck(ctx, o1n); - } - - /* - * if we don't already have a property, or the new object - * is a descendant of the previously found object (meaning - * that the new object's property should override the - * previously found object's property), use this new - * property - */ - if (!found || isdesc) - { - psav = poff; - osavn = o1n; - typsav = typ; - found = TRUE; - } - } - } + /* if we found the property, remember it */ + if (poff != 0) + { + int isdesc = 0; + + /* if we have a previous object, determine lineage */ + if (found) + { + o1 = mcmlck(ctx, o1n); + isdesc = objisd(ctx, o1, osavn); + mcmunlck(ctx, o1n); + } + + /* + * if we don't already have a property, or the new object + * is a descendant of the previously found object (meaning + * that the new object's property should override the + * previously found object's property), use this new + * property + */ + if (!found || isdesc) + { + psav = poff; + osavn = o1n; + typsav = typ; + found = TRUE; + } + } + } - /* set return pointer and return the offset of what we found */ - if (orn != 0) - *orn = osavn; + /* set return pointer and return the offset of what we found */ + if (orn != 0) + *orn = osavn; - /* return the object type if the caller wanted it */ - if (ortyp != 0) - *ortyp = typsav; + /* return the object type if the caller wanted it */ + if (ortyp != 0) + *ortyp = typsav; - /* return the offset of the property if we found one, or zero if not */ - return (found ? psav : 0); + /* return the offset of the property if we found one, or zero if not */ + return (found ? psav : 0); } /* @@ -290,59 +290,59 @@ static uint objgetap0(mcmcxdef *ctx, noreg objnum obj, prpnum prop, * entry). If the offset is zero, the property was not found. */ uint objgetap(mcmcxdef *ctx, noreg objnum obj, prpnum prop, - objnum *ornp, int inh) + objnum *ornp, int inh) { - uint retval; - dattyp typ; - objnum orn; + uint retval; + dattyp typ; + objnum orn; - /* - * even if the caller doesn't care about the original object number, - * we do, so provide our own location to store it if necessary - */ - if (ornp == 0) - ornp = &orn; + /* + * even if the caller doesn't care about the original object number, + * we do, so provide our own location to store it if necessary + */ + if (ornp == 0) + ornp = &orn; - /* keep going until we've finished translating synonyms */ - for (;;) - { - /* look up the property */ - retval = objgetap0(ctx, obj, prop, ornp, inh, &typ); - - /* - * If we found something (i.e., retval != 0), check to see if we - * have a synonym; if so, synonym translation is required - */ - if (retval != 0 && typ == DAT_SYN) - { - prpnum prvprop; - objdef *objptr; - prpdef *p; + /* keep going until we've finished translating synonyms */ + for (;;) + { + /* look up the property */ + retval = objgetap0(ctx, obj, prop, ornp, inh, &typ); + + /* + * If we found something (i.e., retval != 0), check to see if we + * have a synonym; if so, synonym translation is required + */ + if (retval != 0 && typ == DAT_SYN) + { + prpnum prvprop; + objdef *objptr; + prpdef *p; - /* - * Translation is required - get new property and try again. - * First, remember the original property, so we can make - * sure we're not going to loop (at least, not in this one - * synonym definition). - */ - prvprop = prop; + /* + * Translation is required - get new property and try again. + * First, remember the original property, so we can make + * sure we're not going to loop (at least, not in this one + * synonym definition). + */ + prvprop = prop; - objptr = (objdef *)mcmlck(ctx, (mcmon)*ornp); - p = objofsp(objptr, retval); - prop = osrp2(prpvalp(p)); - mcmunlck(ctx, (mcmon)*ornp); + objptr = (objdef *)mcmlck(ctx, (mcmon)*ornp); + p = objofsp(objptr, retval); + prop = osrp2(prpvalp(p)); + mcmunlck(ctx, (mcmon)*ornp); - /* check for direct circularity */ - if (prop == prvprop) - errsig(ctx->mcmcxgl->mcmcxerr, ERR_CIRCSYN); + /* check for direct circularity */ + if (prop == prvprop) + errsig(ctx->mcmcxgl->mcmcxerr, ERR_CIRCSYN); - /* go back for another try with the new property */ - continue; - } + /* go back for another try with the new property */ + continue; + } - /* we don't have to perform a translation; return the result */ - return retval; - } + /* we don't have to perform a translation; return the result */ + return retval; + } } @@ -353,13 +353,13 @@ uint objgetap(mcmcxdef *ctx, noreg objnum obj, prpnum prop, */ objdef *objexp(mcmcxdef *ctx, objnum obj, ushort *siz) { - ushort oldsiz; - uchar *p; - - oldsiz = mcmobjsiz(ctx, (mcmon)obj); - p = mcmrealo(ctx, (mcmon)obj, (ushort)(oldsiz + *siz)); - *siz = mcmobjsiz(ctx, (mcmon)obj) - oldsiz; - return((objdef *)p); + ushort oldsiz; + uchar *p; + + oldsiz = mcmobjsiz(ctx, (mcmon)obj); + p = mcmrealo(ctx, (mcmon)obj, (ushort)(oldsiz + *siz)); + *siz = mcmobjsiz(ctx, (mcmon)obj) - oldsiz; + return((objdef *)p); } /* @@ -375,41 +375,41 @@ objdef *objexp(mcmcxdef *ctx, objnum obj, ushort *siz) */ void objdelp(mcmcxdef *mctx, objnum objn, prpnum prop, int mark_only) { - objdef *objptr; - uint pofs; - prpdef *p; - prpdef *nxt; - size_t movsiz; - - pofs = objgetp(mctx, objn, prop, (dattyp *)0); /* try to find property */ - if (!pofs) return; /* not defined - nothing to delete */ - - objptr = (objdef *)mcmlck(mctx, objn); /* get lock on object */ - p = objofsp(objptr, pofs); /* get actual prpdef pointer */ - nxt = objpnxt(p); /* find next prpdef after this one */ - - /* if this is original, just mark 'ignore' */ - if (prpflg(p) & PRPFORG) - { - prpflg(p) |= PRPFIGN; /* mark this as overridden */ - } - else if (mark_only) - { - prpflg(p) |= PRPFDEL; /* mark as deleted without removing space */ - } - else - { - /* move prpdef's after current one down over current one */ - movsiz = (uchar *)objptr + objfree(objptr) - (uchar *)nxt; - memmove(p, nxt, movsiz); + objdef *objptr; + uint pofs; + prpdef *p; + prpdef *nxt; + size_t movsiz; + + pofs = objgetp(mctx, objn, prop, (dattyp *)0); /* try to find property */ + if (!pofs) return; /* not defined - nothing to delete */ + + objptr = (objdef *)mcmlck(mctx, objn); /* get lock on object */ + p = objofsp(objptr, pofs); /* get actual prpdef pointer */ + nxt = objpnxt(p); /* find next prpdef after this one */ + + /* if this is original, just mark 'ignore' */ + if (prpflg(p) & PRPFORG) + { + prpflg(p) |= PRPFIGN; /* mark this as overridden */ + } + else if (mark_only) + { + prpflg(p) |= PRPFDEL; /* mark as deleted without removing space */ + } + else + { + /* move prpdef's after current one down over current one */ + movsiz = (uchar *)objptr + objfree(objptr) - (uchar *)nxt; + memmove(p, nxt, movsiz); - objsnp(objptr, objnprop(objptr)-1); - objsfree(objptr, objfree(objptr) - (((uchar *)nxt) - ((uchar *)p))); - } - - /* tell cache manager this object has been changed, and unlock it */ - mcmtch(mctx, objn); - mcmunlck(mctx, objn); + objsnp(objptr, objnprop(objptr)-1); + objsfree(objptr, objfree(objptr) - (((uchar *)nxt) - ((uchar *)p))); + } + + /* tell cache manager this object has been changed, and unlock it */ + mcmtch(mctx, objn); + mcmunlck(mctx, objn); } /* @@ -419,327 +419,327 @@ void objdelp(mcmcxdef *mctx, objnum objn, prpnum prop, int mark_only) * pointer is null, no undo information is kept. */ void objsetp(mcmcxdef *ctx, objnum objn, prpnum prop, dattyp typ, - const void *val, objucxdef *undoctx) + const void *val, objucxdef *undoctx) { - objdef *objptr; - prpdef *p; - uint pofs; - uint siz; - ushort newsiz; - int indexed; - int prop_was_set; - - /* get a lock on the object */ - objptr = (objdef *)mcmlck(ctx, objn); - indexed = objflg(objptr) & OBJFINDEX; + objdef *objptr; + prpdef *p; + uint pofs; + uint siz; + ushort newsiz; + int indexed; + int prop_was_set; + + /* get a lock on the object */ + objptr = (objdef *)mcmlck(ctx, objn); + indexed = objflg(objptr) & OBJFINDEX; - /* catch any errors so we can unlock the object */ - ERRBEGIN(ctx->mcmcxgl->mcmcxerr) - { - /* get the previous value of the property, if any */ - pofs = objgetp(ctx, objn, prop, (dattyp *)0); - p = objofsp(objptr, pofs); - prop_was_set = (p != 0); + /* catch any errors so we can unlock the object */ + ERRBEGIN(ctx->mcmcxgl->mcmcxerr) + { + /* get the previous value of the property, if any */ + pofs = objgetp(ctx, objn, prop, (dattyp *)0); + p = objofsp(objptr, pofs); + prop_was_set = (p != 0); - /* start the undo record if we are keeping undo information */ - if (undoctx && objuok(undoctx)) - { - uchar *up; - uchar cmd; + /* start the undo record if we are keeping undo information */ + if (undoctx && objuok(undoctx)) + { + uchar *up; + uchar cmd; - if (p) - { - if (prpflg(p) & PRPFORG) - { - cmd = OBJUOVR; /* override original */ - p = (prpdef *)0; /* pretend it doesn't even exist */ - } - else cmd = OBJUCHG; /* change property */ - } - else cmd = OBJUADD; /* prop didn't exist - adding it */ + if (p) + { + if (prpflg(p) & PRPFORG) + { + cmd = OBJUOVR; /* override original */ + p = (prpdef *)0; /* pretend it doesn't even exist */ + } + else cmd = OBJUCHG; /* change property */ + } + else cmd = OBJUADD; /* prop didn't exist - adding it */ - /* write header, reserve space, and get a pointer to the space */ - up = objures(undoctx, cmd, - (ushort)(sizeof(mcmon) + sizeof(prpnum) - + (p ? PRPHDRSIZ + prpsize(p) : 0))); + /* write header, reserve space, and get a pointer to the space */ + up = objures(undoctx, cmd, + (ushort)(sizeof(mcmon) + sizeof(prpnum) + + (p ? PRPHDRSIZ + prpsize(p) : 0))); - /* write the object and property numbers */ - memcpy(up, &objn, (size_t)sizeof(objn)); - up += sizeof(mcmon); - memcpy(up, &prop, (size_t)sizeof(prop)); - up += sizeof(prop); + /* write the object and property numbers */ + memcpy(up, &objn, (size_t)sizeof(objn)); + up += sizeof(mcmon); + memcpy(up, &prop, (size_t)sizeof(prop)); + up += sizeof(prop); - /* if there's existing data, write it */ - if (p) - { - memcpy(up, p, (size_t)(PRPHDRSIZ + prpsize(p))); - up += PRPHDRSIZ + prpsize(p); - } + /* if there's existing data, write it */ + if (p) + { + memcpy(up, p, (size_t)(PRPHDRSIZ + prpsize(p))); + up += PRPHDRSIZ + prpsize(p); + } - /* update the undo context's head offset for the new value */ - undoctx->objucxhead = up - undoctx->objucxbuf; - } + /* update the undo context's head offset for the new value */ + undoctx->objucxhead = up - undoctx->objucxbuf; + } - /* get the size of the data */ - siz = datsiz(typ, val); + /* get the size of the data */ + siz = datsiz(typ, val); - /* - * If the property is already set, and the new data fits, use the - * existing slot. However, do not use existing slot if it's - * in the non-mutable portion of the object. - */ - if (!p || (uint)prpsize(p) < siz || pofs < (uint)objrst(objptr)) - { - uint avail; + /* + * If the property is already set, and the new data fits, use the + * existing slot. However, do not use existing slot if it's + * in the non-mutable portion of the object. + */ + if (!p || (uint)prpsize(p) < siz || pofs < (uint)objrst(objptr)) + { + uint avail; - /* delete any existing value */ - if (prop_was_set) - objdelp(ctx, objn, prop, FALSE); + /* delete any existing value */ + if (prop_was_set) + objdelp(ctx, objn, prop, FALSE); - /* get the top of the property area */ - p = objpfre(objptr); + /* get the top of the property area */ + p = objpfre(objptr); - /* make sure there's room at the top */ - avail = mcmobjsiz(ctx, (mcmon)objn) - objfree(objptr); - if (avail < siz + PRPHDRSIZ) - { - newsiz = 64 + ((objfree(objptr) + siz + PRPHDRSIZ) - - mcmobjsiz(ctx, (mcmon)objn)); - objptr = objexp(ctx, objn, &newsiz); - p = objpfre(objptr); /* reset pointer if object moved */ - /* NOTE! Index (if present) is now invalid! */ - } + /* make sure there's room at the top */ + avail = mcmobjsiz(ctx, (mcmon)objn) - objfree(objptr); + if (avail < siz + PRPHDRSIZ) + { + newsiz = 64 + ((objfree(objptr) + siz + PRPHDRSIZ) - + mcmobjsiz(ctx, (mcmon)objn)); + objptr = objexp(ctx, objn, &newsiz); + p = objpfre(objptr); /* reset pointer if object moved */ + /* NOTE! Index (if present) is now invalid! */ + } - prpsetsize(p, siz); /* set the new property size */ - prpsetprop(p, prop); /* ... and property id */ - prpflg(p) = 0; /* no property flags yet */ - objsnp(objptr, objnprop(objptr) + 1); /* one more prop */ - objsfree(objptr, objfree(objptr) + siz + PRPHDRSIZ); - } + prpsetsize(p, siz); /* set the new property size */ + prpsetprop(p, prop); /* ... and property id */ + prpflg(p) = 0; /* no property flags yet */ + objsnp(objptr, objnprop(objptr) + 1); /* one more prop */ + objsfree(objptr, objfree(objptr) + siz + PRPHDRSIZ); + } - /* copy the new data to top of object's free space */ - prptype(p) = typ; - if (siz != 0) memcpy(prpvalp(p), val, (size_t)siz); - } - ERRCLEAN(ctx->mcmcxgl->mcmcxerr) - { - mcmunlck(ctx, objn); /* unlock the object */ - } - ERRENDCLN(ctx->mcmcxgl->mcmcxerr) - - /* dirty the object, and release lock on object before return */ - mcmtch(ctx, objn); /* mark the object as changed */ - mcmunlck(ctx, objn); /* unlock it */ + /* copy the new data to top of object's free space */ + prptype(p) = typ; + if (siz != 0) memcpy(prpvalp(p), val, (size_t)siz); + } + ERRCLEAN(ctx->mcmcxgl->mcmcxerr) + { + mcmunlck(ctx, objn); /* unlock the object */ + } + ERRENDCLN(ctx->mcmcxgl->mcmcxerr) + + /* dirty the object, and release lock on object before return */ + mcmtch(ctx, objn); /* mark the object as changed */ + mcmunlck(ctx, objn); /* unlock it */ - /* if necessary, rebuild the property index */ - if (indexed) objindx(ctx, objn); + /* if necessary, rebuild the property index */ + if (indexed) objindx(ctx, objn); } /* set an undo savepoint */ void objusav(objucxdef *undoctx) { - /* the only thing in this record is the OBJUSAV header */ - objures(undoctx, OBJUSAV, (ushort)0); + /* the only thing in this record is the OBJUSAV header */ + objures(undoctx, OBJUSAV, (ushort)0); } /* reserve space in an undo buffer, and write header */ uchar *objures(objucxdef *undoctx, uchar cmd, ushort siz) { - ushort prv; - uchar *p; - - /* adjust size to include header information */ - siz += 1 + sizeof(ushort); - - /* make sure there's enough room overall for the record */ - if (siz > undoctx->objucxsiz) errsig(undoctx->objucxerr, ERR_UNDOVF); - - /* if there's no information, reset buffers */ - if (undoctx->objucxhead == undoctx->objucxprv) - { - undoctx->objucxhead = undoctx->objucxprv = undoctx->objucxtail = 0; - undoctx->objucxtop = 0; - goto done; - } - - /* if tail is below head, we can use to top of entire buffer */ - if (undoctx->objucxtail < undoctx->objucxhead) - { - /* if there's enough space left after head, we're done */ - if (undoctx->objucxsiz - undoctx->objucxhead >= siz) - goto done; - - /* insufficient space: wrap head down to bottom of buffer */ - undoctx->objucxtop = undoctx->objucxprv; /* last was top */ - undoctx->objucxhead = 0; - } - - /* head is below tail: delete records until we have enough room */ - while (undoctx->objucxtail - undoctx->objucxhead < siz) - { - objutadv(undoctx); - - /* if the tail wrapped, advancing won't do any more good */ - if (undoctx->objucxtail <= undoctx->objucxhead) - { - /* if there's enough room at the top, we're done */ - if (undoctx->objucxsiz - undoctx->objucxhead >= siz) - goto done; - - /* still not enough room; wrap the head this time */ - undoctx->objucxtop = undoctx->objucxprv; /* last was top */ - undoctx->objucxhead = 0; - } - } - + ushort prv; + uchar *p; + + /* adjust size to include header information */ + siz += 1 + sizeof(ushort); + + /* make sure there's enough room overall for the record */ + if (siz > undoctx->objucxsiz) errsig(undoctx->objucxerr, ERR_UNDOVF); + + /* if there's no information, reset buffers */ + if (undoctx->objucxhead == undoctx->objucxprv) + { + undoctx->objucxhead = undoctx->objucxprv = undoctx->objucxtail = 0; + undoctx->objucxtop = 0; + goto done; + } + + /* if tail is below head, we can use to top of entire buffer */ + if (undoctx->objucxtail < undoctx->objucxhead) + { + /* if there's enough space left after head, we're done */ + if (undoctx->objucxsiz - undoctx->objucxhead >= siz) + goto done; + + /* insufficient space: wrap head down to bottom of buffer */ + undoctx->objucxtop = undoctx->objucxprv; /* last was top */ + undoctx->objucxhead = 0; + } + + /* head is below tail: delete records until we have enough room */ + while (undoctx->objucxtail - undoctx->objucxhead < siz) + { + objutadv(undoctx); + + /* if the tail wrapped, advancing won't do any more good */ + if (undoctx->objucxtail <= undoctx->objucxhead) + { + /* if there's enough room at the top, we're done */ + if (undoctx->objucxsiz - undoctx->objucxhead >= siz) + goto done; + + /* still not enough room; wrap the head this time */ + undoctx->objucxtop = undoctx->objucxprv; /* last was top */ + undoctx->objucxhead = 0; + } + } + done: - /* save back-link, and set objucxprv pointer to the new record */ - prv = undoctx->objucxprv; - undoctx->objucxprv = undoctx->objucxhead; - - /* write the header: command byte, back-link to previous record */ - p = &undoctx->objucxbuf[undoctx->objucxhead]; - *p++ = cmd; - memcpy(p, &prv, sizeof(prv)); - - /* advance the head pointer past the header */ - undoctx->objucxhead += 1 + sizeof(prv); - - /* set the high-water mark if we've exceeded the old one */ - if (undoctx->objucxprv > undoctx->objucxtop) - undoctx->objucxtop = undoctx->objucxprv; + /* save back-link, and set objucxprv pointer to the new record */ + prv = undoctx->objucxprv; + undoctx->objucxprv = undoctx->objucxhead; + + /* write the header: command byte, back-link to previous record */ + p = &undoctx->objucxbuf[undoctx->objucxhead]; + *p++ = cmd; + memcpy(p, &prv, sizeof(prv)); + + /* advance the head pointer past the header */ + undoctx->objucxhead += 1 + sizeof(prv); + + /* set the high-water mark if we've exceeded the old one */ + if (undoctx->objucxprv > undoctx->objucxtop) + undoctx->objucxtop = undoctx->objucxprv; - /* return the reserved space */ - return &undoctx->objucxbuf[undoctx->objucxhead]; + /* return the reserved space */ + return &undoctx->objucxbuf[undoctx->objucxhead]; } /* advance the undo tail pointer over the record it points to */ void objutadv(objucxdef *undoctx) { - uchar *p; - ushort siz; - uchar pr[PRPHDRSIZ]; /* space for a property header */ - uchar cmd; - - /* if we're at the most recently written record, flush buffer */ - if (undoctx->objucxtail == undoctx->objucxprv) - { - undoctx->objucxtail = 0; - undoctx->objucxprv = 0; - undoctx->objucxhead = 0; - undoctx->objucxtop = 0; - } + uchar *p; + ushort siz; + uchar pr[PRPHDRSIZ]; /* space for a property header */ + uchar cmd; + + /* if we're at the most recently written record, flush buffer */ + if (undoctx->objucxtail == undoctx->objucxprv) + { + undoctx->objucxtail = 0; + undoctx->objucxprv = 0; + undoctx->objucxhead = 0; + undoctx->objucxtop = 0; + } - /* if we've reached high water mark, wrap back to bottom */ - if (undoctx->objucxtail == undoctx->objucxtop) - { - undoctx->objucxtail = 0; - return; - } - - /* determine size by inspecting current record */ - p = undoctx->objucxbuf + undoctx->objucxtail; - siz = 1 + sizeof(ushort); /* basic header size */ - - cmd = *p++; - p += sizeof(ushort); /* skip the previous pointer */ - - switch(cmd) - { - case OBJUCHG: - /* change: property header (added below) plus data value */ - memcpy(pr, p + sizeof(mcmon) + sizeof(prpnum), (size_t)PRPHDRSIZ); - siz += PRPHDRSIZ + prpsize(pr); - /* FALLTHROUGH */ + /* if we've reached high water mark, wrap back to bottom */ + if (undoctx->objucxtail == undoctx->objucxtop) + { + undoctx->objucxtail = 0; + return; + } + + /* determine size by inspecting current record */ + p = undoctx->objucxbuf + undoctx->objucxtail; + siz = 1 + sizeof(ushort); /* basic header size */ + + cmd = *p++; + p += sizeof(ushort); /* skip the previous pointer */ + + switch(cmd) + { + case OBJUCHG: + /* change: property header (added below) plus data value */ + memcpy(pr, p + sizeof(mcmon) + sizeof(prpnum), (size_t)PRPHDRSIZ); + siz += PRPHDRSIZ + prpsize(pr); + /* FALLTHROUGH */ - case OBJUADD: - case OBJUOVR: - /* add/override: property header only */ - siz += sizeof(mcmon) + sizeof(prpnum); - break; - - case OBJUCLI: - siz += (*undoctx->objucxcsz)(undoctx->objucxccx, p); - break; + case OBJUADD: + case OBJUOVR: + /* add/override: property header only */ + siz += sizeof(mcmon) + sizeof(prpnum); + break; + + case OBJUCLI: + siz += (*undoctx->objucxcsz)(undoctx->objucxccx, p); + break; - case OBJUSAV: - break; - } - - undoctx->objucxtail += siz; + case OBJUSAV: + break; + } + + undoctx->objucxtail += siz; } /* undo one undo record, and remove it from the undo list */ void obj1undo(mcmcxdef *mctx, objucxdef *undoctx) { - uchar *p; + uchar *p; prpnum prop = 0; objnum objn = 0; - uchar cmd; - uchar pr[PRPHDRSIZ]; /* space for property header */ - ushort prv; - ushort pofs; - objdef *objptr; + uchar cmd; + uchar pr[PRPHDRSIZ]; /* space for property header */ + ushort prv; + ushort pofs; + objdef *objptr; int indexed = 0; - /* if there's no more undo, signal an error */ - if (undoctx->objucxprv == undoctx->objucxhead) - errsig(undoctx->objucxerr, ERR_NOUNDO); - - /* move back to previous record */ - undoctx->objucxhead = undoctx->objucxprv; - p = &undoctx->objucxbuf[undoctx->objucxprv]; - - /* get command, and set undocxprv to previous record */ - cmd = *p++; - memcpy(&prv, p, sizeof(prv)); - p += sizeof(prv); - - /* if we're at the tail, no more undo; otherwise, use back link */ - if (undoctx->objucxprv == undoctx->objucxtail) - undoctx->objucxprv = undoctx->objucxhead; - else - undoctx->objucxprv = prv; - - if (cmd == OBJUSAV) return; /* savepointer marker - nothing to do */ - - /* get object/property information for property-changing undo */ - if (cmd != OBJUCLI) - { - memcpy(&objn, p, (size_t)sizeof(objn)); - p += sizeof(objn); - memcpy(&prop, p, (size_t)sizeof(prop)); - p += sizeof(prop); - objptr = mcmlck(mctx, objn); - indexed = (objflg(objptr) & OBJFINDEX); - mcmunlck(mctx, objn); - } - - switch(cmd) - { - case OBJUADD: - objdelp(mctx, objn, prop, FALSE); - if (indexed) objindx(mctx, objn); - break; - - case OBJUOVR: - objdelp(mctx, objn, prop, FALSE); /* delete the non-original value */ - pofs = objgetp(mctx, objn, prop, (dattyp *)0); /* get ignored prop */ - objptr = (objdef *)mcmlck(mctx, objn); /* lock the object */ - prpflg(objofsp(objptr, pofs)) &= ~PRPFIGN; /* no longer ignored */ - mcmunlck(mctx, objn); /* unlock the object */ - break; - - case OBJUCHG: - memcpy(pr, p, (size_t)PRPHDRSIZ); - p += PRPHDRSIZ; - objsetp(mctx, objn, prop, prptype(pr), (void *)p, (objucxdef *)0); - break; - - case OBJUCLI: - (*undoctx->objucxcun)(undoctx->objucxccx, p); - break; - } + /* if there's no more undo, signal an error */ + if (undoctx->objucxprv == undoctx->objucxhead) + errsig(undoctx->objucxerr, ERR_NOUNDO); + + /* move back to previous record */ + undoctx->objucxhead = undoctx->objucxprv; + p = &undoctx->objucxbuf[undoctx->objucxprv]; + + /* get command, and set undocxprv to previous record */ + cmd = *p++; + memcpy(&prv, p, sizeof(prv)); + p += sizeof(prv); + + /* if we're at the tail, no more undo; otherwise, use back link */ + if (undoctx->objucxprv == undoctx->objucxtail) + undoctx->objucxprv = undoctx->objucxhead; + else + undoctx->objucxprv = prv; + + if (cmd == OBJUSAV) return; /* savepointer marker - nothing to do */ + + /* get object/property information for property-changing undo */ + if (cmd != OBJUCLI) + { + memcpy(&objn, p, (size_t)sizeof(objn)); + p += sizeof(objn); + memcpy(&prop, p, (size_t)sizeof(prop)); + p += sizeof(prop); + objptr = mcmlck(mctx, objn); + indexed = (objflg(objptr) & OBJFINDEX); + mcmunlck(mctx, objn); + } + + switch(cmd) + { + case OBJUADD: + objdelp(mctx, objn, prop, FALSE); + if (indexed) objindx(mctx, objn); + break; + + case OBJUOVR: + objdelp(mctx, objn, prop, FALSE); /* delete the non-original value */ + pofs = objgetp(mctx, objn, prop, (dattyp *)0); /* get ignored prop */ + objptr = (objdef *)mcmlck(mctx, objn); /* lock the object */ + prpflg(objofsp(objptr, pofs)) &= ~PRPFIGN; /* no longer ignored */ + mcmunlck(mctx, objn); /* unlock the object */ + break; + + case OBJUCHG: + memcpy(pr, p, (size_t)PRPHDRSIZ); + p += PRPHDRSIZ; + objsetp(mctx, objn, prop, prptype(pr), (void *)p, (objucxdef *)0); + break; + + case OBJUCLI: + (*undoctx->objucxcun)(undoctx->objucxccx, p); + break; + } } /* @@ -748,25 +748,25 @@ void obj1undo(mcmcxdef *mctx, objucxdef *undoctx) */ int objuok(objucxdef *undoctx) { - ushort prv; + ushort prv; - /* see if there's any more undo information */ - if (undoctx->objucxprv == undoctx->objucxhead) - return(FALSE); + /* see if there's any more undo information */ + if (undoctx->objucxprv == undoctx->objucxhead) + return(FALSE); - /* look for most recent savepoint marker */ - for (prv = undoctx->objucxprv ;; ) - { - if (undoctx->objucxbuf[prv] == OBJUSAV) - return(TRUE); /* found a savepoint - can add undo */ + /* look for most recent savepoint marker */ + for (prv = undoctx->objucxprv ;; ) + { + if (undoctx->objucxbuf[prv] == OBJUSAV) + return(TRUE); /* found a savepoint - can add undo */ - /* if we've reached the tail, there are no more undo records */ - if (prv == undoctx->objucxtail) - return(FALSE); /* no savepoints - can't add undo */ + /* if we've reached the tail, there are no more undo records */ + if (prv == undoctx->objucxtail) + return(FALSE); /* no savepoints - can't add undo */ - /* get previous record */ - memcpy(&prv, &undoctx->objucxbuf[prv+1], sizeof(prv)); - } + /* get previous record */ + memcpy(&prv, &undoctx->objucxbuf[prv+1], sizeof(prv)); + } } /* @@ -778,146 +778,146 @@ int objuok(objucxdef *undoctx) */ void objundo(mcmcxdef *mctx, objucxdef *undoctx) { - ushort prv; - ushort sav; + ushort prv; + ushort sav; - /* see if there's any more undo information */ - if (undoctx->objucxprv == undoctx->objucxhead) - errsig(undoctx->objucxerr, ERR_NOUNDO); + /* see if there's any more undo information */ + if (undoctx->objucxprv == undoctx->objucxhead) + errsig(undoctx->objucxerr, ERR_NOUNDO); - /* look for most recent savepoint marker */ - for (prv = undoctx->objucxprv ;; ) - { - if (undoctx->objucxbuf[prv] == OBJUSAV) - { - sav = prv; - break; - } - - /* if we've reached the tail, there are no more undo records */ - if (prv == undoctx->objucxtail) - errsig(undoctx->objucxerr, ERR_ICUNDO); + /* look for most recent savepoint marker */ + for (prv = undoctx->objucxprv ;; ) + { + if (undoctx->objucxbuf[prv] == OBJUSAV) + { + sav = prv; + break; + } + + /* if we've reached the tail, there are no more undo records */ + if (prv == undoctx->objucxtail) + errsig(undoctx->objucxerr, ERR_ICUNDO); - /* get previous record */ - memcpy(&prv, &undoctx->objucxbuf[prv+1], sizeof(prv)); - } - - /* now undo everything until we get to the savepoint */ - do { obj1undo(mctx, undoctx); } while (undoctx->objucxhead != sav); + /* get previous record */ + memcpy(&prv, &undoctx->objucxbuf[prv+1], sizeof(prv)); + } + + /* now undo everything until we get to the savepoint */ + do { obj1undo(mctx, undoctx); } while (undoctx->objucxhead != sav); } /* initialize undo context */ objucxdef *objuini(mcmcxdef *ctx, ushort siz, - void (*undocb)(void *, uchar *), - ushort (*sizecb)(void *, uchar *), - void *callctx) + void (*undocb)(void *, uchar *), + ushort (*sizecb)(void *, uchar *), + void *callctx) { - objucxdef *ret; - long totsiz; + objucxdef *ret; + long totsiz; - /* force size into valid range */ - totsiz = (long)siz + sizeof(objucxdef) - 1; - if (totsiz > 0xff00) - siz = 0xff00 - sizeof(objucxdef) + 1; + /* force size into valid range */ + totsiz = (long)siz + sizeof(objucxdef) - 1; + if (totsiz > 0xff00) + siz = 0xff00 - sizeof(objucxdef) + 1; - ret = (objucxdef *)mchalo(ctx->mcmcxgl->mcmcxerr, - (sizeof(objucxdef) + siz - 1), - "objuini"); - - ret->objucxmem = ctx; - ret->objucxerr = ctx->mcmcxgl->mcmcxerr; - ret->objucxsiz = siz; - ret->objucxhead = ret->objucxprv = ret->objucxtail = ret->objucxtop = 0; - - /* set client callback functions */ - ret->objucxcun = undocb; /* callback to apply client undo */ - ret->objucxcsz = sizecb; /* callback to get size of client undo */ - ret->objucxccx = callctx; /* context for client callback functions */ - - return(ret); + ret = (objucxdef *)mchalo(ctx->mcmcxgl->mcmcxerr, + (sizeof(objucxdef) + siz - 1), + "objuini"); + + ret->objucxmem = ctx; + ret->objucxerr = ctx->mcmcxgl->mcmcxerr; + ret->objucxsiz = siz; + ret->objucxhead = ret->objucxprv = ret->objucxtail = ret->objucxtop = 0; + + /* set client callback functions */ + ret->objucxcun = undocb; /* callback to apply client undo */ + ret->objucxcsz = sizecb; /* callback to get size of client undo */ + ret->objucxccx = callctx; /* context for client callback functions */ + + return(ret); } /* discard all undo records */ void objulose(objucxdef *ctx) { - if (ctx) - ctx->objucxhead = - ctx->objucxprv = - ctx->objucxtail = - ctx->objucxtop = 0; + if (ctx) + ctx->objucxhead = + ctx->objucxprv = + ctx->objucxtail = + ctx->objucxtop = 0; } /* uninitialize the undo context - release allocated memory */ void objuterm(objucxdef *uctx) { - /* free the undo memory block */ - mchfre(uctx); + /* free the undo memory block */ + mchfre(uctx); } /* revert object to original (post-compilation) values */ void objrevert(void *ctx0, mcmon objn) { - mcmcxdef *mctx = (mcmcxdef *)ctx0; - uchar *p; - prpdef *pr; - int cnt; - int indexed; - - p = mcmlck(mctx, objn); - pr = objprp(p); - indexed = objflg(p) & OBJFINDEX; - - /* restore original settings */ - objsfree(p, objrst(p)); - objsnp(p, objstat(p)); + mcmcxdef *mctx = (mcmcxdef *)ctx0; + uchar *p; + prpdef *pr; + int cnt; + int indexed; + + p = mcmlck(mctx, objn); + pr = objprp(p); + indexed = objflg(p) & OBJFINDEX; + + /* restore original settings */ + objsfree(p, objrst(p)); + objsnp(p, objstat(p)); - /* go through original properties and remove 'ignore' flag if set */ - for (cnt = objnprop(p) ; cnt ; pr = objpnxt(pr), --cnt) - prpflg(pr) &= ~PRPFIGN; - - /* touch object and unlock it */ - mcmtch(mctx, objn); - mcmunlck(mctx, objn); - - /* if it's indexed, rebuild the index */ - if (indexed) objindx(mctx, objn); + /* go through original properties and remove 'ignore' flag if set */ + for (cnt = objnprop(p) ; cnt ; pr = objpnxt(pr), --cnt) + prpflg(pr) &= ~PRPFIGN; + + /* touch object and unlock it */ + mcmtch(mctx, objn); + mcmunlck(mctx, objn); + + /* if it's indexed, rebuild the index */ + if (indexed) objindx(mctx, objn); } /* set 'ignore' flag for original properties set in mutable part */ void objsetign(mcmcxdef *mctx, objnum objn) { - objdef *objptr; - prpdef *mut; - prpdef *p; - int statcnt; - int cnt; - int indexed; - prpdef *p1; - - objptr = (objdef *)mcmlck(mctx, (mcmon)objn); - p1 = objprp(objptr); - indexed = objflg(objptr) & OBJFINDEX; + objdef *objptr; + prpdef *mut; + prpdef *p; + int statcnt; + int cnt; + int indexed; + prpdef *p1; + + objptr = (objdef *)mcmlck(mctx, (mcmon)objn); + p1 = objprp(objptr); + indexed = objflg(objptr) & OBJFINDEX; - /* go through mutables, and set ignore on duplicates in non-mutables */ - for (mut = (prpdef *)(objptr + objrst(objptr)), - cnt = objnprop(objptr) - objstat(objptr) ; cnt ; - mut = objpnxt(mut), --cnt) - { - for (p = p1, statcnt = objstat(objptr) ; statcnt ; - p = objpnxt(p), --statcnt) - { - /* if this static prop matches a mutable prop, ignore it */ - if (prpprop(p) == prpprop(mut)) - { - prpflg(p) |= PRPFIGN; - break; - } - } - } - - mcmtch(mctx, (mcmon)objn); - mcmunlck(mctx, (mcmon)objn); - if (indexed) objindx(mctx, objn); + /* go through mutables, and set ignore on duplicates in non-mutables */ + for (mut = (prpdef *)(objptr + objrst(objptr)), + cnt = objnprop(objptr) - objstat(objptr) ; cnt ; + mut = objpnxt(mut), --cnt) + { + for (p = p1, statcnt = objstat(objptr) ; statcnt ; + p = objpnxt(p), --statcnt) + { + /* if this static prop matches a mutable prop, ignore it */ + if (prpprop(p) == prpprop(mut)) + { + prpflg(p) |= PRPFIGN; + break; + } + } + } + + mcmtch(mctx, (mcmon)objn); + mcmunlck(mctx, (mcmon)objn); + if (indexed) objindx(mctx, objn); } /* @@ -925,127 +925,127 @@ void objsetign(mcmcxdef *mctx, objnum objn) */ void objindx(mcmcxdef *mctx, objnum objn) { - uint newsiz; - uint avail; - objdef *objptr; - uint cnt; - prpdef *p; + uint newsiz; + uint avail; + objdef *objptr; + uint cnt; + prpdef *p; uchar *indp = nullptr; - uchar *indbase; - uint icnt; - uint first; - uint last; + uchar *indbase; + uint icnt; + uint first; + uint last; uint cur = 0; - - objptr = (objdef *)mcmlck(mctx, objn); /* get object pointer */ - cnt = objnprop(objptr); /* get number of properties */ - p = objprp(objptr); /* get pointer to properties (or old index) */ - newsiz = 2 + 4*cnt; /* figure size needed for the index */ - - avail = mcmobjsiz(mctx, objn) - objfree(objptr); - - /* insert space for the index; expand the object if necessary */ - if (avail < newsiz) - { - ushort need; - - newsiz += 10*4; /* add some extra space for later */ - need = newsiz - avail; /* compute amount of space needed */ - objptr = objexp(mctx, objn, &need); - p = objprp(objptr); - } - - /* now build the index */ - indbase = objpfre(objptr); - for (icnt = 0 ; cnt ; p = objpnxt(p), --cnt, ++icnt) - { - uint ofs = (uchar *)p - (uchar *)objptr; - - if (icnt) - { - /* figure out where to insert this property */ - first = 0; - last = icnt - 1; - for (;;) - { - if (first > last) break; - cur = first + (last - first)/2; - indp = indbase + cur*4; - if (indp[0] == p[0] && indp[1] == p[1]) - break; - else if (indp[0] < p[0] - || (indp[0] == p[0] && indp[1] < p[1])) - first = (cur == first ? first + 1 : cur); - else - last = (cur == last ? last - 1 : cur); - } - - /* make sure we're positioned just before insertion point */ - while (cur < icnt - && (indp[0] <= p[0] - || (indp[0] == p[0] && indp[1] <= p[1]))) - { - indp += 4; - ++cur; - } - - /* move elements above if any */ - if (cur < icnt) - memmove(indp + 4, indp, (size_t)((icnt - cur) * 4)); - } - else - indp = indbase; - - /* insert property into index */ - indp[0] = p[0]; - indp[1] = p[1]; - oswp2(indp+2, ofs); - } - - /* set the index flag, and dirty and free the object */ - objsflg(objptr, objflg(objptr) | OBJFINDEX); - mcmtch(mctx, (mcmon)objn); - mcmunlck(mctx, (mcmon)objn); + + objptr = (objdef *)mcmlck(mctx, objn); /* get object pointer */ + cnt = objnprop(objptr); /* get number of properties */ + p = objprp(objptr); /* get pointer to properties (or old index) */ + newsiz = 2 + 4*cnt; /* figure size needed for the index */ + + avail = mcmobjsiz(mctx, objn) - objfree(objptr); + + /* insert space for the index; expand the object if necessary */ + if (avail < newsiz) + { + ushort need; + + newsiz += 10*4; /* add some extra space for later */ + need = newsiz - avail; /* compute amount of space needed */ + objptr = objexp(mctx, objn, &need); + p = objprp(objptr); + } + + /* now build the index */ + indbase = objpfre(objptr); + for (icnt = 0 ; cnt ; p = objpnxt(p), --cnt, ++icnt) + { + uint ofs = (uchar *)p - (uchar *)objptr; + + if (icnt) + { + /* figure out where to insert this property */ + first = 0; + last = icnt - 1; + for (;;) + { + if (first > last) break; + cur = first + (last - first)/2; + indp = indbase + cur*4; + if (indp[0] == p[0] && indp[1] == p[1]) + break; + else if (indp[0] < p[0] + || (indp[0] == p[0] && indp[1] < p[1])) + first = (cur == first ? first + 1 : cur); + else + last = (cur == last ? last - 1 : cur); + } + + /* make sure we're positioned just before insertion point */ + while (cur < icnt + && (indp[0] <= p[0] + || (indp[0] == p[0] && indp[1] <= p[1]))) + { + indp += 4; + ++cur; + } + + /* move elements above if any */ + if (cur < icnt) + memmove(indp + 4, indp, (size_t)((icnt - cur) * 4)); + } + else + indp = indbase; + + /* insert property into index */ + indp[0] = p[0]; + indp[1] = p[1]; + oswp2(indp+2, ofs); + } + + /* set the index flag, and dirty and free the object */ + objsflg(objptr, objflg(objptr) | OBJFINDEX); + mcmtch(mctx, (mcmon)objn); + mcmunlck(mctx, (mcmon)objn); } /* allocate and initialize an object */ objdef *objnew(mcmcxdef *mctx, int sccnt, ushort propspace, - objnum *objnptr, int classflg) + objnum *objnptr, int classflg) { - objdef *o; - mcmon objn; + objdef *o; + mcmon objn; - /* allocate cache object */ - o = (objdef *)mcmalo(mctx, (ushort)(OBJDEFSIZ + sccnt * 2 + propspace), - &objn); - - /* set up object descriptor for the new object */ - objini(mctx, sccnt, (objnum)objn, classflg); + /* allocate cache object */ + o = (objdef *)mcmalo(mctx, (ushort)(OBJDEFSIZ + sccnt * 2 + propspace), + &objn); + + /* set up object descriptor for the new object */ + objini(mctx, sccnt, (objnum)objn, classflg); - *objnptr = (objnum)objn; - return(o); + *objnptr = (objnum)objn; + return(o); } /* initialize an already allocated object */ void objini(mcmcxdef *mctx, int sccnt, objnum objn, int classflg) { - objdef *o; - uint flags = 0; + objdef *o; + uint flags = 0; - /* get a lock on the object */ - o = (objdef *)mcmlck(mctx, objn); - - memset(o, 0, (size_t)10); - objsnsc(o, sccnt); - objsfree(o, ((uchar *)objsc(o) + 2*sccnt) - (uchar *)o); - - /* set up flags */ - if (classflg) flags |= OBJFCLASS; - objsflg(o, flags); + /* get a lock on the object */ + o = (objdef *)mcmlck(mctx, objn); + + memset(o, 0, (size_t)10); + objsnsc(o, sccnt); + objsfree(o, ((uchar *)objsc(o) + 2*sccnt) - (uchar *)o); + + /* set up flags */ + if (classflg) flags |= OBJFCLASS; + objsflg(o, flags); - /* tell cache manager that this object has been modified */ - mcmtch(mctx, objn); - mcmunlck(mctx, objn); + /* tell cache manager that this object has been modified */ + mcmtch(mctx, objn); + mcmunlck(mctx, objn); } /* @@ -1054,21 +1054,21 @@ void objini(mcmcxdef *mctx, int sccnt, objnum objn, int classflg) */ objnum objget1sc(mcmcxdef *ctx, objnum objn) { - objdef *p; - objnum retval; + objdef *p; + objnum retval; - /* lock the object */ - p = mcmlck(ctx, (mcmon)objn); + /* lock the object */ + p = mcmlck(ctx, (mcmon)objn); - /* get the first superclass if it has any */ - if (objnsc(p) == 0) - retval = MCMONINV; - else - retval = osrp2(objsc(p)); + /* get the first superclass if it has any */ + if (objnsc(p) == 0) + retval = MCMONINV; + else + retval = osrp2(objsc(p)); - /* unlock the object and return the superclass value */ - mcmunlck(ctx, (mcmon)objn); - return retval; + /* unlock the object and return the superclass value */ + mcmunlck(ctx, (mcmon)objn); + return retval; } } // End of namespace TADS2 diff --git a/engines/glk/tads/tads2/object.h b/engines/glk/tads/tads2/object.h index 0536f05914d..324396aec23 100644 --- a/engines/glk/tads/tads2/object.h +++ b/engines/glk/tads/tads2/object.h @@ -95,19 +95,19 @@ typedef uchar objdef; /* undo context */ struct objucxdef { - mcmcxdef *objucxmem; /* cache manager context */ - errcxdef *objucxerr; /* error context */ - ushort objucxsiz; /* size of the undo buffer */ - ushort objucxhead; /* head (position of next write) */ - ushort objucxtail; /* tail (position of oldest record) */ - ushort objucxprv; /* previous head pointer */ - ushort objucxtop; /* highest head value written */ - void (*objucxcun)(void *ctx, uchar *data); - /* apply a client undo record */ - ushort (*objucxcsz)(void *ctx, uchar *data); - /* get size of a client undo record */ - void *objucxccx; /* client undo context */ - uchar objucxbuf[1]; /* undo buffer */ + mcmcxdef *objucxmem; /* cache manager context */ + errcxdef *objucxerr; /* error context */ + ushort objucxsiz; /* size of the undo buffer */ + ushort objucxhead; /* head (position of next write) */ + ushort objucxtail; /* tail (position of oldest record) */ + ushort objucxprv; /* previous head pointer */ + ushort objucxtop; /* highest head value written */ + void (*objucxcun)(void *ctx, uchar *data); + /* apply a client undo record */ + ushort (*objucxcsz)(void *ctx, uchar *data); + /* get size of a client undo record */ + void *objucxccx; /* client undo context */ + uchar objucxbuf[1]; /* undo buffer */ }; /* @@ -236,7 +236,7 @@ objnum objget1sc(mcmcxdef *ctx, objnum objn); * property was not set in the object. */ uint objgetp(mcmcxdef *ctx, objnum objn, prpnum prop, - dattyp *typptr); + dattyp *typptr); /* * Get the *ending* offset of the given property's value, without any @@ -258,7 +258,7 @@ uint objgetp_end(mcmcxdef *ctx, objnum objn, prpnum prop); * undo operation). */ uint objgetap(mcmcxdef *ctx, noreg objnum objn, prpnum prop, - objnum *orn, int inh); + objnum *orn, int inh); /* * expand an object by a requested amount, returning a pointer to the @@ -275,7 +275,7 @@ objdef *objexp(mcmcxdef *ctx, objnum obj, ushort *siz); * undo information is retained. */ void objsetp(mcmcxdef *ctx, objnum obj, prpnum prop, - dattyp typ, const void *val, objucxdef *undoctx); + dattyp typ, const void *val, objucxdef *undoctx); /* * Delete a property. If mark_only is true, we'll only mark the @@ -333,9 +333,9 @@ void objusav(objucxdef *undoctx); /* initialize undo context */ objucxdef *objuini(mcmcxdef *memctx, ushort undosiz, - void (*undocb)(void *ctx, uchar *data), - ushort (*sizecb)(void *ctx, uchar *data), - void *callctx); + void (*undocb)(void *ctx, uchar *data), + ushort (*sizecb)(void *ctx, uchar *data), + void *callctx); /* free the undo context - releases memory allocated by objuini() */ void objuterm(objucxdef *undoctx); @@ -352,8 +352,8 @@ void objulose(objucxdef *undoctx); * memory is returned, and *objnptr receives the object number. */ objdef *objnew(mcmcxdef *mctx, int sccnt, ushort propspace, - objnum *objnptr, int classflg); - + objnum *objnptr, int classflg); + /* initialize an already allocated object */ void objini(mcmcxdef *mctx, int sccnt, objnum objn, int classflg); diff --git a/engines/glk/tads/tads2/opcode.h b/engines/glk/tads/tads2/opcode.h index 4175db3c907..9af62ee8307 100644 --- a/engines/glk/tads/tads2/opcode.h +++ b/engines/glk/tads/tads2/opcode.h @@ -110,8 +110,8 @@ namespace TADS2 { #define OPCGETPSELF 60 /* get property of the 'self' object */ #define OPCGETPSLFD 61 /* get property of 'self' and discard result */ #define OPCGETPOBJ 62 /* get property of a given object */ - /* note: differs from GETP in that object is */ - /* encoded into the instruction */ + /* note: differs from GETP in that object is */ + /* encoded into the instruction */ #define OPCGETPOBJD 63 /* get property of an object and discard result */ #define OPCINDEX 64 /* get an indexed entry from a list */ @@ -152,30 +152,30 @@ namespace TADS2 { /* ASSIGNMENT OPERATIONS - When (opcode & 0xc0 == 0xc0), we have an assignment operation. - (Note that this means that opcodes from 0xc0 up are all reserved - for assignment operations.) The low six bits of the opcode - specify exactly what kind of operation is to be performed: - - bits 0-1: specifies destination type: - 00 2-byte operand is local number - 01 2-byte operand is property to set in obj at tos - 10 tos is index, [sp-1] is list to be indexed and set - 11 tos is property pointer, [sp-1] is object - - bits 2-4: specifies assignment operation: - 000 := (direct assignment) - 001 += (add tos to destination) - 010 -= (subtract tos from destination) - 011 *= (multiply destination by tos) - 100 /= (divide destination by tos) - 101 ++ (increment tos) - 110 -- (decrement tos) - 111 *reserved* - - bit 5: specifies what to do with value computed by assignment - 0 leave on stack (implies pre increment/decrement) - 1 discard (implies post increment/decrement) + When (opcode & 0xc0 == 0xc0), we have an assignment operation. + (Note that this means that opcodes from 0xc0 up are all reserved + for assignment operations.) The low six bits of the opcode + specify exactly what kind of operation is to be performed: + + bits 0-1: specifies destination type: + 00 2-byte operand is local number + 01 2-byte operand is property to set in obj at tos + 10 tos is index, [sp-1] is list to be indexed and set + 11 tos is property pointer, [sp-1] is object + + bits 2-4: specifies assignment operation: + 000 := (direct assignment) + 001 += (add tos to destination) + 010 -= (subtract tos from destination) + 011 *= (multiply destination by tos) + 100 /= (divide destination by tos) + 101 ++ (increment tos) + 110 -- (decrement tos) + 111 *reserved* + + bit 5: specifies what to do with value computed by assignment + 0 leave on stack (implies pre increment/decrement) + 1 discard (implies post increment/decrement) */ #define OPCASI_MASK 0xc0 /* assignment instruction */ diff --git a/engines/glk/tads/tads2/os.h b/engines/glk/tads/tads2/os.h index 46c89bf4da5..fd3a074547c 100644 --- a/engines/glk/tads/tads2/os.h +++ b/engines/glk/tads/tads2/os.h @@ -272,16 +272,16 @@ namespace TADS2 { * OS main entrypoint */ int os0main(int oargc, char **oargv, - int (*mainfn)(int, char **, char *), - const char *before, const char *config); + int (*mainfn)(int, char **, char *), + const char *before, const char *config); /* * new-style OS main entrypoint - takes an application container context */ int os0main2(int oargc, char **oargv, - int (*mainfn)(int, char **, appctxdef *, char *), - const char *before, const char *config, - appctxdef *appctx); + int (*mainfn)(int, char **, appctxdef *, char *), + const char *before, const char *config, + appctxdef *appctx); /* open the error message file for reading */ diff --git a/engines/glk/tads/tads2/output.cpp b/engines/glk/tads/tads2/output.cpp index 5f7e46b70be..ae9c74abffb 100644 --- a/engines/glk/tads/tads2/output.cpp +++ b/engines/glk/tads/tads2/output.cpp @@ -238,130 +238,130 @@ static char out_parse_entity(char *outbuf, size_t outbuf_size, const char **sp, * the state of an individual output stream. */ struct out_stream_info { - /* low-level display routine (va_list version) */ - void (*do_print)(out_stream_info *stream, const char *str); - - /* current line position and output column */ - uchar linepos; - uchar linecol; + /* low-level display routine (va_list version) */ + void (*do_print)(out_stream_info *stream, const char *str); + + /* current line position and output column */ + uchar linepos; + uchar linecol; - /* number of lines on the screen (since last MORE prompt) */ - int linecnt; + /* number of lines on the screen (since last MORE prompt) */ + int linecnt; - /* output buffer */ - char linebuf[MAXWIDTH]; + /* output buffer */ + char linebuf[MAXWIDTH]; - /* - * attribute buffer - we keep one attribute entry for each character in - * the line buffer - */ - int attrbuf[MAXWIDTH]; + /* + * attribute buffer - we keep one attribute entry for each character in + * the line buffer + */ + int attrbuf[MAXWIDTH]; - /* current attribute for text we're buffering into linebuf */ - int cur_attr; + /* current attribute for text we're buffering into linebuf */ + int cur_attr; - /* last attribute we wrote to the osifc layer */ - int os_attr; + /* last attribute we wrote to the osifc layer */ + int os_attr; - /* CAPS mode - next character output is converted to upper-case */ - uchar capsflag; + /* CAPS mode - next character output is converted to upper-case */ + uchar capsflag; - /* NOCAPS mode - next character output is converted to lower-case */ - uchar nocapsflag; + /* NOCAPS mode - next character output is converted to lower-case */ + uchar nocapsflag; - /* ALLCAPS mode - all characters output are converted to upper-case */ - uchar allcapsflag; + /* ALLCAPS mode - all characters output are converted to upper-case */ + uchar allcapsflag; - /* capture information */ - mcmcxdef *capture_ctx; /* memory context to use for capturing */ - mcmon capture_obj; /* object holding captured output */ - uint capture_ofs; /* write offset in capture object */ - int capturing; /* true -> we are capturing output */ + /* capture information */ + mcmcxdef *capture_ctx; /* memory context to use for capturing */ + mcmon capture_obj; /* object holding captured output */ + uint capture_ofs; /* write offset in capture object */ + int capturing; /* true -> we are capturing output */ - /* "preview" state for line flushing */ - int preview; + /* "preview" state for line flushing */ + int preview; - /* flag indicating that we just flushed a new line */ - int just_did_nl; + /* flag indicating that we just flushed a new line */ + int just_did_nl; - /* this output stream uses "MORE" mode */ - int use_more_mode; + /* this output stream uses "MORE" mode */ + int use_more_mode; - /* - * This output stream uses OS-level line wrapping - if this is set, - * the output formatter will not insert a newline at the end of a - * line that it's flushing for word wrapping, but will instead let - * the underlying OS display layer handle the wrapping. - */ - int os_line_wrap; + /* + * This output stream uses OS-level line wrapping - if this is set, + * the output formatter will not insert a newline at the end of a + * line that it's flushing for word wrapping, but will instead let + * the underlying OS display layer handle the wrapping. + */ + int os_line_wrap; - /* - * Flag indicating that the underlying output system wants to - * receive its output as HTML. - * - * If this is true, we'll pass through HTML to the underlying output - * system, and in addition generate HTML sequences for certain - * TADS-native escapes (for example, we'll convert the "\n" sequence - * to a
sequence). - * - * If this is false, we'll do just the opposite: we'll remove HTML - * from the output stream and convert it into normal text sequences. - */ - int html_target; + /* + * Flag indicating that the underlying output system wants to + * receive its output as HTML. + * + * If this is true, we'll pass through HTML to the underlying output + * system, and in addition generate HTML sequences for certain + * TADS-native escapes (for example, we'll convert the "\n" sequence + * to a
sequence). + * + * If this is false, we'll do just the opposite: we'll remove HTML + * from the output stream and convert it into normal text sequences. + */ + int html_target; - /* - * Flag indicating that the target uses plain text. If this flag is - * set, we won't add the OS escape codes for highlighted characters. - */ - int plain_text_target; - - /* - * Flag indicating that the caller is displaying HTML. We always - * start off in text mode; the client can switch to HTML mode by - * displaying a special escape sequence, and can switch back to text - * mode by displaying a separate special escape sequence. - */ - int html_mode; + /* + * Flag indicating that the target uses plain text. If this flag is + * set, we won't add the OS escape codes for highlighted characters. + */ + int plain_text_target; + + /* + * Flag indicating that the caller is displaying HTML. We always + * start off in text mode; the client can switch to HTML mode by + * displaying a special escape sequence, and can switch back to text + * mode by displaying a separate special escape sequence. + */ + int html_mode; - /* current lexical analysis mode */ - unsigned int html_mode_flag; + /* current lexical analysis mode */ + unsigned int html_mode_flag; - /*
defer mode */ - unsigned int html_defer_br; + /*
defer mode */ + unsigned int html_defer_br; - /* - * HTML "ignore" mode - we suppress all output when parsing the - * contents of a or <ABOUTBOX> tag - */ - int html_in_ignore; + /* + * HTML "ignore" mode - we suppress all output when parsing the + * contents of a <TITLE> or <ABOUTBOX> tag + */ + int html_in_ignore; - /* - * HTML <TITLE> mode - when we're in this mode, we're gathering the - * title (i.e., we're inside a <TITLE> tag's contents). We'll copy - * characters to the title buffer rather than the normal output - * buffer, and then call os_set_title() when we reach the - * tag. - */ - int html_in_title; + /* + * HTML mode - when we're in this mode, we're gathering the + * title (i.e., we're inside a <TITLE> tag's contents). We'll copy + * characters to the title buffer rather than the normal output + * buffer, and then call os_set_title() when we reach the + * tag. + */ + int html_in_title; - /* buffer for the title */ - char html_title_buf[256]; + /* buffer for the title */ + char html_title_buf[256]; - /* pointer to next available character in title buffer */ - char *html_title_ptr; + /* pointer to next available character in title buffer */ + char *html_title_ptr; - /* quoting level */ - int html_quote_level; + /* quoting level */ + int html_quote_level; - /* PRE nesting level */ - int html_pre_level; + /* PRE nesting level */ + int html_pre_level; - /* - * Parsing mode flag for ALT attributes. If we're parsing a tag - * that allows ALT, such as IMG or SOUND, we'll set this flag, then - * insert the ALT text if we encounter it during parsing. - */ - int html_allow_alt; + /* + * Parsing mode flag for ALT attributes. If we're parsing a tag + * that allows ALT, such as IMG or SOUND, we'll set this flag, then + * insert the ALT text if we encounter it during parsing. + */ + int html_allow_alt; }; /* @@ -396,23 +396,23 @@ static out_stream_info G_log_disp; /* standard display printer */ static void do_std_print(out_stream_info *stream, const char *str) { - VARUSED(stream); - - /* display the text through the OS layer */ - os_printz(str); + VARUSED(stream); + + /* display the text through the OS layer */ + os_printz(str); } /* log file printer */ static void do_log_print(out_stream_info *stream, const char *str) { - VARUSED(stream); + VARUSED(stream); - /* display to the log file */ - if (logfp != 0 && G_os_moremode) - { - os_fprintz(logfp, str); - osfflush(logfp); - } + /* display to the log file */ + if (logfp != 0 && G_os_moremode) + { + os_fprintz(logfp, str); + osfflush(logfp); + } } @@ -422,66 +422,66 @@ static void do_log_print(out_stream_info *stream, const char *str) */ static void out_state_init(out_stream_info *stream) { - /* start out at the first column */ - stream->linepos = 0; - stream->linecol = 0; - stream->linebuf[0] = '\0'; + /* start out at the first column */ + stream->linepos = 0; + stream->linecol = 0; + stream->linebuf[0] = '\0'; - /* set normal text attributes */ - stream->cur_attr = 0; - stream->os_attr = 0; + /* set normal text attributes */ + stream->cur_attr = 0; + stream->os_attr = 0; - /* start out at the first line */ - stream->linecnt = 0; + /* start out at the first line */ + stream->linecnt = 0; - /* we're not in either "caps", "nocaps", or "allcaps" mode yet */ - stream->capsflag = stream->nocapsflag = stream->allcapsflag = FALSE; + /* we're not in either "caps", "nocaps", or "allcaps" mode yet */ + stream->capsflag = stream->nocapsflag = stream->allcapsflag = FALSE; - /* we're not capturing yet */ - stream->capturing = FALSE; - stream->capture_obj = MCMONINV; + /* we're not capturing yet */ + stream->capturing = FALSE; + stream->capture_obj = MCMONINV; - /* we aren't previewing a line yet */ - stream->preview = 0; + /* we aren't previewing a line yet */ + stream->preview = 0; - /* we haven't flushed a new line yet */ - stream->just_did_nl = FALSE; + /* we haven't flushed a new line yet */ + stream->just_did_nl = FALSE; - /* presume this stream does not use "MORE" mode */ - stream->use_more_mode = FALSE; + /* presume this stream does not use "MORE" mode */ + stream->use_more_mode = FALSE; - /* presume this stream uses formatter-level line wrapping */ - stream->os_line_wrap = FALSE; + /* presume this stream uses formatter-level line wrapping */ + stream->os_line_wrap = FALSE; - /* assume that the underlying system is not HTML-enabled */ - stream->html_target = FALSE; + /* assume that the underlying system is not HTML-enabled */ + stream->html_target = FALSE; - /* presume this target accepts OS highlighting sequences */ - stream->plain_text_target = FALSE; + /* presume this target accepts OS highlighting sequences */ + stream->plain_text_target = FALSE; - /* start out in text mode */ - stream->html_mode = FALSE; + /* start out in text mode */ + stream->html_mode = FALSE; - /* start out in "normal" lexical state */ - stream->html_mode_flag = HTML_MODE_NORMAL; + /* start out in "normal" lexical state */ + stream->html_mode_flag = HTML_MODE_NORMAL; - /* not in an ignored tag yet */ - stream->html_in_ignore = FALSE; + /* not in an ignored tag yet */ + stream->html_in_ignore = FALSE; - /* not in title mode yet */ - stream->html_in_title = FALSE; + /* not in title mode yet */ + stream->html_in_title = FALSE; - /* not yet deferring line breaks */ - stream->html_defer_br = HTML_DEFER_BR_NONE; + /* not yet deferring line breaks */ + stream->html_defer_br = HTML_DEFER_BR_NONE; - /* not yet in quotes */ - stream->html_quote_level = 0; + /* not yet in quotes */ + stream->html_quote_level = 0; - /* not yet in a PRE block */ - stream->html_pre_level = 0; + /* not yet in a PRE block */ + stream->html_pre_level = 0; - /* not in an ALT tag yet */ - stream->html_allow_alt = FALSE; + /* not in an ALT tag yet */ + stream->html_allow_alt = FALSE; } @@ -491,38 +491,38 @@ static void out_state_init(out_stream_info *stream) */ static void out_init_std(out_stream_info *stream) { - /* there's no user output filter function yet */ - out_set_filter(MCMONINV); - - /* initialize the basic stream state */ - out_state_init(stream); + /* there's no user output filter function yet */ + out_set_filter(MCMONINV); + + /* initialize the basic stream state */ + out_state_init(stream); - /* set up the low-level output routine */ - G_std_disp.do_print = do_std_print; + /* set up the low-level output routine */ + G_std_disp.do_print = do_std_print; #ifdef USE_MORE - /* - * We're compiled for MORE mode, and we're not compiling for an - * underlying HTML formatting layer, so use MORE mode for the - * standard display stream. - */ - stream->use_more_mode = TRUE; + /* + * We're compiled for MORE mode, and we're not compiling for an + * underlying HTML formatting layer, so use MORE mode for the + * standard display stream. + */ + stream->use_more_mode = TRUE; #else - /* - * We're compiled for OS-layer (or HTML-layer) MORE handling. For - * this case, use OS-layer (or HTML-layer) line wrapping as well. - */ - stream->os_line_wrap = TRUE; + /* + * We're compiled for OS-layer (or HTML-layer) MORE handling. For + * this case, use OS-layer (or HTML-layer) line wrapping as well. + */ + stream->os_line_wrap = TRUE; #endif #ifdef USE_HTML - /* - * if we're compiled for HTML mode, set the standard output stream - * so that it knows it has an HTML target - this will ensure that - * HTML tags are passed through to the underlying stream, and that - * we generate HTML equivalents for our own control sequences - */ - stream->html_target = TRUE; + /* + * if we're compiled for HTML mode, set the standard output stream + * so that it knows it has an HTML target - this will ensure that + * HTML tags are passed through to the underlying stream, and that + * we generate HTML equivalents for our own control sequences + */ + stream->html_target = TRUE; #endif } @@ -531,14 +531,14 @@ static void out_init_std(out_stream_info *stream) */ static void out_init_log(out_stream_info *stream) { - /* initialize the basic stream state */ - out_state_init(stream); + /* initialize the basic stream state */ + out_state_init(stream); - /* set up the low-level output routine */ - stream->do_print = do_log_print; + /* set up the low-level output routine */ + stream->do_print = do_log_print; - /* use plain text in the log file stream */ - stream->plain_text_target = TRUE; + /* use plain text in the log file stream */ + stream->plain_text_target = TRUE; } @@ -548,14 +548,14 @@ static void out_init_log(out_stream_info *stream) * table of '&' character name sequences */ struct amp_tbl_t { - /* entity name */ - const char *cname; + /* entity name */ + const char *cname; - /* HTML Unicode character value */ - uint html_cval; + /* HTML Unicode character value */ + uint html_cval; - /* native character set expansion */ - char *expan; + /* native character set expansion */ + char *expan; }; /* @@ -568,312 +568,312 @@ struct amp_tbl_t { * table. */ static struct amp_tbl_t amp_tbl[] = { - { "AElig", 198, 0 }, - { "Aacute", 193, 0 }, - { "Abreve", 258, 0 }, - { "Acirc", 194, 0 }, - { "Agrave", 192, 0 }, - { "Alpha", 913, 0 }, - { "Aogon", 260, 0 }, - { "Aring", 197, 0 }, - { "Atilde", 195, 0 }, - { "Auml", 196, 0 }, - { "Beta", 914, 0 }, - { "Cacute", 262, 0 }, - { "Ccaron", 268, 0 }, - { "Ccedil", 199, 0 }, - { "Chi", 935, 0 }, - { "Dagger", 8225, 0 }, - { "Dcaron", 270, 0 }, - { "Delta", 916, 0 }, - { "Dstrok", 272, 0 }, - { "ETH", 208, 0 }, - { "Eacute", 201, 0 }, - { "Ecaron", 282, 0 }, - { "Ecirc", 202, 0 }, - { "Egrave", 200, 0 }, - { "Eogon", 280, 0 }, - { "Epsilon", 917, 0 }, - { "Eta", 919, 0 }, - { "Euml", 203, 0 }, - { "Gamma", 915, 0 }, - { "Iacute", 205, 0 }, - { "Icirc", 206, 0 }, - { "Igrave", 204, 0 }, - { "Iota", 921, 0 }, - { "Iuml", 207, 0 }, - { "Kappa", 922, 0 }, - { "Lacute", 313, 0 }, - { "Lambda", 923, 0 }, - { "Lcaron", 317, 0 }, - { "Lstrok", 321, 0 }, - { "Mu", 924, 0 }, - { "Nacute", 323, 0 }, - { "Ncaron", 327, 0 }, - { "Ntilde", 209, 0 }, - { "Nu", 925, 0 }, - { "OElig", 338, 0 }, - { "Oacute", 211, 0 }, - { "Ocirc", 212, 0 }, - { "Odblac", 336, 0 }, - { "Ograve", 210, 0 }, - { "Omega", 937, 0 }, - { "Omicron", 927, 0 }, - { "Oslash", 216, 0 }, - { "Otilde", 213, 0 }, - { "Ouml", 214, 0 }, - { "Phi", 934, 0 }, - { "Pi", 928, 0 }, - { "Prime", 8243, 0 }, - { "Psi", 936, 0 }, - { "Racute", 340, 0 }, - { "Rcaron", 344, 0 }, - { "Rho", 929, 0 }, - { "Sacute", 346, 0 }, - { "Scaron", 352, 0 }, - { "Scedil", 350, 0 }, - { "Sigma", 931, 0 }, - { "THORN", 222, 0 }, - { "Tau", 932, 0 }, - { "Tcaron", 356, 0 }, - { "Tcedil", 354, 0 }, - { "Theta", 920, 0 }, - { "Uacute", 218, 0 }, - { "Ucirc", 219, 0 }, - { "Udblac", 368, 0 }, - { "Ugrave", 217, 0 }, - { "Upsilon", 933, 0 }, - { "Uring", 366, 0 }, - { "Uuml", 220, 0 }, - { "Xi", 926, 0 }, - { "Yacute", 221, 0 }, - { "Yuml", 376, 0 }, - { "Zacute", 377, 0 }, - { "Zcaron", 381, 0 }, - { "Zdot", 379, 0 }, - { "Zeta", 918, 0 }, - { "aacute", 225, 0 }, - { "abreve", 259, 0 }, - { "acirc", 226, 0 }, - { "acute", 180, 0 }, - { "aelig", 230, 0 }, - { "agrave", 224, 0 }, - { "alefsym", 8501, 0 }, - { "alpha", 945, 0 }, - { "amp", '&', 0 }, - { "and", 8743, 0 }, - { "ang", 8736, 0 }, - { "aogon", 261, 0 }, - { "aring", 229, 0 }, - { "asymp", 8776, 0 }, - { "atilde", 227, 0 }, - { "auml", 228, 0 }, - { "bdquo", 8222, 0 }, - { "beta", 946, 0 }, - { "breve", 728, 0 }, - { "brvbar", 166, 0 }, - { "bull", 8226, 0 }, - { "cacute", 263, 0 }, - { "cap", 8745, 0 }, - { "caron", 711, 0 }, - { "ccaron", 269, 0 }, - { "ccedil", 231, 0 }, - { "cedil", 184, 0 }, - { "cent", 162, 0 }, - { "chi", 967, 0 }, - { "circ", 710, 0 }, - { "clubs", 9827, 0 }, - { "cong", 8773, 0 }, - { "copy", 169, 0 }, - { "crarr", 8629, 0 }, - { "cup", 8746, 0 }, - { "curren", 164, 0 }, - { "dArr", 8659, 0 }, - { "dagger", 8224, 0 }, - { "darr", 8595, 0 }, - { "dblac", 733, 0 }, - { "dcaron", 271, 0 }, - { "deg", 176, 0 }, - { "delta", 948, 0 }, - { "diams", 9830, 0 }, - { "divide", 247, 0 }, - { "dot", 729, 0 }, - { "dstrok", 273, 0 }, - { "eacute", 233, 0 }, - { "ecaron", 283, 0 }, - { "ecirc", 234, 0 }, - { "egrave", 232, 0 }, - { "emdash", 8212, 0 }, - { "empty", 8709, 0 }, - { "endash", 8211, 0 }, - { "eogon", 281, 0 }, - { "epsilon", 949, 0 }, - { "equiv", 8801, 0 }, - { "eta", 951, 0 }, - { "eth", 240, 0 }, - { "euml", 235, 0 }, - { "exist", 8707, 0 }, - { "fnof", 402, 0 }, - { "forall", 8704, 0 }, - { "frac12", 189, 0 }, - { "frac14", 188, 0 }, - { "frac34", 190, 0 }, - { "frasl", 8260, 0 }, - { "gamma", 947, 0 }, - { "ge", 8805, 0 }, - { "gt", '>', 0 }, - { "hArr", 8660, 0 }, - { "harr", 8596, 0 }, - { "hearts", 9829, 0 }, - { "hellip", 8230, 0 }, - { "iacute", 237, 0 }, - { "icirc", 238, 0 }, - { "iexcl", 161, 0 }, - { "igrave", 236, 0 }, - { "image", 8465, 0 }, - { "infin", 8734, 0 }, - { "int", 8747, 0 }, - { "iota", 953, 0 }, - { "iquest", 191, 0 }, - { "isin", 8712, 0 }, - { "iuml", 239, 0 }, - { "kappa", 954, 0 }, - { "lArr", 8656, 0 }, - { "lacute", 314, 0 }, - { "lambda", 955, 0 }, - { "lang", 9001, 0 }, - { "laquo", 171, 0 }, - { "larr", 8592, 0 }, - { "lcaron", 318, 0 }, - { "lceil", 8968, 0 }, - { "ldq", 8220, 0 }, - { "ldquo", 8220, 0 }, - { "le", 8804, 0 }, - { "lfloor", 8970, 0 }, - { "lowast", 8727, 0 }, - { "loz", 9674, 0 }, - { "lsaquo", 8249, 0 }, - { "lsq", 8216, 0 }, - { "lsquo", 8216, 0 }, - { "lstrok", 322, 0 }, - { "lt", '<', 0 }, - { "macr", 175, 0 }, - { "mdash", 8212, 0 }, - { "micro", 181, 0 }, - { "middot", 183, 0 }, - { "minus", 8722, 0 }, - { "mu", 956, 0 }, - { "nabla", 8711, 0 }, - { "nacute", 324, 0 }, - { "nbsp", QSPACE, 0 }, - { "ncaron", 328, 0 }, - { "ndash", 8211, 0 }, - { "ne", 8800, 0 }, - { "ni", 8715, 0 }, - { "not", 172, 0 }, - { "notin", 8713, 0 }, - { "nsub", 8836, 0 }, - { "ntilde", 241, 0 }, - { "nu", 957, 0 }, - { "oacute", 243, 0 }, - { "ocirc", 244, 0 }, - { "odblac", 337, 0 }, - { "oelig", 339, 0 }, - { "ogon", 731, 0 }, - { "ograve", 242, 0 }, - { "oline", 8254, 0 }, - { "omega", 969, 0 }, - { "omicron", 959, 0 }, - { "oplus", 8853, 0 }, - { "or", 8744, 0 }, - { "ordf", 170, 0 }, - { "ordm", 186, 0 }, - { "oslash", 248, 0 }, - { "otilde", 245, 0 }, - { "otimes", 8855, 0 }, - { "ouml", 246, 0 }, - { "para", 182, 0 }, - { "part", 8706, 0 }, - { "permil", 8240, 0 }, - { "perp", 8869, 0 }, - { "phi", 966, 0 }, - { "pi", 960, 0 }, - { "piv", 982, 0 }, - { "plusmn", 177, 0 }, - { "pound", 163, 0 }, - { "prime", 8242, 0 }, - { "prod", 8719, 0 }, - { "prop", 8733, 0 }, - { "psi", 968, 0 }, - { "quot", '"', 0 }, - { "rArr", 8658, 0 }, - { "racute", 341, 0 }, - { "radic", 8730, 0 }, - { "rang", 9002, 0 }, - { "raquo", 187, 0 }, - { "rarr", 8594, 0 }, - { "rcaron", 345, 0 }, - { "rceil", 8969, 0 }, - { "rdq", 8221, 0 }, - { "rdquo", 8221, 0 }, - { "real", 8476, 0 }, - { "reg", 174, 0 }, - { "rfloor", 8971, 0 }, - { "rho", 961, 0 }, - { "rsaquo", 8250, 0 }, - { "rsq", 8217, 0 }, - { "rsquo", 8217, 0 }, - { "sacute", 347, 0 }, - { "sbquo", 8218, 0 }, - { "scaron", 353, 0 }, - { "scedil", 351, 0 }, - { "sdot", 8901, 0 }, - { "sect", 167, 0 }, - { "shy", 173, 0 }, - { "sigma", 963, 0 }, - { "sigmaf", 962, 0 }, - { "sim", 8764, 0 }, - { "spades", 9824, 0 }, - { "sub", 8834, 0 }, - { "sube", 8838, 0 }, - { "sum", 8721, 0 }, - { "sup", 8835, 0 }, - { "sup1", 185, 0 }, - { "sup2", 178, 0 }, - { "sup3", 179, 0 }, - { "supe", 8839, 0 }, - { "szlig", 223, 0 }, - { "tau", 964, 0 }, - { "tcaron", 357, 0 }, - { "tcedil", 355, 0 }, - { "there4", 8756, 0 }, - { "theta", 952, 0 }, - { "thetasym", 977, 0 }, - { "thorn", 254, 0 }, - { "thorn", 254, 0 }, - { "tilde", 732, 0 }, - { "times", 215, 0 }, - { "trade", 8482, 0 }, - { "uArr", 8657, 0 }, - { "uacute", 250, 0 }, - { "uarr", 8593, 0 }, - { "ucirc", 251, 0 }, - { "udblac", 369, 0 }, - { "ugrave", 249, 0 }, - { "uml", 168, 0 }, - { "upsih", 978, 0 }, - { "upsilon", 965, 0 }, - { "uring", 367, 0 }, - { "uuml", 252, 0 }, - { "weierp", 8472, 0 }, - { "xi", 958, 0 }, - { "yacute", 253, 0 }, - { "yen", 165, 0 }, - { "yuml", 255, 0 }, - { "zacute", 378, 0 }, - { "zcaron", 382, 0 }, - { "zdot", 380, 0 }, - { "zeta", 950, 0 } + { "AElig", 198, 0 }, + { "Aacute", 193, 0 }, + { "Abreve", 258, 0 }, + { "Acirc", 194, 0 }, + { "Agrave", 192, 0 }, + { "Alpha", 913, 0 }, + { "Aogon", 260, 0 }, + { "Aring", 197, 0 }, + { "Atilde", 195, 0 }, + { "Auml", 196, 0 }, + { "Beta", 914, 0 }, + { "Cacute", 262, 0 }, + { "Ccaron", 268, 0 }, + { "Ccedil", 199, 0 }, + { "Chi", 935, 0 }, + { "Dagger", 8225, 0 }, + { "Dcaron", 270, 0 }, + { "Delta", 916, 0 }, + { "Dstrok", 272, 0 }, + { "ETH", 208, 0 }, + { "Eacute", 201, 0 }, + { "Ecaron", 282, 0 }, + { "Ecirc", 202, 0 }, + { "Egrave", 200, 0 }, + { "Eogon", 280, 0 }, + { "Epsilon", 917, 0 }, + { "Eta", 919, 0 }, + { "Euml", 203, 0 }, + { "Gamma", 915, 0 }, + { "Iacute", 205, 0 }, + { "Icirc", 206, 0 }, + { "Igrave", 204, 0 }, + { "Iota", 921, 0 }, + { "Iuml", 207, 0 }, + { "Kappa", 922, 0 }, + { "Lacute", 313, 0 }, + { "Lambda", 923, 0 }, + { "Lcaron", 317, 0 }, + { "Lstrok", 321, 0 }, + { "Mu", 924, 0 }, + { "Nacute", 323, 0 }, + { "Ncaron", 327, 0 }, + { "Ntilde", 209, 0 }, + { "Nu", 925, 0 }, + { "OElig", 338, 0 }, + { "Oacute", 211, 0 }, + { "Ocirc", 212, 0 }, + { "Odblac", 336, 0 }, + { "Ograve", 210, 0 }, + { "Omega", 937, 0 }, + { "Omicron", 927, 0 }, + { "Oslash", 216, 0 }, + { "Otilde", 213, 0 }, + { "Ouml", 214, 0 }, + { "Phi", 934, 0 }, + { "Pi", 928, 0 }, + { "Prime", 8243, 0 }, + { "Psi", 936, 0 }, + { "Racute", 340, 0 }, + { "Rcaron", 344, 0 }, + { "Rho", 929, 0 }, + { "Sacute", 346, 0 }, + { "Scaron", 352, 0 }, + { "Scedil", 350, 0 }, + { "Sigma", 931, 0 }, + { "THORN", 222, 0 }, + { "Tau", 932, 0 }, + { "Tcaron", 356, 0 }, + { "Tcedil", 354, 0 }, + { "Theta", 920, 0 }, + { "Uacute", 218, 0 }, + { "Ucirc", 219, 0 }, + { "Udblac", 368, 0 }, + { "Ugrave", 217, 0 }, + { "Upsilon", 933, 0 }, + { "Uring", 366, 0 }, + { "Uuml", 220, 0 }, + { "Xi", 926, 0 }, + { "Yacute", 221, 0 }, + { "Yuml", 376, 0 }, + { "Zacute", 377, 0 }, + { "Zcaron", 381, 0 }, + { "Zdot", 379, 0 }, + { "Zeta", 918, 0 }, + { "aacute", 225, 0 }, + { "abreve", 259, 0 }, + { "acirc", 226, 0 }, + { "acute", 180, 0 }, + { "aelig", 230, 0 }, + { "agrave", 224, 0 }, + { "alefsym", 8501, 0 }, + { "alpha", 945, 0 }, + { "amp", '&', 0 }, + { "and", 8743, 0 }, + { "ang", 8736, 0 }, + { "aogon", 261, 0 }, + { "aring", 229, 0 }, + { "asymp", 8776, 0 }, + { "atilde", 227, 0 }, + { "auml", 228, 0 }, + { "bdquo", 8222, 0 }, + { "beta", 946, 0 }, + { "breve", 728, 0 }, + { "brvbar", 166, 0 }, + { "bull", 8226, 0 }, + { "cacute", 263, 0 }, + { "cap", 8745, 0 }, + { "caron", 711, 0 }, + { "ccaron", 269, 0 }, + { "ccedil", 231, 0 }, + { "cedil", 184, 0 }, + { "cent", 162, 0 }, + { "chi", 967, 0 }, + { "circ", 710, 0 }, + { "clubs", 9827, 0 }, + { "cong", 8773, 0 }, + { "copy", 169, 0 }, + { "crarr", 8629, 0 }, + { "cup", 8746, 0 }, + { "curren", 164, 0 }, + { "dArr", 8659, 0 }, + { "dagger", 8224, 0 }, + { "darr", 8595, 0 }, + { "dblac", 733, 0 }, + { "dcaron", 271, 0 }, + { "deg", 176, 0 }, + { "delta", 948, 0 }, + { "diams", 9830, 0 }, + { "divide", 247, 0 }, + { "dot", 729, 0 }, + { "dstrok", 273, 0 }, + { "eacute", 233, 0 }, + { "ecaron", 283, 0 }, + { "ecirc", 234, 0 }, + { "egrave", 232, 0 }, + { "emdash", 8212, 0 }, + { "empty", 8709, 0 }, + { "endash", 8211, 0 }, + { "eogon", 281, 0 }, + { "epsilon", 949, 0 }, + { "equiv", 8801, 0 }, + { "eta", 951, 0 }, + { "eth", 240, 0 }, + { "euml", 235, 0 }, + { "exist", 8707, 0 }, + { "fnof", 402, 0 }, + { "forall", 8704, 0 }, + { "frac12", 189, 0 }, + { "frac14", 188, 0 }, + { "frac34", 190, 0 }, + { "frasl", 8260, 0 }, + { "gamma", 947, 0 }, + { "ge", 8805, 0 }, + { "gt", '>', 0 }, + { "hArr", 8660, 0 }, + { "harr", 8596, 0 }, + { "hearts", 9829, 0 }, + { "hellip", 8230, 0 }, + { "iacute", 237, 0 }, + { "icirc", 238, 0 }, + { "iexcl", 161, 0 }, + { "igrave", 236, 0 }, + { "image", 8465, 0 }, + { "infin", 8734, 0 }, + { "int", 8747, 0 }, + { "iota", 953, 0 }, + { "iquest", 191, 0 }, + { "isin", 8712, 0 }, + { "iuml", 239, 0 }, + { "kappa", 954, 0 }, + { "lArr", 8656, 0 }, + { "lacute", 314, 0 }, + { "lambda", 955, 0 }, + { "lang", 9001, 0 }, + { "laquo", 171, 0 }, + { "larr", 8592, 0 }, + { "lcaron", 318, 0 }, + { "lceil", 8968, 0 }, + { "ldq", 8220, 0 }, + { "ldquo", 8220, 0 }, + { "le", 8804, 0 }, + { "lfloor", 8970, 0 }, + { "lowast", 8727, 0 }, + { "loz", 9674, 0 }, + { "lsaquo", 8249, 0 }, + { "lsq", 8216, 0 }, + { "lsquo", 8216, 0 }, + { "lstrok", 322, 0 }, + { "lt", '<', 0 }, + { "macr", 175, 0 }, + { "mdash", 8212, 0 }, + { "micro", 181, 0 }, + { "middot", 183, 0 }, + { "minus", 8722, 0 }, + { "mu", 956, 0 }, + { "nabla", 8711, 0 }, + { "nacute", 324, 0 }, + { "nbsp", QSPACE, 0 }, + { "ncaron", 328, 0 }, + { "ndash", 8211, 0 }, + { "ne", 8800, 0 }, + { "ni", 8715, 0 }, + { "not", 172, 0 }, + { "notin", 8713, 0 }, + { "nsub", 8836, 0 }, + { "ntilde", 241, 0 }, + { "nu", 957, 0 }, + { "oacute", 243, 0 }, + { "ocirc", 244, 0 }, + { "odblac", 337, 0 }, + { "oelig", 339, 0 }, + { "ogon", 731, 0 }, + { "ograve", 242, 0 }, + { "oline", 8254, 0 }, + { "omega", 969, 0 }, + { "omicron", 959, 0 }, + { "oplus", 8853, 0 }, + { "or", 8744, 0 }, + { "ordf", 170, 0 }, + { "ordm", 186, 0 }, + { "oslash", 248, 0 }, + { "otilde", 245, 0 }, + { "otimes", 8855, 0 }, + { "ouml", 246, 0 }, + { "para", 182, 0 }, + { "part", 8706, 0 }, + { "permil", 8240, 0 }, + { "perp", 8869, 0 }, + { "phi", 966, 0 }, + { "pi", 960, 0 }, + { "piv", 982, 0 }, + { "plusmn", 177, 0 }, + { "pound", 163, 0 }, + { "prime", 8242, 0 }, + { "prod", 8719, 0 }, + { "prop", 8733, 0 }, + { "psi", 968, 0 }, + { "quot", '"', 0 }, + { "rArr", 8658, 0 }, + { "racute", 341, 0 }, + { "radic", 8730, 0 }, + { "rang", 9002, 0 }, + { "raquo", 187, 0 }, + { "rarr", 8594, 0 }, + { "rcaron", 345, 0 }, + { "rceil", 8969, 0 }, + { "rdq", 8221, 0 }, + { "rdquo", 8221, 0 }, + { "real", 8476, 0 }, + { "reg", 174, 0 }, + { "rfloor", 8971, 0 }, + { "rho", 961, 0 }, + { "rsaquo", 8250, 0 }, + { "rsq", 8217, 0 }, + { "rsquo", 8217, 0 }, + { "sacute", 347, 0 }, + { "sbquo", 8218, 0 }, + { "scaron", 353, 0 }, + { "scedil", 351, 0 }, + { "sdot", 8901, 0 }, + { "sect", 167, 0 }, + { "shy", 173, 0 }, + { "sigma", 963, 0 }, + { "sigmaf", 962, 0 }, + { "sim", 8764, 0 }, + { "spades", 9824, 0 }, + { "sub", 8834, 0 }, + { "sube", 8838, 0 }, + { "sum", 8721, 0 }, + { "sup", 8835, 0 }, + { "sup1", 185, 0 }, + { "sup2", 178, 0 }, + { "sup3", 179, 0 }, + { "supe", 8839, 0 }, + { "szlig", 223, 0 }, + { "tau", 964, 0 }, + { "tcaron", 357, 0 }, + { "tcedil", 355, 0 }, + { "there4", 8756, 0 }, + { "theta", 952, 0 }, + { "thetasym", 977, 0 }, + { "thorn", 254, 0 }, + { "thorn", 254, 0 }, + { "tilde", 732, 0 }, + { "times", 215, 0 }, + { "trade", 8482, 0 }, + { "uArr", 8657, 0 }, + { "uacute", 250, 0 }, + { "uarr", 8593, 0 }, + { "ucirc", 251, 0 }, + { "udblac", 369, 0 }, + { "ugrave", 249, 0 }, + { "uml", 168, 0 }, + { "upsih", 978, 0 }, + { "upsilon", 965, 0 }, + { "uring", 367, 0 }, + { "uuml", 252, 0 }, + { "weierp", 8472, 0 }, + { "xi", 958, 0 }, + { "yacute", 253, 0 }, + { "yen", 165, 0 }, + { "yuml", 255, 0 }, + { "zacute", 378, 0 }, + { "zcaron", 382, 0 }, + { "zdot", 380, 0 }, + { "zeta", 950, 0 } }; @@ -883,12 +883,12 @@ static struct amp_tbl_t amp_tbl[] = { */ static void outcaps_stream(out_stream_info *stream) { - /* turn on CAPS mode */ - stream->capsflag = TRUE; + /* turn on CAPS mode */ + stream->capsflag = TRUE; - /* turn off NOCAPS and ALLCAPS mode */ - stream->nocapsflag = FALSE; - stream->allcapsflag = FALSE; + /* turn off NOCAPS and ALLCAPS mode */ + stream->nocapsflag = FALSE; + stream->allcapsflag = FALSE; } /* @@ -896,12 +896,12 @@ static void outcaps_stream(out_stream_info *stream) */ static void outnocaps_stream(out_stream_info *stream) { - /* turn on NOCAPS mode */ - stream->nocapsflag = TRUE; + /* turn on NOCAPS mode */ + stream->nocapsflag = TRUE; - /* turn off CAPS and ALLCAPS mode */ - stream->capsflag = FALSE; - stream->allcapsflag = FALSE; + /* turn off CAPS and ALLCAPS mode */ + stream->capsflag = FALSE; + stream->allcapsflag = FALSE; } /* @@ -909,12 +909,12 @@ static void outnocaps_stream(out_stream_info *stream) */ static void outallcaps_stream(out_stream_info *stream, int all_caps) { - /* set the ALLCAPS flag */ - stream->allcapsflag = all_caps; + /* set the ALLCAPS flag */ + stream->allcapsflag = all_caps; - /* clear the CAPS and NOCAPS flags */ - stream->capsflag = FALSE; - stream->nocapsflag = FALSE; + /* clear the CAPS and NOCAPS flags */ + stream->capsflag = FALSE; + stream->nocapsflag = FALSE; } /* ------------------------------------------------------------------------ */ @@ -923,93 +923,93 @@ static void outallcaps_stream(out_stream_info *stream, int all_caps) */ static void stream_print(out_stream_info *stream, char *str) { - /* call the stream's do_print method */ - (*stream->do_print)(stream, str); + /* call the stream's do_print method */ + (*stream->do_print)(stream, str); } /* * Write out a line */ static void t_outline(out_stream_info *stream, int nl, - const char *txt, const int *attr) + const char *txt, const int *attr) { - extern int scrquiet; + extern int scrquiet; - /* - * Check the "script quiet" mode - this indicates that we're reading - * a script and not echoing output to the display. If this mode is - * on, and we're writing to the display, suppress this write. If - * the mode is off, or we're writing to another stream (such as the - * log file), show the output as normal. - */ - if (!scrquiet || stream != &G_std_disp) - { - size_t i; - char buf[MAXWIDTH]; - char *dst; - - /* - * Check to see if we've reached the end of the screen, and if - * so run the MORE prompt. Note that we don't make this check - * at all if USE_MORE is undefined, since this means that the OS - * layer code is taking responsibility for pagination issues. - * We also don't display a MORE prompt when reading from a - * script file. - * - * Note that we suppress the MORE prompt if nl == 0, since this - * is used to flush a partial line of text without starting a - * new line (for example, when displaying a prompt where the - * input will appear on the same line following the prompt). - * - * Skip the MORE prompt if this stream doesn't use it. - */ - if (stream->use_more_mode - && scrfp == 0 - && G_os_moremode - && nl != 0 && nl != 4 - && stream->linecnt++ >= G_os_pagelength) - { - /* display the MORE prompt */ - out_more_prompt(); - } + /* + * Check the "script quiet" mode - this indicates that we're reading + * a script and not echoing output to the display. If this mode is + * on, and we're writing to the display, suppress this write. If + * the mode is off, or we're writing to another stream (such as the + * log file), show the output as normal. + */ + if (!scrquiet || stream != &G_std_disp) + { + size_t i; + char buf[MAXWIDTH]; + char *dst; + + /* + * Check to see if we've reached the end of the screen, and if + * so run the MORE prompt. Note that we don't make this check + * at all if USE_MORE is undefined, since this means that the OS + * layer code is taking responsibility for pagination issues. + * We also don't display a MORE prompt when reading from a + * script file. + * + * Note that we suppress the MORE prompt if nl == 0, since this + * is used to flush a partial line of text without starting a + * new line (for example, when displaying a prompt where the + * input will appear on the same line following the prompt). + * + * Skip the MORE prompt if this stream doesn't use it. + */ + if (stream->use_more_mode + && scrfp == 0 + && G_os_moremode + && nl != 0 && nl != 4 + && stream->linecnt++ >= G_os_pagelength) + { + /* display the MORE prompt */ + out_more_prompt(); + } - /* - * Display the text. Run through the text in pieces; each time the - * attributes change, set attributes at the osifc level. - */ - for (i = 0, dst = buf ; txt[i] != '\0' ; ++i) - { - /* if the attribute is changing, notify osifc */ - if (attr != 0 && attr[i] != stream->os_attr) - { - /* flush the preceding text */ - if (dst != buf) - { - *dst = '\0'; - stream_print(stream, buf); - } + /* + * Display the text. Run through the text in pieces; each time the + * attributes change, set attributes at the osifc level. + */ + for (i = 0, dst = buf ; txt[i] != '\0' ; ++i) + { + /* if the attribute is changing, notify osifc */ + if (attr != 0 && attr[i] != stream->os_attr) + { + /* flush the preceding text */ + if (dst != buf) + { + *dst = '\0'; + stream_print(stream, buf); + } - /* set the new attribute */ - os_set_text_attr(attr[i]); + /* set the new attribute */ + os_set_text_attr(attr[i]); - /* remember this as the last OS attribute */ - stream->os_attr = attr[i]; + /* remember this as the last OS attribute */ + stream->os_attr = attr[i]; - /* start with a fresh buffer */ - dst = buf; - } + /* start with a fresh buffer */ + dst = buf; + } - /* buffer this character */ - *dst++ = txt[i]; - } + /* buffer this character */ + *dst++ = txt[i]; + } - /* flush the last chunk of text */ - if (dst != buf) - { - *dst = '\0'; - stream_print(stream, buf); - } - } + /* flush the last chunk of text */ + if (dst != buf) + { + *dst = '\0'; + stream_print(stream, buf); + } + } } /* ------------------------------------------------------------------------ */ @@ -1042,153 +1042,153 @@ static void t_outline(out_stream_info *stream, int nl, /* flush a given output stream */ static void outflushn_stream(out_stream_info *stream, int nl) { - int i; + int i; - /* null-terminate the current output line buffer */ - stream->linebuf[stream->linepos] = '\0'; + /* null-terminate the current output line buffer */ + stream->linebuf[stream->linepos] = '\0'; - /* note the position of the last character to display */ - i = stream->linepos - 1; + /* note the position of the last character to display */ + i = stream->linepos - 1; - /* if we're adding anything, remove trailing spaces */ - if (nl != 0 && nl != 4) - { - /* look for last non-space character */ - for ( ; i >= 0 && outissp(stream->linebuf[i]) ; --i) ; - } + /* if we're adding anything, remove trailing spaces */ + if (nl != 0 && nl != 4) + { + /* look for last non-space character */ + for ( ; i >= 0 && outissp(stream->linebuf[i]) ; --i) ; + } - /* check the output mode */ - if (nl == 3) - { - /* - * this is the special "preview" mode -- only display the part - * that we haven't already previewed for this same line - */ - if (i + 1 > stream->preview) - { - /* write out the line */ - t_outline(stream, 0, &stream->linebuf[stream->preview], - &stream->attrbuf[stream->preview]); + /* check the output mode */ + if (nl == 3) + { + /* + * this is the special "preview" mode -- only display the part + * that we haven't already previewed for this same line + */ + if (i + 1 > stream->preview) + { + /* write out the line */ + t_outline(stream, 0, &stream->linebuf[stream->preview], + &stream->attrbuf[stream->preview]); - /* skip past the part we wrote */ - stream->preview += strlen(&stream->linebuf[stream->preview]); - } - } - else - { - const char *suffix = nullptr; /* extra text to add after the flushed text */ - int countnl = 0; /* true if line counts for [more] paging */ + /* skip past the part we wrote */ + stream->preview += strlen(&stream->linebuf[stream->preview]); + } + } + else + { + const char *suffix = nullptr; /* extra text to add after the flushed text */ + int countnl = 0; /* true if line counts for [more] paging */ - /* null-terminate the buffer at the current position */ - stream->linebuf[++i] = '\0'; + /* null-terminate the buffer at the current position */ + stream->linebuf[++i] = '\0'; - /* check the mode */ - switch(nl) - { - case 0: - case 3: - case 4: - /* no newline - just flush out what we have with no suffix */ - suffix = 0; - break; + /* check the mode */ + switch(nl) + { + case 0: + case 3: + case 4: + /* no newline - just flush out what we have with no suffix */ + suffix = 0; + break; - case 1: - /* - * Add a newline. If there's nothing in the current line, - * or we just wrote out a newline, do not add an extra - * newline. Keep all newlines in PRE mode. - */ - if (stream->linecol != 0 || !stream->just_did_nl - || stream->html_pre_level != 0) - { - /* add a newline after the text */ - suffix = "\n"; - - /* count the line in the page size */ - countnl = 1; - } - else - { - /* don't add a newline */ - suffix = 0; - } - break; + case 1: + /* + * Add a newline. If there's nothing in the current line, + * or we just wrote out a newline, do not add an extra + * newline. Keep all newlines in PRE mode. + */ + if (stream->linecol != 0 || !stream->just_did_nl + || stream->html_pre_level != 0) + { + /* add a newline after the text */ + suffix = "\n"; + + /* count the line in the page size */ + countnl = 1; + } + else + { + /* don't add a newline */ + suffix = 0; + } + break; - case 2: - /* - * we're going to depend on the underlying OS output layer - * to do line breaking, so don't add a newline, but do add a - * space, so that the underlying OS layer knows we have a - * word break here - */ - suffix = " "; - break; - } + case 2: + /* + * we're going to depend on the underlying OS output layer + * to do line breaking, so don't add a newline, but do add a + * space, so that the underlying OS layer knows we have a + * word break here + */ + suffix = " "; + break; + } - /* - * display the line, as long as we have something buffered to - * display; even if we don't, display it if our column is - * non-zero and we didn't just do a newline, since this must - * mean that we've flushed a partial line and are just now doing - * the newline - */ - if (stream->linebuf[stream->preview] != '\0' - || (stream->linecol != 0 && !stream->just_did_nl) - || stream->html_pre_level > 0) - { - /* write it out */ - t_outline(stream, countnl, &stream->linebuf[stream->preview], - &stream->attrbuf[stream->preview]); + /* + * display the line, as long as we have something buffered to + * display; even if we don't, display it if our column is + * non-zero and we didn't just do a newline, since this must + * mean that we've flushed a partial line and are just now doing + * the newline + */ + if (stream->linebuf[stream->preview] != '\0' + || (stream->linecol != 0 && !stream->just_did_nl) + || stream->html_pre_level > 0) + { + /* write it out */ + t_outline(stream, countnl, &stream->linebuf[stream->preview], + &stream->attrbuf[stream->preview]); - /* write the suffix, if any */ - if (suffix != 0) - t_outline(stream, 0, suffix, 0); - } + /* write the suffix, if any */ + if (suffix != 0) + t_outline(stream, 0, suffix, 0); + } - /* generate an HTML line break if necessary */ - if (nl == 1 && stream->html_mode && stream->html_target) - t_outline(stream, 0, "
", 0); + /* generate an HTML line break if necessary */ + if (nl == 1 && stream->html_mode && stream->html_target) + t_outline(stream, 0, "
", 0); - if (nl == 0) - { - /* we're not displaying a newline, so flush what we have */ - os_flush(); - } - else - { - /* we displayed a newline, so reset the column position */ - stream->linecol = 0; - } + if (nl == 0) + { + /* we're not displaying a newline, so flush what we have */ + os_flush(); + } + else + { + /* we displayed a newline, so reset the column position */ + stream->linecol = 0; + } - /* reset the line output buffer position */ - stream->linepos = stream->preview = 0; + /* reset the line output buffer position */ + stream->linepos = stream->preview = 0; - /* - * If we just output a newline, note it. If we didn't just - * output a newline, but we did write out anything else, note - * that we're no longer at the start of a line on the underlying - * output device. - */ - if (nl == 1) - stream->just_did_nl = TRUE; - else if (stream->linebuf[stream->preview] != '\0') - stream->just_did_nl = FALSE; - } + /* + * If we just output a newline, note it. If we didn't just + * output a newline, but we did write out anything else, note + * that we're no longer at the start of a line on the underlying + * output device. + */ + if (nl == 1) + stream->just_did_nl = TRUE; + else if (stream->linebuf[stream->preview] != '\0') + stream->just_did_nl = FALSE; + } - /* - * If the osifc-level attributes don't match the current attributes, - * bring the osifc layer up to date. This is necessary in cases where - * we set attributes immediately before asking for input - we - * essentially need to flush the attributes without flushing any text. - */ - if (stream->cur_attr != stream->os_attr) - { - /* set the osifc attributes */ - os_set_text_attr(stream->cur_attr); + /* + * If the osifc-level attributes don't match the current attributes, + * bring the osifc layer up to date. This is necessary in cases where + * we set attributes immediately before asking for input - we + * essentially need to flush the attributes without flushing any text. + */ + if (stream->cur_attr != stream->os_attr) + { + /* set the osifc attributes */ + os_set_text_attr(stream->cur_attr); - /* remember the new attributes as the current osifc attributes */ - stream->os_attr = stream->cur_attr; - } + /* remember the new attributes as the current osifc attributes */ + stream->os_attr = stream->cur_attr; + } } /* ------------------------------------------------------------------------ */ @@ -1199,26 +1199,26 @@ static void outflushn_stream(out_stream_info *stream, int nl) */ static int out_is_hidden() { - /* check the output flag */ - if (!outflag) - { - /* trace the hidden output if desired */ - if (dbghid && !hidout) - trchid(); + /* check the output flag */ + if (!outflag) + { + /* trace the hidden output if desired */ + if (dbghid && !hidout) + trchid(); - /* note the hidden output */ - hidout = 1; + /* note the hidden output */ + hidout = 1; - /* - * unless we're showing hidden text in the debugger, we're - * suppressing output, so return true - */ - if (!dbghid) - return TRUE; - } + /* + * unless we're showing hidden text in the debugger, we're + * suppressing output, so return true + */ + if (!dbghid) + return TRUE; + } - /* we're not suppressing output */ - return FALSE; + /* we're not suppressing output */ + return FALSE; } /* ------------------------------------------------------------------------ */ @@ -1227,15 +1227,15 @@ static int out_is_hidden() */ static void outblank_stream(out_stream_info *stream) { - /* flush the stream */ - outflushn_stream(stream, 1); + /* flush the stream */ + outflushn_stream(stream, 1); - /* if generating for an HTML display target, add an HTML line break */ - if (stream->html_mode && stream->html_target) - outstring_stream(stream, "
"); + /* if generating for an HTML display target, add an HTML line break */ + if (stream->html_mode && stream->html_target) + outstring_stream(stream, "
"); - /* write out the newline */ - t_outline(stream, 1, "\n", 0); + /* write out the newline */ + t_outline(stream, 1, "\n", 0); } /* ------------------------------------------------------------------------ */ @@ -1252,41 +1252,41 @@ static void outblank_stream(out_stream_info *stream) */ static void outtab_stream(out_stream_info *stream) { - /* check to see what the underlying system is expecting */ - if (stream->html_target) - { - /* the underlying system is HTML - check for HTML mode */ - if (stream->html_mode) - { - /* we're in HTML mode, so use the HTML tag */ - outstring_stream(stream, ""); - } - else - { - /* we're not in HTML mode, so generate a hard tab character */ - outchar_noxlat_stream(stream, QTAB); - } - } - else - { - int maxcol; + /* check to see what the underlying system is expecting */ + if (stream->html_target) + { + /* the underlying system is HTML - check for HTML mode */ + if (stream->html_mode) + { + /* we're in HTML mode, so use the HTML tag */ + outstring_stream(stream, ""); + } + else + { + /* we're not in HTML mode, so generate a hard tab character */ + outchar_noxlat_stream(stream, QTAB); + } + } + else + { + int maxcol; - /* - * We're not in HTML mode - expand the tab with spaces. Figure - * the maximum column: if we're doing our own line wrapping, never - * go beyond the actual display width. - */ - maxcol = (stream->os_line_wrap ? OS_MAXWIDTH : G_os_linewidth); + /* + * We're not in HTML mode - expand the tab with spaces. Figure + * the maximum column: if we're doing our own line wrapping, never + * go beyond the actual display width. + */ + maxcol = (stream->os_line_wrap ? OS_MAXWIDTH : G_os_linewidth); - /* add the spaces */ - do - { - stream->attrbuf[stream->linepos] = stream->cur_attr; - stream->linebuf[stream->linepos++] = ' '; - ++(stream->linecol); - } while (((stream->linecol + 1) & 3) != 0 - && stream->linecol < maxcol); - } + /* add the spaces */ + do + { + stream->attrbuf[stream->linepos] = stream->cur_attr; + stream->linebuf[stream->linepos++] = ' '; + ++(stream->linecol); + } while (((stream->linecol + 1) & 3) != 0 + && stream->linecol < maxcol); + } } @@ -1296,43 +1296,43 @@ static void outtab_stream(out_stream_info *stream) */ static void out_flushline(out_stream_info *stream, int padding) { - /* - * check to see if we're using the underlying display layer's line - * wrapping - */ - if (stream->os_line_wrap) - { - /* - * In the HTML version, we don't need the normal *MORE* - * processing, since the HTML layer will handle that. - * Furthermore, we don't need to provide actual newline breaks - * -- that happens after the HTML is parsed, so we don't have - * enough information here to figure out actual line breaks. - * So, we'll just flush out our buffer whenever it fills up, and - * suppress newlines. - * - * Similarly, if we have OS-level MORE processing, don't try to - * figure out where the line breaks go -- just flush our buffer - * without a trailing newline whenever the buffer is full, and - * let the OS layer worry about formatting lines and paragraphs. - * - * If we're using padding, use mode 2. If we don't want padding - * (which is the case if we completely fill up the buffer - * without finding any word breaks), write out in mode 0, which - * just flushes the buffer exactly like it is. - */ - outflushn_stream(stream, padding ? 2 : 4); - } - else - { - /* - * Normal mode - we process the *MORE* prompt ourselves, and we - * are responsible for figuring out where the actual line breaks - * go. Use outflush() to generate an actual newline whenever we - * flush out our buffer. - */ - outflushn_stream(stream, 1); - } + /* + * check to see if we're using the underlying display layer's line + * wrapping + */ + if (stream->os_line_wrap) + { + /* + * In the HTML version, we don't need the normal *MORE* + * processing, since the HTML layer will handle that. + * Furthermore, we don't need to provide actual newline breaks + * -- that happens after the HTML is parsed, so we don't have + * enough information here to figure out actual line breaks. + * So, we'll just flush out our buffer whenever it fills up, and + * suppress newlines. + * + * Similarly, if we have OS-level MORE processing, don't try to + * figure out where the line breaks go -- just flush our buffer + * without a trailing newline whenever the buffer is full, and + * let the OS layer worry about formatting lines and paragraphs. + * + * If we're using padding, use mode 2. If we don't want padding + * (which is the case if we completely fill up the buffer + * without finding any word breaks), write out in mode 0, which + * just flushes the buffer exactly like it is. + */ + outflushn_stream(stream, padding ? 2 : 4); + } + else + { + /* + * Normal mode - we process the *MORE* prompt ourselves, and we + * are responsible for figuring out where the actual line breaks + * go. Use outflush() to generate an actual newline whenever we + * flush out our buffer. + */ + outflushn_stream(stream, 1); + } } @@ -1342,269 +1342,269 @@ static void out_flushline(out_stream_info *stream, int padding) */ static void outchar_noxlat_stream(out_stream_info *stream, char c) { - int i; - int qspace; - - /* check for the special quoted space character */ - if (c == QSPACE) - { - /* it's a quoted space - note it and convert it to a regular space */ - qspace = 1; - c = ' '; - } - else if (c == QTAB) - { - /* it's a hard tab - convert it to an ordinary tab */ - c = '\t'; - qspace = 0; - } - else - { - /* translate any whitespace character to a regular space character */ - if (outissp(c)) - c = ' '; - - /* it's not a quoted space */ - qspace = 0; - } + int i; + int qspace; + + /* check for the special quoted space character */ + if (c == QSPACE) + { + /* it's a quoted space - note it and convert it to a regular space */ + qspace = 1; + c = ' '; + } + else if (c == QTAB) + { + /* it's a hard tab - convert it to an ordinary tab */ + c = '\t'; + qspace = 0; + } + else + { + /* translate any whitespace character to a regular space character */ + if (outissp(c)) + c = ' '; + + /* it's not a quoted space */ + qspace = 0; + } - /* check for the caps/nocaps flags */ - if ((stream->capsflag || stream->allcapsflag) && outisal(c)) - { - /* capsflag is set, so capitalize this character */ - if (outislo(c)) - c = toupper(c); + /* check for the caps/nocaps flags */ + if ((stream->capsflag || stream->allcapsflag) && outisal(c)) + { + /* capsflag is set, so capitalize this character */ + if (outislo(c)) + c = toupper(c); - /* okay, we've capitalized something; clear flag */ - stream->capsflag = 0; - } - else if (stream->nocapsflag && outisal(c)) - { - /* nocapsflag is set, so minisculize this character */ - if (outisup(c)) - c = tolower(c); + /* okay, we've capitalized something; clear flag */ + stream->capsflag = 0; + } + else if (stream->nocapsflag && outisal(c)) + { + /* nocapsflag is set, so minisculize this character */ + if (outisup(c)) + c = tolower(c); - /* clear the flag now that we've done the job */ - stream->nocapsflag = 0; - } + /* clear the flag now that we've done the job */ + stream->nocapsflag = 0; + } - /* if in capture mode, simply capture the character */ - if (stream->capturing) - { - uchar *p; + /* if in capture mode, simply capture the character */ + if (stream->capturing) + { + uchar *p; - /* if we have a valid capture object, copy to it */ - if (stream->capture_obj != MCMONINV) - { - /* lock the object holding the captured text */ - p = mcmlck(stream->capture_ctx, stream->capture_obj); - - /* make sure the capture object is big enough */ - if (mcmobjsiz(stream->capture_ctx, stream->capture_obj) - <= stream->capture_ofs) - { - /* expand the object by another 256 bytes */ - p = mcmrealo(stream->capture_ctx, stream->capture_obj, - (ushort)(stream->capture_ofs + 256)); - } - - /* add this character */ - *(p + stream->capture_ofs++) = c; - - /* unlock the capture object */ - mcmtch(stream->capture_ctx, stream->capture_obj); - mcmunlck(stream->capture_ctx, stream->capture_obj); - } + /* if we have a valid capture object, copy to it */ + if (stream->capture_obj != MCMONINV) + { + /* lock the object holding the captured text */ + p = mcmlck(stream->capture_ctx, stream->capture_obj); + + /* make sure the capture object is big enough */ + if (mcmobjsiz(stream->capture_ctx, stream->capture_obj) + <= stream->capture_ofs) + { + /* expand the object by another 256 bytes */ + p = mcmrealo(stream->capture_ctx, stream->capture_obj, + (ushort)(stream->capture_ofs + 256)); + } + + /* add this character */ + *(p + stream->capture_ofs++) = c; + + /* unlock the capture object */ + mcmtch(stream->capture_ctx, stream->capture_obj); + mcmunlck(stream->capture_ctx, stream->capture_obj); + } - /* - * we're done - we don't want to actually display the character - * while capturing - */ - return; - } + /* + * we're done - we don't want to actually display the character + * while capturing + */ + return; + } - /* add the character to out output buffer, flushing as needed */ - if (stream->linecol + 1 < G_os_linewidth) - { - /* - * there's room for this character, so add it to the buffer - */ - - /* ignore non-quoted space at start of line outside of PRE */ - if (outissp(c) && c != '\t' && stream->linecol == 0 && !qspace - && stream->html_pre_level == 0) - return; + /* add the character to out output buffer, flushing as needed */ + if (stream->linecol + 1 < G_os_linewidth) + { + /* + * there's room for this character, so add it to the buffer + */ + + /* ignore non-quoted space at start of line outside of PRE */ + if (outissp(c) && c != '\t' && stream->linecol == 0 && !qspace + && stream->html_pre_level == 0) + return; - /* is this a non-quoted space not at the start of the line? */ - if (outissp(c) && c != '\t' && stream->linecol != 0 && !qspace - && stream->html_pre_level == 0) - { - int pos1 = stream->linepos - 1; - char p = stream->linebuf[pos1]; /* check previous character */ + /* is this a non-quoted space not at the start of the line? */ + if (outissp(c) && c != '\t' && stream->linecol != 0 && !qspace + && stream->html_pre_level == 0) + { + int pos1 = stream->linepos - 1; + char p = stream->linebuf[pos1]; /* check previous character */ - /* ignore repeated spaces - collapse into a single space */ - if (outissp(p)) - return; + /* ignore repeated spaces - collapse into a single space */ + if (outissp(p)) + return; - /* - * Certain punctuation requires a double space: a period, a - * question mark, an exclamation mark, or a colon; or any of - * these characters followed by any number of single and/or - * double quotes. First, scan back to before any quotes, if - * are on one now, then check the preceding character; if - * it's one of the punctuation marks requiring a double - * space, add this space a second time. (In addition to - * scanning back past quotes, scan past parentheses, - * brackets, and braces.) Don't double the spacing if we're - * not in the normal doublespace mode; some people may - * prefer single spacing after punctuation, so we make this - * a run-time option. - */ - if (doublespace) - { - /* find the previous relevant punctuation character */ - while (pos1 && - (p == '"' || p == '\'' || p == ')' || p == ']' - || p == '}')) - { - p = stream->linebuf[--pos1]; - } - if ( p == '.' || p == '?' || p == '!' || p == ':' ) - { - /* a double-space is required after this character */ - stream->attrbuf[stream->linepos] = stream->cur_attr; - stream->linebuf[stream->linepos++] = c; - ++(stream->linecol); - } - } - } + /* + * Certain punctuation requires a double space: a period, a + * question mark, an exclamation mark, or a colon; or any of + * these characters followed by any number of single and/or + * double quotes. First, scan back to before any quotes, if + * are on one now, then check the preceding character; if + * it's one of the punctuation marks requiring a double + * space, add this space a second time. (In addition to + * scanning back past quotes, scan past parentheses, + * brackets, and braces.) Don't double the spacing if we're + * not in the normal doublespace mode; some people may + * prefer single spacing after punctuation, so we make this + * a run-time option. + */ + if (doublespace) + { + /* find the previous relevant punctuation character */ + while (pos1 && + (p == '"' || p == '\'' || p == ')' || p == ']' + || p == '}')) + { + p = stream->linebuf[--pos1]; + } + if ( p == '.' || p == '?' || p == '!' || p == ':' ) + { + /* a double-space is required after this character */ + stream->attrbuf[stream->linepos] = stream->cur_attr; + stream->linebuf[stream->linepos++] = c; + ++(stream->linecol); + } + } + } - /* add this character to the buffer */ - stream->attrbuf[stream->linepos] = stream->cur_attr; - stream->linebuf[stream->linepos++] = c; + /* add this character to the buffer */ + stream->attrbuf[stream->linepos] = stream->cur_attr; + stream->linebuf[stream->linepos++] = c; - /* advance the output column position */ - ++(stream->linecol); - return; - } + /* advance the output column position */ + ++(stream->linecol); + return; + } - /* - * The line would overflow if this character were added. Find the - * most recent word break, and output the line up to the previous - * word. Note that if we're trying to output a space, we'll just - * add it to the line buffer. If the last character of the line - * buffer is already a space, we won't do anything right now. - */ - if (outissp(c) && c != '\t' && !qspace) - { - /* this is a space, so we're at a word break */ - if (stream->linebuf[stream->linepos - 1] != ' ') - { - stream->attrbuf[stream->linepos] = stream->cur_attr; - stream->linebuf[stream->linepos++] = ' '; - } - return; - } - - /* - * Find the most recent word break: look for a space or dash, starting - * at the end of the line. - * - * If we're about to write a hyphen, we want to skip all contiguous - * hyphens, because we want to keep them together as a single - * punctuation mark; then keep going in the normal manner, which will - * keep the hyphens plus the word they're attached to together as a - * single unit. If spaces precede the sequence of hyphens, include - * the prior word as well. - */ - i = stream->linepos - 1; - if (c == '-') - { - /* skip any contiguous hyphens at the end of the line */ - for ( ; i >= 0 && stream->linebuf[i] == '-' ; --i) ; - - /* skip any spaces preceding the sequence of hyphens */ - for ( ; i >= 0 && outissp(stream->linebuf[i]) ; --i) ; - } + /* + * The line would overflow if this character were added. Find the + * most recent word break, and output the line up to the previous + * word. Note that if we're trying to output a space, we'll just + * add it to the line buffer. If the last character of the line + * buffer is already a space, we won't do anything right now. + */ + if (outissp(c) && c != '\t' && !qspace) + { + /* this is a space, so we're at a word break */ + if (stream->linebuf[stream->linepos - 1] != ' ') + { + stream->attrbuf[stream->linepos] = stream->cur_attr; + stream->linebuf[stream->linepos++] = ' '; + } + return; + } + + /* + * Find the most recent word break: look for a space or dash, starting + * at the end of the line. + * + * If we're about to write a hyphen, we want to skip all contiguous + * hyphens, because we want to keep them together as a single + * punctuation mark; then keep going in the normal manner, which will + * keep the hyphens plus the word they're attached to together as a + * single unit. If spaces precede the sequence of hyphens, include + * the prior word as well. + */ + i = stream->linepos - 1; + if (c == '-') + { + /* skip any contiguous hyphens at the end of the line */ + for ( ; i >= 0 && stream->linebuf[i] == '-' ; --i) ; + + /* skip any spaces preceding the sequence of hyphens */ + for ( ; i >= 0 && outissp(stream->linebuf[i]) ; --i) ; + } - /* - * Now find the preceding space. If we're doing our own wrapping - * (i.e., we're not using OS line wrapping), then look for the - * nearest hyphen as well. - */ - for ( ; i >= 0 && !outissp(stream->linebuf[i]) - && !(!stream->os_line_wrap && stream->linebuf[i] == '-') ; --i) ; + /* + * Now find the preceding space. If we're doing our own wrapping + * (i.e., we're not using OS line wrapping), then look for the + * nearest hyphen as well. + */ + for ( ; i >= 0 && !outissp(stream->linebuf[i]) + && !(!stream->os_line_wrap && stream->linebuf[i] == '-') ; --i) ; - /* check to see if we found a good place to break */ - if (i < 0) - { - /* - * we didn't find any good place to break - flush the entire - * line as-is, breaking arbitrarily in the middle of a word - */ - out_flushline(stream, FALSE); + /* check to see if we found a good place to break */ + if (i < 0) + { + /* + * we didn't find any good place to break - flush the entire + * line as-is, breaking arbitrarily in the middle of a word + */ + out_flushline(stream, FALSE); - /* - * we've completely cleared out the line buffer, so reset all of - * the line buffer counters - */ - stream->linepos = 0; - stream->linecol = 0; - stream->linebuf[0] = '\0'; - } - else - { - char brkchar; - char tmpbuf[MAXWIDTH]; - int tmpattr[MAXWIDTH]; - size_t tmpcnt; + /* + * we've completely cleared out the line buffer, so reset all of + * the line buffer counters + */ + stream->linepos = 0; + stream->linecol = 0; + stream->linebuf[0] = '\0'; + } + else + { + char brkchar; + char tmpbuf[MAXWIDTH]; + int tmpattr[MAXWIDTH]; + size_t tmpcnt; - /* remember the word-break character */ - brkchar = stream->linebuf[i]; + /* remember the word-break character */ + brkchar = stream->linebuf[i]; - /* null-terminate the line buffer */ - stream->linebuf[stream->linepos] = '\0'; + /* null-terminate the line buffer */ + stream->linebuf[stream->linepos] = '\0'; - /* the next line starts after the break - save a copy */ - tmpcnt = strlen(&stream->linebuf[i+1]); - memcpy(tmpbuf, &stream->linebuf[i+1], tmpcnt + 1); - memcpy(tmpattr, &stream->attrbuf[i+1], tmpcnt * sizeof(tmpattr[0])); + /* the next line starts after the break - save a copy */ + tmpcnt = strlen(&stream->linebuf[i+1]); + memcpy(tmpbuf, &stream->linebuf[i+1], tmpcnt + 1); + memcpy(tmpattr, &stream->attrbuf[i+1], tmpcnt * sizeof(tmpattr[0])); - /* - * terminate the buffer at the space or after the hyphen, - * depending on where we broke - */ - if (outissp(brkchar)) - stream->linebuf[i] = '\0'; - else - stream->linebuf[i+1] = '\0'; + /* + * terminate the buffer at the space or after the hyphen, + * depending on where we broke + */ + if (outissp(brkchar)) + stream->linebuf[i] = '\0'; + else + stream->linebuf[i+1] = '\0'; - /* write out everything up to the word break */ - out_flushline(stream, TRUE); + /* write out everything up to the word break */ + out_flushline(stream, TRUE); - /* copy the next line into line buffer */ - memcpy(stream->linebuf, tmpbuf, tmpcnt + 1); - memcpy(stream->attrbuf, tmpattr, tmpcnt * sizeof(tmpattr[0])); - stream->linepos = tmpcnt; + /* copy the next line into line buffer */ + memcpy(stream->linebuf, tmpbuf, tmpcnt + 1); + memcpy(stream->attrbuf, tmpattr, tmpcnt * sizeof(tmpattr[0])); + stream->linepos = tmpcnt; - /* - * figure what column we're now in - count all of the printable - * characters in the new line - */ - for (stream->linecol = 0, i = 0 ; i < stream->linepos ; ++i) - { - /* if it's printable, count it */ - if (((unsigned char)stream->linebuf[i]) >= 26) - ++(stream->linecol); - } - } - - /* add the new character to buffer */ - stream->attrbuf[stream->linepos] = stream->cur_attr; - stream->linebuf[stream->linepos++] = c; + /* + * figure what column we're now in - count all of the printable + * characters in the new line + */ + for (stream->linecol = 0, i = 0 ; i < stream->linepos ; ++i) + { + /* if it's printable, count it */ + if (((unsigned char)stream->linebuf[i]) >= 26) + ++(stream->linecol); + } + } + + /* add the new character to buffer */ + stream->attrbuf[stream->linepos] = stream->cur_attr; + stream->linebuf[stream->linepos++] = c; - /* advance the column counter */ - ++(stream->linecol); + /* advance the column counter */ + ++(stream->linecol); } /* ------------------------------------------------------------------------ */ @@ -1614,7 +1614,7 @@ static void outchar_noxlat_stream(out_stream_info *stream, char c) */ static void outchar_stream(out_stream_info *stream, char c) { - outchar_noxlat_stream(stream, cmap_i2n(c)); + outchar_noxlat_stream(stream, cmap_i2n(c)); } /* @@ -1622,9 +1622,9 @@ static void outchar_stream(out_stream_info *stream, char c) */ static void outstring_stream(out_stream_info *stream, const char *s) { - /* write out each character in the string */ - for ( ; *s ; ++s) - outchar_stream(stream, *s); + /* write out each character in the string */ + for ( ; *s ; ++s) + outchar_stream(stream, *s); } /* @@ -1632,8 +1632,8 @@ static void outstring_stream(out_stream_info *stream, const char *s) */ static void outstring_noxlat_stream(out_stream_info *stream, char *s) { - for ( ; *s ; ++s) - outchar_noxlat_stream(stream, *s); + for ( ; *s ; ++s) + outchar_noxlat_stream(stream, *s); } @@ -1643,46 +1643,46 @@ static void outstring_noxlat_stream(out_stream_info *stream, char *s) * set. */ static void outchar_html_stream(out_stream_info *stream, - unsigned int htmlchar) + unsigned int htmlchar) { - amp_tbl_t *ampptr; + amp_tbl_t *ampptr; - /* - * search for a mapping entry for this entity, in case it's defined - * in an external mapping file - */ - for (ampptr = amp_tbl ; - ampptr < amp_tbl + sizeof(amp_tbl)/sizeof(amp_tbl[0]) ; ++ampptr) - { - /* if this is the one, stop looking */ - if (ampptr->html_cval == htmlchar) - break; - } + /* + * search for a mapping entry for this entity, in case it's defined + * in an external mapping file + */ + for (ampptr = amp_tbl ; + ampptr < amp_tbl + sizeof(amp_tbl)/sizeof(amp_tbl[0]) ; ++ampptr) + { + /* if this is the one, stop looking */ + if (ampptr->html_cval == htmlchar) + break; + } - /* - * If we found a mapping table entry, and the entry has an expansion - * from the external character mapping table file, use the external - * expansion; otherwise, use the default expansion. - */ - if (ampptr >= amp_tbl + sizeof(amp_tbl)/sizeof(amp_tbl[0]) - || ampptr->expan == 0) - { - char xlat_buf[50]; + /* + * If we found a mapping table entry, and the entry has an expansion + * from the external character mapping table file, use the external + * expansion; otherwise, use the default expansion. + */ + if (ampptr >= amp_tbl + sizeof(amp_tbl)/sizeof(amp_tbl[0]) + || ampptr->expan == 0) + { + char xlat_buf[50]; - /* - * there's no external mapping table file expansion -- use the - * default OS mapping routine - */ - os_xlat_html4(htmlchar, xlat_buf, sizeof(xlat_buf)); - outstring_noxlat_stream(stream, xlat_buf); - } - else - { - /* - * use the explicit mapping from the mapping table file - */ - outstring_noxlat_stream(stream, ampptr->expan); - } + /* + * there's no external mapping table file expansion -- use the + * default OS mapping routine + */ + os_xlat_html4(htmlchar, xlat_buf, sizeof(xlat_buf)); + outstring_noxlat_stream(stream, xlat_buf); + } + else + { + /* + * use the explicit mapping from the mapping table file + */ + outstring_noxlat_stream(stream, ampptr->expan); + } } @@ -1698,22 +1698,22 @@ static void outchar_html_stream(out_stream_info *stream, */ static int out_push_stream(out_stream_info *stream) { - /* - * if we're already in the formatter, and the new stream doesn't - * match the enclosing recursion level's stream, tell the caller to - * abort the operation - */ - if (G_recurse != 0 && G_cur_stream != stream) - return FALSE; - - /* note the active stream */ - G_cur_stream = stream; + /* + * if we're already in the formatter, and the new stream doesn't + * match the enclosing recursion level's stream, tell the caller to + * abort the operation + */ + if (G_recurse != 0 && G_cur_stream != stream) + return FALSE; + + /* note the active stream */ + G_cur_stream = stream; - /* count the entry */ - ++G_recurse; + /* count the entry */ + ++G_recurse; - /* tell the caller to proceed */ - return TRUE; + /* tell the caller to proceed */ + return TRUE; } /* @@ -1721,8 +1721,8 @@ static int out_push_stream(out_stream_info *stream) */ static void out_pop_stream() { - /* count the exit */ - --G_recurse; + /* count the exit */ + --G_recurse; } /* ------------------------------------------------------------------------ */ @@ -1741,14 +1741,14 @@ static void out_pop_stream() * output stream if it's not null. */ static char nextout_copy(const char **s, size_t *slen, - char prv, out_stream_info *stream) + char prv, out_stream_info *stream) { - /* if there's a stream, write the previous character to the stream */ - if (stream != 0) - outchar_stream(stream, prv); + /* if there's a stream, write the previous character to the stream */ + if (stream != 0) + outchar_stream(stream, prv); - /* return the next character */ - return nextout(s, slen); + /* return the next character */ + return nextout(s, slen); } /* ------------------------------------------------------------------------ */ @@ -1758,52 +1758,52 @@ static char nextout_copy(const char **s, size_t *slen, * the next character after the tag name. */ static char read_tag(char *dst, size_t dstlen, int *is_end_tag, - const char **s, size_t *slen, out_stream_info *stream) + const char **s, size_t *slen, out_stream_info *stream) { - char c; - - /* skip the opening '<' */ - c = nextout_copy(s, slen, '<', stream); + char c; + + /* skip the opening '<' */ + c = nextout_copy(s, slen, '<', stream); - /* skip spaces */ - while (outissp(c)) - c = nextout_copy(s, slen, c, stream); + /* skip spaces */ + while (outissp(c)) + c = nextout_copy(s, slen, c, stream); - /* note if this is a closing tag */ - if (c == '/' || c == '\\') - { - /* it's an end tag - note it and skip the slash */ - *is_end_tag = TRUE; - c = nextout_copy(s, slen, c, stream); + /* note if this is a closing tag */ + if (c == '/' || c == '\\') + { + /* it's an end tag - note it and skip the slash */ + *is_end_tag = TRUE; + c = nextout_copy(s, slen, c, stream); - /* skip yet more spaces */ - while (outissp(c)) - c = nextout_copy(s, slen, c, stream); - } - else - *is_end_tag = FALSE; - - /* - * find the end of the tag name - the tag continues to the next space, - * '>', or end of line - */ - for ( ; c != '\0' && !outissp(c) && c != '>' ; - c = nextout_copy(s, slen, c, stream)) - { - /* add this to the tag buffer if it fits */ - if (dstlen > 1) - { - *dst++ = c; - --dstlen; - } - } - - /* null-terminate the tag name */ - if (dstlen > 0) - *dst = '\0'; + /* skip yet more spaces */ + while (outissp(c)) + c = nextout_copy(s, slen, c, stream); + } + else + *is_end_tag = FALSE; + + /* + * find the end of the tag name - the tag continues to the next space, + * '>', or end of line + */ + for ( ; c != '\0' && !outissp(c) && c != '>' ; + c = nextout_copy(s, slen, c, stream)) + { + /* add this to the tag buffer if it fits */ + if (dstlen > 1) + { + *dst++ = c; + --dstlen; + } + } + + /* null-terminate the tag name */ + if (dstlen > 0) + *dst = '\0'; - /* return the next character */ - return c; + /* return the next character */ + return c; } @@ -1812,909 +1812,909 @@ static char read_tag(char *dst, size_t dstlen, int *is_end_tag, * display a string of a given length to a given stream */ static int outformatlen_stream(out_stream_info *stream, - const char *s, size_t slen) + const char *s, size_t slen) { - char c; - int done = 0; - char fmsbuf[40]; /* space for constructing translation string */ - uint fmslen; - char *f = 0; - char *f1; - int infmt = 0; - - /* - * This routine can recurse because of format strings ("%xxx%" - * sequences). When we recurse, we want to ensure that the - * recursion is directed to the original stream only. So, note the - * current stream statically in case we re-enter the formatter. - */ - if (!out_push_stream(stream)) - return 0; - - /* get the first character */ - c = nextout(&s, &slen); - - /* if we have anything to show, show it */ - while (c != '\0') - { - /* check if we're collecting translation string */ - if (infmt) - { - /* - * if the string is too long for our buffer, or we've come - * across a backslash (illegal in a format string), or we've - * come across an HTML-significant character ('&' or '<') in - * HTML mode, we must have a stray percent sign; dump the - * whole string so far and act as though we have no format - * string - */ - if (c == '\\' - || f == &fmsbuf[sizeof(fmsbuf)] - || (stream->html_mode && (c == '<' || c == '&'))) - { - outchar_stream(stream, '%'); - for (f1 = fmsbuf ; f1 < f ; ++f1) - outchar_stream(stream, *f1); - infmt = 0; - - /* process this character again */ - continue; - } - else if (c == '%' && f == fmsbuf) /* double percent sign? */ - { - outchar_stream(stream, '%'); /* send out a single '%' */ - infmt = 0; /* no longer processing translation string */ - } - else if (c == '%') /* found end of string? translate it if so */ - { - uchar *fms; - int initcap = FALSE; - int allcaps = FALSE; - char fmsbuf_srch[sizeof(fmsbuf)]; - - /* null-terminate the string */ - *f = '\0'; - - /* check for an init cap */ - if (outisup(fmsbuf[0])) - { - /* - * note the initial capital, so that we follow the - * original capitalization in the substituted string - */ - initcap = TRUE; - - /* - * if the second letter is capitalized as well, - * capitalize the entire substituted string - */ - if (fmsbuf[1] != '\0' && outisup(fmsbuf[1])) - { - /* use all caps */ - allcaps = TRUE; - } - } - - /* convert the entire string to lower case for searching */ - strcpy(fmsbuf_srch, fmsbuf); - os_strlwr(fmsbuf_srch); - - /* find the string in the format string table */ - fmslen = strlen(fmsbuf_srch); - for (fms = fmsbase ; fms < fmstop ; ) - { - uint propnum; - uint len; - - /* get the information on this entry */ - propnum = osrp2(fms); - len = osrp2(fms + 2) - 2; - - /* check for a match */ - if (len == fmslen && - !memcmp(fms + 4, fmsbuf_srch, (size_t)len)) - { - int old_all_caps; - - /* note the current ALLCAPS mode */ - old_all_caps = stream->allcapsflag; - - /* - * we have a match - set the appropriate - * capitalization mode - */ - if (allcaps) - outallcaps_stream(stream, TRUE); - else if (initcap) - outcaps_stream(stream); - - /* - * evaluate the associated property to generate - * the substitution text - */ - runppr(runctx, cmdActor, (prpnum)propnum, 0); - - /* turn off ALLCAPS mode */ - outallcaps_stream(stream, old_all_caps); - - /* no need to look any further */ - break; - } - - /* move on to next formatstring if not yet found */ - fms += len + 4; - } - - /* if we can't find it, dump the format string as-is */ - if (fms == fmstop) - { - outchar_stream(stream, '%'); - for (f1 = fmsbuf ; f1 < f ; ++f1) - outchar_stream(stream, *f1); - outchar_stream(stream, '%'); - } - - /* no longer reading format string */ - infmt = 0; - } - else - { - /* copy this character of the format string */ - *f++ = c; - } - - /* move on to the next character and continue scanning */ - c = nextout(&s, &slen); - continue; - } - - /* - * If we're parsing HTML here, and we're inside a tag, skip - * characters until we reach the end of the tag. - */ - if (stream->html_mode_flag != HTML_MODE_NORMAL) - { - switch(stream->html_mode_flag) - { - case HTML_MODE_TAG: - /* - * keep skipping up to the closing '>', but note when we - * enter any quoted section - */ - switch(c) - { - case '>': - /* we've reached the end of the tag */ - stream->html_mode_flag = HTML_MODE_NORMAL; - - /* if we have a deferred
, process it now */ - switch(stream->html_defer_br) - { - case HTML_DEFER_BR_NONE: - /* no deferred
*/ - break; - - case HTML_DEFER_BR_FLUSH: - outflushn_stream(stream, 1); - break; - - case HTML_DEFER_BR_BLANK: - outblank_stream(stream); - break; - } - - /* no more deferred
pending */ - stream->html_defer_br = HTML_DEFER_BR_NONE; - - /* no more ALT attribute allowed */ - stream->html_allow_alt = FALSE; - break; - - case '"': - /* enter a double-quoted string */ - stream->html_mode_flag = HTML_MODE_DQUOTE; - break; - - case '\'': - /* enter a single-quoted string */ - stream->html_mode_flag = HTML_MODE_SQUOTE; - break; - - default: - /* if it's alphabetic, note the attribute name */ - if (outisal(c)) - { - char attrname[128]; - char attrval[256]; - char *dst; - - /* gather up the attribute name */ - for (dst = attrname ; - dst + 1 < attrname + sizeof(attrname) ; ) - { - /* store this character */ - *dst++ = c; - - /* get the next character */ - c = nextout(&s, &slen); - - /* if it's not alphanumeric, stop scanning */ - if (!outisal(c) && !outisdg(c)) - break; - } - - /* null-terminate the result */ - *dst++ = '\0'; - - /* gather the value if present */ - if (c == '=') - { - char qu; - - /* skip the '=' */ - c = nextout(&s, &slen); - - /* if we have a quote, so note */ - if (c == '"' || c == '\'') - { - /* remember the quote */ - qu = c; - - /* skip it */ - c = nextout(&s, &slen); - } - else - { - /* no quote */ - qu = 0; - } - - /* read the value */ - for (dst = attrval ; - dst + 1 < attrval + sizeof(attrval) ; ) - { - /* store this character */ - *dst++ = c; - - /* read the next one */ - c = nextout(&s, &slen); - if (c == '\0') - { - /* - * we've reached the end of the - * string, and we're still inside - * this attribute - abandon the - * attribute but note that we're - * inside a quoted string if - * necessary - */ - if (qu == '"') - stream->html_mode_flag = - HTML_MODE_DQUOTE; - else if (qu == '\'') - stream->html_mode_flag = - HTML_MODE_SQUOTE; - else - stream->html_mode_flag - = HTML_MODE_TAG; - - /* stop scanning the string */ - break; - } - - /* - * if we're looking for a quote, check - * for the closing quote; otherwise, - * check for alphanumerics - */ - if (qu != 0) - { - /* if this is our quote, stop scanning */ - if (c == qu) - break; - } - else - { - /* if it's non-alphanumeric, we're done */ - if (!outisal(c) && !outisdg(c)) - break; - } - } - - /* skip the closing quote, if necessary */ - if (qu != 0 && c == qu) - c = nextout(&s, &slen); - - /* null-terminate the value string */ - *dst = '\0'; - } - else - { - /* no value */ - attrval[0] = '\0'; - } - - /* - * see if we recognize it, and it's meaningful - * in the context of the current tag - */ - if (!scumm_stricmp(attrname, "height") - && stream->html_defer_br != HTML_DEFER_BR_NONE) - { - int ht; - - /* - * If the height is zero, always treat this - * as a non-blanking flush. If it's one, - * treat it as we originally planned to. If - * it's greater than one, add n blank lines. - */ - ht = atoi(attrval); - if (ht == 0) - { - /* always use non-blanking flush */ - stream->html_defer_br = HTML_DEFER_BR_FLUSH; - } - else if (ht == 1) - { - /* keep original setting */ - } - else - { - for ( ; ht > 0 ; --ht) - outblank_stream(stream); - } - } - else if (!scumm_stricmp(attrname, "alt") - && !stream->html_in_ignore - && stream->html_allow_alt) - { - /* write out the ALT string */ - outstring_stream(stream, attrval); - } - - /* - * since we already read the next character, - * simply loop back immediately - */ - continue; - } - break; - } - break; - - case HTML_MODE_DQUOTE: - /* if we've reached the closing quote, return to tag state */ - if (c == '"') - stream->html_mode_flag = HTML_MODE_TAG; - break; - - case HTML_MODE_SQUOTE: - /* if we've reached the closing quote, return to tag state */ - if (c == '\'') - stream->html_mode_flag = HTML_MODE_TAG; - break; - } - - /* - * move on to the next character, and start over with the - * new character - */ - c = nextout(&s, &slen); - continue; - } - - /* - * If we're in a title, and this isn't the start of a new tag, - * skip the character - we suppress all regular text output - * inside a ... sequence. - */ - if (stream->html_in_ignore && c != '<') - { - /* check for entities */ - char cbuf[50]; - if (c == '&') - { - /* translate the entity */ - c = out_parse_entity(cbuf, sizeof(cbuf), &s, &slen); - } - else - { - /* it's an ordinary character - copy it out literally */ - cbuf[0] = c; - cbuf[1] = '\0'; - - /* get the next character */ - c = nextout(&s, &slen); - } - - /* - * if we're gathering a title, and there's room in the title - * buffer for more (always leaving room for a null - * terminator), add this to the title buffer - */ - if (stream->html_in_title) - { - char *cbp; - for (cbp = cbuf ; *cbp != '\0' ; ++cbp) - { - /* if there's room, add it */ - if (stream->html_title_ptr + 1 < - stream->html_title_buf - + sizeof(stream->html_title_buf)) - *stream->html_title_ptr++ = *cbp; - } - } - - /* don't display anything in an ignore section */ - continue; - } - - if ( c == '%' ) /* translation string? */ - { - infmt = 1; - f = fmsbuf; - } - else if ( c == '\\' ) /* special escape code? */ - { - c = nextout(&s, &slen); - - if (stream->capturing && c != '^' && c != 'v' && c != '\0') - { - outchar_stream(stream, '\\'); - outchar_stream(stream, c); - - /* keep the \- and also put out the next two chars */ - if (c == '-') - { - outchar_stream(stream, nextout(&s, &slen)); - outchar_stream(stream, nextout(&s, &slen)); - } - } - else - { - switch(c) - { - case 'H': /* HTML mode entry */ - /* turn on HTML mode in the renderer */ - switch(c = nextout(&s, &slen)) - { - case '-': - /* if we have an HTML target, notify it */ - if (stream->html_target) - { - /* flush its stream */ - outflushn_stream(stream, 0); - - /* tell the OS layer to switch to normal mode */ - out_end_html(stream); - } - - /* switch to normal mode */ - stream->html_mode = FALSE; - break; - - case '+': - default: - /* if we have an HTML target, notify it */ - if (stream->html_target) - { - /* flush the underlying stream */ - outflushn_stream(stream, 0); - - /* tell the OS layer to switch to HTML mode */ - out_start_html(stream); - } - - /* switch to HTML mode */ - stream->html_mode = TRUE; - - /* - * if the character wasn't a "+", it's not part - * of the "\H" sequence, so display it normally - */ - if (c != '+' && c != 0) - outchar_stream(stream, c); - break; - } - - /* this sequence doesn't result in any actual output */ - break; - - case 'n': /* newline? */ - outflushn_stream(stream, 1); /* yes, output line */ - break; - - case 't': /* tab? */ - outtab_stream(stream); - break; - - case 'b': /* blank line? */ - outblank_stream(stream); - break; - - case '\0': /* line ends here? */ - done = 1; - break; - - case ' ': /* quoted space */ - if (stream->html_target && stream->html_mode) - { - /* - * we're generating for an HTML target and we're - * in HTML mode - generate the HTML non-breaking - * space - */ - outstring_stream(stream, " "); - } - else - { - /* - * we're not in HTML mode - generate our - * internal quoted space character - */ - outchar_stream(stream, QSPACE); - } - break; - - case '^': /* capitalize next character */ - stream->capsflag = 1; - stream->nocapsflag = 0; - break; - - case 'v': - stream->nocapsflag = 1; - stream->capsflag = 0; - break; - - case '(': - /* generate HTML if in the appropriate mode */ - if (stream->html_mode && stream->html_target) - { - /* send HTML to the renderer */ - outstring_stream(stream, ""); - } - else - { - /* turn on the 'hilite' attribute */ - stream->cur_attr |= OS_ATTR_HILITE; - } - break; - - case ')': - /* generate HTML if in the appropriate mode */ - if (stream->html_mode && stream->html_target) - { - /* send HTML to the renderer */ - outstring_stream(stream, ""); - } - else - { - /* turn off the 'hilite' attribute */ - stream->cur_attr &= ~OS_ATTR_HILITE; - } - break; - - case '-': - outchar_stream(stream, nextout(&s, &slen)); - outchar_stream(stream, nextout(&s, &slen)); - break; - - default: /* just pass invalid escapes as-is */ - outchar_stream(stream, c); - break; - } - } - } - else if (!stream->html_target - && stream->html_mode - && (c == '<' || c == '&')) - { - /* - * We're in HTML mode, but the underlying target does not - * accept HTML sequences. It appears we're at the start of - * an "&" entity or a tag sequence, so parse it, remove it, - * and replace it (if possible) with a text-only equivalent. - */ - if (c == '<') - { - /* read the tag */ - char tagbuf[50]; - int is_end_tag; - c = read_tag(tagbuf, sizeof(tagbuf), &is_end_tag, - &s, &slen, 0); - - /* - * Check to see if we recognize the tag. We only - * recognize a few simple tags that map easily to - * character mode. - */ - if (!scumm_stricmp(tagbuf, "br")) - { - /* - * line break - if there's anything buffered up, - * just flush the current line, otherwise write out - * a blank line - */ - if (stream->html_in_ignore) - /* suppress breaks in ignore mode */; - else if (stream->linepos != 0) - stream->html_defer_br = HTML_DEFER_BR_FLUSH; - else - stream->html_defer_br = HTML_DEFER_BR_BLANK; - } - else if (!scumm_stricmp(tagbuf, "b") - || !scumm_stricmp(tagbuf, "i") - || !scumm_stricmp(tagbuf, "em") - || !scumm_stricmp(tagbuf, "strong")) - { - int attr = 0; - - /* choose the attribute flag */ - switch (tagbuf[0]) - { - case 'b': - case 'B': - attr = OS_ATTR_BOLD; - break; - - case 'i': - case 'I': - attr = OS_ATTR_ITALIC; - break; - - case 'e': - case 'E': - attr = OS_ATTR_EM; - break; - - case 's': - case 'S': - attr = OS_ATTR_STRONG; - break; - } - - /* bold on/off - send out appropriate os-layer code */ - if (stream->html_in_ignore) - { - /* suppress any change in 'ignore' mode */ - } - else if (!is_end_tag) - { - /* turn on the selected attribute */ - stream->cur_attr |= attr; - } - else - { - /* turn off the selected attribute */ - stream->cur_attr &= ~attr; - } - } - else if (!scumm_stricmp(tagbuf, "p")) - { - /* paragraph - send out a blank line */ - if (!stream->html_in_ignore) - outblank_stream(stream); - } - else if (!scumm_stricmp(tagbuf, "tab")) - { - /* tab - send out a \t */ - if (!stream->html_in_ignore) - outtab_stream(stream); - } - else if (!scumm_stricmp(tagbuf, "img") || !scumm_stricmp(tagbuf, "sound")) - { - /* IMG and SOUND - allow ALT attributes */ - stream->html_allow_alt = TRUE; - } - else if (!scumm_stricmp(tagbuf, "hr")) - { - int rem; - - if (!stream->html_in_ignore) - { - /* start a new line */ - outflushn_stream(stream, 1); - - /* write out underscores to the display width */ - for (rem = G_os_linewidth - 1 ; rem > 0 ; ) - { - char dashbuf[100]; - int cur; - - /* do as much as we can on this pass */ - cur = rem; - if ((size_t)cur > sizeof(dashbuf) - 1) - cur = sizeof(dashbuf) - 1; - - /* do a buffer-full of dashes */ - memset(dashbuf, '_', cur); - dashbuf[cur] = '\0'; - outstring_stream(stream, dashbuf); - - /* deduct this from the total */ - rem -= cur; - } - - /* put a blank line after the underscores */ - outblank_stream(stream); - } - } - else if (!scumm_stricmp(tagbuf, "q")) - { - unsigned int htmlchar; - - if (!stream->html_in_ignore) - { - /* if it's an open quote, increment the level */ - if (!is_end_tag) - ++(stream->html_quote_level); - - /* add the open quote */ - htmlchar = - (!is_end_tag - ? ((stream->html_quote_level & 1) == 1 - ? 8220 : 8216) - : ((stream->html_quote_level & 1) == 1 - ? 8221 : 8217)); - - /* - * write out the HTML character, translated to - * the local character set - */ - outchar_html_stream(stream, htmlchar); - - /* if it's a close quote, decrement the level */ - if (is_end_tag) - --(stream->html_quote_level); - } - } - else if (!scumm_stricmp(tagbuf, "title")) - { - /* - * Turn ignore mode on or off as appropriate, and - * turn on or off title mode as well. - */ - if (is_end_tag) - { - /* - * note that we're leaving an ignore section and - * a title section - */ - --(stream->html_in_ignore); - --(stream->html_in_title); - - /* - * if we're no longer in a title, call the OS - * layer to tell it the title string, in case it - * wants to change the window title or otherwise - * make use of the title - */ - if (stream->html_in_title == 0) - { - /* null-terminate the title string */ - *stream->html_title_ptr = '\0'; - - /* tell the OS about the title */ - os_set_title(stream->html_title_buf); - } - } - else - { - /* - * if we aren't already in a title, set up to - * capture the title into the title buffer - */ - if (!stream->html_in_title) - stream->html_title_ptr = stream->html_title_buf; - - /* - * note that we're in a title and in an ignore - * section, since nothing within gets displayed - */ - ++(stream->html_in_ignore); - ++(stream->html_in_title); - } - } - else if (!scumm_stricmp(tagbuf, "aboutbox")) - { - /* turn ignore mode on or off as appropriate */ - if (is_end_tag) - --(stream->html_in_ignore); - else - ++(stream->html_in_ignore); - } - else if (!scumm_stricmp(tagbuf, "pre")) - { - /* count the nesting level if starting PRE mode */ - if (!is_end_tag) - stream->html_pre_level += 1; - - /* surround the PRE block with line breaks */ - outblank_stream(stream); - - /* count the nesting level if ending PRE mode */ - if (is_end_tag && stream->html_pre_level != 0) - stream->html_pre_level -= 1; - } - - /* suppress everything up to the next '>' */ - stream->html_mode_flag = HTML_MODE_TAG; - - /* - * continue with the current character; since we're in - * html tag mode, we'll skip everything until we get to - * the closing '>' - */ - continue; - } - else if (c == '&') - { - /* parse it */ - char xlat_buf[50]; - c = out_parse_entity(xlat_buf, sizeof(xlat_buf), &s, &slen); - - /* write it out (we've already translated it) */ - outstring_noxlat_stream(stream, xlat_buf); - - /* proceed with the next character */ - continue; - } - } - else if (stream->html_target && stream->html_mode && c == '<') - { - /* - * We're in HTML mode, and we have an underlying HTML target. - * We don't need to do much HTML interpretation at this level. - * However, we do need to keep track of when we're in a PRE - * block, so that we can pass whitespaces and newlines through - * to the underlying HTML engine without filtering when we're - * in preformatted text. - */ - char tagbuf[50]; - int is_end_tag; - c = read_tag(tagbuf, sizeof(tagbuf), &is_end_tag, - &s, &slen, stream); - - /* check for special tags */ - if (!scumm_stricmp(tagbuf, "pre")) - { - /* count the nesting level */ - if (!is_end_tag) - stream->html_pre_level += 1; - else if (is_end_tag && stream->html_pre_level != 0) - stream->html_pre_level -= 1; - } - - /* copy the last character after the tag to the stream */ - outchar_stream(stream, c); - } - else - { - /* normal character */ - outchar_stream(stream, c); - } - - /* move on to the next character, unless we're finished */ - if (done) - c = '\0'; - else - c = nextout(&s, &slen); - } - - /* if we ended up inside what looked like a format string, dump string */ - if (infmt) - { - outchar_stream(stream, '%'); - for (f1 = fmsbuf ; f1 < f ; ++f1) - outchar_stream(stream, *f1); - } - - /* exit a recursion level */ - out_pop_stream(); - - /* success */ - return 0; + char c; + int done = 0; + char fmsbuf[40]; /* space for constructing translation string */ + uint fmslen; + char *f = 0; + char *f1; + int infmt = 0; + + /* + * This routine can recurse because of format strings ("%xxx%" + * sequences). When we recurse, we want to ensure that the + * recursion is directed to the original stream only. So, note the + * current stream statically in case we re-enter the formatter. + */ + if (!out_push_stream(stream)) + return 0; + + /* get the first character */ + c = nextout(&s, &slen); + + /* if we have anything to show, show it */ + while (c != '\0') + { + /* check if we're collecting translation string */ + if (infmt) + { + /* + * if the string is too long for our buffer, or we've come + * across a backslash (illegal in a format string), or we've + * come across an HTML-significant character ('&' or '<') in + * HTML mode, we must have a stray percent sign; dump the + * whole string so far and act as though we have no format + * string + */ + if (c == '\\' + || f == &fmsbuf[sizeof(fmsbuf)] + || (stream->html_mode && (c == '<' || c == '&'))) + { + outchar_stream(stream, '%'); + for (f1 = fmsbuf ; f1 < f ; ++f1) + outchar_stream(stream, *f1); + infmt = 0; + + /* process this character again */ + continue; + } + else if (c == '%' && f == fmsbuf) /* double percent sign? */ + { + outchar_stream(stream, '%'); /* send out a single '%' */ + infmt = 0; /* no longer processing translation string */ + } + else if (c == '%') /* found end of string? translate it if so */ + { + uchar *fms; + int initcap = FALSE; + int allcaps = FALSE; + char fmsbuf_srch[sizeof(fmsbuf)]; + + /* null-terminate the string */ + *f = '\0'; + + /* check for an init cap */ + if (outisup(fmsbuf[0])) + { + /* + * note the initial capital, so that we follow the + * original capitalization in the substituted string + */ + initcap = TRUE; + + /* + * if the second letter is capitalized as well, + * capitalize the entire substituted string + */ + if (fmsbuf[1] != '\0' && outisup(fmsbuf[1])) + { + /* use all caps */ + allcaps = TRUE; + } + } + + /* convert the entire string to lower case for searching */ + strcpy(fmsbuf_srch, fmsbuf); + os_strlwr(fmsbuf_srch); + + /* find the string in the format string table */ + fmslen = strlen(fmsbuf_srch); + for (fms = fmsbase ; fms < fmstop ; ) + { + uint propnum; + uint len; + + /* get the information on this entry */ + propnum = osrp2(fms); + len = osrp2(fms + 2) - 2; + + /* check for a match */ + if (len == fmslen && + !memcmp(fms + 4, fmsbuf_srch, (size_t)len)) + { + int old_all_caps; + + /* note the current ALLCAPS mode */ + old_all_caps = stream->allcapsflag; + + /* + * we have a match - set the appropriate + * capitalization mode + */ + if (allcaps) + outallcaps_stream(stream, TRUE); + else if (initcap) + outcaps_stream(stream); + + /* + * evaluate the associated property to generate + * the substitution text + */ + runppr(runctx, cmdActor, (prpnum)propnum, 0); + + /* turn off ALLCAPS mode */ + outallcaps_stream(stream, old_all_caps); + + /* no need to look any further */ + break; + } + + /* move on to next formatstring if not yet found */ + fms += len + 4; + } + + /* if we can't find it, dump the format string as-is */ + if (fms == fmstop) + { + outchar_stream(stream, '%'); + for (f1 = fmsbuf ; f1 < f ; ++f1) + outchar_stream(stream, *f1); + outchar_stream(stream, '%'); + } + + /* no longer reading format string */ + infmt = 0; + } + else + { + /* copy this character of the format string */ + *f++ = c; + } + + /* move on to the next character and continue scanning */ + c = nextout(&s, &slen); + continue; + } + + /* + * If we're parsing HTML here, and we're inside a tag, skip + * characters until we reach the end of the tag. + */ + if (stream->html_mode_flag != HTML_MODE_NORMAL) + { + switch(stream->html_mode_flag) + { + case HTML_MODE_TAG: + /* + * keep skipping up to the closing '>', but note when we + * enter any quoted section + */ + switch(c) + { + case '>': + /* we've reached the end of the tag */ + stream->html_mode_flag = HTML_MODE_NORMAL; + + /* if we have a deferred
, process it now */ + switch(stream->html_defer_br) + { + case HTML_DEFER_BR_NONE: + /* no deferred
*/ + break; + + case HTML_DEFER_BR_FLUSH: + outflushn_stream(stream, 1); + break; + + case HTML_DEFER_BR_BLANK: + outblank_stream(stream); + break; + } + + /* no more deferred
pending */ + stream->html_defer_br = HTML_DEFER_BR_NONE; + + /* no more ALT attribute allowed */ + stream->html_allow_alt = FALSE; + break; + + case '"': + /* enter a double-quoted string */ + stream->html_mode_flag = HTML_MODE_DQUOTE; + break; + + case '\'': + /* enter a single-quoted string */ + stream->html_mode_flag = HTML_MODE_SQUOTE; + break; + + default: + /* if it's alphabetic, note the attribute name */ + if (outisal(c)) + { + char attrname[128]; + char attrval[256]; + char *dst; + + /* gather up the attribute name */ + for (dst = attrname ; + dst + 1 < attrname + sizeof(attrname) ; ) + { + /* store this character */ + *dst++ = c; + + /* get the next character */ + c = nextout(&s, &slen); + + /* if it's not alphanumeric, stop scanning */ + if (!outisal(c) && !outisdg(c)) + break; + } + + /* null-terminate the result */ + *dst++ = '\0'; + + /* gather the value if present */ + if (c == '=') + { + char qu; + + /* skip the '=' */ + c = nextout(&s, &slen); + + /* if we have a quote, so note */ + if (c == '"' || c == '\'') + { + /* remember the quote */ + qu = c; + + /* skip it */ + c = nextout(&s, &slen); + } + else + { + /* no quote */ + qu = 0; + } + + /* read the value */ + for (dst = attrval ; + dst + 1 < attrval + sizeof(attrval) ; ) + { + /* store this character */ + *dst++ = c; + + /* read the next one */ + c = nextout(&s, &slen); + if (c == '\0') + { + /* + * we've reached the end of the + * string, and we're still inside + * this attribute - abandon the + * attribute but note that we're + * inside a quoted string if + * necessary + */ + if (qu == '"') + stream->html_mode_flag = + HTML_MODE_DQUOTE; + else if (qu == '\'') + stream->html_mode_flag = + HTML_MODE_SQUOTE; + else + stream->html_mode_flag + = HTML_MODE_TAG; + + /* stop scanning the string */ + break; + } + + /* + * if we're looking for a quote, check + * for the closing quote; otherwise, + * check for alphanumerics + */ + if (qu != 0) + { + /* if this is our quote, stop scanning */ + if (c == qu) + break; + } + else + { + /* if it's non-alphanumeric, we're done */ + if (!outisal(c) && !outisdg(c)) + break; + } + } + + /* skip the closing quote, if necessary */ + if (qu != 0 && c == qu) + c = nextout(&s, &slen); + + /* null-terminate the value string */ + *dst = '\0'; + } + else + { + /* no value */ + attrval[0] = '\0'; + } + + /* + * see if we recognize it, and it's meaningful + * in the context of the current tag + */ + if (!scumm_stricmp(attrname, "height") + && stream->html_defer_br != HTML_DEFER_BR_NONE) + { + int ht; + + /* + * If the height is zero, always treat this + * as a non-blanking flush. If it's one, + * treat it as we originally planned to. If + * it's greater than one, add n blank lines. + */ + ht = atoi(attrval); + if (ht == 0) + { + /* always use non-blanking flush */ + stream->html_defer_br = HTML_DEFER_BR_FLUSH; + } + else if (ht == 1) + { + /* keep original setting */ + } + else + { + for ( ; ht > 0 ; --ht) + outblank_stream(stream); + } + } + else if (!scumm_stricmp(attrname, "alt") + && !stream->html_in_ignore + && stream->html_allow_alt) + { + /* write out the ALT string */ + outstring_stream(stream, attrval); + } + + /* + * since we already read the next character, + * simply loop back immediately + */ + continue; + } + break; + } + break; + + case HTML_MODE_DQUOTE: + /* if we've reached the closing quote, return to tag state */ + if (c == '"') + stream->html_mode_flag = HTML_MODE_TAG; + break; + + case HTML_MODE_SQUOTE: + /* if we've reached the closing quote, return to tag state */ + if (c == '\'') + stream->html_mode_flag = HTML_MODE_TAG; + break; + } + + /* + * move on to the next character, and start over with the + * new character + */ + c = nextout(&s, &slen); + continue; + } + + /* + * If we're in a title, and this isn't the start of a new tag, + * skip the character - we suppress all regular text output + * inside a ... sequence. + */ + if (stream->html_in_ignore && c != '<') + { + /* check for entities */ + char cbuf[50]; + if (c == '&') + { + /* translate the entity */ + c = out_parse_entity(cbuf, sizeof(cbuf), &s, &slen); + } + else + { + /* it's an ordinary character - copy it out literally */ + cbuf[0] = c; + cbuf[1] = '\0'; + + /* get the next character */ + c = nextout(&s, &slen); + } + + /* + * if we're gathering a title, and there's room in the title + * buffer for more (always leaving room for a null + * terminator), add this to the title buffer + */ + if (stream->html_in_title) + { + char *cbp; + for (cbp = cbuf ; *cbp != '\0' ; ++cbp) + { + /* if there's room, add it */ + if (stream->html_title_ptr + 1 < + stream->html_title_buf + + sizeof(stream->html_title_buf)) + *stream->html_title_ptr++ = *cbp; + } + } + + /* don't display anything in an ignore section */ + continue; + } + + if ( c == '%' ) /* translation string? */ + { + infmt = 1; + f = fmsbuf; + } + else if ( c == '\\' ) /* special escape code? */ + { + c = nextout(&s, &slen); + + if (stream->capturing && c != '^' && c != 'v' && c != '\0') + { + outchar_stream(stream, '\\'); + outchar_stream(stream, c); + + /* keep the \- and also put out the next two chars */ + if (c == '-') + { + outchar_stream(stream, nextout(&s, &slen)); + outchar_stream(stream, nextout(&s, &slen)); + } + } + else + { + switch(c) + { + case 'H': /* HTML mode entry */ + /* turn on HTML mode in the renderer */ + switch(c = nextout(&s, &slen)) + { + case '-': + /* if we have an HTML target, notify it */ + if (stream->html_target) + { + /* flush its stream */ + outflushn_stream(stream, 0); + + /* tell the OS layer to switch to normal mode */ + out_end_html(stream); + } + + /* switch to normal mode */ + stream->html_mode = FALSE; + break; + + case '+': + default: + /* if we have an HTML target, notify it */ + if (stream->html_target) + { + /* flush the underlying stream */ + outflushn_stream(stream, 0); + + /* tell the OS layer to switch to HTML mode */ + out_start_html(stream); + } + + /* switch to HTML mode */ + stream->html_mode = TRUE; + + /* + * if the character wasn't a "+", it's not part + * of the "\H" sequence, so display it normally + */ + if (c != '+' && c != 0) + outchar_stream(stream, c); + break; + } + + /* this sequence doesn't result in any actual output */ + break; + + case 'n': /* newline? */ + outflushn_stream(stream, 1); /* yes, output line */ + break; + + case 't': /* tab? */ + outtab_stream(stream); + break; + + case 'b': /* blank line? */ + outblank_stream(stream); + break; + + case '\0': /* line ends here? */ + done = 1; + break; + + case ' ': /* quoted space */ + if (stream->html_target && stream->html_mode) + { + /* + * we're generating for an HTML target and we're + * in HTML mode - generate the HTML non-breaking + * space + */ + outstring_stream(stream, " "); + } + else + { + /* + * we're not in HTML mode - generate our + * internal quoted space character + */ + outchar_stream(stream, QSPACE); + } + break; + + case '^': /* capitalize next character */ + stream->capsflag = 1; + stream->nocapsflag = 0; + break; + + case 'v': + stream->nocapsflag = 1; + stream->capsflag = 0; + break; + + case '(': + /* generate HTML if in the appropriate mode */ + if (stream->html_mode && stream->html_target) + { + /* send HTML to the renderer */ + outstring_stream(stream, ""); + } + else + { + /* turn on the 'hilite' attribute */ + stream->cur_attr |= OS_ATTR_HILITE; + } + break; + + case ')': + /* generate HTML if in the appropriate mode */ + if (stream->html_mode && stream->html_target) + { + /* send HTML to the renderer */ + outstring_stream(stream, ""); + } + else + { + /* turn off the 'hilite' attribute */ + stream->cur_attr &= ~OS_ATTR_HILITE; + } + break; + + case '-': + outchar_stream(stream, nextout(&s, &slen)); + outchar_stream(stream, nextout(&s, &slen)); + break; + + default: /* just pass invalid escapes as-is */ + outchar_stream(stream, c); + break; + } + } + } + else if (!stream->html_target + && stream->html_mode + && (c == '<' || c == '&')) + { + /* + * We're in HTML mode, but the underlying target does not + * accept HTML sequences. It appears we're at the start of + * an "&" entity or a tag sequence, so parse it, remove it, + * and replace it (if possible) with a text-only equivalent. + */ + if (c == '<') + { + /* read the tag */ + char tagbuf[50]; + int is_end_tag; + c = read_tag(tagbuf, sizeof(tagbuf), &is_end_tag, + &s, &slen, 0); + + /* + * Check to see if we recognize the tag. We only + * recognize a few simple tags that map easily to + * character mode. + */ + if (!scumm_stricmp(tagbuf, "br")) + { + /* + * line break - if there's anything buffered up, + * just flush the current line, otherwise write out + * a blank line + */ + if (stream->html_in_ignore) + /* suppress breaks in ignore mode */; + else if (stream->linepos != 0) + stream->html_defer_br = HTML_DEFER_BR_FLUSH; + else + stream->html_defer_br = HTML_DEFER_BR_BLANK; + } + else if (!scumm_stricmp(tagbuf, "b") + || !scumm_stricmp(tagbuf, "i") + || !scumm_stricmp(tagbuf, "em") + || !scumm_stricmp(tagbuf, "strong")) + { + int attr = 0; + + /* choose the attribute flag */ + switch (tagbuf[0]) + { + case 'b': + case 'B': + attr = OS_ATTR_BOLD; + break; + + case 'i': + case 'I': + attr = OS_ATTR_ITALIC; + break; + + case 'e': + case 'E': + attr = OS_ATTR_EM; + break; + + case 's': + case 'S': + attr = OS_ATTR_STRONG; + break; + } + + /* bold on/off - send out appropriate os-layer code */ + if (stream->html_in_ignore) + { + /* suppress any change in 'ignore' mode */ + } + else if (!is_end_tag) + { + /* turn on the selected attribute */ + stream->cur_attr |= attr; + } + else + { + /* turn off the selected attribute */ + stream->cur_attr &= ~attr; + } + } + else if (!scumm_stricmp(tagbuf, "p")) + { + /* paragraph - send out a blank line */ + if (!stream->html_in_ignore) + outblank_stream(stream); + } + else if (!scumm_stricmp(tagbuf, "tab")) + { + /* tab - send out a \t */ + if (!stream->html_in_ignore) + outtab_stream(stream); + } + else if (!scumm_stricmp(tagbuf, "img") || !scumm_stricmp(tagbuf, "sound")) + { + /* IMG and SOUND - allow ALT attributes */ + stream->html_allow_alt = TRUE; + } + else if (!scumm_stricmp(tagbuf, "hr")) + { + int rem; + + if (!stream->html_in_ignore) + { + /* start a new line */ + outflushn_stream(stream, 1); + + /* write out underscores to the display width */ + for (rem = G_os_linewidth - 1 ; rem > 0 ; ) + { + char dashbuf[100]; + int cur; + + /* do as much as we can on this pass */ + cur = rem; + if ((size_t)cur > sizeof(dashbuf) - 1) + cur = sizeof(dashbuf) - 1; + + /* do a buffer-full of dashes */ + memset(dashbuf, '_', cur); + dashbuf[cur] = '\0'; + outstring_stream(stream, dashbuf); + + /* deduct this from the total */ + rem -= cur; + } + + /* put a blank line after the underscores */ + outblank_stream(stream); + } + } + else if (!scumm_stricmp(tagbuf, "q")) + { + unsigned int htmlchar; + + if (!stream->html_in_ignore) + { + /* if it's an open quote, increment the level */ + if (!is_end_tag) + ++(stream->html_quote_level); + + /* add the open quote */ + htmlchar = + (!is_end_tag + ? ((stream->html_quote_level & 1) == 1 + ? 8220 : 8216) + : ((stream->html_quote_level & 1) == 1 + ? 8221 : 8217)); + + /* + * write out the HTML character, translated to + * the local character set + */ + outchar_html_stream(stream, htmlchar); + + /* if it's a close quote, decrement the level */ + if (is_end_tag) + --(stream->html_quote_level); + } + } + else if (!scumm_stricmp(tagbuf, "title")) + { + /* + * Turn ignore mode on or off as appropriate, and + * turn on or off title mode as well. + */ + if (is_end_tag) + { + /* + * note that we're leaving an ignore section and + * a title section + */ + --(stream->html_in_ignore); + --(stream->html_in_title); + + /* + * if we're no longer in a title, call the OS + * layer to tell it the title string, in case it + * wants to change the window title or otherwise + * make use of the title + */ + if (stream->html_in_title == 0) + { + /* null-terminate the title string */ + *stream->html_title_ptr = '\0'; + + /* tell the OS about the title */ + os_set_title(stream->html_title_buf); + } + } + else + { + /* + * if we aren't already in a title, set up to + * capture the title into the title buffer + */ + if (!stream->html_in_title) + stream->html_title_ptr = stream->html_title_buf; + + /* + * note that we're in a title and in an ignore + * section, since nothing within gets displayed + */ + ++(stream->html_in_ignore); + ++(stream->html_in_title); + } + } + else if (!scumm_stricmp(tagbuf, "aboutbox")) + { + /* turn ignore mode on or off as appropriate */ + if (is_end_tag) + --(stream->html_in_ignore); + else + ++(stream->html_in_ignore); + } + else if (!scumm_stricmp(tagbuf, "pre")) + { + /* count the nesting level if starting PRE mode */ + if (!is_end_tag) + stream->html_pre_level += 1; + + /* surround the PRE block with line breaks */ + outblank_stream(stream); + + /* count the nesting level if ending PRE mode */ + if (is_end_tag && stream->html_pre_level != 0) + stream->html_pre_level -= 1; + } + + /* suppress everything up to the next '>' */ + stream->html_mode_flag = HTML_MODE_TAG; + + /* + * continue with the current character; since we're in + * html tag mode, we'll skip everything until we get to + * the closing '>' + */ + continue; + } + else if (c == '&') + { + /* parse it */ + char xlat_buf[50]; + c = out_parse_entity(xlat_buf, sizeof(xlat_buf), &s, &slen); + + /* write it out (we've already translated it) */ + outstring_noxlat_stream(stream, xlat_buf); + + /* proceed with the next character */ + continue; + } + } + else if (stream->html_target && stream->html_mode && c == '<') + { + /* + * We're in HTML mode, and we have an underlying HTML target. + * We don't need to do much HTML interpretation at this level. + * However, we do need to keep track of when we're in a PRE + * block, so that we can pass whitespaces and newlines through + * to the underlying HTML engine without filtering when we're + * in preformatted text. + */ + char tagbuf[50]; + int is_end_tag; + c = read_tag(tagbuf, sizeof(tagbuf), &is_end_tag, + &s, &slen, stream); + + /* check for special tags */ + if (!scumm_stricmp(tagbuf, "pre")) + { + /* count the nesting level */ + if (!is_end_tag) + stream->html_pre_level += 1; + else if (is_end_tag && stream->html_pre_level != 0) + stream->html_pre_level -= 1; + } + + /* copy the last character after the tag to the stream */ + outchar_stream(stream, c); + } + else + { + /* normal character */ + outchar_stream(stream, c); + } + + /* move on to the next character, unless we're finished */ + if (done) + c = '\0'; + else + c = nextout(&s, &slen); + } + + /* if we ended up inside what looked like a format string, dump string */ + if (infmt) + { + outchar_stream(stream, '%'); + for (f1 = fmsbuf ; f1 < f ; ++f1) + outchar_stream(stream, *f1); + } + + /* exit a recursion level */ + out_pop_stream(); + + /* success */ + return 0; } /* ------------------------------------------------------------------------ */ @@ -2722,194 +2722,194 @@ static int outformatlen_stream(out_stream_info *stream, * Parse an HTML entity markup */ static char out_parse_entity(char *outbuf, size_t outbuf_size, const char **sp, size_t *slenp) { - char ampbuf[10]; - char *dst; - const char *orig_s; - size_t orig_slen; - const amp_tbl_t *ampptr; - size_t lo, hi, cur; - char c; + char ampbuf[10]; + char *dst; + const char *orig_s; + size_t orig_slen; + const amp_tbl_t *ampptr; + size_t lo, hi, cur; + char c; - /* - * remember where the part after the '&' begins, so we can come back - * here later if necessary - */ - orig_s = *sp; - orig_slen = *slenp; + /* + * remember where the part after the '&' begins, so we can come back + * here later if necessary + */ + orig_s = *sp; + orig_slen = *slenp; - /* get the character after the ampersand */ - c = nextout(sp, slenp); + /* get the character after the ampersand */ + c = nextout(sp, slenp); - /* if it's numeric, parse the number */ - if (c == '#') - { - uint val; - - /* skip the '#' */ - c = nextout(sp, slenp); + /* if it's numeric, parse the number */ + if (c == '#') + { + uint val; + + /* skip the '#' */ + c = nextout(sp, slenp); - /* check for hex */ - if (c == 'x' || c == 'X') - { - /* skip the 'x' */ - c = nextout(sp, slenp); + /* check for hex */ + if (c == 'x' || c == 'X') + { + /* skip the 'x' */ + c = nextout(sp, slenp); - /* read the hex number */ - for (val = 0 ; Common::isXDigit((uchar)c) ; c = nextout(sp, slenp)) - { - /* accumulate the current digit into the value */ - val *= 16; - if (outisdg(c)) - val += c - '0'; - else if (c >= 'a' && c <= 'f') - val += c - 'a' + 10; - else - val += c - 'A' + 10; - } - } - else - { - /* read the number */ - for (val = 0 ; outisdg(c) ; c = nextout(sp, slenp)) - { - /* accumulate the current digit into the value */ - val *= 10; - val += c - '0'; - } - } - - /* if we found a ';' at the end, skip it */ - if (c == ';') - c = nextout(sp, slenp); - - /* translate the character into the output buffer */ - os_xlat_html4(val, outbuf, outbuf_size); - - /* we're done with this character */ - return c; - } + /* read the hex number */ + for (val = 0 ; Common::isXDigit((uchar)c) ; c = nextout(sp, slenp)) + { + /* accumulate the current digit into the value */ + val *= 16; + if (outisdg(c)) + val += c - '0'; + else if (c >= 'a' && c <= 'f') + val += c - 'a' + 10; + else + val += c - 'A' + 10; + } + } + else + { + /* read the number */ + for (val = 0 ; outisdg(c) ; c = nextout(sp, slenp)) + { + /* accumulate the current digit into the value */ + val *= 10; + val += c - '0'; + } + } + + /* if we found a ';' at the end, skip it */ + if (c == ';') + c = nextout(sp, slenp); + + /* translate the character into the output buffer */ + os_xlat_html4(val, outbuf, outbuf_size); + + /* we're done with this character */ + return c; + } - /* - * Parse the sequence after the '&'. Parse up to the closing - * semicolon, or any non-alphanumeric, or until we fill up the buffer. - */ - for (dst = ampbuf ; - c != '\0' && (outisdg(c) || outisal(c)) - && dst < ampbuf + sizeof(ampbuf) - 1 ; - *dst++ = c, c = nextout(sp, slenp)) ; - - /* null-terminate the name */ - *dst = '\0'; - - /* do a binary search for the name */ - lo = 0; - hi = sizeof(amp_tbl)/sizeof(amp_tbl[0]) - 1; - for (;;) - { - int diff; - - /* if we've converged, look no further */ - if (lo > hi || lo >= sizeof(amp_tbl)/sizeof(amp_tbl[0])) - { - ampptr = 0; - break; - } - - /* split the difference */ - cur = lo + (hi - lo)/2; - ampptr = &_tbl[cur]; - - /* see where we are relative to the target item */ - diff = strcmp(ampptr->cname, ampbuf); - if (diff == 0) - { - /* this is it */ - break; - } - else if (diff > 0) - { - /* make sure we don't go off the end */ - if (cur == hi && cur == 0) - { - /* we've failed to find it */ - ampptr = 0; - break; - } - - /* this one is too high - check the lower half */ - hi = (cur == hi ? hi - 1 : cur); - } - else - { - /* this one is too low - check the upper half */ - lo = (cur == lo ? lo + 1 : cur); - } - } - - /* skip to the appropriate next character */ - if (c == ';') - { - /* name ended with semicolon - skip the semicolon */ - c = nextout(sp, slenp); - } - else if (ampptr != 0) - { - int skipcnt; - - /* found the name - skip its exact length */ - skipcnt = strlen(ampptr->cname); - for (*sp = orig_s, *slenp = orig_slen ; skipcnt != 0 ; - c = nextout(sp, slenp), --skipcnt) ; - } - - /* if we found the entry, write out the character */ - if (ampptr != 0) - { - /* - * if this one has an external mapping table entry, use the mapping - * table entry; otherwise, use the default OS routine mapping - */ - if (ampptr->expan != 0) - { - /* - * we have an explicit expansion from the mapping table file - - * use it - */ - size_t copylen = strlen(ampptr->expan); - if (copylen > outbuf_size - 1) - copylen = outbuf_size - 1; + /* + * Parse the sequence after the '&'. Parse up to the closing + * semicolon, or any non-alphanumeric, or until we fill up the buffer. + */ + for (dst = ampbuf ; + c != '\0' && (outisdg(c) || outisal(c)) + && dst < ampbuf + sizeof(ampbuf) - 1 ; + *dst++ = c, c = nextout(sp, slenp)) ; + + /* null-terminate the name */ + *dst = '\0'; + + /* do a binary search for the name */ + lo = 0; + hi = sizeof(amp_tbl)/sizeof(amp_tbl[0]) - 1; + for (;;) + { + int diff; + + /* if we've converged, look no further */ + if (lo > hi || lo >= sizeof(amp_tbl)/sizeof(amp_tbl[0])) + { + ampptr = 0; + break; + } + + /* split the difference */ + cur = lo + (hi - lo)/2; + ampptr = &_tbl[cur]; + + /* see where we are relative to the target item */ + diff = strcmp(ampptr->cname, ampbuf); + if (diff == 0) + { + /* this is it */ + break; + } + else if (diff > 0) + { + /* make sure we don't go off the end */ + if (cur == hi && cur == 0) + { + /* we've failed to find it */ + ampptr = 0; + break; + } + + /* this one is too high - check the lower half */ + hi = (cur == hi ? hi - 1 : cur); + } + else + { + /* this one is too low - check the upper half */ + lo = (cur == lo ? lo + 1 : cur); + } + } + + /* skip to the appropriate next character */ + if (c == ';') + { + /* name ended with semicolon - skip the semicolon */ + c = nextout(sp, slenp); + } + else if (ampptr != 0) + { + int skipcnt; + + /* found the name - skip its exact length */ + skipcnt = strlen(ampptr->cname); + for (*sp = orig_s, *slenp = orig_slen ; skipcnt != 0 ; + c = nextout(sp, slenp), --skipcnt) ; + } + + /* if we found the entry, write out the character */ + if (ampptr != 0) + { + /* + * if this one has an external mapping table entry, use the mapping + * table entry; otherwise, use the default OS routine mapping + */ + if (ampptr->expan != 0) + { + /* + * we have an explicit expansion from the mapping table file - + * use it + */ + size_t copylen = strlen(ampptr->expan); + if (copylen > outbuf_size - 1) + copylen = outbuf_size - 1; - memcpy(outbuf, ampptr->expan, copylen); - outbuf[copylen] = '\0'; - } - else - { - /* - * there's no mapping table expansion - use the default OS code - * expansion - */ - os_xlat_html4(ampptr->html_cval, outbuf, outbuf_size); - } - } - else - { - /* - * didn't find it - output the '&' literally, then back up and - * output the entire sequence following - */ - *sp = orig_s; - *slenp = orig_slen; - c = nextout(sp, slenp); + memcpy(outbuf, ampptr->expan, copylen); + outbuf[copylen] = '\0'; + } + else + { + /* + * there's no mapping table expansion - use the default OS code + * expansion + */ + os_xlat_html4(ampptr->html_cval, outbuf, outbuf_size); + } + } + else + { + /* + * didn't find it - output the '&' literally, then back up and + * output the entire sequence following + */ + *sp = orig_s; + *slenp = orig_slen; + c = nextout(sp, slenp); - /* fill in the '&' return value */ - outbuf[0] = '&'; - outbuf[1] = '\0'; - } + /* fill in the '&' return value */ + outbuf[0] = '&'; + outbuf[1] = '\0'; + } - /* return the next character */ - return c; + /* return the next character */ + return c; } - + /* ------------------------------------------------------------------------ */ @@ -2918,16 +2918,16 @@ static char out_parse_entity(char *outbuf, size_t outbuf_size, const char **sp, */ void out_init() { - /* not yet hiding output */ - outflag = 1; - outcnt = 0; - hidout = 0; + /* not yet hiding output */ + outflag = 1; + outcnt = 0; + hidout = 0; - /* initialize the standard display stream */ - out_init_std(&G_std_disp); + /* initialize the standard display stream */ + out_init_std(&G_std_disp); - /* initialize the log file stream */ - out_init_log(&G_log_disp); + /* initialize the log file stream */ + out_init_log(&G_log_disp); } @@ -2937,10 +2937,10 @@ void out_init() */ void tiosetfmt(tiocxdef *ctx, runcxdef *rctx, uchar *fbase, uint flen) { - VARUSED(ctx); - fmsbase = fbase; - fmstop = fbase + flen; - runctx = rctx; + VARUSED(ctx); + fmsbase = fbase; + fmstop = fbase + flen; + runctx = rctx; } @@ -2956,28 +2956,28 @@ void tiosetfmt(tiocxdef *ctx, runcxdef *rctx, uchar *fbase, uint flen) * single active native character set. */ void tio_set_html_expansion(unsigned int html_char_val, - const char *expansion, size_t expansion_len) + const char *expansion, size_t expansion_len) { - amp_tbl_t *p; + amp_tbl_t *p; - /* find the character value */ - for (p = amp_tbl ; - p < amp_tbl + sizeof(amp_tbl)/sizeof(amp_tbl[0]) ; ++p) - { - /* if this is the one, store it */ - if (p->html_cval == html_char_val) - { - /* allocate space for it */ - p->expan = (char *)osmalloc(expansion_len + 1); + /* find the character value */ + for (p = amp_tbl ; + p < amp_tbl + sizeof(amp_tbl)/sizeof(amp_tbl[0]) ; ++p) + { + /* if this is the one, store it */ + if (p->html_cval == html_char_val) + { + /* allocate space for it */ + p->expan = (char *)osmalloc(expansion_len + 1); - /* save it */ - memcpy(p->expan, expansion, expansion_len); - p->expan[expansion_len] = '\0'; + /* save it */ + memcpy(p->expan, expansion, expansion_len); + p->expan[expansion_len] = '\0'; - /* no need to look any further */ - return; - } - } + /* no need to look any further */ + return; + } + } } @@ -2986,7 +2986,7 @@ void tio_set_html_expansion(unsigned int html_char_val, * Write out a c-style (null-terminated) string. */ int outformat(const char *s) { - return outformatlen(s, strlen(s)); + return outformatlen(s, strlen(s)); } @@ -2996,95 +2996,95 @@ int outformat(const char *s) { * Escape codes ('\n', and so forth) are handled here. */ int outformatlen(const char *s, uint slen) { - char c; - uint orig_slen; - const char *orig_s; - int ret; - int called_filter; + char c; + uint orig_slen; + const char *orig_s; + int ret; + int called_filter; - /* presume we'll return success */ - ret = 0; + /* presume we'll return success */ + ret = 0; - /* presume we won't call the filter function */ - called_filter = FALSE; + /* presume we won't call the filter function */ + called_filter = FALSE; - /* if there's a user filter function to invoke, call it */ - if (G_user_filter != MCMONINV) - { - /* push the string */ - runpstr(runctx, s, slen, 1); + /* if there's a user filter function to invoke, call it */ + if (G_user_filter != MCMONINV) + { + /* push the string */ + runpstr(runctx, s, slen, 1); - /* call the filter */ - runfn(runctx, G_user_filter, 1); + /* call the filter */ + runfn(runctx, G_user_filter, 1); - /* - * note that we called the filter, so that we'll remove the - * result of the filter from the stack before we return - */ - called_filter = TRUE; + /* + * note that we called the filter, so that we'll remove the + * result of the filter from the stack before we return + */ + called_filter = TRUE; - /* if the result is a string, use it in place of the original text */ - if (runtostyp(runctx) == DAT_SSTRING) - { - runsdef val; - uchar *p; + /* if the result is a string, use it in place of the original text */ + if (runtostyp(runctx) == DAT_SSTRING) + { + runsdef val; + uchar *p; - /* pop the value */ - runpop(runctx, &val); + /* pop the value */ + runpop(runctx, &val); - /* - * get the text from the string, and use it as a replacement - * for the original string - */ - p = val.runsv.runsvstr; - slen = osrp2(p) - 2; - s = (char *)(p + 2); + /* + * get the text from the string, and use it as a replacement + * for the original string + */ + p = val.runsv.runsvstr; + slen = osrp2(p) - 2; + s = (char *)(p + 2); - /* - * push the string back onto the stack - this will ensure - * that the string stays referenced while we're working, so - * that the garbage collector won't delete it - */ - runrepush(runctx, &val); - } - } + /* + * push the string back onto the stack - this will ensure + * that the string stays referenced while we're working, so + * that the garbage collector won't delete it + */ + runrepush(runctx, &val); + } + } - /* remember the original string, before we scan the first character */ - orig_s = s; - orig_slen = slen; + /* remember the original string, before we scan the first character */ + orig_s = s; + orig_slen = slen; - /* get the first character to display */ - c = nextout(&s, &slen); + /* get the first character to display */ + c = nextout(&s, &slen); - /* if the string is non-empty, note that we've displayed something */ - if (c != 0) - outcnt = 1; + /* if the string is non-empty, note that we've displayed something */ + if (c != 0) + outcnt = 1; - /* check to see if we're hiding output */ - if (out_is_hidden()) - goto done; + /* check to see if we're hiding output */ + if (out_is_hidden()) + goto done; - /* if the debugger is showing watchpoints, suppress all output */ - if (outwxflag) - goto done; + /* if the debugger is showing watchpoints, suppress all output */ + if (outwxflag) + goto done; - /* display the string */ - ret = outformatlen_stream(&G_std_disp, orig_s, orig_slen); + /* display the string */ + ret = outformatlen_stream(&G_std_disp, orig_s, orig_slen); - /* if there's a log file, write to the log file as well */ - if (logfp != 0) - { - outformatlen_stream(&G_log_disp, orig_s, orig_slen); - osfflush(logfp); - } + /* if there's a log file, write to the log file as well */ + if (logfp != 0) + { + outformatlen_stream(&G_log_disp, orig_s, orig_slen); + osfflush(logfp); + } done: - /* if we called the filter, remove the result from the stack */ - if (called_filter) - rundisc(runctx); + /* if we called the filter, remove the result from the stack */ + if (called_filter) + rundisc(runctx); - /* return the result from displaying to the screen */ - return ret; + /* return the result from displaying to the screen */ + return ret; } /* ------------------------------------------------------------------------ */ @@ -3093,22 +3093,22 @@ done: */ void outblank() { - /* note that we've displayed something */ - outcnt = 1; + /* note that we've displayed something */ + outcnt = 1; - /* check to see if we're hiding output */ - if (out_is_hidden()) - return; + /* check to see if we're hiding output */ + if (out_is_hidden()) + return; - /* generate the newline to the standard display */ - outblank_stream(&G_std_disp); + /* generate the newline to the standard display */ + outblank_stream(&G_std_disp); - /* if we're logging, generate the newline to the log file as well */ - if (logfp != 0) - { - outblank_stream(&G_log_disp); - osfflush(logfp); - } + /* if we're logging, generate the newline to the log file as well */ + if (logfp != 0) + { + outblank_stream(&G_log_disp); + osfflush(logfp); + } } @@ -3120,8 +3120,8 @@ void outblank() */ void outcaps(void) { - outcaps_stream(&G_std_disp); - outcaps_stream(&G_log_disp); + outcaps_stream(&G_std_disp); + outcaps_stream(&G_log_disp); } /* @@ -3130,8 +3130,8 @@ void outcaps(void) */ void outnocaps(void) { - outnocaps_stream(&G_std_disp); - outnocaps_stream(&G_log_disp); + outnocaps_stream(&G_std_disp); + outnocaps_stream(&G_log_disp); } /* ------------------------------------------------------------------------ */ @@ -3140,32 +3140,32 @@ void outnocaps(void) */ int tiologopn(tiocxdef *ctx, char *fn) { - /* if there's an old log file, close it */ - if (tiologcls(ctx)) - return 1; + /* if there's an old log file, close it */ + if (tiologcls(ctx)) + return 1; - /* save the filename for later */ - strcpy(logfname, fn); + /* save the filename for later */ + strcpy(logfname, fn); - /* open the new file */ - logfp = osfopwt(fn, OSFTLOG); + /* open the new file */ + logfp = osfopwt(fn, OSFTLOG); - /* - * Reset the log file's output formatter state, since we're opening - * a new file. - */ - out_init_log(&G_log_disp); + /* + * Reset the log file's output formatter state, since we're opening + * a new file. + */ + out_init_log(&G_log_disp); - /* - * Set the log file's HTML source mode flag to the same value as is - * currently being used in the main display stream, so that it will - * interpret source markups the same way that the display stream is - * going to. - */ - G_log_disp.html_mode = G_std_disp.html_mode; + /* + * Set the log file's HTML source mode flag to the same value as is + * currently being used in the main display stream, so that it will + * interpret source markups the same way that the display stream is + * going to. + */ + G_log_disp.html_mode = G_std_disp.html_mode; - /* return 0 on success, non-zero on failure */ - return (logfp == 0); + /* return 0 on success, non-zero on failure */ + return (logfp == 0); } /* @@ -3173,21 +3173,21 @@ int tiologopn(tiocxdef *ctx, char *fn) */ int tiologcls(tiocxdef *ctx) { - /* if we have a file, close it */ - if (logfp != 0) - { - /* close the handle */ - osfcls(logfp); + /* if we have a file, close it */ + if (logfp != 0) + { + /* close the handle */ + osfcls(logfp); - /* set the system file type to "log file" */ - os_settype(logfname, OSFTLOG); + /* set the system file type to "log file" */ + os_settype(logfname, OSFTLOG); - /* forget about our log file handle */ - logfp = 0; - } + /* forget about our log file handle */ + logfp = 0; + } - /* success */ - return 0; + /* success */ + return 0; } /* ------------------------------------------------------------------------ */ @@ -3205,26 +3205,26 @@ int tiologcls(tiocxdef *ctx) */ void out_logfile_print(const char *txt, int nl) { - /* if there's no log file, there's nothing to do */ - if (logfp == 0) - return; + /* if there's no log file, there's nothing to do */ + if (logfp == 0) + return; - /* add the text */ - os_fprintz(logfp, txt); + /* add the text */ + os_fprintz(logfp, txt); - /* add a newline if desired */ - if (nl) - { - /* add a normal newline */ - os_fprintz(logfp, "\n"); + /* add a newline if desired */ + if (nl) + { + /* add a normal newline */ + os_fprintz(logfp, "\n"); - /* if the logfile is an html target, write an HTML line break */ - if (G_log_disp.html_target && G_log_disp.html_mode) - os_fprintz(logfp, "
\n"); - } + /* if the logfile is an html target, write an HTML line break */ + if (G_log_disp.html_target && G_log_disp.html_mode) + os_fprintz(logfp, "
\n"); + } - /* flush the output */ - osfflush(logfp); + /* flush the output */ + osfflush(logfp); } /* ------------------------------------------------------------------------ */ @@ -3233,10 +3233,10 @@ void out_logfile_print(const char *txt, int nl) */ int setmore(int state) { - int oldstate = G_os_moremode; - - G_os_moremode = state; - return oldstate; + int oldstate = G_os_moremode; + + G_os_moremode = state; + return oldstate; } /* ------------------------------------------------------------------------ */ @@ -3250,92 +3250,92 @@ int setmore(int state) void out_more_prompt() { #ifdef USE_MORE - /* - * USE_MORE defined - we take responsibility for pagination. Show - * our default MORE prompt and wait for a keystroke. - */ + /* + * USE_MORE defined - we take responsibility for pagination. Show + * our default MORE prompt and wait for a keystroke. + */ - int done; + int done; int next_page = FALSE; - /* display the "MORE" prompt */ - os_printz("[More]"); - os_flush(); + /* display the "MORE" prompt */ + os_printz("[More]"); + os_flush(); - /* wait for an acceptable keystroke */ - for (done = FALSE ; !done ; ) - { - os_event_info_t evt; - - /* get an event */ - switch(os_get_event(0, FALSE, &evt)) - { - case OS_EVT_KEY: - switch(evt.key[0]) - { - case ' ': - /* stop waiting, show one page */ - done = TRUE; - next_page = TRUE; - break; - - case '\r': - case '\n': - /* stop waiting, show one line */ - done = TRUE; - next_page = FALSE; - break; + /* wait for an acceptable keystroke */ + for (done = FALSE ; !done ; ) + { + os_event_info_t evt; + + /* get an event */ + switch(os_get_event(0, FALSE, &evt)) + { + case OS_EVT_KEY: + switch(evt.key[0]) + { + case ' ': + /* stop waiting, show one page */ + done = TRUE; + next_page = TRUE; + break; + + case '\r': + case '\n': + /* stop waiting, show one line */ + done = TRUE; + next_page = FALSE; + break; - default: - /* ignore any other keystrokes */ - break; - } - break; + default: + /* ignore any other keystrokes */ + break; + } + break; - case OS_EVT_EOF: - /* end of file - there's nothing to wait for now */ - done = TRUE; - next_page = TRUE; + case OS_EVT_EOF: + /* end of file - there's nothing to wait for now */ + done = TRUE; + next_page = TRUE; - /* don't use more prompts any more, as the user can't respond */ - G_os_moremode = FALSE; - break; + /* don't use more prompts any more, as the user can't respond */ + G_os_moremode = FALSE; + break; - default: - /* ignore other events */ - break; - } - } + default: + /* ignore other events */ + break; + } + } - /* - * Remove the prompt from the screen by backing up and overwriting - * it with spaces. (Note that this assumes that we're running in - * some kind of terminal or character mode with a fixed-pitch font; - * if that's not the case, the OS layer should be taking - * responsibility for pagination anyway, so this code shouldn't be - * in use in the first place.) - */ - os_printz("\r \r"); + /* + * Remove the prompt from the screen by backing up and overwriting + * it with spaces. (Note that this assumes that we're running in + * some kind of terminal or character mode with a fixed-pitch font; + * if that's not the case, the OS layer should be taking + * responsibility for pagination anyway, so this code shouldn't be + * in use in the first place.) + */ + os_printz("\r \r"); - /* - * if they pressed the space key, it means that we should show an - * entire new page, so reset the line count to zero; otherwise, - * we'll want to display another MORE prompt at the very next line, - * so leave the line count alone - */ - if (next_page) - G_std_disp.linecnt = 0; + /* + * if they pressed the space key, it means that we should show an + * entire new page, so reset the line count to zero; otherwise, + * we'll want to display another MORE prompt at the very next line, + * so leave the line count alone + */ + if (next_page) + G_std_disp.linecnt = 0; #else /* USE_MORE */ - /* - * USE_MORE is undefined - this means that the OS layer is taking - * all responsibility for pagination. We must ask the OS layer to - * display the MORE prompt, because we can't make any assumptions - * about what the prompt looks like. - */ + /* + * USE_MORE is undefined - this means that the OS layer is taking + * all responsibility for pagination. We must ask the OS layer to + * display the MORE prompt, because we can't make any assumptions + * about what the prompt looks like. + */ - os_more_prompt(); + os_more_prompt(); #endif /* USE_MORE */ } @@ -3346,7 +3346,7 @@ void out_more_prompt() */ void outreset(void) { - G_std_disp.linecnt = 0; + G_std_disp.linecnt = 0; } /* ------------------------------------------------------------------------ */ @@ -3358,8 +3358,8 @@ void outreset(void) */ int tio_is_html_mode() { - /* return the current HTML mode flag for the standard display stream */ - return G_std_disp.html_mode; + /* return the current HTML mode flag for the standard display stream */ + return G_std_disp.html_mode; } @@ -3375,49 +3375,49 @@ int tio_is_html_mode() */ void tiocapture(tiocxdef *tioctx, mcmcxdef *memctx, int flag) { - if (flag) - { - /* create a new object if necessary */ - if (G_std_disp.capture_obj == MCMONINV) - { - mcmalo(memctx, 256, &G_std_disp.capture_obj); - mcmunlck(memctx, G_std_disp.capture_obj); - } + if (flag) + { + /* create a new object if necessary */ + if (G_std_disp.capture_obj == MCMONINV) + { + mcmalo(memctx, 256, &G_std_disp.capture_obj); + mcmunlck(memctx, G_std_disp.capture_obj); + } - /* remember the memory context */ - G_std_disp.capture_ctx = memctx; - } + /* remember the memory context */ + G_std_disp.capture_ctx = memctx; + } - /* - * remember capture status in the standard output stream as well as - * the log stream - */ - G_std_disp.capturing = flag; - G_log_disp.capturing = flag; + /* + * remember capture status in the standard output stream as well as + * the log stream + */ + G_std_disp.capturing = flag; + G_log_disp.capturing = flag; } /* clear all captured output */ void tioclrcapture(tiocxdef *tioctx) { - G_std_disp.capture_ofs = 0; + G_std_disp.capture_ofs = 0; } /* clear captured output back to a given size */ void tiopopcapture(tiocxdef *tioctx, uint orig_size) { - G_std_disp.capture_ofs = orig_size; + G_std_disp.capture_ofs = orig_size; } /* get the object handle of the captured output */ mcmon tiogetcapture(tiocxdef *ctx) { - return G_std_disp.capture_obj; + return G_std_disp.capture_obj; } /* get the amount of text captured */ uint tiocapturesize(tiocxdef *ctx) { - return G_std_disp.capture_ofs; + return G_std_disp.capture_ofs; } /* ------------------------------------------------------------------------ */ @@ -3426,8 +3426,8 @@ uint tiocapturesize(tiocxdef *ctx) */ void tiosetactor(tiocxdef *ctx, objnum actor) { - VARUSED(ctx); - cmdActor = actor; + VARUSED(ctx); + cmdActor = actor; } /* @@ -3435,10 +3435,10 @@ void tiosetactor(tiocxdef *ctx, objnum actor) */ objnum tiogetactor(tiocxdef *ctx) { - VARUSED(ctx); - return cmdActor; + VARUSED(ctx); + return cmdActor; } - + /* ------------------------------------------------------------------------ */ /* * Flush the output line. We'll write to both the standard display and @@ -3446,15 +3446,15 @@ objnum tiogetactor(tiocxdef *ctx) */ void outflushn(int nl) { - /* flush the display stream */ - outflushn_stream(&G_std_disp, nl); + /* flush the display stream */ + outflushn_stream(&G_std_disp, nl); - /* flush the log stream, if we have an open log file */ - if (logfp != 0) - { - outflushn_stream(&G_log_disp, nl); - osfflush(logfp); - } + /* flush the log stream, if we have an open log file */ + if (logfp != 0) + { + outflushn_stream(&G_log_disp, nl); + osfflush(logfp); + } } /* @@ -3462,8 +3462,8 @@ void outflushn(int nl) */ void outflush(void) { - /* use the common flushing routine in mode 1 (regular newline) */ - outflushn(1); + /* use the common flushing routine in mode 1 (regular newline) */ + outflushn(1); } /* ------------------------------------------------------------------------ */ @@ -3476,9 +3476,9 @@ void outflush(void) */ void outhide(void) { - outflag = 0; - outcnt = 0; - hidout = 0; + outflag = 0; + outcnt = 0; + hidout = 0; } /* @@ -3487,15 +3487,15 @@ void outhide(void) */ void outstat(int *hidden, int *output_occurred) { - *hidden = !outflag; - *output_occurred = outcnt; + *hidden = !outflag; + *output_occurred = outcnt; } /* set the flag to indicate that output has occurred */ void outsethidden(void) { - outcnt = 1; - hidout = 1; + outcnt = 1; + hidout = 1; } /* @@ -3504,18 +3504,18 @@ void outsethidden(void) */ int outshow(void) { - /* turn output back on */ - outflag = 1; + /* turn output back on */ + outflag = 1; - /* if we're debugging, note the end of hidden output */ - if (dbghid && hidout) - { - hidout = 0; - trcsho(); - } + /* if we're debugging, note the end of hidden output */ + if (dbghid && hidout) + { + hidout = 0; + trcsho(); + } - /* return the flag indicating whether hidden output occurred */ - return outcnt; + /* return the flag indicating whether hidden output occurred */ + return outcnt; } /* ------------------------------------------------------------------------ */ @@ -3524,7 +3524,7 @@ int outshow(void) */ void outwx(int flag) { - outwxflag = flag; + outwxflag = flag; } @@ -3535,8 +3535,8 @@ void outwx(int flag) */ void out_set_filter(objnum filter_fn) { - /* remember the filter function */ - G_user_filter = filter_fn; + /* remember the filter function */ + G_user_filter = filter_fn; } /* ------------------------------------------------------------------------ */ @@ -3545,8 +3545,8 @@ void out_set_filter(objnum filter_fn) */ void out_set_doublespace(int dbl) { - /* remember the new setting */ - doublespace = dbl; + /* remember the new setting */ + doublespace = dbl; } int tio_askfile(const char *prompt, char *reply, int replen, int prompt_type, os_filetype_t file_type) { @@ -3564,16 +3564,16 @@ int tio_input_dialog(int icon_id, const char *prompt, int standard_button_set, } void outfmt(tiocxdef *ctx, uchar *txt) { - uint len; + uint len; - VARUSED(ctx); + VARUSED(ctx); - /* read the length prefix */ - len = osrp2(txt) - 2; - txt += 2; + /* read the length prefix */ + len = osrp2(txt) - 2; + txt += 2; - /* write out the string */ - tioputslen(ctx, (char *)txt, len); + /* write out the string */ + tioputslen(ctx, (char *)txt, len); } } // End of namespace TADS2 diff --git a/engines/glk/tads/tads2/play.cpp b/engines/glk/tads/tads2/play.cpp index 0c78c6dd094..25ce28125b2 100644 --- a/engines/glk/tads/tads2/play.cpp +++ b/engines/glk/tads/tads2/play.cpp @@ -30,326 +30,326 @@ namespace TADS2 { void plygo(runcxdef *run, voccxdef *voc, tiocxdef *tio, objnum preinit, char *restore_fname) { int err; - errcxdef *ec = run->runcxerr; - char filbuf[128]; - int first_time; - int noreg inited = FALSE; + errcxdef *ec = run->runcxerr; + char filbuf[128]; + int first_time; + int noreg inited = FALSE; - NOREG((&inited)); + NOREG((&inited)); - first_time = TRUE; + first_time = TRUE; - /* - * Write out the special HTML sequence, in case we're on an HTML - * system. This tells the HTML parser to use the parsing rules for - * TADS 2 callers. - */ - outformat("\\H+\\H-"); - + /* + * Write out the special HTML sequence, in case we're on an HTML + * system. This tells the HTML parser to use the parsing rules for + * TADS 2 callers. + */ + outformat("\\H+\\H-"); + startover: - if (!inited) - { - /* use Me as the format-string actor for preinit and init */ - tiosetactor(voc->voccxtio, voc->voccxme); + if (!inited) + { + /* use Me as the format-string actor for preinit and init */ + tiosetactor(voc->voccxtio, voc->voccxme); - /* - * Run preinit, if it hasn't been run yet. Note that we only - * do this the first time through. If we come back here via the - * restart function, preinit will already have been run in the - * restart function itself, so we don't need to run it again. - */ - if (first_time) - { - /* make a note that we've been through here once already */ - first_time = FALSE; + /* + * Run preinit, if it hasn't been run yet. Note that we only + * do this the first time through. If we come back here via the + * restart function, preinit will already have been run in the + * restart function itself, so we don't need to run it again. + */ + if (first_time) + { + /* make a note that we've been through here once already */ + first_time = FALSE; - /* remember the preinit function for later use in restarting */ - voc->voccxpreinit = preinit; + /* remember the preinit function for later use in restarting */ + voc->voccxpreinit = preinit; - /* run the preinit() function */ - ERRBEGIN(ec) - { - /* reset the interpreter */ - runrst(run); + /* run the preinit() function */ + ERRBEGIN(ec) + { + /* reset the interpreter */ + runrst(run); - /* reset the parser */ - voc_stk_ini(voc, (uint)VOC_STACK_SIZE); + /* reset the parser */ + voc_stk_ini(voc, (uint)VOC_STACK_SIZE); - /* run preinit */ - if (preinit != MCMONINV) - runfn(run, preinit, 0); - } - ERRCATCH(ec, err) - { - /* if they restarted, go back and start over */ - if (err == ERR_RUNRESTART) - goto startover; + /* run preinit */ + if (preinit != MCMONINV) + runfn(run, preinit, 0); + } + ERRCATCH(ec, err) + { + /* if they restarted, go back and start over */ + if (err == ERR_RUNRESTART) + goto startover; - /* resignal the error */ - errrse(ec); - } - ERREND(ec); - } - - /* - * Run the "init" function. Do NOT run init if we're restoring - * a game directly from the command line AND there's an - * initRestore function defined. - */ - if (restore_fname == 0 || voc->voccxinitrestore == MCMONINV) - { - ERRBEGIN(ec) - { - /* reset the interpreter */ - runrst(run); + /* resignal the error */ + errrse(ec); + } + ERREND(ec); + } + + /* + * Run the "init" function. Do NOT run init if we're restoring + * a game directly from the command line AND there's an + * initRestore function defined. + */ + if (restore_fname == 0 || voc->voccxinitrestore == MCMONINV) + { + ERRBEGIN(ec) + { + /* reset the interpreter */ + runrst(run); - /* reset the parser */ - voc_stk_ini(voc, (uint)VOC_STACK_SIZE); + /* reset the parser */ + voc_stk_ini(voc, (uint)VOC_STACK_SIZE); - /* run init */ - runfn(run, (objnum)voc->voccxini, 0); - } - ERRCATCH(ec, err) - { - /* if they restarted, go back and start over */ - if (err == ERR_RUNRESTART) - goto startover; - - /* resignal the error */ - errrse(ec); - } - ERREND(ec); - } - } - - /* next time through, we'll need to run init again */ - inited = FALSE; + /* run init */ + runfn(run, (objnum)voc->voccxini, 0); + } + ERRCATCH(ec, err) + { + /* if they restarted, go back and start over */ + if (err == ERR_RUNRESTART) + goto startover; + + /* resignal the error */ + errrse(ec); + } + ERREND(ec); + } + } + + /* next time through, we'll need to run init again */ + inited = FALSE; - /* - * check for startup parameter file to restore - if there's a - * system-specific parameter file specified, pretend that it was - * specified as the restore file - */ - if (os_paramfile(filbuf)) - restore_fname = filbuf; + /* + * check for startup parameter file to restore - if there's a + * system-specific parameter file specified, pretend that it was + * specified as the restore file + */ + if (os_paramfile(filbuf)) + restore_fname = filbuf; - /* check for a file to restore */ - if (restore_fname != 0) - { - /* - * Check to see if the game file supports the initRestore - * function. If so, call it to restore the game. If not, - * restore the game directly. - */ - if (voc->voccxinitrestore != MCMONINV) - { - char restore_buf[OSFNMAX*2]; - char *src; - char *dst; - - /* convert any backslashes to double backslashes */ - for (src = restore_fname, dst = restore_buf ; - *src != '\0' && dst + 2 < restore_buf + sizeof(restore_buf) ; - ++src) - { - switch(*src) - { - case '\\': - /* it's a backslash - double it */ - *dst++ = '\\'; - *dst++ = '\\'; - break; + /* check for a file to restore */ + if (restore_fname != 0) + { + /* + * Check to see if the game file supports the initRestore + * function. If so, call it to restore the game. If not, + * restore the game directly. + */ + if (voc->voccxinitrestore != MCMONINV) + { + char restore_buf[OSFNMAX*2]; + char *src; + char *dst; + + /* convert any backslashes to double backslashes */ + for (src = restore_fname, dst = restore_buf ; + *src != '\0' && dst + 2 < restore_buf + sizeof(restore_buf) ; + ++src) + { + switch(*src) + { + case '\\': + /* it's a backslash - double it */ + *dst++ = '\\'; + *dst++ = '\\'; + break; - default: - /* copy the character as-is */ - *dst++ = *src; - } - } - - /* - * all the game's initRestore function with the name of - * saved game file to restore as the argument - */ + default: + /* copy the character as-is */ + *dst++ = *src; + } + } + + /* + * all the game's initRestore function with the name of + * saved game file to restore as the argument + */ - /* reset the interpreter */ - runrst(run); + /* reset the interpreter */ + runrst(run); - /* reset the parser */ - voc_stk_ini(voc, (uint)VOC_STACK_SIZE); + /* reset the parser */ + voc_stk_ini(voc, (uint)VOC_STACK_SIZE); - /* push the game file name and run initRestore */ - runpstr(run, restore_buf, dst - restore_buf, 0); - runfn(run, (objnum)voc->voccxinitrestore, 1); - } - else - { - /* restore the game */ - os_printz("\n\n[Restoring saved game]\n\n"); - err = fiorso(voc, restore_fname); - if (err) - { - char buf[60 + OSFNMAX]; + /* push the game file name and run initRestore */ + runpstr(run, restore_buf, dst - restore_buf, 0); + runfn(run, (objnum)voc->voccxinitrestore, 1); + } + else + { + /* restore the game */ + os_printz("\n\n[Restoring saved game]\n\n"); + err = fiorso(voc, restore_fname); + if (err) + { + char buf[60 + OSFNMAX]; - sprintf(buf, "\n\nError: unable to restore file \"%s\"\n\n", - restore_fname); - os_printz(buf); - } - } + sprintf(buf, "\n\nError: unable to restore file \"%s\"\n\n", + restore_fname); + os_printz(buf); + } + } - /* forget the saved game name, in case we restore */ - restore_fname = 0; - } + /* forget the saved game name, in case we restore */ + restore_fname = 0; + } - /* clear out the redo command buffer */ - voc->voccxredobuf[0] = '\0'; - - /* read and execute commands */ - for (;;) - { - char buf[128]; - - err = 0; - ERRBEGIN(ec) - - /* read a new command if there's nothing to redo */ - if (!voc->voccxredo) - { - /* reset hidden output so we're showing output */ - tioshow(tio); - tioflush(tio); + /* clear out the redo command buffer */ + voc->voccxredobuf[0] = '\0'; + + /* read and execute commands */ + for (;;) + { + char buf[128]; + + err = 0; + ERRBEGIN(ec) + + /* read a new command if there's nothing to redo */ + if (!voc->voccxredo) + { + /* reset hidden output so we're showing output */ + tioshow(tio); + tioflush(tio); - /* clear the interpreter stack */ - runrst(run); + /* clear the interpreter stack */ + runrst(run); - /* read a command */ - vocread(voc, MCMONINV, MCMONINV, buf, (int)sizeof(buf), 0); + /* read a command */ + vocread(voc, MCMONINV, MCMONINV, buf, (int)sizeof(buf), 0); - /* special qa checking */ - if (buf[0] == '@') - { - int quiet = FALSE; - char *p; - - p = buf + 1; - if (*p == '@') - { - /* turn off MORE mode */ - setmore(0); + /* special qa checking */ + if (buf[0] == '@') + { + int quiet = FALSE; + char *p; + + p = buf + 1; + if (*p == '@') + { + /* turn off MORE mode */ + setmore(0); - /* set NONSTOP mode in the OS layer */ - os_nonstop_mode(TRUE); + /* set NONSTOP mode in the OS layer */ + os_nonstop_mode(TRUE); - /* skip the extra '@' */ - ++p; - } - else if (*p == '!') - { - quiet = TRUE; - ++p; - } - while (*p != '\0' && t_isspace(*p)) ++p; - if (*p != '\0') - { - /* open the named file */ - qasopn(p, quiet); - } - else - { - char fname[256]; + /* skip the extra '@' */ + ++p; + } + else if (*p == '!') + { + quiet = TRUE; + ++p; + } + while (*p != '\0' && t_isspace(*p)) ++p; + if (*p != '\0') + { + /* open the named file */ + qasopn(p, quiet); + } + else + { + char fname[256]; - /* no file was named - ask the user to select a file */ - if (tio_askfile("Read script file:", fname, sizeof(fname), - OS_AFP_OPEN, OSFTCMD) == 0) - qasopn(fname, quiet); - } - goto end_loop; - } - } + /* no file was named - ask the user to select a file */ + if (tio_askfile("Read script file:", fname, sizeof(fname), + OS_AFP_OPEN, OSFTCMD) == 0) + qasopn(fname, quiet); + } + goto end_loop; + } + } - /* - * If there's redo in the redo buffer, use it now. If the - * buffer is empty and the redo flag is set, we'll just - * re-execute whatever's in our internal buffer. - */ - if (voc->voccxredo && voc->voccxredobuf[0] != '\0') - { - /* copy the redo buffer into our internal buffer */ - strcpy(buf, voc->voccxredobuf); + /* + * If there's redo in the redo buffer, use it now. If the + * buffer is empty and the redo flag is set, we'll just + * re-execute whatever's in our internal buffer. + */ + if (voc->voccxredo && voc->voccxredobuf[0] != '\0') + { + /* copy the redo buffer into our internal buffer */ + strcpy(buf, voc->voccxredobuf); - /* we've consumed it now, so clear it out */ - voc->voccxredobuf[0] = '\0'; - } + /* we've consumed it now, so clear it out */ + voc->voccxredobuf[0] = '\0'; + } - /* we've now consumed the redo */ - voc->voccxredo = FALSE; + /* we've now consumed the redo */ + voc->voccxredo = FALSE; - /* clear any pending break that's queued up */ - (void)os_break(); + /* clear any pending break that's queued up */ + (void)os_break(); - /* execute the command */ - (void)voccmd(voc, buf, (uint)sizeof(buf)); - - end_loop: - ERRCATCH(ec, err) - { - if (err != ERR_RUNQUIT - && err != ERR_RUNRESTART - && !(err == ERR_RUNABRT && voc->voccxredo)) - errclog(ec); - } - ERREND(ec); + /* execute the command */ + (void)voccmd(voc, buf, (uint)sizeof(buf)); + + end_loop: + ERRCATCH(ec, err) + { + if (err != ERR_RUNQUIT + && err != ERR_RUNRESTART + && !(err == ERR_RUNABRT && voc->voccxredo)) + errclog(ec); + } + ERREND(ec); - /* on interrupt, undo last command (which was partially executed) */ - if (err == ERR_USRINT && voc->voccxundo) - { - ERRBEGIN(ec) - objundo(voc->voccxmem, voc->voccxundo); - ERRCATCH(ec, err) - if (err != ERR_NOUNDO && err != ERR_ICUNDO) - errrse(ec); - ERREND(ec) - } - - /* if they want to quit, we're done */ - if (err == ERR_RUNQUIT) - break; - else if (err == ERR_RUNRESTART) - goto startover; - } + /* on interrupt, undo last command (which was partially executed) */ + if (err == ERR_USRINT && voc->voccxundo) + { + ERRBEGIN(ec) + objundo(voc->voccxmem, voc->voccxundo); + ERRCATCH(ec, err) + if (err != ERR_NOUNDO && err != ERR_ICUNDO) + errrse(ec); + ERREND(ec) + } + + /* if they want to quit, we're done */ + if (err == ERR_RUNQUIT) + break; + else if (err == ERR_RUNRESTART) + goto startover; + } - /* - * If we're quitting, give the debugger one last chance at taking - * control. If it just returns, we can go ahead and terminate, but - * if it wants it can restart the game by calling bifrst() as - * normal. - */ - ERRBEGIN(ec) - { - /* clear anything in the debugger stack trace */ - run->runcxdbg->dbgcxfcn = 0; - run->runcxdbg->dbgcxdep = 0; + /* + * If we're quitting, give the debugger one last chance at taking + * control. If it just returns, we can go ahead and terminate, but + * if it wants it can restart the game by calling bifrst() as + * normal. + */ + ERRBEGIN(ec) + { + /* clear anything in the debugger stack trace */ + run->runcxdbg->dbgcxfcn = 0; + run->runcxdbg->dbgcxdep = 0; - /* tell the debugger the game has exited */ - dbguquitting(run->runcxdbg); - } - ERRCATCH(ec, err) - { - switch(err) - { - case ERR_RUNRESTART: - /* they restarted the game - re-enter the play loop */ - goto startover; + /* tell the debugger the game has exited */ + dbguquitting(run->runcxdbg); + } + ERRCATCH(ec, err) + { + switch(err) + { + case ERR_RUNRESTART: + /* they restarted the game - re-enter the play loop */ + goto startover; - case ERR_RUNQUIT: - /* quitting - proceed to return as normal */ - break; + case ERR_RUNQUIT: + /* quitting - proceed to return as normal */ + break; - default: - /* resignal any other error */ - errrse(ec); - } - } - ERREND(ec); + default: + /* resignal any other error */ + errrse(ec); + } + } + ERREND(ec); } } // End of namespace TADS2 diff --git a/engines/glk/tads/tads2/post_compilation.h b/engines/glk/tads/tads2/post_compilation.h index 1d7ac7ac6dd..f74771c6d35 100644 --- a/engines/glk/tads/tads2/post_compilation.h +++ b/engines/glk/tads/tads2/post_compilation.h @@ -36,13 +36,13 @@ namespace TADS2 { /* setup context */ struct supcxdef { - errcxdef *supcxerr; - mcmcxdef *supcxmem; /* memory manager client context */ - voccxdef *supcxvoc; /* player command parsing context */ - tokthdef *supcxtab; /* top-level symbol table */ - runcxdef *supcxrun; /* execution context */ - uchar *supcxbuf; /* space for building a list */ - ushort supcxlen; /* size of buffer */ + errcxdef *supcxerr; + mcmcxdef *supcxmem; /* memory manager client context */ + voccxdef *supcxvoc; /* player command parsing context */ + tokthdef *supcxtab; /* top-level symbol table */ + runcxdef *supcxrun; /* execution context */ + uchar *supcxbuf; /* space for building a list */ + ushort supcxlen; /* size of buffer */ }; /* set up contents list for one object for demand-on-load */ @@ -53,32 +53,32 @@ extern void supivoc(supcxdef *ctx); /* find required objects/functions */ extern void supfind(errcxdef *ctx, tokthdef *tab, voccxdef *voc, - objnum *preinit, int warnlevel, int casefold); + objnum *preinit, int warnlevel, int casefold); /* set up reserved words */ extern void suprsrv(supcxdef *sup, void (*bif[])(struct bifcxdef *, int), - toktdef *tab, int fncntmax, int v1compat, char *new_do, - int casefold); + toktdef *tab, int fncntmax, int v1compat, char *new_do, + int casefold); /* set up built-in functions without symbol table (for run-time) */ extern void supbif(supcxdef *sup, void (*bif[])(struct bifcxdef *, int), - int bifsiz); + int bifsiz); /* log an undefined-object error */ extern void sup_log_undefobj(mcmcxdef *mctx, errcxdef *ec, int err, - char *sym_name, int sym_name_len, objnum objn); + char *sym_name, int sym_name_len, objnum objn); /* set up inherited vocabulary for a particular object */ extern void supivoc1(supcxdef *sup, voccxdef *ctx, vocidef *v, objnum target, - int inh_from_obj, int flags); + int inh_from_obj, int flags); /* get name of an object out of symbol table */ extern void supgnam(char *buf, tokthdef *tab, objnum objn); /* table of built-in functions */ struct supbidef { - char *supbinam; /* name of function */ - void (*supbifn)(struct bifcxdef *, int); /* C routine to call */ + char *supbinam; /* name of function */ + void (*supbifn)(struct bifcxdef *, int); /* C routine to call */ }; /* external definition for special token table */ diff --git a/engines/glk/tads/tads2/qa_scriptor.cpp b/engines/glk/tads/tads2/qa_scriptor.cpp index bb235d52d25..aec06910d0e 100644 --- a/engines/glk/tads/tads2/qa_scriptor.cpp +++ b/engines/glk/tads/tads2/qa_scriptor.cpp @@ -37,80 +37,80 @@ osfildef *scrfp = (osfildef *)0; /* script file */ int scrquiet = 0; /* flag: true ==> script is NOT shown as read */ int qasopn(char *scrnam, int quiet) { - if (scrfp) return 1; /* already reading from script */ - if ((scrfp = osfoprt(scrnam, OSFTCMD)) == 0) return 1; - scrquiet = quiet; - return 0; + if (scrfp) return 1; /* already reading from script */ + if ((scrfp = osfoprt(scrnam, OSFTCMD)) == 0) return 1; + scrquiet = quiet; + return 0; } void qasclose() { - /* only close the script file if there's one open */ - if (scrfp) - { - osfcls(scrfp); - scrfp = 0; /* no more script file */ - scrquiet = 0; - } + /* only close the script file if there's one open */ + if (scrfp) + { + osfcls(scrfp); + scrfp = 0; /* no more script file */ + scrquiet = 0; + } } char *qasgets(char *buf, int bufl) { - /* shouldn't be here at all if there's no script file */ - if (scrfp == 0) - return 0; + /* shouldn't be here at all if there's no script file */ + if (scrfp == 0) + return 0; - /* update status line */ - runstat(); + /* update status line */ + runstat(); - /* keep going until we find something we like */ - for (;;) - { - char c; - - /* - * Read the next character of input. If it's not a newline, - * there's more on the same line, so read the rest and see what - * to do. - */ - c = osfgetc(scrfp); - if (c != '\n' && c != '\r') - { - /* read the rest of the line */ - if (!osfgets(buf, bufl, scrfp)) - { - /* end of file: close the script and return eof */ - qasclose(); - return 0; - } - - /* if the line started with '>', strip '\n' and return line */ - if (c == '>') - { - int l; + /* keep going until we find something we like */ + for (;;) + { + char c; + + /* + * Read the next character of input. If it's not a newline, + * there's more on the same line, so read the rest and see what + * to do. + */ + c = osfgetc(scrfp); + if (c != '\n' && c != '\r') + { + /* read the rest of the line */ + if (!osfgets(buf, bufl, scrfp)) + { + /* end of file: close the script and return eof */ + qasclose(); + return 0; + } + + /* if the line started with '>', strip '\n' and return line */ + if (c == '>') + { + int l; - /* remove the trailing newline */ - if ((l = strlen(buf)) > 0 - && (buf[l-1] == '\n' || buf[l-1] == '\r')) - buf[l-1] = 0; + /* remove the trailing newline */ + if ((l = strlen(buf)) > 0 + && (buf[l-1] == '\n' || buf[l-1] == '\r')) + buf[l-1] = 0; - /* - * if we're not in quiet mode, echo the command to the - * display - */ - if (!scrquiet) - outformat(buf); + /* + * if we're not in quiet mode, echo the command to the + * display + */ + if (!scrquiet) + outformat(buf); - /* flush the current line without adding any blank lines */ - outflushn(1); + /* flush the current line without adding any blank lines */ + outflushn(1); - /* return the command */ - return buf; - } - } else if ((int)c == EOF) { - /* end of file - close the script and return eof */ - qasclose(); - return 0; - } - } + /* return the command */ + return buf; + } + } else if ((int)c == EOF) { + /* end of file - close the script and return eof */ + qasclose(); + return 0; + } + } } } // End of namespace TADS2 diff --git a/engines/glk/tads/tads2/regex.cpp b/engines/glk/tads/tads2/regex.cpp index 9b55b93fb0d..dfbe160ac33 100644 --- a/engines/glk/tads/tads2/regex.cpp +++ b/engines/glk/tads/tads2/regex.cpp @@ -132,11 +132,11 @@ enum { * and final state ID's. */ struct re_machine { - /* the machine's initial state */ - re_state_id init; + /* the machine's initial state */ + re_state_id init; - /* the machine's final state */ - re_state_id final_state; + /* the machine's final state */ + re_state_id final_state; }; /* ------------------------------------------------------------------------ */ @@ -146,21 +146,21 @@ struct re_machine { */ void re_init(re_context *ctx, errcxdef *errctx) { - /* save the error context */ - ctx->errctx = errctx; - - /* no tuple array yet */ - ctx->tuple_arr = 0; - ctx->tuples_alloc = 0; + /* save the error context */ + ctx->errctx = errctx; + + /* no tuple array yet */ + ctx->tuple_arr = 0; + ctx->tuples_alloc = 0; - /* clear states */ - ctx->next_state = RE_STATE_FIRST_VALID; + /* clear states */ + ctx->next_state = RE_STATE_FIRST_VALID; - /* clear groups */ - ctx->cur_group = 0; + /* clear groups */ + ctx->cur_group = 0; - /* no string buffer yet */ - ctx->strbuf = 0; + /* no string buffer yet */ + ctx->strbuf = 0; } /* ------------------------------------------------------------------------ */ @@ -169,23 +169,23 @@ void re_init(re_context *ctx, errcxdef *errctx) */ static void re_reset(re_context *ctx) { - int i; - - /* delete any range tables we've allocated */ - for (i = 0 ; i < ctx->next_state ; ++i) - { - if (ctx->tuple_arr[i].char_range != 0) - { - mchfre(ctx->tuple_arr[i].char_range); - ctx->tuple_arr[i].char_range = 0; - } - } + int i; + + /* delete any range tables we've allocated */ + for (i = 0 ; i < ctx->next_state ; ++i) + { + if (ctx->tuple_arr[i].char_range != 0) + { + mchfre(ctx->tuple_arr[i].char_range); + ctx->tuple_arr[i].char_range = 0; + } + } - /* clear states */ - ctx->next_state = RE_STATE_FIRST_VALID; + /* clear states */ + ctx->next_state = RE_STATE_FIRST_VALID; - /* clear groups */ - ctx->cur_group = 0; + /* clear groups */ + ctx->cur_group = 0; } /* ------------------------------------------------------------------------ */ @@ -195,22 +195,22 @@ static void re_reset(re_context *ctx) */ void re_delete(re_context *ctx) { - /* reset state */ - re_reset(ctx); - - /* if we've allocated an array, delete it */ - if (ctx->tuple_arr != 0) - { - mchfre(ctx->tuple_arr); - ctx->tuple_arr = 0; - } + /* reset state */ + re_reset(ctx); + + /* if we've allocated an array, delete it */ + if (ctx->tuple_arr != 0) + { + mchfre(ctx->tuple_arr); + ctx->tuple_arr = 0; + } - /* if we allocated a string buffer, delete it */ - if (ctx->strbuf != 0) - { - mchfre(ctx->strbuf); - ctx->strbuf = 0; - } + /* if we allocated a string buffer, delete it */ + if (ctx->strbuf != 0) + { + mchfre(ctx->strbuf); + ctx->strbuf = 0; + } } /* ------------------------------------------------------------------------ */ @@ -219,57 +219,57 @@ void re_delete(re_context *ctx) */ static re_state_id re_alloc_state(re_context *ctx) { - /* - * If we don't have enough room for another state, expand the array - */ - if (ctx->next_state >= ctx->tuples_alloc) - { - uint new_alloc; - - /* bump the size by a bit */ - new_alloc = ctx->tuples_alloc + 100; - - /* allocate or expand the array */ - if (ctx->tuples_alloc == 0) - { - /* allocate the initial memory block */ - ctx->tuple_arr = - (re_tuple *)mchalo(ctx->errctx, - (new_alloc * sizeof(re_tuple)), - "regex"); - } - else - { - re_tuple *ptr; - - /* allocate a new memory block */ - ptr = (re_tuple *)mchalo(ctx->errctx, - (new_alloc * sizeof(re_tuple)), - "regex"); - - /* copy the old memory to the new memory */ - memcpy(ptr, ctx->tuple_arr, ctx->tuples_alloc * sizeof(re_tuple)); + /* + * If we don't have enough room for another state, expand the array + */ + if (ctx->next_state >= ctx->tuples_alloc) + { + uint new_alloc; + + /* bump the size by a bit */ + new_alloc = ctx->tuples_alloc + 100; + + /* allocate or expand the array */ + if (ctx->tuples_alloc == 0) + { + /* allocate the initial memory block */ + ctx->tuple_arr = + (re_tuple *)mchalo(ctx->errctx, + (new_alloc * sizeof(re_tuple)), + "regex"); + } + else + { + re_tuple *ptr; + + /* allocate a new memory block */ + ptr = (re_tuple *)mchalo(ctx->errctx, + (new_alloc * sizeof(re_tuple)), + "regex"); + + /* copy the old memory to the new memory */ + memcpy(ptr, ctx->tuple_arr, ctx->tuples_alloc * sizeof(re_tuple)); - /* free the old block */ - mchfre(ctx->tuple_arr); + /* free the old block */ + mchfre(ctx->tuple_arr); - /* use the new block */ - ctx->tuple_arr = ptr; - } + /* use the new block */ + ctx->tuple_arr = ptr; + } - /* remember the new allocation size */ - ctx->tuples_alloc = new_alloc; - } + /* remember the new allocation size */ + ctx->tuples_alloc = new_alloc; + } - /* initialize the next state */ - ctx->tuple_arr[ctx->next_state].next_state_1 = RE_STATE_INVALID; - ctx->tuple_arr[ctx->next_state].next_state_2 = RE_STATE_INVALID; - ctx->tuple_arr[ctx->next_state].ch = RE_EPSILON; - ctx->tuple_arr[ctx->next_state].flags = 0; - ctx->tuple_arr[ctx->next_state].char_range = 0; + /* initialize the next state */ + ctx->tuple_arr[ctx->next_state].next_state_1 = RE_STATE_INVALID; + ctx->tuple_arr[ctx->next_state].next_state_2 = RE_STATE_INVALID; + ctx->tuple_arr[ctx->next_state].ch = RE_EPSILON; + ctx->tuple_arr[ctx->next_state].flags = 0; + ctx->tuple_arr[ctx->next_state].char_range = 0; - /* return the new state's ID */ - return ctx->next_state++; + /* return the new state's ID */ + return ctx->next_state++; } @@ -278,44 +278,44 @@ static re_state_id re_alloc_state(re_context *ctx) * Set a transition from a state to a given destination state. */ static void re_set_trans(re_context *ctx, - re_state_id id, re_state_id dest_id, char ch) + re_state_id id, re_state_id dest_id, char ch) { - re_tuple *tuple; - - /* - * get the tuple containing the transitions for this state ID - the - * state ID is the index of the state's transition tuple in the - * array - */ - tuple = &ctx->tuple_arr[id]; + re_tuple *tuple; + + /* + * get the tuple containing the transitions for this state ID - the + * state ID is the index of the state's transition tuple in the + * array + */ + tuple = &ctx->tuple_arr[id]; - /* - * If the first state pointer hasn't been set yet, set it to the new - * destination. Otherwise, set the second state pointer. - * - * Only set the character on setting the first state. When setting - * the second state, we must assume that the character for the state - * has already been set, since any given state can have only one - * character setting. - */ - if (tuple->next_state_1 == RE_STATE_INVALID) - { - /* - * set the character ID, unless the state has been marked with a - * special flag which indicates that the character value has - * another meaning (in particular, a group marker) - */ - if (!(tuple->flags & (RE_STATE_GROUP_BEGIN | RE_STATE_GROUP_END))) - tuple->ch = ch; + /* + * If the first state pointer hasn't been set yet, set it to the new + * destination. Otherwise, set the second state pointer. + * + * Only set the character on setting the first state. When setting + * the second state, we must assume that the character for the state + * has already been set, since any given state can have only one + * character setting. + */ + if (tuple->next_state_1 == RE_STATE_INVALID) + { + /* + * set the character ID, unless the state has been marked with a + * special flag which indicates that the character value has + * another meaning (in particular, a group marker) + */ + if (!(tuple->flags & (RE_STATE_GROUP_BEGIN | RE_STATE_GROUP_END))) + tuple->ch = ch; - /* set the first transition */ - tuple->next_state_1 = dest_id; - } - else - { - /* set only the second transition state - don't set the character */ - tuple->next_state_2 = dest_id; - } + /* set the first transition */ + tuple->next_state_1 = dest_id; + } + else + { + /* set only the second transition state - don't set the character */ + tuple->next_state_2 = dest_id; + } } /* ------------------------------------------------------------------------ */ @@ -324,8 +324,8 @@ static void re_set_trans(re_context *ctx, */ static void re_init_machine(re_context *ctx, re_machine *machine) { - machine->init = re_alloc_state(ctx); - machine->final_state = re_alloc_state(ctx); + machine->init = re_alloc_state(ctx); + machine->final_state = re_alloc_state(ctx); } /* @@ -333,11 +333,11 @@ static void re_init_machine(re_context *ctx, re_machine *machine) */ static void re_build_char(re_context *ctx, re_machine *machine, char ch) { - /* initialize our new machine */ - re_init_machine(ctx, machine); + /* initialize our new machine */ + re_init_machine(ctx, machine); - /* allocate a transition tuple for the new state */ - re_set_trans(ctx, machine->init, machine->final_state, ch); + /* allocate a transition tuple for the new state */ + re_set_trans(ctx, machine->init, machine->final_state, ch); } /* @@ -345,27 +345,27 @@ static void re_build_char(re_context *ctx, re_machine *machine, char ch) * bit vector. */ static void re_build_char_range(re_context *ctx, re_machine *machine, - unsigned char *range, int exclusion) + unsigned char *range, int exclusion) { - unsigned char *range_copy; - - /* initialize our new machine */ - re_init_machine(ctx, machine); + unsigned char *range_copy; + + /* initialize our new machine */ + re_init_machine(ctx, machine); - /* allocate a transition table for the new state */ - re_set_trans(ctx, machine->init, machine->final_state, - (char)(exclusion ? RE_RANGE_EXCL : RE_RANGE)); + /* allocate a transition table for the new state */ + re_set_trans(ctx, machine->init, machine->final_state, + (char)(exclusion ? RE_RANGE_EXCL : RE_RANGE)); - /* allocate a copy of the range bit vector */ - range_copy = (unsigned char *)mchalo(ctx->errctx, 32, "regex range"); + /* allocate a copy of the range bit vector */ + range_copy = (unsigned char *)mchalo(ctx->errctx, 32, "regex range"); - /* copy the caller's range */ - memcpy(range_copy, range, 32); + /* copy the caller's range */ + memcpy(range_copy, range, 32); - /* store it in the tuple */ - ctx->tuple_arr[machine->init].char_range = range_copy; + /* store it in the tuple */ + ctx->tuple_arr[machine->init].char_range = range_copy; } - + /* * Build a group recognizer. This is almost the same as a character @@ -373,18 +373,18 @@ static void re_build_char_range(re_context *ctx, re_machine *machine, * character. */ static void re_build_group_matcher(re_context *ctx, - re_machine *machine, int group_num) + re_machine *machine, int group_num) { - /* initialize our new machine */ - re_init_machine(ctx, machine); + /* initialize our new machine */ + re_init_machine(ctx, machine); - /* - * Allocate a transition tuple for the new state, using the group ID - * as the character code. Store the special code for a group - * recognizer rather than the normal literal character code. - */ - re_set_trans(ctx, machine->init, machine->final_state, - (char)(group_num + RE_GROUP_MATCH_0)); + /* + * Allocate a transition tuple for the new state, using the group ID + * as the character code. Store the special code for a group + * recognizer rather than the normal literal character code. + */ + re_set_trans(ctx, machine->init, machine->final_state, + (char)(group_num + RE_GROUP_MATCH_0)); } @@ -392,28 +392,28 @@ static void re_build_group_matcher(re_context *ctx, * Build a concatenation recognizer */ static void re_build_concat(re_context *ctx, re_machine *new_machine, - re_machine *lhs, re_machine *rhs) + re_machine *lhs, re_machine *rhs) { - /* initialize the new machine */ - re_init_machine(ctx, new_machine); + /* initialize the new machine */ + re_init_machine(ctx, new_machine); - /* - * set up an epsilon transition from the new machine's initial state - * to the first submachine's initial state - */ - re_set_trans(ctx, new_machine->init, lhs->init, RE_EPSILON); + /* + * set up an epsilon transition from the new machine's initial state + * to the first submachine's initial state + */ + re_set_trans(ctx, new_machine->init, lhs->init, RE_EPSILON); - /* - * Set up an epsilon transition from the first submachine's final - * state to the second submachine's initial state - */ - re_set_trans(ctx, lhs->final_state, rhs->init, RE_EPSILON); + /* + * Set up an epsilon transition from the first submachine's final + * state to the second submachine's initial state + */ + re_set_trans(ctx, lhs->final_state, rhs->init, RE_EPSILON); - /* - * Set up an epsilon transition from the second submachine's final - * state to our new machine's final state - */ - re_set_trans(ctx, rhs->final_state, new_machine->final_state, RE_EPSILON); + /* + * Set up an epsilon transition from the second submachine's final + * state to our new machine's final state + */ + re_set_trans(ctx, rhs->final_state, new_machine->final_state, RE_EPSILON); } /* @@ -422,92 +422,92 @@ static void re_build_concat(re_context *ctx, re_machine *new_machine, * newly-created machine that encloses and marks the group. */ static void re_build_group(re_context *ctx, re_machine *new_machine, - re_machine *sub_machine, int group_id) + re_machine *sub_machine, int group_id) { - /* initialize the container machine */ - re_init_machine(ctx, new_machine); + /* initialize the container machine */ + re_init_machine(ctx, new_machine); - /* - * set up an epsilon transition from the new machine's initial state - * into the initial state of the group, and another transition from - * the group's final state into the container's final state - */ - re_set_trans(ctx, new_machine->init, sub_machine->init, RE_EPSILON); - re_set_trans(ctx, sub_machine->final_state, new_machine->final_state, RE_EPSILON); + /* + * set up an epsilon transition from the new machine's initial state + * into the initial state of the group, and another transition from + * the group's final state into the container's final state + */ + re_set_trans(ctx, new_machine->init, sub_machine->init, RE_EPSILON); + re_set_trans(ctx, sub_machine->final_state, new_machine->final_state, RE_EPSILON); - /* - * Mark the initial and final states of the group machine as being - * group markers. - */ - ctx->tuple_arr[new_machine->init].flags |= RE_STATE_GROUP_BEGIN; - ctx->tuple_arr[new_machine->final_state].flags |= RE_STATE_GROUP_END; + /* + * Mark the initial and final states of the group machine as being + * group markers. + */ + ctx->tuple_arr[new_machine->init].flags |= RE_STATE_GROUP_BEGIN; + ctx->tuple_arr[new_machine->final_state].flags |= RE_STATE_GROUP_END; - /* store the group ID in the 'ch' member of the start and end states */ - ctx->tuple_arr[new_machine->init].ch = group_id; - ctx->tuple_arr[new_machine->final_state].ch = group_id; + /* store the group ID in the 'ch' member of the start and end states */ + ctx->tuple_arr[new_machine->init].ch = group_id; + ctx->tuple_arr[new_machine->final_state].ch = group_id; } /* * Build an alternation recognizer */ static void re_build_alter(re_context *ctx, re_machine *new_machine, - re_machine *lhs, re_machine *rhs) + re_machine *lhs, re_machine *rhs) { - /* initialize the new machine */ - re_init_machine(ctx, new_machine); + /* initialize the new machine */ + re_init_machine(ctx, new_machine); - /* - * Set up an epsilon transition from our new machine's initial state - * to the initial state of each submachine - */ - re_set_trans(ctx, new_machine->init, lhs->init, RE_EPSILON); - re_set_trans(ctx, new_machine->init, rhs->init, RE_EPSILON); + /* + * Set up an epsilon transition from our new machine's initial state + * to the initial state of each submachine + */ + re_set_trans(ctx, new_machine->init, lhs->init, RE_EPSILON); + re_set_trans(ctx, new_machine->init, rhs->init, RE_EPSILON); - /* - * Set up an epsilon transition from the final state of each - * submachine to our final state - */ - re_set_trans(ctx, lhs->final_state, new_machine->final_state, RE_EPSILON); - re_set_trans(ctx, rhs->final_state, new_machine->final_state, RE_EPSILON); + /* + * Set up an epsilon transition from the final state of each + * submachine to our final state + */ + re_set_trans(ctx, lhs->final_state, new_machine->final_state, RE_EPSILON); + re_set_trans(ctx, rhs->final_state, new_machine->final_state, RE_EPSILON); } /* * Build a closure recognizer */ static void re_build_closure(re_context *ctx, - re_machine *new_machine, re_machine *sub, - char specifier) + re_machine *new_machine, re_machine *sub, + char specifier) { - /* initialize the new machine */ - re_init_machine(ctx, new_machine); + /* initialize the new machine */ + re_init_machine(ctx, new_machine); - /* - * set up an epsilon transition from our initial state to the - * submachine's initial state, and from the submachine's final state - * to our final state - */ - re_set_trans(ctx, new_machine->init, sub->init, RE_EPSILON); - re_set_trans(ctx, sub->final_state, new_machine->final_state, RE_EPSILON); + /* + * set up an epsilon transition from our initial state to the + * submachine's initial state, and from the submachine's final state + * to our final state + */ + re_set_trans(ctx, new_machine->init, sub->init, RE_EPSILON); + re_set_trans(ctx, sub->final_state, new_machine->final_state, RE_EPSILON); - /* - * If this is an unbounded closure ('*' or '+', but not '?'), set up - * the loop transition that takes us from the new machine's final - * state back to its initial state. We don't do this on the - * zero-or-one closure, because we can only match the expression - * once. - */ - if (specifier != '?') - re_set_trans(ctx, sub->final_state, sub->init, RE_EPSILON); + /* + * If this is an unbounded closure ('*' or '+', but not '?'), set up + * the loop transition that takes us from the new machine's final + * state back to its initial state. We don't do this on the + * zero-or-one closure, because we can only match the expression + * once. + */ + if (specifier != '?') + re_set_trans(ctx, sub->final_state, sub->init, RE_EPSILON); - /* - * If this is a zero-or-one closure or a zero-or-more closure, set - * up an epsilon transition from our initial state to our final - * state, since we can skip the entire subexpression. We don't do - * this on the one-or-more closure, because we can't skip the - * subexpression in this case. - */ - if (specifier != '+') - re_set_trans(ctx, new_machine->init, new_machine->final_state, RE_EPSILON); + /* + * If this is a zero-or-one closure or a zero-or-more closure, set + * up an epsilon transition from our initial state to our final + * state, since we can skip the entire subexpression. We don't do + * this on the one-or-more closure, because we can't skip the + * subexpression in this case. + */ + if (specifier != '+') + re_set_trans(ctx, new_machine->init, new_machine->final_state, RE_EPSILON); } /* @@ -515,7 +515,7 @@ static void re_build_closure(re_context *ctx, */ static void re_build_null_machine(re_context *ctx, re_machine *machine) { - machine->init = machine->final_state = RE_STATE_INVALID; + machine->init = machine->final_state = RE_STATE_INVALID; } /* ------------------------------------------------------------------------ */ @@ -524,7 +524,7 @@ static void re_build_null_machine(re_context *ctx, re_machine *machine) */ static int re_is_machine_null(re_context *ctx, re_machine *machine) { - return (machine->init == RE_STATE_INVALID); + return (machine->init == RE_STATE_INVALID); } @@ -536,27 +536,27 @@ static int re_is_machine_null(re_context *ctx, re_machine *machine) * the second machine into the first. */ static void re_concat_onto(re_context *ctx, - re_machine *dest, re_machine *rhs) + re_machine *dest, re_machine *rhs) { - /* check for a null destination machine */ - if (re_is_machine_null(ctx, dest)) - { - /* - * the first machine is null - simply copy the second machine - * onto the first unchanged - */ - *dest = *rhs; - } - else - { - re_machine new_machine; - - /* build the concatenated machine */ - re_build_concat(ctx, &new_machine, dest, rhs); + /* check for a null destination machine */ + if (re_is_machine_null(ctx, dest)) + { + /* + * the first machine is null - simply copy the second machine + * onto the first unchanged + */ + *dest = *rhs; + } + else + { + re_machine new_machine; + + /* build the concatenated machine */ + re_build_concat(ctx, &new_machine, dest, rhs); - /* copy the concatenated machine onto the first machine */ - *dest = new_machine; - } + /* copy the concatenated machine onto the first machine */ + *dest = new_machine; + } } /* @@ -567,34 +567,34 @@ static void re_concat_onto(re_context *ctx, * machine unchanged. */ static void re_alternate_onto(re_context *ctx, - re_machine *dest, re_machine *rhs) + re_machine *dest, re_machine *rhs) { - /* check to see if the first machine is null */ - if (re_is_machine_null(ctx, dest)) - { - /* - * the first machine is null - simply copy the second machine - * onto the first - */ - *dest = *rhs; - } - else - { - /* - * if the second machine is null, don't do anything; otherwise, - * build the alternation - */ - if (!re_is_machine_null(ctx, rhs)) - { - re_machine new_machine; - - /* build the alternation */ - re_build_alter(ctx, &new_machine, dest, rhs); + /* check to see if the first machine is null */ + if (re_is_machine_null(ctx, dest)) + { + /* + * the first machine is null - simply copy the second machine + * onto the first + */ + *dest = *rhs; + } + else + { + /* + * if the second machine is null, don't do anything; otherwise, + * build the alternation + */ + if (!re_is_machine_null(ctx, rhs)) + { + re_machine new_machine; + + /* build the alternation */ + re_build_alter(ctx, &new_machine, dest, rhs); - /* replace the first machine with the alternation */ - *dest = new_machine; - } - } + /* replace the first machine with the alternation */ + *dest = new_machine; + } + } } /* ------------------------------------------------------------------------ */ @@ -602,465 +602,465 @@ static void re_alternate_onto(re_context *ctx, * Set a bit in a bit vector. */ #define re_set_bit(set, bit) \ - (((unsigned char *)(set))[(bit) >> 3] |= (1 << ((bit) & 7))) + (((unsigned char *)(set))[(bit) >> 3] |= (1 << ((bit) & 7))) /* * Test a bit in a bit vector */ #define re_is_bit_set(set, bit) \ - ((((unsigned char *)(set))[(bit) >> 3] & (1 << ((bit) & 7))) != 0) + ((((unsigned char *)(set))[(bit) >> 3] & (1 << ((bit) & 7))) != 0) /* ------------------------------------------------------------------------ */ /* * Compile an expression */ static re_status_t re_compile(re_context *ctx, - const char *expr, size_t exprlen, - re_machine *result_machine) + const char *expr, size_t exprlen, + re_machine *result_machine) { - re_machine cur_machine; - re_machine alter_machine; - re_machine new_machine; - size_t group_stack_level; - struct - { - re_machine old_cur; - re_machine old_alter; - int group_id; - } group_stack[50]; + re_machine cur_machine; + re_machine alter_machine; + re_machine new_machine; + size_t group_stack_level; + struct + { + re_machine old_cur; + re_machine old_alter; + int group_id; + } group_stack[50]; - /* reset everything */ - re_reset(ctx); + /* reset everything */ + re_reset(ctx); - /* start out with no current machine and no alternate machine */ - re_build_null_machine(ctx, &cur_machine); - re_build_null_machine(ctx, &alter_machine); + /* start out with no current machine and no alternate machine */ + re_build_null_machine(ctx, &cur_machine); + re_build_null_machine(ctx, &alter_machine); - /* nothing on the stack yet */ - group_stack_level = 0; + /* nothing on the stack yet */ + group_stack_level = 0; - /* loop until we run out of expression to parse */ - for ( ; exprlen != 0 ; ++expr, --exprlen) - { - switch(*expr) - { - case '^': - /* - * beginning of line - if we're not at the beginning of the - * current expression (i.e., we already have some - * concatentations accumulated), treat it as an ordinary - * character - */ - if (!re_is_machine_null(ctx, &cur_machine)) - goto normal_char; + /* loop until we run out of expression to parse */ + for ( ; exprlen != 0 ; ++expr, --exprlen) + { + switch(*expr) + { + case '^': + /* + * beginning of line - if we're not at the beginning of the + * current expression (i.e., we already have some + * concatentations accumulated), treat it as an ordinary + * character + */ + if (!re_is_machine_null(ctx, &cur_machine)) + goto normal_char; - /* build a new start-of-text recognizer */ - re_build_char(ctx, &new_machine, RE_TEXT_BEGIN); + /* build a new start-of-text recognizer */ + re_build_char(ctx, &new_machine, RE_TEXT_BEGIN); - /* - * concatenate it onto the string - note that this can't - * have any postfix operators - */ - re_concat_onto(ctx, &cur_machine, &new_machine); - break; + /* + * concatenate it onto the string - note that this can't + * have any postfix operators + */ + re_concat_onto(ctx, &cur_machine, &new_machine); + break; - case '$': - /* - * End of line specifier - if there's anything left after - * the '$' other than a close parens or alternation - * specifier, great it as a normal character - */ - if (exprlen > 1 - && (*(expr+1) != ')' && *(expr+1) != '|')) - goto normal_char; + case '$': + /* + * End of line specifier - if there's anything left after + * the '$' other than a close parens or alternation + * specifier, great it as a normal character + */ + if (exprlen > 1 + && (*(expr+1) != ')' && *(expr+1) != '|')) + goto normal_char; - /* build a new end-of-text recognizer */ - re_build_char(ctx, &new_machine, RE_TEXT_END); + /* build a new end-of-text recognizer */ + re_build_char(ctx, &new_machine, RE_TEXT_END); - /* - * concatenate it onto the string - note that this can't - * have any postfix operators - */ - re_concat_onto(ctx, &cur_machine, &new_machine); - break; - - case '(': - /* - * Add a nesting level. Push the current machine and - * alternate machines onto the group stack, and clear - * everything out for the new group. - */ - if (group_stack_level - > sizeof(group_stack)/sizeof(group_stack[0])) - { - /* we cannot proceed - return an error */ - return RE_STATUS_GROUP_NESTING_TOO_DEEP; - } + /* + * concatenate it onto the string - note that this can't + * have any postfix operators + */ + re_concat_onto(ctx, &cur_machine, &new_machine); + break; + + case '(': + /* + * Add a nesting level. Push the current machine and + * alternate machines onto the group stack, and clear + * everything out for the new group. + */ + if (group_stack_level + > sizeof(group_stack)/sizeof(group_stack[0])) + { + /* we cannot proceed - return an error */ + return RE_STATUS_GROUP_NESTING_TOO_DEEP; + } - /* save the current state on the stack */ - group_stack[group_stack_level].old_cur = cur_machine; - group_stack[group_stack_level].old_alter = alter_machine; + /* save the current state on the stack */ + group_stack[group_stack_level].old_cur = cur_machine; + group_stack[group_stack_level].old_alter = alter_machine; - /* - * Assign the group a group ID - groups are numbered in - * order of their opening (left) parentheses, so we want to - * assign a group number now. We won't actually need to - * know the group number until we get to the matching close - * paren, but we need to assign it now, so store it in the - * group stack. - */ - group_stack[group_stack_level].group_id = ctx->cur_group; + /* + * Assign the group a group ID - groups are numbered in + * order of their opening (left) parentheses, so we want to + * assign a group number now. We won't actually need to + * know the group number until we get to the matching close + * paren, but we need to assign it now, so store it in the + * group stack. + */ + group_stack[group_stack_level].group_id = ctx->cur_group; - /* consume the group number */ - ctx->cur_group++; + /* consume the group number */ + ctx->cur_group++; - /* push the level */ - ++group_stack_level; + /* push the level */ + ++group_stack_level; - /* start the new group with empty machines */ - re_build_null_machine(ctx, &cur_machine); - re_build_null_machine(ctx, &alter_machine); - break; + /* start the new group with empty machines */ + re_build_null_machine(ctx, &cur_machine); + re_build_null_machine(ctx, &alter_machine); + break; - case ')': - /* if there's nothing on the stack, ignore this */ - if (group_stack_level == 0) - break; + case ')': + /* if there's nothing on the stack, ignore this */ + if (group_stack_level == 0) + break; - /* take a level off the stack */ - --group_stack_level; + /* take a level off the stack */ + --group_stack_level; - /* - * Remove a nesting level. If we have a pending alternate - * expression, build the alternation expression. This will - * leave the entire group expression in alter_machine, - * regardless of whether an alternation was in progress or - * not. - */ - re_alternate_onto(ctx, &alter_machine, &cur_machine); + /* + * Remove a nesting level. If we have a pending alternate + * expression, build the alternation expression. This will + * leave the entire group expression in alter_machine, + * regardless of whether an alternation was in progress or + * not. + */ + re_alternate_onto(ctx, &alter_machine, &cur_machine); - /* - * Create a group machine that encloses the group and marks - * it with a group number. We assigned the group number - * when we parsed the open paren, so read that group number - * from the stack. - * - * Note that this will leave 'new_machine' with the entire - * group machine. - */ - re_build_group(ctx, &new_machine, &alter_machine, - group_stack[group_stack_level].group_id); + /* + * Create a group machine that encloses the group and marks + * it with a group number. We assigned the group number + * when we parsed the open paren, so read that group number + * from the stack. + * + * Note that this will leave 'new_machine' with the entire + * group machine. + */ + re_build_group(ctx, &new_machine, &alter_machine, + group_stack[group_stack_level].group_id); - /* - * Pop the stack - restore the alternation and current - * machines that were in progress before the group started. - */ - cur_machine = group_stack[group_stack_level].old_cur; - alter_machine = group_stack[group_stack_level].old_alter; + /* + * Pop the stack - restore the alternation and current + * machines that were in progress before the group started. + */ + cur_machine = group_stack[group_stack_level].old_cur; + alter_machine = group_stack[group_stack_level].old_alter; - /* - * Check the group expression (in new_machine) for postfix - * expressions - */ - goto apply_postfix; + /* + * Check the group expression (in new_machine) for postfix + * expressions + */ + goto apply_postfix; - case '|': - /* - * Start a new alternation. This ends the current - * alternation; if we have a previous pending alternate, - * build an alternation machine out of the previous - * alternate and the current machine and move that to the - * alternate; otherwise, simply move the current machine to - * the pending alternate. - */ - re_alternate_onto(ctx, &alter_machine, &cur_machine); + case '|': + /* + * Start a new alternation. This ends the current + * alternation; if we have a previous pending alternate, + * build an alternation machine out of the previous + * alternate and the current machine and move that to the + * alternate; otherwise, simply move the current machine to + * the pending alternate. + */ + re_alternate_onto(ctx, &alter_machine, &cur_machine); - /* - * the alternation starts out with a blank slate, so null - * out the current machine - */ - re_build_null_machine(ctx, &cur_machine); - break; + /* + * the alternation starts out with a blank slate, so null + * out the current machine + */ + re_build_null_machine(ctx, &cur_machine); + break; - case '%': - /* - * quoted character - skip the quote mark and see what we - * have - */ - ++expr; - --exprlen; + case '%': + /* + * quoted character - skip the quote mark and see what we + * have + */ + ++expr; + --exprlen; - /* check to see if we're at the end of the expression */ - if (exprlen == 0) - { - /* - * end of the string - ignore it, but undo the extra - * increment of the expression index so that we exit the - * enclosing loop properly - */ - --expr; - ++exprlen; - break; - } + /* check to see if we're at the end of the expression */ + if (exprlen == 0) + { + /* + * end of the string - ignore it, but undo the extra + * increment of the expression index so that we exit the + * enclosing loop properly + */ + --expr; + ++exprlen; + break; + } - /* see what we have */ - switch(*expr) - { - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - /* group match - build a new literal group recognizer */ - re_build_group_matcher(ctx, &new_machine, (int)(*expr - '1')); + /* see what we have */ + switch(*expr) + { + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + /* group match - build a new literal group recognizer */ + re_build_group_matcher(ctx, &new_machine, (int)(*expr - '1')); - /* apply any postfix expression to the group recognizer */ - goto apply_postfix; + /* apply any postfix expression to the group recognizer */ + goto apply_postfix; - case '<': - /* build a beginning-of-word recognizer */ - re_build_char(ctx, &new_machine, RE_WORD_BEGIN); + case '<': + /* build a beginning-of-word recognizer */ + re_build_char(ctx, &new_machine, RE_WORD_BEGIN); - /* it can't be postfixed - just concatenate it */ - re_concat_onto(ctx, &cur_machine, &new_machine); - break; + /* it can't be postfixed - just concatenate it */ + re_concat_onto(ctx, &cur_machine, &new_machine); + break; - case '>': - /* build an end-of-word recognizer */ - re_build_char(ctx, &new_machine, RE_WORD_END); + case '>': + /* build an end-of-word recognizer */ + re_build_char(ctx, &new_machine, RE_WORD_END); - /* it can't be postfixed - just concatenate it */ - re_concat_onto(ctx, &cur_machine, &new_machine); - break; + /* it can't be postfixed - just concatenate it */ + re_concat_onto(ctx, &cur_machine, &new_machine); + break; - case 'w': - /* word character */ - re_build_char(ctx, &new_machine, RE_WORD_CHAR); - goto apply_postfix; + case 'w': + /* word character */ + re_build_char(ctx, &new_machine, RE_WORD_CHAR); + goto apply_postfix; - case 'W': - /* non-word character */ - re_build_char(ctx, &new_machine, RE_NON_WORD_CHAR); - goto apply_postfix; + case 'W': + /* non-word character */ + re_build_char(ctx, &new_machine, RE_NON_WORD_CHAR); + goto apply_postfix; - case 'b': - /* word boundary */ - re_build_char(ctx, &new_machine, RE_WORD_BOUNDARY); + case 'b': + /* word boundary */ + re_build_char(ctx, &new_machine, RE_WORD_BOUNDARY); - /* it can't be postfixed */ - re_concat_onto(ctx, &cur_machine, &new_machine); - break; + /* it can't be postfixed */ + re_concat_onto(ctx, &cur_machine, &new_machine); + break; - case 'B': - /* not a word boundary */ - re_build_char(ctx, &new_machine, RE_NON_WORD_BOUNDARY); + case 'B': + /* not a word boundary */ + re_build_char(ctx, &new_machine, RE_NON_WORD_BOUNDARY); - /* it can't be postfixed */ - re_concat_onto(ctx, &cur_machine, &new_machine); - break; + /* it can't be postfixed */ + re_concat_onto(ctx, &cur_machine, &new_machine); + break; - default: - /* build a new literal character recognizer */ - re_build_char(ctx, &new_machine, *expr); + default: + /* build a new literal character recognizer */ + re_build_char(ctx, &new_machine, *expr); - /* apply any postfix expression to the character */ - goto apply_postfix; - } - break; + /* apply any postfix expression to the character */ + goto apply_postfix; + } + break; - case '.': - /* - * wildcard character - build a single character recognizer - * for the special wildcard symbol, then go check it for a - * postfix operator - */ - re_build_char(ctx, &new_machine, RE_WILDCARD); - goto apply_postfix; - break; + case '.': + /* + * wildcard character - build a single character recognizer + * for the special wildcard symbol, then go check it for a + * postfix operator + */ + re_build_char(ctx, &new_machine, RE_WILDCARD); + goto apply_postfix; + break; - case '[': - /* range expression */ - { - int is_exclusive = FALSE; - unsigned char set[32]; + case '[': + /* range expression */ + { + int is_exclusive = FALSE; + unsigned char set[32]; - /* clear out the set of characters in the range */ - memset(set, 0, sizeof(set)); + /* clear out the set of characters in the range */ + memset(set, 0, sizeof(set)); - /* first, skip the open bracket */ - ++expr; - --exprlen; + /* first, skip the open bracket */ + ++expr; + --exprlen; - /* check to see if starts with the exclusion character */ - if (exprlen != 0 && *expr == '^') - { - /* skip the exclusion specifier */ - ++expr; - --exprlen; + /* check to see if starts with the exclusion character */ + if (exprlen != 0 && *expr == '^') + { + /* skip the exclusion specifier */ + ++expr; + --exprlen; - /* note it */ - is_exclusive = TRUE; - } + /* note it */ + is_exclusive = TRUE; + } - /* - * if the first character is a ']', include it in the - * range - */ - if (exprlen != 0 && *expr == ']') - { - re_set_bit(set, (int)']'); - ++expr; - --exprlen; - } + /* + * if the first character is a ']', include it in the + * range + */ + if (exprlen != 0 && *expr == ']') + { + re_set_bit(set, (int)']'); + ++expr; + --exprlen; + } - /* - * if the next character is a '-', include it in the - * range - */ - if (exprlen != 0 && *expr == '-') - { - re_set_bit(set, (int)'-'); - ++expr; - --exprlen; - } + /* + * if the next character is a '-', include it in the + * range + */ + if (exprlen != 0 && *expr == '-') + { + re_set_bit(set, (int)'-'); + ++expr; + --exprlen; + } - /* scan the character set */ - while (exprlen != 0 && *expr != ']') - { - int ch; - - /* note this character */ - ch = (int)(unsigned char)*expr; + /* scan the character set */ + while (exprlen != 0 && *expr != ']') + { + int ch; + + /* note this character */ + ch = (int)(unsigned char)*expr; - /* set it */ - re_set_bit(set, ch); + /* set it */ + re_set_bit(set, ch); - /* skip this character of the expression */ - ++expr; - --exprlen; + /* skip this character of the expression */ + ++expr; + --exprlen; - /* check for a range */ - if (exprlen != 0 && *expr == '-') - { - int ch2; - - /* skip the '-' */ - ++expr; - --exprlen; - if (exprlen != 0) - { - /* get the other end of the range */ - ch2 = (int)(unsigned char)*expr; + /* check for a range */ + if (exprlen != 0 && *expr == '-') + { + int ch2; + + /* skip the '-' */ + ++expr; + --exprlen; + if (exprlen != 0) + { + /* get the other end of the range */ + ch2 = (int)(unsigned char)*expr; - /* skip the second character */ - ++expr; - --exprlen; + /* skip the second character */ + ++expr; + --exprlen; - /* if the range is reversed, swap it */ - if (ch > ch2) - { - int tmp = ch; - ch = ch2; - ch2 = tmp; - } + /* if the range is reversed, swap it */ + if (ch > ch2) + { + int tmp = ch; + ch = ch2; + ch2 = tmp; + } - /* fill in the range */ - for ( ; ch <= ch2 ; ++ch) - re_set_bit(set, ch); - } - } - } + /* fill in the range */ + for ( ; ch <= ch2 ; ++ch) + re_set_bit(set, ch); + } + } + } - /* create a character range machine */ - re_build_char_range(ctx, &new_machine, set, is_exclusive); + /* create a character range machine */ + re_build_char_range(ctx, &new_machine, set, is_exclusive); - /* apply any postfix operator */ - goto apply_postfix; - } - break; + /* apply any postfix operator */ + goto apply_postfix; + } + break; - default: - normal_char: - /* - * it's an ordinary character - build a single character - * recognizer machine, and then concatenate it onto any - * existing machine - */ - re_build_char(ctx, &new_machine, *expr); + default: + normal_char: + /* + * it's an ordinary character - build a single character + * recognizer machine, and then concatenate it onto any + * existing machine + */ + re_build_char(ctx, &new_machine, *expr); - apply_postfix: - /* - * Check for a postfix operator, and apply it to the machine - * in 'new_machine' if present. In any case, concatenate - * the 'new_machine' (modified by a postix operator or not) - * to the current machien. - */ - if (exprlen > 1) - { - switch(*(expr+1)) - { - case '*': - case '+': - case '?': - /* - * We have a postfix closure operator. Build a new - * closure machine out of 'new_machine'. - */ - { - re_machine closure_machine; - - /* move onto the closure operator */ - ++expr; - --exprlen; - - /* build the closure machine */ - re_build_closure(ctx, &closure_machine, - &new_machine, *expr); - - /* replace the original machine with the closure */ - new_machine = closure_machine; - - /* - * skip any redundant closure symbols, keeping - * only the first one we saw - */ - while (exprlen > 1 && (*(expr+1) == '?' - || *(expr+1) == '+' - || *(expr+1) == '*')) - { - ++expr; - --exprlen; - } - } - break; - - default: - /* no postfix operator */ - break; - } - } + apply_postfix: + /* + * Check for a postfix operator, and apply it to the machine + * in 'new_machine' if present. In any case, concatenate + * the 'new_machine' (modified by a postix operator or not) + * to the current machien. + */ + if (exprlen > 1) + { + switch(*(expr+1)) + { + case '*': + case '+': + case '?': + /* + * We have a postfix closure operator. Build a new + * closure machine out of 'new_machine'. + */ + { + re_machine closure_machine; + + /* move onto the closure operator */ + ++expr; + --exprlen; + + /* build the closure machine */ + re_build_closure(ctx, &closure_machine, + &new_machine, *expr); + + /* replace the original machine with the closure */ + new_machine = closure_machine; + + /* + * skip any redundant closure symbols, keeping + * only the first one we saw + */ + while (exprlen > 1 && (*(expr+1) == '?' + || *(expr+1) == '+' + || *(expr+1) == '*')) + { + ++expr; + --exprlen; + } + } + break; + + default: + /* no postfix operator */ + break; + } + } - /* - * Concatenate the new machine onto the current machine - * under construction. - */ - re_concat_onto(ctx, &cur_machine, &new_machine); - break; - } - } + /* + * Concatenate the new machine onto the current machine + * under construction. + */ + re_concat_onto(ctx, &cur_machine, &new_machine); + break; + } + } - /* complete any pending alternation */ - re_alternate_onto(ctx, &alter_machine, &cur_machine); + /* complete any pending alternation */ + re_alternate_onto(ctx, &alter_machine, &cur_machine); - /* store the resulting machine in the caller's machine descriptor */ - *result_machine = alter_machine; + /* store the resulting machine in the caller's machine descriptor */ + *result_machine = alter_machine; - /* no errors encountered */ - return RE_STATUS_SUCCESS; + /* no errors encountered */ + return RE_STATUS_SUCCESS; } @@ -1073,27 +1073,27 @@ static re_status_t re_compile(re_context *ctx, * Note a group position if appropriate */ static void re_note_group(re_context *ctx, re_group_register *regs, - re_state_id id, const char *p) + re_state_id id, const char *p) { - int group_index; + int group_index; - /* - * Check to see if this is a valid state and it's a group marker - - * if not, there's nothing to do - */ - if (id == RE_STATE_INVALID - || !(ctx->tuple_arr[id].flags - & (RE_STATE_GROUP_BEGIN | RE_STATE_GROUP_END)) - || (group_index = (int)ctx->tuple_arr[id].ch) >= RE_GROUP_REG_CNT) - return; + /* + * Check to see if this is a valid state and it's a group marker - + * if not, there's nothing to do + */ + if (id == RE_STATE_INVALID + || !(ctx->tuple_arr[id].flags + & (RE_STATE_GROUP_BEGIN | RE_STATE_GROUP_END)) + || (group_index = (int)ctx->tuple_arr[id].ch) >= RE_GROUP_REG_CNT) + return; - /* - * It's a valid group marker - note the appropriate register value - */ - if ((ctx->tuple_arr[id].flags & RE_STATE_GROUP_BEGIN) != 0) - regs[group_index].start_ofs = p; - else - regs[group_index].end_ofs = p; + /* + * It's a valid group marker - note the appropriate register value + */ + if ((ctx->tuple_arr[id].flags & RE_STATE_GROUP_BEGIN) != 0) + regs[group_index].start_ofs = p; + else + regs[group_index].end_ofs = p; } /* @@ -1109,335 +1109,335 @@ static int re_is_word_char(char c) { * match if successful, or -1 if no match was found. */ static int re_match(re_context *ctx, const char *entire_str, - const char *str, size_t origlen, - const re_machine *machine, re_group_register *regs) + const char *str, size_t origlen, + const re_machine *machine, re_group_register *regs) { - re_state_id cur_state; - const char *p; - size_t curlen; + re_state_id cur_state; + const char *p; + size_t curlen; - /* start at the machine's initial state */ - cur_state = machine->init; + /* start at the machine's initial state */ + cur_state = machine->init; - /* start at the beginning of the string */ - p = str; - curlen = origlen; + /* start at the beginning of the string */ + p = str; + curlen = origlen; - /* note any group involved in the initial state */ - re_note_group(ctx, regs, cur_state, p); + /* note any group involved in the initial state */ + re_note_group(ctx, regs, cur_state, p); - /* - * if we're starting in the final state, immediately return success - * with a zero-length match - */ - if (cur_state == machine->final_state) - { - /* return success with a zero-length match */ - return 0; - } + /* + * if we're starting in the final state, immediately return success + * with a zero-length match + */ + if (cur_state == machine->final_state) + { + /* return success with a zero-length match */ + return 0; + } - /* run the machine */ - for (;;) - { - re_tuple *tuple; + /* run the machine */ + for (;;) + { + re_tuple *tuple; - /* get the tuple for this state */ - tuple = &ctx->tuple_arr[cur_state]; + /* get the tuple for this state */ + tuple = &ctx->tuple_arr[cur_state]; - /* if this is a group state, adjust the group registers */ - re_note_group(ctx, regs, cur_state, p); - - /* see what kind of state we're in */ - if (!(tuple->flags & (RE_STATE_GROUP_BEGIN | RE_STATE_GROUP_END)) - && tuple->ch != RE_EPSILON) - { - /* - * This is a character or group recognizer state. If we - * match the character or group, continue on to the next - * state; otherwise, return failure. - */ - switch(tuple->ch) - { - case RE_GROUP_MATCH_0: - case RE_GROUP_MATCH_0 + 1: - case RE_GROUP_MATCH_0 + 2: - case RE_GROUP_MATCH_0 + 3: - case RE_GROUP_MATCH_0 + 4: - case RE_GROUP_MATCH_0 + 5: - case RE_GROUP_MATCH_0 + 6: - case RE_GROUP_MATCH_0 + 7: - case RE_GROUP_MATCH_0 + 8: - case RE_GROUP_MATCH_0 + 9: - { - int group_num; - re_group_register *group_reg; - size_t reg_len; - - /* it's a group - get the group number */ - group_num = tuple->ch - RE_GROUP_MATCH_0; - group_reg = ®s[group_num]; - - /* - * if this register isn't defined, there's nothing - * to match, so fail - */ - if (group_reg->start_ofs == 0 || group_reg->end_ofs == 0) - return -1; - - /* calculate the length of the register value */ - reg_len = group_reg->end_ofs - group_reg->start_ofs; - - /* if we don't have enough left to match, it fails */ - if (curlen < reg_len) - return -1; - - /* if the string doesn't match exactly, we fail */ - if (memcmp(p, group_reg->start_ofs, reg_len) != 0) - return -1; - - /* - * It matches exactly - skip the entire length of - * the register in the source string - */ - p += reg_len; - curlen -= reg_len; - } - break; + /* if this is a group state, adjust the group registers */ + re_note_group(ctx, regs, cur_state, p); + + /* see what kind of state we're in */ + if (!(tuple->flags & (RE_STATE_GROUP_BEGIN | RE_STATE_GROUP_END)) + && tuple->ch != RE_EPSILON) + { + /* + * This is a character or group recognizer state. If we + * match the character or group, continue on to the next + * state; otherwise, return failure. + */ + switch(tuple->ch) + { + case RE_GROUP_MATCH_0: + case RE_GROUP_MATCH_0 + 1: + case RE_GROUP_MATCH_0 + 2: + case RE_GROUP_MATCH_0 + 3: + case RE_GROUP_MATCH_0 + 4: + case RE_GROUP_MATCH_0 + 5: + case RE_GROUP_MATCH_0 + 6: + case RE_GROUP_MATCH_0 + 7: + case RE_GROUP_MATCH_0 + 8: + case RE_GROUP_MATCH_0 + 9: + { + int group_num; + re_group_register *group_reg; + size_t reg_len; + + /* it's a group - get the group number */ + group_num = tuple->ch - RE_GROUP_MATCH_0; + group_reg = ®s[group_num]; + + /* + * if this register isn't defined, there's nothing + * to match, so fail + */ + if (group_reg->start_ofs == 0 || group_reg->end_ofs == 0) + return -1; + + /* calculate the length of the register value */ + reg_len = group_reg->end_ofs - group_reg->start_ofs; + + /* if we don't have enough left to match, it fails */ + if (curlen < reg_len) + return -1; + + /* if the string doesn't match exactly, we fail */ + if (memcmp(p, group_reg->start_ofs, reg_len) != 0) + return -1; + + /* + * It matches exactly - skip the entire length of + * the register in the source string + */ + p += reg_len; + curlen -= reg_len; + } + break; - case RE_TEXT_BEGIN: - /* - * Match only the exact beginning of the string - if - * we're anywhere else, this isn't a match. If this - * succeeds, we don't skip any characters. - */ - if (p != entire_str) - return -1; - break; + case RE_TEXT_BEGIN: + /* + * Match only the exact beginning of the string - if + * we're anywhere else, this isn't a match. If this + * succeeds, we don't skip any characters. + */ + if (p != entire_str) + return -1; + break; - case RE_TEXT_END: - /* - * Match only the exact end of the string - if we're - * anywhere else, this isn't a match. Don't skip any - * characters on success. - */ - if (curlen != 0) - return -1; - break; + case RE_TEXT_END: + /* + * Match only the exact end of the string - if we're + * anywhere else, this isn't a match. Don't skip any + * characters on success. + */ + if (curlen != 0) + return -1; + break; - case RE_WORD_BEGIN: - /* - * if the previous character is a word character, we're - * not at the beginning of a word - */ - if (p != entire_str && re_is_word_char(*(p-1))) - return -1; + case RE_WORD_BEGIN: + /* + * if the previous character is a word character, we're + * not at the beginning of a word + */ + if (p != entire_str && re_is_word_char(*(p-1))) + return -1; - /* - * if we're at the end of the string, or the current - * character isn't the start of a word, we're not at the - * beginning of a word - */ - if (curlen == 0 || !re_is_word_char(*p)) - return -1; - break; + /* + * if we're at the end of the string, or the current + * character isn't the start of a word, we're not at the + * beginning of a word + */ + if (curlen == 0 || !re_is_word_char(*p)) + return -1; + break; - case RE_WORD_END: - /* - * if the current character is a word character, we're not - * at the end of a word - */ - if (curlen != 0 && re_is_word_char(*p)) - return -1; + case RE_WORD_END: + /* + * if the current character is a word character, we're not + * at the end of a word + */ + if (curlen != 0 && re_is_word_char(*p)) + return -1; - /* - * if we're at the beginning of the string, or the - * previous character is not a word character, we're not - * at the end of a word - */ - if (p == entire_str || !re_is_word_char(*(p-1))) - return -1; - break; + /* + * if we're at the beginning of the string, or the + * previous character is not a word character, we're not + * at the end of a word + */ + if (p == entire_str || !re_is_word_char(*(p-1))) + return -1; + break; - case RE_WORD_CHAR: - /* if it's not a word character, it's a failure */ - if (curlen == 0 || !re_is_word_char(*p)) - return -1; + case RE_WORD_CHAR: + /* if it's not a word character, it's a failure */ + if (curlen == 0 || !re_is_word_char(*p)) + return -1; - /* skip this character of input */ - ++p; - --curlen; - break; + /* skip this character of input */ + ++p; + --curlen; + break; - case RE_NON_WORD_CHAR: - /* if it's a word character, it's a failure */ - if (curlen == 0 || re_is_word_char(*p)) - return -1; + case RE_NON_WORD_CHAR: + /* if it's a word character, it's a failure */ + if (curlen == 0 || re_is_word_char(*p)) + return -1; - /* skip the input */ - ++p; - --curlen; - break; + /* skip the input */ + ++p; + --curlen; + break; - case RE_WORD_BOUNDARY: - case RE_NON_WORD_BOUNDARY: - { - int prev_is_word; - int next_is_word; - int boundary; + case RE_WORD_BOUNDARY: + case RE_NON_WORD_BOUNDARY: + { + int prev_is_word; + int next_is_word; + int boundary; - /* - * Determine if the previous character is a word - * character -- if we're at the beginning of the - * string, it's obviously not, otherwise check its - * classification - */ - prev_is_word = (p != entire_str - && re_is_word_char(*(p-1))); + /* + * Determine if the previous character is a word + * character -- if we're at the beginning of the + * string, it's obviously not, otherwise check its + * classification + */ + prev_is_word = (p != entire_str + && re_is_word_char(*(p-1))); - /* make the same check for the current character */ - next_is_word = (curlen != 0 - && re_is_word_char(*p)); + /* make the same check for the current character */ + next_is_word = (curlen != 0 + && re_is_word_char(*p)); - /* - * Determine if this is a boundary - it is if the - * two states are different - */ - boundary = ((prev_is_word != 0) ^ (next_is_word != 0)); + /* + * Determine if this is a boundary - it is if the + * two states are different + */ + boundary = ((prev_is_word != 0) ^ (next_is_word != 0)); - /* - * make sure it matches what was desired, and return - * failure if not - */ - if ((tuple->ch == RE_WORD_BOUNDARY && !boundary) - || (tuple->ch == RE_NON_WORD_BOUNDARY && boundary)) - return -1; - } - break; + /* + * make sure it matches what was desired, and return + * failure if not + */ + if ((tuple->ch == RE_WORD_BOUNDARY && !boundary) + || (tuple->ch == RE_NON_WORD_BOUNDARY && boundary)) + return -1; + } + break; - case RE_WILDCARD: - /* make sure we have a character to match */ - if (curlen == 0) - return -1; + case RE_WILDCARD: + /* make sure we have a character to match */ + if (curlen == 0) + return -1; - /* skip this character */ - ++p; - --curlen; - break; + /* skip this character */ + ++p; + --curlen; + break; - case RE_RANGE: - case RE_RANGE_EXCL: - { - int match; - - /* make sure we have a character to match */ - if (curlen == 0) - return -1; - - /* see if we match */ - match = re_is_bit_set(tuple->char_range, - (int)(unsigned char)*p); - - /* make sure we got what we wanted */ - if ((tuple->ch == RE_RANGE && !match) - || (tuple->ch == RE_RANGE_EXCL && match)) - return -1; + case RE_RANGE: + case RE_RANGE_EXCL: + { + int match; + + /* make sure we have a character to match */ + if (curlen == 0) + return -1; + + /* see if we match */ + match = re_is_bit_set(tuple->char_range, + (int)(unsigned char)*p); + + /* make sure we got what we wanted */ + if ((tuple->ch == RE_RANGE && !match) + || (tuple->ch == RE_RANGE_EXCL && match)) + return -1; - /* skip this character of the input */ - ++p; - --curlen; - } - break; + /* skip this character of the input */ + ++p; + --curlen; + } + break; - default: - /* make sure we have an exact match */ - if (curlen == 0 || tuple->ch != *p) - return -1; + default: + /* make sure we have an exact match */ + if (curlen == 0 || tuple->ch != *p) + return -1; - /* skip this character of the input */ - ++p; - --curlen; - break; - } + /* skip this character of the input */ + ++p; + --curlen; + break; + } - /* - * if we got this far, we were successful - move on to the - * next state - */ - cur_state = tuple->next_state_1; - } - else if (tuple->next_state_2 == RE_STATE_INVALID) - { - /* - * We have only one transition, so this state is entirely - * deterministic. Simply move on to the next state. - */ - cur_state = tuple->next_state_1; - } - else - { - re_machine sub_machine; - re_group_register regs1[RE_GROUP_REG_CNT]; - re_group_register regs2[RE_GROUP_REG_CNT]; - int ret1; - int ret2; - - /* - * This state has two possible transitions, and we don't - * know which one to take. So, try both, see which one - * works better, and return the result. Try the first - * transition first. Note that each separate attempt must - * use a separate copy of the registers. - */ - memcpy(regs1, regs, sizeof(regs1)); - sub_machine.init = tuple->next_state_1; - sub_machine.final_state = machine->final_state; - ret1 = re_match(ctx, entire_str, p, curlen, &sub_machine, regs1); + /* + * if we got this far, we were successful - move on to the + * next state + */ + cur_state = tuple->next_state_1; + } + else if (tuple->next_state_2 == RE_STATE_INVALID) + { + /* + * We have only one transition, so this state is entirely + * deterministic. Simply move on to the next state. + */ + cur_state = tuple->next_state_1; + } + else + { + re_machine sub_machine; + re_group_register regs1[RE_GROUP_REG_CNT]; + re_group_register regs2[RE_GROUP_REG_CNT]; + int ret1; + int ret2; + + /* + * This state has two possible transitions, and we don't + * know which one to take. So, try both, see which one + * works better, and return the result. Try the first + * transition first. Note that each separate attempt must + * use a separate copy of the registers. + */ + memcpy(regs1, regs, sizeof(regs1)); + sub_machine.init = tuple->next_state_1; + sub_machine.final_state = machine->final_state; + ret1 = re_match(ctx, entire_str, p, curlen, &sub_machine, regs1); - /* - * Now try the second transition - */ - memcpy(regs2, regs, sizeof(regs2)); - sub_machine.init = tuple->next_state_2; - sub_machine.final_state = machine->final_state; - ret2 = re_match(ctx, entire_str, p, curlen, &sub_machine, regs2); + /* + * Now try the second transition + */ + memcpy(regs2, regs, sizeof(regs2)); + sub_machine.init = tuple->next_state_2; + sub_machine.final_state = machine->final_state; + ret2 = re_match(ctx, entire_str, p, curlen, &sub_machine, regs2); - /* - * If they both failed, the whole thing failed. Otherwise, - * return the longer of the two, plus the length we - * ourselves matched previously. Note that we return the - * register set from the winning match. - */ - if (ret1 < 0 && ret2 < 0) - { - /* they both failed */ - return -1; - } - else if (ret1 > ret2) - { - /* use the first register set and result length */ - memcpy(regs, regs1, sizeof(regs1)); - return ret1 + (p - str); - } - else - { - /* use the second register set and result length */ - memcpy(regs, regs2, sizeof(regs2)); - return ret2 + (p - str); - } - } + /* + * If they both failed, the whole thing failed. Otherwise, + * return the longer of the two, plus the length we + * ourselves matched previously. Note that we return the + * register set from the winning match. + */ + if (ret1 < 0 && ret2 < 0) + { + /* they both failed */ + return -1; + } + else if (ret1 > ret2) + { + /* use the first register set and result length */ + memcpy(regs, regs1, sizeof(regs1)); + return ret1 + (p - str); + } + else + { + /* use the second register set and result length */ + memcpy(regs, regs2, sizeof(regs2)); + return ret2 + (p - str); + } + } - /* - * If we're in the final state, return success - */ - if (cur_state == machine->final_state) - { - /* finish off any group involved in the final state */ - re_note_group(ctx, regs, cur_state, p); - - /* return the length we matched */ - return p - str; - } - } + /* + * If we're in the final state, return success + */ + if (cur_state == machine->final_state) + { + /* finish off any group involved in the final state */ + re_note_group(ctx, regs, cur_state, p); + + /* return the length we matched */ + return p - str; + } + } } /* ------------------------------------------------------------------------ */ @@ -1448,33 +1448,33 @@ static int re_match(re_context *ctx, const char *entire_str, * pattern. */ static int re_search(re_context *ctx, const char *str, size_t len, - const re_machine *machine, re_group_register *regs, - int *result_len) + const re_machine *machine, re_group_register *regs, + int *result_len) { - int ofs; - - /* - * Starting at the first character in the string, search for the - * pattern at each subsequent character until we either find the - * pattern or run out of string to test. - */ - for (ofs = 0 ; ofs < (int)len ; ++ofs) - { - int matchlen; - - /* check for a match */ - matchlen = re_match(ctx, str, str + ofs, len - ofs, - machine, regs); - if (matchlen >= 0) - { - /* we found a match here - return the length and offset */ - *result_len = matchlen; - return ofs; - } - } + int ofs; + + /* + * Starting at the first character in the string, search for the + * pattern at each subsequent character until we either find the + * pattern or run out of string to test. + */ + for (ofs = 0 ; ofs < (int)len ; ++ofs) + { + int matchlen; + + /* check for a match */ + matchlen = re_match(ctx, str, str + ofs, len - ofs, + machine, regs); + if (matchlen >= 0) + { + /* we found a match here - return the length and offset */ + *result_len = matchlen; + return ofs; + } + } - /* we didn't find a match */ - return -1; + /* we didn't find a match */ + return -1; } /* ------------------------------------------------------------------------ */ @@ -1483,42 +1483,42 @@ static int re_search(re_context *ctx, const char *str, size_t len, */ static void re_save_search_str(re_context *ctx, const char *str, size_t len) { - /* if the string is empty, this is easy */ - if (len == 0) - { - /* nothing to store - just save the length and return */ - ctx->curlen = 0; - return; - } - - /* if the current buffer isn't big enough, allocate a new one */ - if (ctx->strbuf == 0 || ctx->strbufsiz < len) - { - /* - * free any previous buffer - its contents are no longer - * important, since we're about to overwrite it with a new - * string - */ - if (ctx->strbuf != 0) - mchfre(ctx->strbuf); + /* if the string is empty, this is easy */ + if (len == 0) + { + /* nothing to store - just save the length and return */ + ctx->curlen = 0; + return; + } + + /* if the current buffer isn't big enough, allocate a new one */ + if (ctx->strbuf == 0 || ctx->strbufsiz < len) + { + /* + * free any previous buffer - its contents are no longer + * important, since we're about to overwrite it with a new + * string + */ + if (ctx->strbuf != 0) + mchfre(ctx->strbuf); - /* - * allocate a new buffer; round up to the next 256-byte - * increment to make sure we're not constantly reallocating to - * random sizes - */ - ctx->strbufsiz = ((len + 255) & ~255); + /* + * allocate a new buffer; round up to the next 256-byte + * increment to make sure we're not constantly reallocating to + * random sizes + */ + ctx->strbufsiz = ((len + 255) & ~255); - /* allocate it */ - ctx->strbuf = (char *)mchalo(ctx->errctx, ctx->strbufsiz, - "regex str"); - } + /* allocate it */ + ctx->strbuf = (char *)mchalo(ctx->errctx, ctx->strbufsiz, + "regex str"); + } - /* copy the string */ - memcpy(ctx->strbuf, str, len); + /* copy the string */ + memcpy(ctx->strbuf, str, len); - /* save the length */ - ctx->curlen = len; + /* save the length */ + ctx->curlen = len; } /* ------------------------------------------------------------------------ */ @@ -1527,31 +1527,31 @@ static void re_save_search_str(re_context *ctx, const char *str, size_t len) * Returns the offset of the match, or -1 if no match was found. */ int re_compile_and_search(re_context *ctx, - const char *pattern, size_t patlen, - const char *searchstr, size_t searchlen, - int *result_len) + const char *pattern, size_t patlen, + const char *searchstr, size_t searchlen, + int *result_len) { - re_machine machine; - - /* compile the expression - return failure if we get an error */ - if (re_compile(ctx, pattern, patlen, &machine) != RE_STATUS_SUCCESS) - return -1; + re_machine machine; + + /* compile the expression - return failure if we get an error */ + if (re_compile(ctx, pattern, patlen, &machine) != RE_STATUS_SUCCESS) + return -1; - /* save the search string in our internal buffer */ - re_save_search_str(ctx, searchstr, searchlen); + /* save the search string in our internal buffer */ + re_save_search_str(ctx, searchstr, searchlen); - /* clear the group registers */ - for (uint i = 0; i < ARRAYSIZE(ctx->regs); i++) { - ctx->regs[i].clear(); - } + /* clear the group registers */ + for (uint i = 0; i < ARRAYSIZE(ctx->regs); i++) { + ctx->regs[i].clear(); + } - /* - * search for the pattern in our copy of the string - use the copy - * so that the group registers stay valid even if the caller - * deallocates the original string after we return - */ - return re_search(ctx, ctx->strbuf, ctx->curlen, &machine, - ctx->regs, result_len); + /* + * search for the pattern in our copy of the string - use the copy + * so that the group registers stay valid even if the caller + * deallocates the original string after we return + */ + return re_search(ctx, ctx->strbuf, ctx->curlen, &machine, + ctx->regs, result_len); } /* ------------------------------------------------------------------------ */ @@ -1562,26 +1562,26 @@ int re_compile_and_search(re_context *ctx, * string to the given pattern. */ int re_compile_and_match(re_context *ctx, - const char *pattern, size_t patlen, - const char *searchstr, size_t searchlen) + const char *pattern, size_t patlen, + const char *searchstr, size_t searchlen) { - re_machine machine; + re_machine machine; - /* compile the expression - return failure if we get an error */ - if (re_compile(ctx, pattern, patlen, &machine) != RE_STATUS_SUCCESS) - return FALSE; + /* compile the expression - return failure if we get an error */ + if (re_compile(ctx, pattern, patlen, &machine) != RE_STATUS_SUCCESS) + return FALSE; - /* save the search string in our internal buffer */ - re_save_search_str(ctx, searchstr, searchlen); + /* save the search string in our internal buffer */ + re_save_search_str(ctx, searchstr, searchlen); - /* clear the group registers */ - for (uint i = 0; i < ARRAYSIZE(ctx->regs); i++) { - ctx->regs[i].clear(); - } + /* clear the group registers */ + for (uint i = 0; i < ARRAYSIZE(ctx->regs); i++) { + ctx->regs[i].clear(); + } - /* match the string */ - return re_match(ctx, ctx->strbuf, ctx->strbuf, ctx->curlen, - &machine, ctx->regs); + /* match the string */ + return re_match(ctx, ctx->strbuf, ctx->strbuf, ctx->curlen, + &machine, ctx->regs); } diff --git a/engines/glk/tads/tads2/regex.h b/engines/glk/tads/tads2/regex.h index 71ed99cd22e..7fcf3a49ce2 100644 --- a/engines/glk/tads/tads2/regex.h +++ b/engines/glk/tads/tads2/regex.h @@ -48,15 +48,15 @@ typedef int re_state_id; */ typedef struct _re_group_register { - const char *start_ofs; - const char *end_ofs; + const char *start_ofs; + const char *end_ofs; - _re_group_register() : start_ofs(nullptr), end_ofs(nullptr) {} + _re_group_register() : start_ofs(nullptr), end_ofs(nullptr) {} - void clear() { - start_ofs = nullptr; - end_ofs = nullptr; - } + void clear() { + start_ofs = nullptr; + end_ofs = nullptr; + } } re_group_register; /* number of group registers we keep */ @@ -73,18 +73,18 @@ typedef struct _re_group_register */ typedef struct { - /* the character we must match to transition to the target state */ - char ch; + /* the character we must match to transition to the target state */ + char ch; - /* the target states */ - re_state_id next_state_1; - re_state_id next_state_2; + /* the target states */ + re_state_id next_state_1; + re_state_id next_state_2; - /* character range match table, if used */ - unsigned char *char_range; + /* character range match table, if used */ + unsigned char *char_range; - /* flags */ - unsigned char flags; + /* flags */ + unsigned char flags; } re_tuple; @@ -107,43 +107,43 @@ typedef struct */ typedef struct _re_context { - /* error context */ - errcxdef *errctx; + /* error context */ + errcxdef *errctx; - /* next available state ID */ - re_state_id next_state; + /* next available state ID */ + re_state_id next_state; - /* - * The array of transition tuples. We'll allocate this array and - * expand it as necessary. - */ - re_tuple *tuple_arr; + /* + * The array of transition tuples. We'll allocate this array and + * expand it as necessary. + */ + re_tuple *tuple_arr; - /* number of transition tuples allocated in the array */ - int tuples_alloc; + /* number of transition tuples allocated in the array */ + int tuples_alloc; - /* current group ID */ - int cur_group; + /* current group ID */ + int cur_group; - /* group registers */ - re_group_register regs[RE_GROUP_REG_CNT]; + /* group registers */ + re_group_register regs[RE_GROUP_REG_CNT]; - /* - * Buffer for retaining a copy of the last string we scanned. We - * retain our own copy of each string, and point the group registers - * into this copy rather than the caller's original string -- this - * ensures that the group registers remain valid even after the - * caller has deallocated the original string. - */ - char *strbuf; + /* + * Buffer for retaining a copy of the last string we scanned. We + * retain our own copy of each string, and point the group registers + * into this copy rather than the caller's original string -- this + * ensures that the group registers remain valid even after the + * caller has deallocated the original string. + */ + char *strbuf; - /* length of the string currently in the buffer */ - size_t curlen; + /* length of the string currently in the buffer */ + size_t curlen; - /* size of the buffer allocated to strbuf */ - size_t strbufsiz; + /* size of the buffer allocated to strbuf */ + size_t strbufsiz; - _re_context() : errctx(nullptr), next_state(0), tuple_arr(nullptr), tuples_alloc(0), cur_group(0), strbuf(nullptr), curlen(0), strbufsiz(0) {} + _re_context() : errctx(nullptr), next_state(0), tuple_arr(nullptr), tuples_alloc(0), cur_group(0), strbuf(nullptr), curlen(0), strbufsiz(0) {} } re_context; @@ -153,11 +153,11 @@ typedef struct _re_context */ typedef enum { - /* success */ - RE_STATUS_SUCCESS = 0, + /* success */ + RE_STATUS_SUCCESS = 0, - /* compilation error - group nesting too deep */ - RE_STATUS_GROUP_NESTING_TOO_DEEP + /* compilation error - group nesting too deep */ + RE_STATUS_GROUP_NESTING_TOO_DEEP } re_status_t; @@ -179,9 +179,9 @@ void re_delete(re_context *ctx); * Returns the offset of the match, or -1 if no match was found. */ int re_compile_and_search(re_context *ctx, - const char *pattern, size_t patlen, - const char *searchstr, size_t searchlen, - int *result_len); + const char *pattern, size_t patlen, + const char *searchstr, size_t searchlen, + int *result_len); /* * Compile an expression and check for a match. Returns the length of @@ -190,8 +190,8 @@ int re_compile_and_search(re_context *ctx, * string to the given pattern. */ int re_compile_and_match(re_context *ctx, - const char *pattern, size_t patlen, - const char *searchstr, size_t searchlen); + const char *pattern, size_t patlen, + const char *searchstr, size_t searchlen); } // End of namespace TADS2 } // End of namespace TADS diff --git a/engines/glk/tads/tads2/run.cpp b/engines/glk/tads/tads2/run.cpp index 03fd80a5017..5ff02b283ff 100644 --- a/engines/glk/tads/tads2/run.cpp +++ b/engines/glk/tads/tads2/run.cpp @@ -243,8 +243,8 @@ void runhcmp(runcxdef *ctx, uint siz, uint below, /* check the explicitly referenced value pointers as well */ #define CHECK_VAL(val) \ - if (val && val->runsv.runsvstr == hp) \ - ref = TRUE, val->runsv.runsvstr = dst; + if (val && val->runsv.runsvstr == hp) \ + ref = TRUE, val->runsv.runsvstr = dst; CHECK_VAL(val1); CHECK_VAL(val2); CHECK_VAL(val3); diff --git a/engines/glk/tads/tads2/run.h b/engines/glk/tads/tads2/run.h index 8b7c5905fca..3f45c087252 100644 --- a/engines/glk/tads/tads2/run.h +++ b/engines/glk/tads/tads2/run.h @@ -51,12 +51,12 @@ struct bifcxdef; /* stack element - the stack is an array of these structures */ struct runsdef { - uchar runstyp; /* type of element */ - union { - long runsvnum; /* numeric value */ - objnum runsvobj; /* object value */ - prpnum runsvprp; /* property number value */ - uchar *runsvstr; /* string/list value */ + uchar runstyp; /* type of element */ + union { + long runsvnum; /* numeric value */ + objnum runsvobj; /* object value */ + prpnum runsvprp; /* property number value */ + uchar *runsvstr; /* string/list value */ } runsv; runsdef() : runstyp(0) { @@ -66,56 +66,56 @@ struct runsdef { /* external function control structure */ struct runxdef { - char runxnam[TOKNAMMAX + 1]; /* name of external function */ - int (*runxptr)(void *); /* pointer to memory containing code */ + char runxnam[TOKNAMMAX + 1]; /* name of external function */ + int (*runxptr)(void *); /* pointer to memory containing code */ }; /* external function context structure - passed to user exits */ struct runuxdef { - struct runcxdef osfar_t *runuxctx; /* run-time context */ - struct runufdef osfar_t *runuxvec; /* vector of functions */ - int runuxargc; /* count of arguments to function */ + struct runcxdef osfar_t *runuxctx; /* run-time context */ + struct runufdef osfar_t *runuxvec; /* vector of functions */ + int runuxargc; /* count of arguments to function */ }; /* external function callback vector */ struct runufdef { - int (osfar_t *runuftyp)(runuxdef *); /* type of top of stack */ - long (osfar_t *runufnpo)(runuxdef *); /* pop a number */ - uchar *(osfar_t *runufspo)(runuxdef *); /* pop a string */ - void (osfar_t *runufdsc)(runuxdef *); /* discard item at top of stack */ - void (osfar_t *runufnpu)(runuxdef *, long); /* push a number */ - void (osfar_t *runufspu)(runuxdef *, uchar *); /* push alloc'd string */ - void (osfar_t *runufcspu)(runuxdef *, char *); /* push a C-string */ - uchar *(osfar_t *runufsal)(runuxdef *, int); /* allocate a new string */ - void (osfar_t *runuflpu)(runuxdef *, int);/* push DAT_TRUE or DAT_NIL */ + int (osfar_t *runuftyp)(runuxdef *); /* type of top of stack */ + long (osfar_t *runufnpo)(runuxdef *); /* pop a number */ + uchar *(osfar_t *runufspo)(runuxdef *); /* pop a string */ + void (osfar_t *runufdsc)(runuxdef *); /* discard item at top of stack */ + void (osfar_t *runufnpu)(runuxdef *, long); /* push a number */ + void (osfar_t *runufspu)(runuxdef *, uchar *); /* push alloc'd string */ + void (osfar_t *runufcspu)(runuxdef *, char *); /* push a C-string */ + uchar *(osfar_t *runufsal)(runuxdef *, int); /* allocate a new string */ + void (osfar_t *runuflpu)(runuxdef *, int);/* push DAT_TRUE or DAT_NIL */ }; /* execution context */ struct runcxdef { - errcxdef *runcxerr; /* error management context */ - mcmcxdef *runcxmem; /* cache manager context for object references */ - runsdef *runcxstk; /* base of interpreter stack */ - runsdef *runcxstop; /* top of stack */ - runsdef *runcxsp; /* current stack pointer (stack grows upwards) */ - runsdef *runcxbp; /* base pointer */ - uchar *runcxheap; /* run-time variable-length object heap */ - uchar *runcxhp; /* current heap pointer */ - uchar *runcxhtop; /* top of heap */ - objucxdef *runcxundo; /* undo context */ - tiocxdef *runcxtio; /* text I/O context */ - void *runcxbcx; /* context for built-in callback functions */ - void (**runcxbi)(struct bifcxdef *ctx, int argc); - /* built-in functions */ - struct dbgcxdef *runcxdbg; /* debugger context */ - struct voccxdef *runcxvoc; /* player command parser context */ - void (*runcxdmd)(void *ctx, objnum obj, prpnum prp); - /* demand-loader callback function */ - void *runcxdmc; /* demand-loader callback context */ - runxdef *runcxext; /* external function array */ - int runcxexc; /* count of external functions */ - uint runcxlofs; /* offset of last line record encountered */ - char *runcxgamename; /* name of the .GAM file */ - char *runcxgamepath; /* absolute directory path of .GAM file */ + errcxdef *runcxerr; /* error management context */ + mcmcxdef *runcxmem; /* cache manager context for object references */ + runsdef *runcxstk; /* base of interpreter stack */ + runsdef *runcxstop; /* top of stack */ + runsdef *runcxsp; /* current stack pointer (stack grows upwards) */ + runsdef *runcxbp; /* base pointer */ + uchar *runcxheap; /* run-time variable-length object heap */ + uchar *runcxhp; /* current heap pointer */ + uchar *runcxhtop; /* top of heap */ + objucxdef *runcxundo; /* undo context */ + tiocxdef *runcxtio; /* text I/O context */ + void *runcxbcx; /* context for built-in callback functions */ + void (**runcxbi)(struct bifcxdef *ctx, int argc); + /* built-in functions */ + struct dbgcxdef *runcxdbg; /* debugger context */ + struct voccxdef *runcxvoc; /* player command parser context */ + void (*runcxdmd)(void *ctx, objnum obj, prpnum prp); + /* demand-loader callback function */ + void *runcxdmc; /* demand-loader callback context */ + runxdef *runcxext; /* external function array */ + int runcxexc; /* count of external functions */ + uint runcxlofs; /* offset of last line record encountered */ + char *runcxgamename; /* name of the .GAM file */ + char *runcxgamepath; /* absolute directory path of .GAM file */ }; /* execute a function, given the function object number */ @@ -129,7 +129,7 @@ void runfn(runcxdef *ctx, noreg objnum objn, int argc); * executed; 0 is used for functions. */ void runexe(runcxdef *ctx, uchar *p, objnum self, objnum target, - prpnum targprop, int argc); + prpnum targprop, int argc); /* push a value onto the stack */ void runpush(runcxdef *ctx, dattyp typ, runsdef *val); @@ -171,8 +171,8 @@ void runpushcstr(runcxdef *ctx, const char *str, size_t len, int sav); * operations, with the current target object given as 'obj'. */ void runpprop(runcxdef *ctx, uchar *noreg *codepp, objnum callobj, - prpnum callprop, noreg objnum obj, prpnum prop, int inh, - int argc, objnum self); + prpnum callprop, noreg objnum obj, prpnum prop, int inh, + int argc, objnum self); /* top level runpprop, when caller is not executing in an object */ /* void runppr(runcxdef *ctx, objnum obj, prpnum prp, int argc); */ @@ -207,7 +207,7 @@ void runpprop(runcxdef *ctx, uchar *noreg *codepp, objnum callobj, (runstkund(ctx), ((--(ctx)->runcxsp))->runstyp==DAT_OBJECT ? \ ((ctx)->runcxsp->runsv.runsvobj) : \ ((ctx)->runcxsp->runstyp==DAT_NIL ? MCMONINV : \ - (runsig(ctx,ERR_REQVOB), (objnum)0))) + (runsig(ctx,ERR_REQVOB), (objnum)0))) /* pop a list, signalling an error if not a list */ /* uchar *runpoplst(runcxdef *ctx); */ @@ -228,8 +228,8 @@ void runpprop(runcxdef *ctx, uchar *noreg *codepp, objnum callobj, /* objnum runpopfn(runcxdef *ctx); */ #define runpopfn(ctx) \ ((objnum)(runstkund(ctx), ((--(ctx)->runcxsp))->runstyp!=DAT_FNADDR ? \ - (runsig(ctx,ERR_REQVFN), (objnum)0) : \ - ((ctx)->runcxsp->runsv.runsvobj))) + (runsig(ctx,ERR_REQVFN), (objnum)0) : \ + ((ctx)->runcxsp->runsv.runsvobj))) /* pop a string value */ /* char *runpopstr(runcxdef *ctx); */ @@ -279,8 +279,8 @@ int runeq(runcxdef *ctx); * values to meet the need. */ #define runcheckargc(ctx, nargc) \ - while ((ctx)->runcxsp - (ctx)->runcxbp < *(nargc)) \ - runpnil(ctx) + while ((ctx)->runcxsp - (ctx)->runcxbp < *(nargc)) \ + runpnil(ctx) #ifdef RUNFAST # define runstkovf(ctx) (DISCARD 0) @@ -316,7 +316,7 @@ int runeq(runcxdef *ctx); /* garbage collect heap, making sure 'siz' bytes are available afterwards */ void runhcmp(runcxdef *ctx, uint siz, uint below, - runsdef *val1, runsdef *val2, runsdef *val3); + runsdef *val1, runsdef *val2, runsdef *val3); /* determine size of a data item */ int runsiz(runsdef *item); @@ -347,12 +347,12 @@ uchar *runcprst(runcxdef *ctx, uint ofs, objnum obj, prpnum prop); /* reset run-time: throw away entire stack and heap */ /* void runrst(runcxdef *ctx); */ #define runrst(ctx) (((ctx)->runcxsp = (ctx)->runcxstk), \ - ((ctx)->runcxhp = (ctx)->runcxheap), \ - dbgrst(ctx->runcxdbg)) + ((ctx)->runcxhp = (ctx)->runcxheap), \ + dbgrst(ctx->runcxdbg)) /* set up runtime status line display */ void runistat(struct voccxdef *vctx, struct runcxdef *rctx, - struct tiocxdef *tctx); + struct tiocxdef *tctx); /* signal a run-time error - allows debugger trapping */ void runsign(runcxdef *ctx, int err); @@ -370,7 +370,7 @@ void runstat(); /* initialize output status */ void runistat(struct voccxdef *vctx, struct runcxdef *rctx, - struct tiocxdef *tctx); + struct tiocxdef *tctx); } // End of namespace TADS2 } // End of namespace TADS diff --git a/engines/glk/tads/tads2/runstat.cpp b/engines/glk/tads/tads2/runstat.cpp index 8b30138b0bc..2e2d0854e1c 100644 --- a/engines/glk/tads/tads2/runstat.cpp +++ b/engines/glk/tads/tads2/runstat.cpp @@ -37,51 +37,51 @@ static tiocxdef *tioctx; void runstat(void) { - objnum locobj; - int savemoremode; + objnum locobj; + int savemoremode; - /* get the location of the Me object */ - runppr(runctx, vocctx->voccxme, PRP_LOCATION, 0); + /* get the location of the Me object */ + runppr(runctx, vocctx->voccxme, PRP_LOCATION, 0); - /* if that's no an object, there's nothing we can do */ - if (runtostyp(runctx) != DAT_OBJECT) - { - rundisc(runctx); - return; - } + /* if that's no an object, there's nothing we can do */ + if (runtostyp(runctx) != DAT_OBJECT) + { + rundisc(runctx); + return; + } - /* get Me.location */ - locobj = runpopobj(runctx); + /* get Me.location */ + locobj = runpopobj(runctx); - /* flush any pending output */ - outflushn(0); + /* flush any pending output */ + outflushn(0); - /* switch to output display mode 1 (status line) */ - os_status(1); + /* switch to output display mode 1 (status line) */ + os_status(1); - /* turn off MORE mode */ - savemoremode = setmore(0); + /* turn off MORE mode */ + savemoremode = setmore(0); - /* call the statusLine method of the current room */ - runppr(runctx, locobj, PRP_STATUSLINE, 0); + /* call the statusLine method of the current room */ + runppr(runctx, locobj, PRP_STATUSLINE, 0); - /* if we're in the status line, make sure the line gets flushed */ - if (os_get_status() != 0) - tioputs(tioctx, "\\n"); - outflushn(0); + /* if we're in the status line, make sure the line gets flushed */ + if (os_get_status() != 0) + tioputs(tioctx, "\\n"); + outflushn(0); - /* restore the previous MORE mode */ - setmore(savemoremode); + /* restore the previous MORE mode */ + setmore(savemoremode); - /* switch to output display mode 0 (main text area) */ - os_status(0); + /* switch to output display mode 0 (main text area) */ + os_status(0); } void runistat(voccxdef *vctx, runcxdef *rctx, tiocxdef *tctx) { - runctx = rctx; - vocctx = vctx; - tioctx = tctx; + runctx = rctx; + vocctx = vctx; + tioctx = tctx; } } // End of namespace TADS2 diff --git a/engines/glk/tads/tads2/runtime_driver.cpp b/engines/glk/tads/tads2/runtime_driver.cpp index 2eb6602077a..c263c64a201 100644 --- a/engines/glk/tads/tads2/runtime_driver.cpp +++ b/engines/glk/tads/tads2/runtime_driver.cpp @@ -43,13 +43,13 @@ namespace TADS2 { /* dummy setup function */ void supgnam(char *buf, tokthdef *tab, objnum sc) { - strcpy(buf, "???"); + strcpy(buf, "???"); } /* dummy file read functions */ void tok_read_defines(tokcxdef *tctx, osfildef *fp, errcxdef *ec) { - errsig(ec, ERR_UNKRSC); + errsig(ec, ERR_UNKRSC); } /* dummy debugger functions */ @@ -136,41 +136,41 @@ void trcsho(void) {} struct runsdef *dbgfrfind(dbgcxdef *ctx, objnum frobj, uint frofs) { - VARUSED(frobj); - VARUSED(frofs); - errsig(ctx->dbgcxerr, ERR_INACTFR); - return 0; + VARUSED(frobj); + VARUSED(frofs); + errsig(ctx->dbgcxerr, ERR_INACTFR); + return 0; } void dbgss(struct dbgcxdef *ctx, uint ofs, int instr, int err, - uchar *noreg *p) + uchar *noreg *p) { - VARUSED(ctx); - VARUSED(ofs); - VARUSED(instr); - VARUSED(err); - VARUSED(p); + VARUSED(ctx); + VARUSED(ofs); + VARUSED(instr); + VARUSED(err); + VARUSED(p); } int dbgstart(struct dbgcxdef *ctx) { - VARUSED(ctx); - return TRUE; + VARUSED(ctx); + return TRUE; } /* printf-style formatting */ static void trdptf(const char *fmt, ...) { - char buf[256]; - va_list va; + char buf[256]; + va_list va; - /* format the string */ - va_start(va, fmt); - vsprintf(buf, fmt, va); - va_end(va); + /* format the string */ + va_start(va, fmt); + vsprintf(buf, fmt, va); + va_end(va); - /* print the formatted buffer */ - os_printz(buf); + /* print the formatted buffer */ + os_printz(buf); } @@ -179,14 +179,14 @@ static void trdptf(const char *fmt, ...) */ static void trdusage_show_range(errcxdef *ec, int msg_first, int msg_last) { - int i; - char buf[128]; + int i; + char buf[128]; - for (i = msg_first ; i <= msg_last ; ++i) - { - errmsg(ec, buf, (uint)sizeof(buf), i); - trdptf("%s\n", buf); - } + for (i = msg_first ; i <= msg_last ; ++i) + { + errmsg(ec, buf, (uint)sizeof(buf), i); + trdptf("%s\n", buf); + } } @@ -195,11 +195,11 @@ static void trdusage_show_range(errcxdef *ec, int msg_first, int msg_last) */ static void trdusage_range(errcxdef *ec, int msg_first, int msg_last) { - /* show the message range */ - trdusage_show_range(ec, msg_first, msg_last); + /* show the message range */ + trdusage_show_range(ec, msg_first, msg_last); - /* signal the usage error */ - errsig(ec, ERR_USAGE); + /* signal the usage error */ + errsig(ec, ERR_USAGE); } /* @@ -207,41 +207,41 @@ static void trdusage_range(errcxdef *ec, int msg_first, int msg_last) */ static void trdusage(errcxdef *ec) { - int first; + int first; - /* - * if we have an app display name, display it instead of the - * hard-coded text in the message identifying the app - */ - first = ERR_TRUS1; - if (ec->errcxappctx != 0 && ec->errcxappctx->usage_app_name != 0) - { - char buf[128]; - char buf2[128]; - erradef argv[1]; - - /* get the parameterized usage message */ - errmsg(ec, buf, (uint)sizeof(buf), ERR_TRUSPARM); + /* + * if we have an app display name, display it instead of the + * hard-coded text in the message identifying the app + */ + first = ERR_TRUS1; + if (ec->errcxappctx != 0 && ec->errcxappctx->usage_app_name != 0) + { + char buf[128]; + char buf2[128]; + erradef argv[1]; + + /* get the parameterized usage message */ + errmsg(ec, buf, (uint)sizeof(buf), ERR_TRUSPARM); - /* format in the application name */ - argv[0].errastr = ec->errcxappctx->usage_app_name; - errfmt(buf2, (int)sizeof(buf2), buf, 1, argv); - - /* display it */ - trdptf("%s\n", buf2); + /* format in the application name */ + argv[0].errastr = ec->errcxappctx->usage_app_name; + errfmt(buf2, (int)sizeof(buf2), buf, 1, argv); + + /* display it */ + trdptf("%s\n", buf2); - /* start at the next message */ - ++first; - } + /* start at the next message */ + ++first; + } - /* display the main option list messages */ - trdusage_show_range(ec, first, ERR_TRUSL); + /* display the main option list messages */ + trdusage_show_range(ec, first, ERR_TRUSL); - /* display the OS-specific option messages, if any */ - trdusage_show_range(ec, ERR_TRUS_OS_FIRST, ERR_TRUS_OS_LAST); + /* display the OS-specific option messages, if any */ + trdusage_show_range(ec, ERR_TRUS_OS_FIRST, ERR_TRUS_OS_LAST); - /* display the usage footer messages */ - trdusage_range(ec, ERR_TRUSFT1, ERR_TRUSFTL); + /* display the usage footer messages */ + trdusage_range(ec, ERR_TRUSFT1, ERR_TRUSFTL); } /* @@ -249,521 +249,521 @@ static void trdusage(errcxdef *ec) */ static void trdusage_s(errcxdef *ec) { - trdusage_range(ec, ERR_TRSUS1, ERR_TRSUSL); + trdusage_range(ec, ERR_TRSUS1, ERR_TRSUSL); } static void trdmain1(errcxdef *ec, int argc, char *argv[], - appctxdef *appctx, const char *save_ext) + appctxdef *appctx, const char *save_ext) { - osfildef *swapfp = (osfildef *)0; - runcxdef runctx; - bifcxdef bifctx; - voccxdef vocctx; - void (*bif[100])(struct bifcxdef *, int); - mcmcxdef *mctx = 0; - mcmcx1def *globalctx = 0; - dbgcxdef dbg; - supcxdef supctx; - char *swapname = 0; - char swapbuf[OSFNMAX]; - char **argp; - char *arg; - char *infile; - char infile_abs[OSFNMAX]; /* fully-qualified input file name */ - char infile_path[OSFNMAX]; /* absolute path to input file */ - const char *exefile; /* try with executable file if no infile */ - ulong swapsize = 0xffffffffL; /* allow unlimited swap space */ - int swapena = OS_DEFAULT_SWAP_ENABLED; /* swapping enabled? */ - int i; - int pause = FALSE; /* pause after finishing game */ - fiolcxdef fiolctx; - noreg int loadopen = FALSE; - char inbuf[OSFNMAX]; - ulong cachelimit = 0xffffffff; - ushort undosiz = TRD_UNDOSIZ; /* default undo context size 16k */ - objucxdef *undoptr = 0; - uint flags; /* flags used to write the file we're reading */ - objnum preinit; /* preinit object, if we need to execute it */ - uint heapsiz = TRD_HEAPSIZ; - uint stksiz = TRD_STKSIZ; - runsdef *mystack; - uchar *myheap; - extern osfildef *cmdfile; /* hacky v1 qa interface - command log fp */ - extern osfildef *logfp; /* hacky v1 qa interface - output log fp */ - int preload = FALSE; /* TRUE => preload all objects */ - ulong totsize; - extern voccxdef *main_voc_ctx; - int safety_read, safety_write; /* file I/O safety level */ - char *restore_file = 0; /* .SAV file to restore */ - char *charmap = 0; /* character map file */ - int charmap_none; /* explicitly do not use a character set */ - int doublespace = TRUE; /* formatter double-space setting */ - - NOREG((&loadopen)) + osfildef *swapfp = (osfildef *)0; + runcxdef runctx; + bifcxdef bifctx; + voccxdef vocctx; + void (*bif[100])(struct bifcxdef *, int); + mcmcxdef *mctx = 0; + mcmcx1def *globalctx = 0; + dbgcxdef dbg; + supcxdef supctx; + char *swapname = 0; + char swapbuf[OSFNMAX]; + char **argp; + char *arg; + char *infile; + char infile_abs[OSFNMAX]; /* fully-qualified input file name */ + char infile_path[OSFNMAX]; /* absolute path to input file */ + const char *exefile; /* try with executable file if no infile */ + ulong swapsize = 0xffffffffL; /* allow unlimited swap space */ + int swapena = OS_DEFAULT_SWAP_ENABLED; /* swapping enabled? */ + int i; + int pause = FALSE; /* pause after finishing game */ + fiolcxdef fiolctx; + noreg int loadopen = FALSE; + char inbuf[OSFNMAX]; + ulong cachelimit = 0xffffffff; + ushort undosiz = TRD_UNDOSIZ; /* default undo context size 16k */ + objucxdef *undoptr = 0; + uint flags; /* flags used to write the file we're reading */ + objnum preinit; /* preinit object, if we need to execute it */ + uint heapsiz = TRD_HEAPSIZ; + uint stksiz = TRD_STKSIZ; + runsdef *mystack; + uchar *myheap; + extern osfildef *cmdfile; /* hacky v1 qa interface - command log fp */ + extern osfildef *logfp; /* hacky v1 qa interface - output log fp */ + int preload = FALSE; /* TRUE => preload all objects */ + ulong totsize; + extern voccxdef *main_voc_ctx; + int safety_read, safety_write; /* file I/O safety level */ + char *restore_file = 0; /* .SAV file to restore */ + char *charmap = 0; /* character map file */ + int charmap_none; /* explicitly do not use a character set */ + int doublespace = TRUE; /* formatter double-space setting */ + + NOREG((&loadopen)) - /* initialize the output formatter */ - out_init(); + /* initialize the output formatter */ + out_init(); - /* set safety level to 2 by default - read any/write current dir only */ - safety_read = safety_write = 2; + /* set safety level to 2 by default - read any/write current dir only */ + safety_read = safety_write = 2; - /* no -ctab- yet */ - charmap_none = FALSE; + /* no -ctab- yet */ + charmap_none = FALSE; - /* parse arguments */ - for (i = 1, argp = argv + 1 ; i < argc ; ++argp, ++i) - { - arg = *argp; - if (*arg == '-') - { - switch(*(arg+1)) - { - case 'c': - if (!strcmp(arg+1, "ctab")) - { - /* get the character mapping table */ - charmap = cmdarg(ec, &argp, &i, argc, 4, trdusage); - } - else if (!strcmp(arg+1, "ctab-")) - { - /* use the default mapping */ - charmap_none = TRUE; - } - else - trdusage(ec); - break; - - case 'r': - /* restore a game */ - restore_file = cmdarg(ec, &argp, &i, argc, 1, trdusage); - break; - - case 'i': - qasopn(cmdarg(ec, &argp, &i, argc, 1, trdusage), TRUE); - break; - - case 'o': - cmdfile = osfopwt(cmdarg(ec, &argp, &i, argc, 1, trdusage), - OSFTCMD); - break; - - case 'l': - logfp = osfopwt(cmdarg(ec, &argp, &i, argc, 1, trdusage), - OSFTCMD); - break; + /* parse arguments */ + for (i = 1, argp = argv + 1 ; i < argc ; ++argp, ++i) + { + arg = *argp; + if (*arg == '-') + { + switch(*(arg+1)) + { + case 'c': + if (!strcmp(arg+1, "ctab")) + { + /* get the character mapping table */ + charmap = cmdarg(ec, &argp, &i, argc, 4, trdusage); + } + else if (!strcmp(arg+1, "ctab-")) + { + /* use the default mapping */ + charmap_none = TRUE; + } + else + trdusage(ec); + break; + + case 'r': + /* restore a game */ + restore_file = cmdarg(ec, &argp, &i, argc, 1, trdusage); + break; + + case 'i': + qasopn(cmdarg(ec, &argp, &i, argc, 1, trdusage), TRUE); + break; + + case 'o': + cmdfile = osfopwt(cmdarg(ec, &argp, &i, argc, 1, trdusage), + OSFTCMD); + break; + + case 'l': + logfp = osfopwt(cmdarg(ec, &argp, &i, argc, 1, trdusage), + OSFTCMD); + break; - case 'p': - if (!scumm_stricmp(arg, "-plain")) - { - os_plain(); - break; - } - pause = cmdtog(ec, pause, arg, 1, trdusage); - break; + case 'p': + if (!scumm_stricmp(arg, "-plain")) + { + os_plain(); + break; + } + pause = cmdtog(ec, pause, arg, 1, trdusage); + break; - case 'd': - if (!scumm_strnicmp(arg, "-double", 7)) - { - /* get the argument value */ - doublespace = cmdtog(ec, doublespace, arg, 6, trdusage); + case 'd': + if (!scumm_strnicmp(arg, "-double", 7)) + { + /* get the argument value */ + doublespace = cmdtog(ec, doublespace, arg, 6, trdusage); - /* set the double-space mode in the formatter */ - out_set_doublespace(doublespace); - break; - } - break; + /* set the double-space mode in the formatter */ + out_set_doublespace(doublespace); + break; + } + break; - case 's': - { - char *p; + case 's': + { + char *p; - /* get the option */ - p = cmdarg(ec, &argp, &i, argc, 1, trdusage); + /* get the option */ + p = cmdarg(ec, &argp, &i, argc, 1, trdusage); - /* if they're asking for help, display detailed usage */ - if (*p == '?') - trdusage_s(ec); + /* if they're asking for help, display detailed usage */ + if (*p == '?') + trdusage_s(ec); - /* get the safety level from the argument */ - safety_read = *p - '0'; - safety_write = (*(p+1) != '\0' ? *(p+1) - '0' : - safety_read); + /* get the safety level from the argument */ + safety_read = *p - '0'; + safety_write = (*(p+1) != '\0' ? *(p+1) - '0' : + safety_read); - /* range-check the values */ - if (safety_read < 0 || safety_read > 4 - || safety_write < 0 || safety_write > 4) - trdusage_s(ec); + /* range-check the values */ + if (safety_read < 0 || safety_read > 4 + || safety_write < 0 || safety_write > 4) + trdusage_s(ec); - /* tell the host system about the setting */ - if (appctx != 0 && appctx->set_io_safety_level != 0) - (*appctx->set_io_safety_level) - (appctx->io_safety_level_ctx, - safety_read, safety_write); - } - break; - - case 'm': - switch(*(arg + 2)) - { - case 's': - stksiz = atoi(cmdarg(ec, &argp, &i, argc, 2, trdusage)); - break; - - case 'h': - heapsiz = atoi(cmdarg(ec, &argp, &i, argc, 2, trdusage)); - break; - - default: - cachelimit = atol(cmdarg(ec, &argp, &i, argc, 1, - trdusage)); - break; - } - break; - - case 't': - /* swap file options: -tf file, -ts size, -t- (no swap) */ - switch(*(arg+2)) - { - case 'f': - swapname = cmdarg(ec, &argp, &i, argc, 2, trdusage); - break; - - case 's': - swapsize = atol(cmdarg(ec, &argp, &i, argc, 2, trdusage)); - break; - - case 'p': - preload = cmdtog(ec, preload, arg, 2, trdusage); - break; - - default: - swapena = cmdtog(ec, swapena, arg, 1, trdusage); - break; - } - break; - - case 'u': - undosiz = atoi(cmdarg(ec, &argp, &i, argc, 1, trdusage)); - break; - - default: - trdusage(ec); - } - } - else break; - } + /* tell the host system about the setting */ + if (appctx != 0 && appctx->set_io_safety_level != 0) + (*appctx->set_io_safety_level) + (appctx->io_safety_level_ctx, + safety_read, safety_write); + } + break; + + case 'm': + switch(*(arg + 2)) + { + case 's': + stksiz = atoi(cmdarg(ec, &argp, &i, argc, 2, trdusage)); + break; + + case 'h': + heapsiz = atoi(cmdarg(ec, &argp, &i, argc, 2, trdusage)); + break; + + default: + cachelimit = atol(cmdarg(ec, &argp, &i, argc, 1, + trdusage)); + break; + } + break; + + case 't': + /* swap file options: -tf file, -ts size, -t- (no swap) */ + switch(*(arg+2)) + { + case 'f': + swapname = cmdarg(ec, &argp, &i, argc, 2, trdusage); + break; + + case 's': + swapsize = atol(cmdarg(ec, &argp, &i, argc, 2, trdusage)); + break; + + case 'p': + preload = cmdtog(ec, preload, arg, 2, trdusage); + break; + + default: + swapena = cmdtog(ec, swapena, arg, 1, trdusage); + break; + } + break; + + case 'u': + undosiz = atoi(cmdarg(ec, &argp, &i, argc, 1, trdusage)); + break; + + default: + trdusage(ec); + } + } + else break; + } - /* presume we won't take the .gam from the application executable */ - exefile = 0; + /* presume we won't take the .gam from the application executable */ + exefile = 0; - /* get input name argument, and make sure it's the last argument */ - if (i == argc) - { - osfildef *fp; - ulong curpos; - ulong endpos; - int use_exe; + /* get input name argument, and make sure it's the last argument */ + if (i == argc) + { + osfildef *fp; + ulong curpos; + ulong endpos; + int use_exe; - /* - * There's no input name argument, so we need to find the game - * to play some other way. First, check to see if we have a - * game to restore, and if so whether it has the .GAM name - * encoded into it. Next, look to see if there's a game - * attached to the executable file; if so, use it. If not, see - * if the host system wants to provide a name through its - * callback. - */ - - /* presume we won't find a game attached to the executable file */ - infile = 0; - use_exe = FALSE; + /* + * There's no input name argument, so we need to find the game + * to play some other way. First, check to see if we have a + * game to restore, and if so whether it has the .GAM name + * encoded into it. Next, look to see if there's a game + * attached to the executable file; if so, use it. If not, see + * if the host system wants to provide a name through its + * callback. + */ + + /* presume we won't find a game attached to the executable file */ + infile = 0; + use_exe = FALSE; - /* - * see if we have a saved game to restore, and it specifies the - * GAM file that saved it - */ - if (restore_file != 0) - { - /* try getting the game name from the restore file */ - if (fiorso_getgame(restore_file, inbuf, sizeof(inbuf))) - { - /* got it - use this file */ - infile = inbuf; - } - } - - /* - * it that didn't work, try to read from os-dependent part of - * program being executed - */ - if (infile == 0) - { - /* try opening the executable file */ - exefile = (argv && argv[0] ? argv[0] : "TRX"); - fp = os_exeseek(exefile, "TGAM"); - if (fp != 0) - { - /* see if there's a game file attached to the executable */ - curpos = osfpos(fp); - osfseek(fp, 0L, OSFSK_END); - endpos = osfpos(fp); - osfcls(fp); - - /* if we found it, use it */ - if (endpos != curpos) - use_exe = TRUE; - } - } - - /* - * if we didn't find a game in the executable, try the host - * system callback - */ - if (infile == 0 && !use_exe) - { - /* - * ask the host system callback what to do - if we don't - * have a host system callback, or the callback - */ - if (appctx != 0 && appctx->get_game_name != 0) - { - /* call the host system callback */ - if ((*appctx->get_game_name)(appctx->get_game_name_ctx, - inbuf, sizeof(inbuf))) - { - /* the host system provided a name - use it */ - infile = inbuf; - } - else - { - /* - * the host didn't provide a name - simply display a - * message indicating that no game file has been - * chosen, and return - */ - trdptf("\n"); - trdptf("(No game has been selected.)\n"); - return; - } - } - else - { - /* - * we've run out of ways to get a filename - give the - * user the usage message and quit - */ - trdusage(ec); - } - } - } - else - { - infile = *argp; - if (i + 1 != argc) - trdusage(ec); + /* + * see if we have a saved game to restore, and it specifies the + * GAM file that saved it + */ + if (restore_file != 0) + { + /* try getting the game name from the restore file */ + if (fiorso_getgame(restore_file, inbuf, sizeof(inbuf))) + { + /* got it - use this file */ + infile = inbuf; + } + } + + /* + * it that didn't work, try to read from os-dependent part of + * program being executed + */ + if (infile == 0) + { + /* try opening the executable file */ + exefile = (argv && argv[0] ? argv[0] : "TRX"); + fp = os_exeseek(exefile, "TGAM"); + if (fp != 0) + { + /* see if there's a game file attached to the executable */ + curpos = osfpos(fp); + osfseek(fp, 0L, OSFSK_END); + endpos = osfpos(fp); + osfcls(fp); + + /* if we found it, use it */ + if (endpos != curpos) + use_exe = TRUE; + } + } + + /* + * if we didn't find a game in the executable, try the host + * system callback + */ + if (infile == 0 && !use_exe) + { + /* + * ask the host system callback what to do - if we don't + * have a host system callback, or the callback + */ + if (appctx != 0 && appctx->get_game_name != 0) + { + /* call the host system callback */ + if ((*appctx->get_game_name)(appctx->get_game_name_ctx, + inbuf, sizeof(inbuf))) + { + /* the host system provided a name - use it */ + infile = inbuf; + } + else + { + /* + * the host didn't provide a name - simply display a + * message indicating that no game file has been + * chosen, and return + */ + trdptf("\n"); + trdptf("(No game has been selected.)\n"); + return; + } + } + else + { + /* + * we've run out of ways to get a filename - give the + * user the usage message and quit + */ + trdusage(ec); + } + } + } + else + { + infile = *argp; + if (i + 1 != argc) + trdusage(ec); #ifndef OS_HATES_EXTENSIONS - /* - * If original name exists, use it; otherwise, try adding .GAM. - * Note that this code is ifdef'd so that platforms that don't - * use filename extensions in the manner conventional for DOS - * and Unix won't use this code. - */ - if (osfacc(infile)) - { - strcpy(inbuf, infile); - os_defext(inbuf, "gam"); - infile = inbuf; - } + /* + * If original name exists, use it; otherwise, try adding .GAM. + * Note that this code is ifdef'd so that platforms that don't + * use filename extensions in the manner conventional for DOS + * and Unix won't use this code. + */ + if (osfacc(infile)) + { + strcpy(inbuf, infile); + os_defext(inbuf, "gam"); + infile = inbuf; + } #endif /* !defined(OS_HATES_EXTENSIONS) */ - } - - /* open up the swap file */ - if (swapena && swapsize) - { - swapfp = os_create_tempfile(swapname, swapbuf); - if (swapname == 0) swapname = swapbuf; - if (swapfp == 0) errsig(ec, ERR_OPSWAP); - } - - /* load the character map */ - if (charmap_none) - cmap_override(); - else if (cmap_load(charmap)) - errsig(ec, ERR_INVCMAP); + } + + /* open up the swap file */ + if (swapena && swapsize) + { + swapfp = os_create_tempfile(swapname, swapbuf); + if (swapname == 0) swapname = swapbuf; + if (swapfp == 0) errsig(ec, ERR_OPSWAP); + } + + /* load the character map */ + if (charmap_none) + cmap_override(); + else if (cmap_load(charmap)) + errsig(ec, ERR_INVCMAP); - ERRBEGIN(ec) + ERRBEGIN(ec) - /* initialize cache manager context */ - globalctx = mcmini(cachelimit, 128, swapsize, swapfp, swapname, ec); - mctx = mcmcini(globalctx, 128, fioldobj, &fiolctx, - objrevert, (void *)0); - mctx->mcmcxrvc = mctx; + /* initialize cache manager context */ + globalctx = mcmini(cachelimit, 128, swapsize, swapfp, swapname, ec); + mctx = mcmcini(globalctx, 128, fioldobj, &fiolctx, + objrevert, (void *)0); + mctx->mcmcxrvc = mctx; - /* set up an undo context */ - if (undosiz) - undoptr = objuini(mctx, undosiz, vocdundo, vocdusz, &vocctx); - else - undoptr = (objucxdef *)0; + /* set up an undo context */ + if (undosiz) + undoptr = objuini(mctx, undosiz, vocdundo, vocdusz, &vocctx); + else + undoptr = (objucxdef *)0; - /* set up vocabulary context */ - vocini(&vocctx, ec, mctx, &runctx, undoptr, 100, 100, 200); + /* set up vocabulary context */ + vocini(&vocctx, ec, mctx, &runctx, undoptr, 100, 100, 200); - /* - * save a pointer to the voc context globally, so that certain - * external routines (such as Unix-style signal handlers) can reach - * it - */ - main_voc_ctx = &vocctx; - - /* allocate stack and heap */ - totsize = (ulong)stksiz * (ulong)sizeof(runsdef); - if (totsize != (size_t)totsize) - errsig1(ec, ERR_STKSIZE, ERRTINT, (uint)(65535/sizeof(runsdef))); - mystack = (runsdef *)mchalo(ec, (size_t)totsize, "runtime stack"); - myheap = mchalo(ec, heapsiz, "runtime heap"); + /* + * save a pointer to the voc context globally, so that certain + * external routines (such as Unix-style signal handlers) can reach + * it + */ + main_voc_ctx = &vocctx; + + /* allocate stack and heap */ + totsize = (ulong)stksiz * (ulong)sizeof(runsdef); + if (totsize != (size_t)totsize) + errsig1(ec, ERR_STKSIZE, ERRTINT, (uint)(65535/sizeof(runsdef))); + mystack = (runsdef *)mchalo(ec, (size_t)totsize, "runtime stack"); + myheap = mchalo(ec, heapsiz, "runtime heap"); - /* get the absolute path for the input file */ - if (infile != 0) - os_get_abs_filename(infile_abs, sizeof(infile_abs), infile); - else if (exefile != 0) - os_get_abs_filename(infile_abs, sizeof(infile_abs), exefile); - else - infile_abs[0] = '\0'; - os_get_path_name(infile_path, sizeof(infile_path), infile_abs); + /* get the absolute path for the input file */ + if (infile != 0) + os_get_abs_filename(infile_abs, sizeof(infile_abs), infile); + else if (exefile != 0) + os_get_abs_filename(infile_abs, sizeof(infile_abs), exefile); + else + infile_abs[0] = '\0'; + os_get_path_name(infile_path, sizeof(infile_path), infile_abs); - /* set up execution context */ - runctx.runcxerr = ec; - runctx.runcxmem = mctx; - runctx.runcxstk = mystack; - runctx.runcxstop = &mystack[stksiz]; - runctx.runcxsp = mystack; - runctx.runcxbp = mystack; - runctx.runcxheap = myheap; - runctx.runcxhp = myheap; - runctx.runcxhtop = &myheap[heapsiz]; - runctx.runcxundo = undoptr; - runctx.runcxbcx = &bifctx; - runctx.runcxbi = bif; - runctx.runcxtio = (tiocxdef *)0; - runctx.runcxdbg = &dbg; - runctx.runcxvoc = &vocctx; - runctx.runcxdmd = supcont; - runctx.runcxdmc = &supctx; - runctx.runcxext = 0; - runctx.runcxgamename = infile; - runctx.runcxgamepath = infile_path; + /* set up execution context */ + runctx.runcxerr = ec; + runctx.runcxmem = mctx; + runctx.runcxstk = mystack; + runctx.runcxstop = &mystack[stksiz]; + runctx.runcxsp = mystack; + runctx.runcxbp = mystack; + runctx.runcxheap = myheap; + runctx.runcxhp = myheap; + runctx.runcxhtop = &myheap[heapsiz]; + runctx.runcxundo = undoptr; + runctx.runcxbcx = &bifctx; + runctx.runcxbi = bif; + runctx.runcxtio = (tiocxdef *)0; + runctx.runcxdbg = &dbg; + runctx.runcxvoc = &vocctx; + runctx.runcxdmd = supcont; + runctx.runcxdmc = &supctx; + runctx.runcxext = 0; + runctx.runcxgamename = infile; + runctx.runcxgamepath = infile_path; - /* set up setup context */ - supctx.supcxerr = ec; - supctx.supcxmem = mctx; - supctx.supcxtab = (tokthdef *)0; - supctx.supcxbuf = (uchar *)0; - supctx.supcxlen = 0; - supctx.supcxvoc = &vocctx; - supctx.supcxrun = &runctx; - - /* set up debug context */ - dbg.dbgcxtio = (tiocxdef *)0; - dbg.dbgcxmem = mctx; - dbg.dbgcxerr = ec; - dbg.dbgcxtab = (tokthdef *)0; - dbg.dbgcxfcn = 0; - dbg.dbgcxdep = 0; - dbg.dbgcxflg = 0; - dbg.dbgcxlin = (lindef *)0; /* no line sources yet */ - - /* set up built-in function context */ - bifctx.bifcxerr = ec; - bifctx.bifcxrun = &runctx; - bifctx.bifcxtio = (tiocxdef *)0; - bifctx.bifcxrnd = 0; - bifctx.bifcxrndset = FALSE; - bifctx.bifcxappctx = appctx; - bifctx.bifcxsafetyr = safety_read; - bifctx.bifcxsafetyw = safety_write; - bifctx.bifcxsavext = save_ext; + /* set up setup context */ + supctx.supcxerr = ec; + supctx.supcxmem = mctx; + supctx.supcxtab = (tokthdef *)0; + supctx.supcxbuf = (uchar *)0; + supctx.supcxlen = 0; + supctx.supcxvoc = &vocctx; + supctx.supcxrun = &runctx; + + /* set up debug context */ + dbg.dbgcxtio = (tiocxdef *)0; + dbg.dbgcxmem = mctx; + dbg.dbgcxerr = ec; + dbg.dbgcxtab = (tokthdef *)0; + dbg.dbgcxfcn = 0; + dbg.dbgcxdep = 0; + dbg.dbgcxflg = 0; + dbg.dbgcxlin = (lindef *)0; /* no line sources yet */ + + /* set up built-in function context */ + bifctx.bifcxerr = ec; + bifctx.bifcxrun = &runctx; + bifctx.bifcxtio = (tiocxdef *)0; + bifctx.bifcxrnd = 0; + bifctx.bifcxrndset = FALSE; + bifctx.bifcxappctx = appctx; + bifctx.bifcxsafetyr = safety_read; + bifctx.bifcxsafetyw = safety_write; + bifctx.bifcxsavext = save_ext; - /* initialize the regular expression parser context */ - re_init(&bifctx.bifcxregex, ec); - - /* add the built-in functions, keywords, etc */ - supbif(&supctx, bif, (int)(sizeof(bif)/sizeof(bif[0]))); - - /* set up status line hack */ - runistat(&vocctx, &runctx, (tiocxdef *)0); + /* initialize the regular expression parser context */ + re_init(&bifctx.bifcxregex, ec); + + /* add the built-in functions, keywords, etc */ + supbif(&supctx, bif, (int)(sizeof(bif)/sizeof(bif[0]))); + + /* set up status line hack */ + runistat(&vocctx, &runctx, (tiocxdef *)0); - /* turn on the "busy" cursor before loading */ - os_csr_busy(TRUE); - - /* read the game from the binary file */ - fiord(mctx, &vocctx, (struct tokcxdef *)0, - infile, exefile, &fiolctx, &preinit, &flags, - (struct tokpdef *)0, (uchar **)0, (uint *)0, (uint *)0, - (preload ? 2 : 0), appctx, argv[0]); - loadopen = TRUE; + /* turn on the "busy" cursor before loading */ + os_csr_busy(TRUE); + + /* read the game from the binary file */ + fiord(mctx, &vocctx, (struct tokcxdef *)0, + infile, exefile, &fiolctx, &preinit, &flags, + (struct tokpdef *)0, (uchar **)0, (uint *)0, (uint *)0, + (preload ? 2 : 0), appctx, argv[0]); + loadopen = TRUE; - /* turn off the "busy" cursor */ - os_csr_busy(FALSE); - - /* play the game */ - plygo(&runctx, &vocctx, (tiocxdef *)0, preinit, restore_file); - - /* close load file */ - fiorcls(&fiolctx); - - if (pause) - { - trdptf("[press a key to exit]"); - os_waitc(); - trdptf("\n"); - } - - /* close and delete swapfile, if one was opened */ - trd_close_swapfile(&runctx); + /* turn off the "busy" cursor */ + os_csr_busy(FALSE); + + /* play the game */ + plygo(&runctx, &vocctx, (tiocxdef *)0, preinit, restore_file); + + /* close load file */ + fiorcls(&fiolctx); + + if (pause) + { + trdptf("[press a key to exit]"); + os_waitc(); + trdptf("\n"); + } + + /* close and delete swapfile, if one was opened */ + trd_close_swapfile(&runctx); - /* make sure the script file is closed, if we have one */ - qasclose(); + /* make sure the script file is closed, if we have one */ + qasclose(); - ERRCLEAN(ec) - /* close and delete swapfile, if one was opened */ - trd_close_swapfile(&runctx); - - /* close the load file if one was opened */ - if (loadopen) - fiorcls(&fiolctx); + ERRCLEAN(ec) + /* close and delete swapfile, if one was opened */ + trd_close_swapfile(&runctx); + + /* close the load file if one was opened */ + if (loadopen) + fiorcls(&fiolctx); - /* vocctx is going out of scope - forget the global reference to it */ - main_voc_ctx = 0; + /* vocctx is going out of scope - forget the global reference to it */ + main_voc_ctx = 0; - /* delete the voc context */ - vocterm(&vocctx); + /* delete the voc context */ + vocterm(&vocctx); - /* delete the undo context */ - if (undoptr != 0) - objuterm(undoptr); + /* delete the undo context */ + if (undoptr != 0) + objuterm(undoptr); - /* release the object cache structures */ - if (mctx != 0) - mcmcterm(mctx); - if (globalctx != 0) - mcmterm(globalctx); - ERRENDCLN(ec) + /* release the object cache structures */ + if (mctx != 0) + mcmcterm(mctx); + if (globalctx != 0) + mcmterm(globalctx); + ERRENDCLN(ec) - /* vocctx is going out of scope - forget the global reference to it */ - main_voc_ctx = 0; + /* vocctx is going out of scope - forget the global reference to it */ + main_voc_ctx = 0; - /* delete the voc contxt */ - vocterm(&vocctx); + /* delete the voc contxt */ + vocterm(&vocctx); - /* delete the undo context */ - if (undoptr != 0) - objuterm(undoptr); + /* delete the undo context */ + if (undoptr != 0) + objuterm(undoptr); - /* release the object cache structures */ - mcmcterm(mctx); - mcmterm(globalctx); + /* release the object cache structures */ + mcmcterm(mctx); + mcmterm(globalctx); } /* @@ -789,21 +789,21 @@ static void trdmain1(errcxdef *ec, int argc, char *argv[], /* log an error */ static void trdlogerr(void *ctx0, const char *fac, int err, int argc, erradef *argv) { - errcxdef *ctx = (errcxdef *)ctx0; - char buf[256]; - char msg[256]; + errcxdef *ctx = (errcxdef *)ctx0; + char buf[256]; + char msg[256]; - /* display the prefix message to the console and log file */ - sprintf(buf, TRDLOGERR_PREFIX, fac, err); - trdptf("%s", buf); - out_logfile_print(buf, FALSE); + /* display the prefix message to the console and log file */ + sprintf(buf, TRDLOGERR_PREFIX, fac, err); + trdptf("%s", buf); + out_logfile_print(buf, FALSE); - /* display the error message text to the console and log file */ - errmsg(ctx, msg, (uint)sizeof(msg), err); - errfmt(buf, (int)sizeof(buf), msg, argc, argv); - trdptf("%s]\n", buf); - out_logfile_print(buf, FALSE); - out_logfile_print("]", TRUE); + /* display the error message text to the console and log file */ + errmsg(ctx, msg, (uint)sizeof(msg), err); + errfmt(buf, (int)sizeof(buf), msg, argc, argv); + trdptf("%s]\n", buf); + out_logfile_print(buf, FALSE); + out_logfile_print("]", TRUE); } @@ -812,101 +812,101 @@ static void trdlogerr(void *ctx0, const char *fac, int err, int argc, erradef *a */ void trd_close_swapfile(runcxdef *runctx) { - extern voccxdef *main_voc_ctx; - mcmcxdef *mctx; - mcmcx1def *globalctx; - mcscxdef *mcsctx; + extern voccxdef *main_voc_ctx; + mcmcxdef *mctx; + mcmcx1def *globalctx; + mcscxdef *mcsctx; - /* if no run context was supplied, find it from the main voc context */ - if (runctx == 0) - { - /* if there is no main voc context, we're out of luck */ - if (main_voc_ctx == 0) - return; + /* if no run context was supplied, find it from the main voc context */ + if (runctx == 0) + { + /* if there is no main voc context, we're out of luck */ + if (main_voc_ctx == 0) + return; - /* get the run context */ - runctx = main_voc_ctx->voccxrun; - } + /* get the run context */ + runctx = main_voc_ctx->voccxrun; + } - /* get the other relevant contexts */ - mctx = runctx->runcxmem; - globalctx = mctx->mcmcxgl; - mcsctx = &globalctx->mcmcxswc; + /* get the other relevant contexts */ + mctx = runctx->runcxmem; + globalctx = mctx->mcmcxgl; + mcsctx = &globalctx->mcmcxswc; - /* if we have a swap file open, close it */ - if (mcsctx->mcscxfp != 0) - { - /* close the file */ - osfcls(mcsctx->mcscxfp); + /* if we have a swap file open, close it */ + if (mcsctx->mcscxfp != 0) + { + /* close the file */ + osfcls(mcsctx->mcscxfp); - /* forget about the file, so we don't try to close it again */ - mcsctx->mcscxfp = (osfildef *)0; - } + /* forget about the file, so we don't try to close it again */ + mcsctx->mcscxfp = (osfildef *)0; + } - /* if we have a filename, delete the file */ - if (mcsctx->mcscxfname != 0) - { - /* delete the file */ - osfdel_temp(mcsctx->mcscxfname); + /* if we have a filename, delete the file */ + if (mcsctx->mcscxfname != 0) + { + /* delete the file */ + osfdel_temp(mcsctx->mcscxfname); - /* forget the filename, so we don't try to delete the file again */ - mchfre(mcsctx->mcscxfname); - mcsctx->mcscxfname = 0; - } + /* forget the filename, so we don't try to delete the file again */ + mchfre(mcsctx->mcscxfname); + mcsctx->mcscxfname = 0; + } } /* main - called by os main after setting up arguments */ int trdmain(int argc, char *argv[], appctxdef *appctx, const char *save_ext) { - errcxdef errctx; - int err; - osfildef *fp; - - errctx.errcxlog = trdlogerr; - errctx.errcxlgc = &errctx; - errctx.errcxfp = (osfildef *)0; - errctx.errcxofs = 0; - errctx.errcxappctx = appctx; - fp = oserrop(argv[0]); - errini(&errctx, fp); - - /* copyright-date-string */ + errcxdef errctx; + int err; + osfildef *fp; + + errctx.errcxlog = trdlogerr; + errctx.errcxlgc = &errctx; + errctx.errcxfp = (osfildef *)0; + errctx.errcxofs = 0; + errctx.errcxappctx = appctx; + fp = oserrop(argv[0]); + errini(&errctx, fp); + + /* copyright-date-string */ #ifndef NO_T2_COPYRIGHT_NOTICE - trdptf("%s - A %s TADS %s Interpreter.\n", - G_tads_oem_app_name, G_tads_oem_display_mode, - TADS_RUNTIME_VERSION); - trdptf("%sopyright (c) 1993, 2012 by Michael J. Roberts.\n", - G_tads_oem_copyright_prefix ? "TADS c" : "C"); - trdptf("%s\n", G_tads_oem_author); + trdptf("%s - A %s TADS %s Interpreter.\n", + G_tads_oem_app_name, G_tads_oem_display_mode, + TADS_RUNTIME_VERSION); + trdptf("%sopyright (c) 1993, 2012 by Michael J. Roberts.\n", + G_tads_oem_copyright_prefix ? "TADS c" : "C"); + trdptf("%s\n", G_tads_oem_author); #endif - - ERRBEGIN(&errctx) - trdmain1(&errctx, argc, argv, appctx, save_ext); - ERRCATCH(&errctx, err) - /* - * log the error, unless it's usage (in which case we logged it - * already) or we're simply quitting the game - */ - if (err != ERR_USAGE && err != ERR_RUNQUIT) - errclog(&errctx); - - /* close the error file */ - if (errctx.errcxfp != 0) - osfcls(errctx.errcxfp); + + ERRBEGIN(&errctx) + trdmain1(&errctx, argc, argv, appctx, save_ext); + ERRCATCH(&errctx, err) + /* + * log the error, unless it's usage (in which case we logged it + * already) or we're simply quitting the game + */ + if (err != ERR_USAGE && err != ERR_RUNQUIT) + errclog(&errctx); + + /* close the error file */ + if (errctx.errcxfp != 0) + osfcls(errctx.errcxfp); - /* pause before exiting if the OS desires it */ - os_expause(); + /* pause before exiting if the OS desires it */ + os_expause(); - /* return failure unless we're simply quitting the game */ - return (err == ERR_RUNQUIT ? OSEXSUCC : OSEXFAIL); - ERREND(&errctx) - - /* close the error file if we opened it */ - if (errctx.errcxfp != 0) - osfcls(errctx.errcxfp); + /* return failure unless we're simply quitting the game */ + return (err == ERR_RUNQUIT ? OSEXSUCC : OSEXFAIL); + ERREND(&errctx) + + /* close the error file if we opened it */ + if (errctx.errcxfp != 0) + osfcls(errctx.errcxfp); - /* successful completion */ - return(OSEXSUCC); + /* successful completion */ + return(OSEXSUCC); } } // End of namespace TADS2 diff --git a/engines/glk/tads/tads2/text_io.h b/engines/glk/tads/tads2/text_io.h index c6ba34c093f..6fbc1a636da 100644 --- a/engines/glk/tads/tads2/text_io.h +++ b/engines/glk/tads/tads2/text_io.h @@ -44,7 +44,7 @@ struct runcxdef; * Text i/o context */ struct tiocxdef { - errcxdef *tiocxerr; /* error handling context */ + errcxdef *tiocxerr; /* error handling context */ }; /** @@ -71,7 +71,7 @@ void out_init(); /* set up format strings in output subsystem */ void tiosetfmt(tiocxdef *ctx, runcxdef *rctx, uchar *fmtbase, - uint fmtlen); + uint fmtlen); /* tell tio subsystem the current actor */ void tiosetactor(tiocxdef *ctx, objnum actor); @@ -195,7 +195,7 @@ char *qasgets(char *buf, int bufl); * local character set. */ void tio_set_html_expansion(unsigned int html_char_val, - const char *expansion, size_t expansion_len); + const char *expansion, size_t expansion_len); /* check for HTML mode - returns true if an "\H+" sequence is active */ int tio_is_html_mode(); @@ -221,8 +221,8 @@ int tio_askfile(const char *prompt, char *reply, int replen, int prompt_type, os * formatted text for text-only implementations. */ int tio_input_dialog(int icon_id, const char *prompt, int standard_button_set, - const char **buttons, int button_count, - int default_index, int cancel_index); + const char **buttons, int button_count, + int default_index, int cancel_index); } // End of namespace TADS2 diff --git a/engines/glk/tads/tads2/tokenizer.cpp b/engines/glk/tads/tads2/tokenizer.cpp index b41846923d0..674d367040e 100644 --- a/engines/glk/tads/tads2/tokenizer.cpp +++ b/engines/glk/tads/tads2/tokenizer.cpp @@ -45,77 +45,77 @@ static int tokdfhsh(const char *sym, int len); /* find a #define symbol */ static tokdfdef *tok_find_define(tokcxdef *ctx, const char *sym, int len) { - int hsh; - tokdfdef *df; + int hsh; + tokdfdef *df; - /* find the appropriate chain the hash table */ - hsh = tokdfhsh(sym, len); + /* find the appropriate chain the hash table */ + hsh = tokdfhsh(sym, len); - /* search the chain for this symbol */ - for (df = ctx->tokcxdf[hsh] ; df ; df = df->nxt) - { - /* if this one matches, return it */ - if (df->len == len && !memcmp(df->nm, sym, (size_t)len)) - { - /* fix it up if it's the special __FILE__ or __LINE__ symbol */ - if (len == 8) - { - if (!memcmp(sym, "__FILE__", (size_t)8)) - { - size_t elen; + /* search the chain for this symbol */ + for (df = ctx->tokcxdf[hsh] ; df ; df = df->nxt) + { + /* if this one matches, return it */ + if (df->len == len && !memcmp(df->nm, sym, (size_t)len)) + { + /* fix it up if it's the special __FILE__ or __LINE__ symbol */ + if (len == 8) + { + if (!memcmp(sym, "__FILE__", (size_t)8)) + { + size_t elen; - /* - * put in the opening single quote, since we want - * the expanded result to be a string - */ - df->expan[0] = '\''; + /* + * put in the opening single quote, since we want + * the expanded result to be a string + */ + df->expan[0] = '\''; - /* get the name */ - linnam(ctx->tokcxlin, df->expan+1); + /* get the name */ + linnam(ctx->tokcxlin, df->expan+1); - /* get the length, and add the closing quote */ - elen = strlen(df->expan); - df->expan[elen] = '\''; + /* get the length, and add the closing quote */ + elen = strlen(df->expan); + df->expan[elen] = '\''; - /* - * set the length of the expansion, including the - * quotes (the first quote was measured in the - * length originally, but the second quote hasn't - * been counted yet, so add one to our original - * length) - */ - df->explen = (int)elen + 1; + /* + * set the length of the expansion, including the + * quotes (the first quote was measured in the + * length originally, but the second quote hasn't + * been counted yet, so add one to our original + * length) + */ + df->explen = (int)elen + 1; - /* if the expansion is too long, it's an error */ - if (df->explen >= OSFNMAX) - errsig(ctx->tokcxerr, ERR_LONG_FILE_MACRO); - } - else if (!memcmp(sym, "__LINE__", (size_t)8)) - { - ulong l; + /* if the expansion is too long, it's an error */ + if (df->explen >= OSFNMAX) + errsig(ctx->tokcxerr, ERR_LONG_FILE_MACRO); + } + else if (!memcmp(sym, "__LINE__", (size_t)8)) + { + ulong l; - /* get the line number */ - l = linlnum(ctx->tokcxlin); + /* get the line number */ + l = linlnum(ctx->tokcxlin); - /* convert it to a textual format for the expansion */ - sprintf(df->expan, "%lu", l); + /* convert it to a textual format for the expansion */ + sprintf(df->expan, "%lu", l); - /* set the expanded value's length */ - df->explen = strlen(df->expan); + /* set the expanded value's length */ + df->explen = strlen(df->expan); - /* make sure the expansion isn't too long */ - if (df->explen >= 40) - errsig(ctx->tokcxerr, ERR_LONG_LINE_MACRO); - } - } - - /* return it */ - return df; - } - } + /* make sure the expansion isn't too long */ + if (df->explen >= 40) + errsig(ctx->tokcxerr, ERR_LONG_LINE_MACRO); + } + } + + /* return it */ + return df; + } + } - /* didn't find anything */ - return 0; + /* didn't find anything */ + return 0; } /* @@ -123,64 +123,64 @@ static tokdfdef *tok_find_define(tokcxdef *ctx, const char *sym, int len) */ void tok_write_defines(tokcxdef *ctx, osfildef *fp, errcxdef *ec) { - int i; - tokdfdef **dfp; - tokdfdef *df; - char buf[4]; + int i; + tokdfdef **dfp; + tokdfdef *df; + char buf[4]; - /* write each element of the hash chains */ - for (i = TOKDFHSHSIZ, dfp = ctx->tokcxdf ; i ; ++dfp, --i) - { - /* write each entry in this hash chain */ - for (df = *dfp ; df ; df = df->nxt) - { - /* write this entry */ - oswp2(buf, df->len); - oswp2(buf + 2, df->explen); - if (osfwb(fp, buf, 4) - || osfwb(fp, df->nm, df->len) - || (df->explen != 0 && osfwb(fp, df->expan, df->explen))) - errsig(ec, ERR_WRTGAM); - } + /* write each element of the hash chains */ + for (i = TOKDFHSHSIZ, dfp = ctx->tokcxdf ; i ; ++dfp, --i) + { + /* write each entry in this hash chain */ + for (df = *dfp ; df ; df = df->nxt) + { + /* write this entry */ + oswp2(buf, df->len); + oswp2(buf + 2, df->explen); + if (osfwb(fp, buf, 4) + || osfwb(fp, df->nm, df->len) + || (df->explen != 0 && osfwb(fp, df->expan, df->explen))) + errsig(ec, ERR_WRTGAM); + } - /* write a zero-length entry to indicate the end of this chain */ - oswp2(buf, 0); - if (osfwb(fp, buf, 4)) errsig(ec, ERR_WRTGAM); - } + /* write a zero-length entry to indicate the end of this chain */ + oswp2(buf, 0); + if (osfwb(fp, buf, 4)) errsig(ec, ERR_WRTGAM); + } } /* compute a #define symbol's hash value */ static int tokdfhsh(const char *sym, int len) { - uint hsh; + uint hsh; - for (hsh = 0 ; len ; ++sym, --len) - hsh = (hsh + *sym) & TOKDFHSHMASK; - return hsh; + for (hsh = 0 ; len ; ++sym, --len) + hsh = (hsh + *sym) & TOKDFHSHMASK; + return hsh; } /* convert a #define symbol to lower case if folding case */ static const char *tok_casefold_defsym(tokcxdef *ctx, char *outbuf, - const char *src, int len) + const char *src, int len) { - if (ctx->tokcxflg & TOKCXCASEFOLD) - { - char *dst; - int rem; + if (ctx->tokcxflg & TOKCXCASEFOLD) + { + char *dst; + int rem; - /* make a lower-case copy of the symbol */ - rem = (len > TOKNAMMAX ? TOKNAMMAX : len); - for (dst = outbuf ; rem > 0 ; ++dst, ++src, --rem) - *dst = (Common::isUpper((uchar)*src) ? Common::isLower((uchar)*src) : *src); + /* make a lower-case copy of the symbol */ + rem = (len > TOKNAMMAX ? TOKNAMMAX : len); + for (dst = outbuf ; rem > 0 ; ++dst, ++src, --rem) + *dst = (Common::isUpper((uchar)*src) ? Common::isLower((uchar)*src) : *src); - /* use the lower-case copy instead of the original */ - return outbuf; - } - else - { - /* return the original unchanged */ - return src; - } + /* use the lower-case copy instead of the original */ + return outbuf; + } + else + { + /* return the original unchanged */ + return src; + } } /* @@ -188,154 +188,154 @@ static const char *tok_casefold_defsym(tokcxdef *ctx, char *outbuf, */ void tok_case_fold(tokcxdef *ctx, tokdef *tok) { - /* if we're in case-insensitive mode, convert the token to lower-case */ - if (ctx->tokcxflg & TOKCXCASEFOLD) - { - char *p; - int len; + /* if we're in case-insensitive mode, convert the token to lower-case */ + if (ctx->tokcxflg & TOKCXCASEFOLD) + { + char *p; + int len; - /* convert each character in the token to lower-case */ - for (p = tok->toknam, len = tok->toklen ; len != 0 ; ++p, --len) - { - /* if this character is upper-case, convert it to lower-case */ - if (Common::isUpper((uchar)*p)) - *p = Common::isLower((uchar)*p); - } - } + /* convert each character in the token to lower-case */ + for (p = tok->toknam, len = tok->toklen ; len != 0 ; ++p, --len) + { + /* if this character is upper-case, convert it to lower-case */ + if (Common::isUpper((uchar)*p)) + *p = Common::isLower((uchar)*p); + } + } } /* add a symbol to the #define symbol table, folding case if necessary */ void tok_add_define_cvtcase(tokcxdef *ctx, const char *sym, int len, - const char *expan, int explen) + const char *expan, int explen) { - char mysym[TOKNAMMAX]; - - /* convert to lower-case if necessary */ - sym = tok_casefold_defsym(ctx, mysym, sym, len); + char mysym[TOKNAMMAX]; + + /* convert to lower-case if necessary */ + sym = tok_casefold_defsym(ctx, mysym, sym, len); - /* add the symbol */ - tok_add_define(ctx, sym, len, expan, explen); + /* add the symbol */ + tok_add_define(ctx, sym, len, expan, explen); } /* add a symbol to the #define symbol table */ void tok_add_define(tokcxdef *ctx, const char *sym, int len, - const char *expan, int explen) + const char *expan, int explen) { - int hsh; - tokdfdef *df; + int hsh; + tokdfdef *df; - /* if it's already defined, ignore it */ - if (tok_find_define(ctx, sym, len)) - return; + /* if it's already defined, ignore it */ + if (tok_find_define(ctx, sym, len)) + return; - /* find the appropriate entry in the hash table */ - hsh = tokdfhsh(sym, len); + /* find the appropriate entry in the hash table */ + hsh = tokdfhsh(sym, len); - /* allocate space for the symbol */ - df = (tokdfdef *)mchalo(ctx->tokcxerr, - (sizeof(tokdfdef) + len + explen - 1), - "tok_add_define"); + /* allocate space for the symbol */ + df = (tokdfdef *)mchalo(ctx->tokcxerr, + (sizeof(tokdfdef) + len + explen - 1), + "tok_add_define"); - /* set up the new symbol */ - df->nm = df->expan + explen; - df->len = len; - df->explen = explen; - memcpy(df->expan, expan, explen); - memcpy(df->nm, sym, len); + /* set up the new symbol */ + df->nm = df->expan + explen; + df->len = len; + df->explen = explen; + memcpy(df->expan, expan, explen); + memcpy(df->nm, sym, len); - /* link it into the hash chain */ - df->nxt = ctx->tokcxdf[hsh]; - ctx->tokcxdf[hsh] = df; + /* link it into the hash chain */ + df->nxt = ctx->tokcxdf[hsh]; + ctx->tokcxdf[hsh] = df; } /* add a #define symbol with a numeric value */ void tok_add_define_num_cvtcase(tokcxdef *ctx, char *sym, int len, int num) { - char buf[20]; - - /* convert the value to a string */ - sprintf(buf, "%d", num); + char buf[20]; + + /* convert the value to a string */ + sprintf(buf, "%d", num); - /* add the text value */ - tok_add_define_cvtcase(ctx, sym, len, buf, strlen(buf)); + /* add the text value */ + tok_add_define_cvtcase(ctx, sym, len, buf, strlen(buf)); } /* undefine a #define symbol */ void tok_del_define(tokcxdef *ctx, const char *sym, int len) { - int hsh; - tokdfdef *df; - tokdfdef *prv; - - /* find the appropriate chain the hash table */ - hsh = tokdfhsh(sym, len); + int hsh; + tokdfdef *df; + tokdfdef *prv; + + /* find the appropriate chain the hash table */ + hsh = tokdfhsh(sym, len); - /* search the chain for this symbol */ - for (prv = 0, df = ctx->tokcxdf[hsh] ; df ; prv = df, df = df->nxt) - { - /* if this one matches, delete it */ - if (df->len == len && !memcmp(df->nm, sym, (size_t)len)) - { - /* unlink it from the chain */ - if (prv) - prv->nxt = df->nxt; - else - ctx->tokcxdf[hsh] = df->nxt; + /* search the chain for this symbol */ + for (prv = 0, df = ctx->tokcxdf[hsh] ; df ; prv = df, df = df->nxt) + { + /* if this one matches, delete it */ + if (df->len == len && !memcmp(df->nm, sym, (size_t)len)) + { + /* unlink it from the chain */ + if (prv) + prv->nxt = df->nxt; + else + ctx->tokcxdf[hsh] = df->nxt; - /* delete this symbol, and we're done */ - mchfre(df); - break; - } - } + /* delete this symbol, and we're done */ + mchfre(df); + break; + } + } } /* scan a #define symbol to see how long it is */ static int tok_scan_defsym(tokcxdef *ctx, const char *p, int len) { - int symlen; + int symlen; - /* make sure it's a valid symbol */ - if (!(Common::isAlpha((uchar)*p) || *p == '_' || *p == '$')) - { - errlog(ctx->tokcxerr, ERR_REQSYM); - return 0; - } + /* make sure it's a valid symbol */ + if (!(Common::isAlpha((uchar)*p) || *p == '_' || *p == '$')) + { + errlog(ctx->tokcxerr, ERR_REQSYM); + return 0; + } - /* count characters as long as we have valid symbol characters */ - for (symlen = 0 ; len && TOKISSYM(*p) ; ++p, --len, ++symlen) ; - return symlen; + /* count characters as long as we have valid symbol characters */ + for (symlen = 0 ; len && TOKISSYM(*p) ; ++p, --len, ++symlen) ; + return symlen; } /* process a #define */ static void tokdefine(tokcxdef *ctx, const char *p, int len) { - const char *sym; - int symlen; - const char *expan; - char mysym[TOKNAMMAX]; - - /* get the symbol */ - sym = p; - if (!(symlen = tok_scan_defsym(ctx, p, len))) - return; + const char *sym; + int symlen; + const char *expan; + char mysym[TOKNAMMAX]; + + /* get the symbol */ + sym = p; + if (!(symlen = tok_scan_defsym(ctx, p, len))) + return; - /* if it's already in the table, log an error */ - if (tok_find_define(ctx, sym, symlen)) - { - errlog(ctx->tokcxerr, ERR_DEFREDEF); - return; - } + /* if it's already in the table, log an error */ + if (tok_find_define(ctx, sym, symlen)) + { + errlog(ctx->tokcxerr, ERR_DEFREDEF); + return; + } - /* skip whitespace following the symbol */ - expan = sym + symlen; - len -= symlen; - while (len && t_isspace(*expan)) --len, ++expan; + /* skip whitespace following the symbol */ + expan = sym + symlen; + len -= symlen; + while (len && t_isspace(*expan)) --len, ++expan; - /* if we're folding case, convert the symbol to lower case */ - sym = tok_casefold_defsym(ctx, mysym, sym, symlen); + /* if we're folding case, convert the symbol to lower case */ + sym = tok_casefold_defsym(ctx, mysym, sym, symlen); - /* define the symbol */ - tok_add_define(ctx, sym, symlen, expan, len); + /* define the symbol */ + tok_add_define(ctx, sym, symlen, expan, len); } /* @@ -347,1154 +347,1154 @@ static void tokdefine(tokcxdef *ctx, const char *p, int len) */ static void tok_update_if_stat(tokcxdef *ctx) { - int i; + int i; - /* look through nesting from the outermost level */ - for (i = 0 ; i < ctx->tokcxifcnt ; ++i) - { - /* assume this level will apply to everything inside */ - ctx->tokcxifcur = ctx->tokcxif[i]; + /* look through nesting from the outermost level */ + for (i = 0 ; i < ctx->tokcxifcnt ; ++i) + { + /* assume this level will apply to everything inside */ + ctx->tokcxifcur = ctx->tokcxif[i]; - /* if this level is off, everything inside is off */ - switch (ctx->tokcxif[i]) - { - case TOKIF_IF_NO: - case TOKIF_ELSE_NO: - /* - * this level is off, hence everything inside is off -- stop - * here with the current (negative) determination - */ - return; + /* if this level is off, everything inside is off */ + switch (ctx->tokcxif[i]) + { + case TOKIF_IF_NO: + case TOKIF_ELSE_NO: + /* + * this level is off, hence everything inside is off -- stop + * here with the current (negative) determination + */ + return; - default: - /* so far we're in the "on" section, so keep looking */ - break; - } - } + default: + /* so far we're in the "on" section, so keep looking */ + break; + } + } } /* process an #ifdef or a #ifndef */ static void tok_ifdef_ifndef(tokcxdef *ctx, const char *p, int len, int is_ifdef) { - int symlen; - const char *sym; - int stat; - int found; - char mysym[TOKNAMMAX]; + int symlen; + const char *sym; + int stat; + int found; + char mysym[TOKNAMMAX]; - /* get the symbol */ - sym = p; - if (!(symlen = tok_scan_defsym(ctx, p, len))) - return; + /* get the symbol */ + sym = p; + if (!(symlen = tok_scan_defsym(ctx, p, len))) + return; - /* if we're folding case, convert the symbol to lower case */ - sym = tok_casefold_defsym(ctx, mysym, sym, symlen); + /* if we're folding case, convert the symbol to lower case */ + sym = tok_casefold_defsym(ctx, mysym, sym, symlen); - /* see if we can find it in the table, and set the status accordingly */ - found = (tok_find_define(ctx, sym, symlen) != 0); + /* see if we can find it in the table, and set the status accordingly */ + found = (tok_find_define(ctx, sym, symlen) != 0); - /* invert the test if this is an ifndef */ - if (!is_ifdef) found = !found; + /* invert the test if this is an ifndef */ + if (!is_ifdef) found = !found; - /* set the #if status accordingly */ - if (found) - stat = TOKIF_IF_YES; - else - stat = TOKIF_IF_NO; - ctx->tokcxif[ctx->tokcxifcnt] = stat; + /* set the #if status accordingly */ + if (found) + stat = TOKIF_IF_YES; + else + stat = TOKIF_IF_NO; + ctx->tokcxif[ctx->tokcxifcnt] = stat; - /* allocate a new #if level (making sure we have room) */ - if (ctx->tokcxifcnt >= TOKIFNEST) - { - errlog(ctx->tokcxerr, ERR_MANYPIF); - return; - } - ctx->tokcxifcnt++; + /* allocate a new #if level (making sure we have room) */ + if (ctx->tokcxifcnt >= TOKIFNEST) + { + errlog(ctx->tokcxerr, ERR_MANYPIF); + return; + } + ctx->tokcxifcnt++; - /* update the current status */ - tok_update_if_stat(ctx); + /* update the current status */ + tok_update_if_stat(ctx); } /* process a #error */ static void tok_p_error(tokcxdef *ctx, const char *p, int len) { - errlog1(ctx->tokcxerr, ERR_P_ERROR, - ERRTSTR, errstr(ctx->tokcxerr, p, len)); + errlog1(ctx->tokcxerr, ERR_P_ERROR, + ERRTSTR, errstr(ctx->tokcxerr, p, len)); } /* process a #ifdef */ static void tokifdef(tokcxdef *ctx, const char *p, int len) { - tok_ifdef_ifndef(ctx, p, len, TRUE); + tok_ifdef_ifndef(ctx, p, len, TRUE); } /* process a #ifndef */ static void tokifndef(tokcxdef *ctx, const char *p, int len) { - tok_ifdef_ifndef(ctx, p, len, FALSE); + tok_ifdef_ifndef(ctx, p, len, FALSE); } /* process a #if */ static void tokif(tokcxdef *ctx, const char *p, int len) { - errsig(ctx->tokcxerr, ERR_PIF_NA); + errsig(ctx->tokcxerr, ERR_PIF_NA); } /* process a #elif */ static void tokelif(tokcxdef *ctx, const char *p, int len) { - errsig(ctx->tokcxerr, ERR_PELIF_NA); + errsig(ctx->tokcxerr, ERR_PELIF_NA); } /* process a #else */ static void tokelse(tokcxdef *ctx, const char *p, int len) { - int cnt; - - /* if we're not expecting #else, it's an error */ - cnt = ctx->tokcxifcnt; - if (cnt == 0 || ctx->tokcxif[cnt-1] == TOKIF_ELSE_YES - || ctx->tokcxif[cnt-1] == TOKIF_ELSE_NO) - { - errlog(ctx->tokcxerr, ERR_BADPELSE); - return; - } + int cnt; + + /* if we're not expecting #else, it's an error */ + cnt = ctx->tokcxifcnt; + if (cnt == 0 || ctx->tokcxif[cnt-1] == TOKIF_ELSE_YES + || ctx->tokcxif[cnt-1] == TOKIF_ELSE_NO) + { + errlog(ctx->tokcxerr, ERR_BADPELSE); + return; + } - /* switch to the appropriate #else state (opposite the #if state) */ - if (ctx->tokcxif[cnt-1] == TOKIF_IF_YES) - ctx->tokcxif[cnt-1] = TOKIF_ELSE_NO; - else - ctx->tokcxif[cnt-1] = TOKIF_ELSE_YES; + /* switch to the appropriate #else state (opposite the #if state) */ + if (ctx->tokcxif[cnt-1] == TOKIF_IF_YES) + ctx->tokcxif[cnt-1] = TOKIF_ELSE_NO; + else + ctx->tokcxif[cnt-1] = TOKIF_ELSE_YES; - /* update the current status */ - tok_update_if_stat(ctx); + /* update the current status */ + tok_update_if_stat(ctx); } /* process a #endif */ static void tokendif(tokcxdef *ctx, const char *p, int len) { - /* if we're not expecting #endif, it's an error */ - if (ctx->tokcxifcnt == 0) - { - errlog(ctx->tokcxerr, ERR_BADENDIF); - return; - } + /* if we're not expecting #endif, it's an error */ + if (ctx->tokcxifcnt == 0) + { + errlog(ctx->tokcxerr, ERR_BADENDIF); + return; + } - /* remove the #if level */ - ctx->tokcxifcnt--; + /* remove the #if level */ + ctx->tokcxifcnt--; - /* update the current status */ - tok_update_if_stat(ctx); + /* update the current status */ + tok_update_if_stat(ctx); } /* process a #undef */ static void tokundef(tokcxdef *ctx, const char *p, int len) { - const char *sym; - int symlen; - char mysym[TOKNAMMAX]; - - /* get the symbol */ - sym = p; - if (!(symlen = tok_scan_defsym(ctx, p, len))) - return; + const char *sym; + int symlen; + char mysym[TOKNAMMAX]; + + /* get the symbol */ + sym = p; + if (!(symlen = tok_scan_defsym(ctx, p, len))) + return; - /* if we're folding case, convert the symbol to lower case */ - sym = tok_casefold_defsym(ctx, mysym, sym, symlen); + /* if we're folding case, convert the symbol to lower case */ + sym = tok_casefold_defsym(ctx, mysym, sym, symlen); - /* if it's not defined, log a warning */ - if (!tok_find_define(ctx, sym, symlen)) - { - errlog(ctx->tokcxerr, ERR_PUNDEF); - return; - } + /* if it's not defined, log a warning */ + if (!tok_find_define(ctx, sym, symlen)) + { + errlog(ctx->tokcxerr, ERR_PUNDEF); + return; + } - /* undefine the symbol */ - tok_del_define(ctx, sym, symlen); + /* undefine the symbol */ + tok_del_define(ctx, sym, symlen); } /* process a #pragma directive */ static void tokpragma(tokcxdef *ctx, const char *p, int len) { - /* ignore empty pragmas */ - if (len == 0) - { - errlog(ctx->tokcxerr, ERR_PRAGMA); - return; - } + /* ignore empty pragmas */ + if (len == 0) + { + errlog(ctx->tokcxerr, ERR_PRAGMA); + return; + } - /* see what we have */ - if (len > 1 - && (*p == 'c' || *p == 'C') - && (*(p+1) == '+' || *(p+1) == '-' || t_isspace(*(p+1)))) - { - /* skip spaces after the 'C', if any */ - for (++p, --len ; len && t_isspace(*p) ; ++p, --len) ; + /* see what we have */ + if (len > 1 + && (*p == 'c' || *p == 'C') + && (*(p+1) == '+' || *(p+1) == '-' || t_isspace(*(p+1)))) + { + /* skip spaces after the 'C', if any */ + for (++p, --len ; len && t_isspace(*p) ; ++p, --len) ; - /* look for the + or - flag */ - if (len && *p == '+') - ctx->tokcxflg |= TOKCXFCMODE; - else if (len && *p == '-') - ctx->tokcxflg &= ~TOKCXFCMODE; - else - { - errlog(ctx->tokcxerr, ERR_PRAGMA); - return; - } - } - else - { - errlog(ctx->tokcxerr, ERR_PRAGMA); - } + /* look for the + or - flag */ + if (len && *p == '+') + ctx->tokcxflg |= TOKCXFCMODE; + else if (len && *p == '-') + ctx->tokcxflg &= ~TOKCXFCMODE; + else + { + errlog(ctx->tokcxerr, ERR_PRAGMA); + return; + } + } + else + { + errlog(ctx->tokcxerr, ERR_PRAGMA); + } } /* process a #include directive */ static void tokinclude(tokcxdef *ctx, const char *p, int len) { - linfdef *child; - tokpdef *path; - const char *fname; - int match; - int flen; - linfdef *lin; - const char *q; - size_t flen2; + linfdef *child; + tokpdef *path; + const char *fname; + int match; + int flen; + linfdef *lin; + const char *q; + size_t flen2; - /* find the filename portion */ - fname = p + 1; /* remember start of filename */ - path = ctx->tokcxinc; /* start with first path entry */ + /* find the filename portion */ + fname = p + 1; /* remember start of filename */ + path = ctx->tokcxinc; /* start with first path entry */ - if (!len) - { - errlog(ctx->tokcxerr, ERR_INCNOFN); - return; - } - - switch(*p) - { - case '<': - match = '>'; - if (path && path->tokpnxt) path = path->tokpnxt; /* skip 1st path */ - goto find_matching_delim; + if (!len) + { + errlog(ctx->tokcxerr, ERR_INCNOFN); + return; + } + + switch(*p) + { + case '<': + match = '>'; + if (path && path->tokpnxt) path = path->tokpnxt; /* skip 1st path */ + goto find_matching_delim; - case '"': - match = '"'; + case '"': + match = '"'; - find_matching_delim: - for (++p, --len ; len && *p != match ; --len, ++p) ; - if (len == 0 || *p != match) errlog(ctx->tokcxerr, ERR_INCMTCH); - break; - - default: - errlog(ctx->tokcxerr, ERR_INCSYN); - return; - } - - flen = p - fname; /* compute length of filename */ - for (q = p, flen2 = 0 ; - q > fname && *(q-1) != OSPATHCHAR && !strchr(OSPATHALT, *(q-1)) ; - --q, ++flen2) ; - - /* check to see if this file has already been included */ - for (lin = ctx->tokcxhdr ; lin ; lin = (linfdef *)lin->linflin.linnxt) - { - char *p2 = lin->linfnam; - - p2 += strlen(p2); - - while (p2 > lin->linfnam && *(p2-1) != OSPATHCHAR - && !strchr(OSPATHALT, *(p2-1))) - --p2; - if (strlen(p2) == flen2 - && !memicmp(p2, q, flen2)) - { - errlog1(ctx->tokcxerr, ERR_INCRPT, ERRTSTR, - errstr(ctx->tokcxerr, fname, flen)); - return; - } - } - - /* initialize the line source */ - child = linfini(ctx->tokcxmem, ctx->tokcxerr, fname, flen, path, TRUE, - (ctx->tokcxflg & TOKCXFLIN2) != 0); - - /* if not found, signal an error */ - if (!child) errsig1(ctx->tokcxerr, ERR_INCSEAR, - ERRTSTR, errstr(ctx->tokcxerr, fname, flen)); - - /* link into tokenizer list of line records */ - child->linflin.linnxt = (lindef *)ctx->tokcxhdr; - ctx->tokcxhdr = child; + find_matching_delim: + for (++p, --len ; len && *p != match ; --len, ++p) ; + if (len == 0 || *p != match) errlog(ctx->tokcxerr, ERR_INCMTCH); + break; + + default: + errlog(ctx->tokcxerr, ERR_INCSYN); + return; + } + + flen = p - fname; /* compute length of filename */ + for (q = p, flen2 = 0 ; + q > fname && *(q-1) != OSPATHCHAR && !strchr(OSPATHALT, *(q-1)) ; + --q, ++flen2) ; + + /* check to see if this file has already been included */ + for (lin = ctx->tokcxhdr ; lin ; lin = (linfdef *)lin->linflin.linnxt) + { + char *p2 = lin->linfnam; + + p2 += strlen(p2); + + while (p2 > lin->linfnam && *(p2-1) != OSPATHCHAR + && !strchr(OSPATHALT, *(p2-1))) + --p2; + if (strlen(p2) == flen2 + && !memicmp(p2, q, flen2)) + { + errlog1(ctx->tokcxerr, ERR_INCRPT, ERRTSTR, + errstr(ctx->tokcxerr, fname, flen)); + return; + } + } + + /* initialize the line source */ + child = linfini(ctx->tokcxmem, ctx->tokcxerr, fname, flen, path, TRUE, + (ctx->tokcxflg & TOKCXFLIN2) != 0); + + /* if not found, signal an error */ + if (!child) errsig1(ctx->tokcxerr, ERR_INCSEAR, + ERRTSTR, errstr(ctx->tokcxerr, fname, flen)); + + /* link into tokenizer list of line records */ + child->linflin.linnxt = (lindef *)ctx->tokcxhdr; + ctx->tokcxhdr = child; - /* if we're tracking sources for debugging, add into the chain */ - if (ctx->tokcxdbg) - { - ctx->tokcxdbg->dbgcxlin = &child->linflin; - child->linflin.linid = ctx->tokcxdbg->dbgcxfid++; - } + /* if we're tracking sources for debugging, add into the chain */ + if (ctx->tokcxdbg) + { + ctx->tokcxdbg->dbgcxlin = &child->linflin; + child->linflin.linid = ctx->tokcxdbg->dbgcxfid++; + } - /* remember my C-mode setting */ - if (ctx->tokcxflg & TOKCXFCMODE) - ctx->tokcxlin->linflg |= LINFCMODE; - else - ctx->tokcxlin->linflg &= ~LINFCMODE; - - child->linflin.linpar = ctx->tokcxlin; /* remember parent line source */ - ctx->tokcxlin = &child->linflin; /* make the child the current source */ + /* remember my C-mode setting */ + if (ctx->tokcxflg & TOKCXFCMODE) + ctx->tokcxlin->linflg |= LINFCMODE; + else + ctx->tokcxlin->linflg &= ~LINFCMODE; + + child->linflin.linpar = ctx->tokcxlin; /* remember parent line source */ + ctx->tokcxlin = &child->linflin; /* make the child the current source */ } /* get a new line from line source, processing '#' directives */ static int tokgetlin(tokcxdef *ctx, int dopound) { - for (;;) - { - if (linget(ctx->tokcxlin)) - { - /* at eof in current source; resume parent if there is one */ - if (ctx->tokcxlin->linpar) - { - lindef *parent; - - parent = ctx->tokcxlin->linpar; /* remember parent */ - lincls(ctx->tokcxlin); /* close included file */ - if (!ctx->tokcxdbg) /* if no debug context... */ - mchfre(ctx->tokcxlin); /* free line source */ - ctx->tokcxlin = parent; /* reset to parent line source */ - if (parent->linflg & LINFCMODE) - ctx->tokcxflg |= TOKCXFCMODE; - else - ctx->tokcxflg &= ~TOKCXFCMODE; - continue; /* back for another attempt */ - } - else - { - /* check for outstanding #if/#ifdef */ - if (ctx->tokcxifcnt) - errlog(ctx->tokcxerr, ERR_NOENDIF); + for (;;) + { + if (linget(ctx->tokcxlin)) + { + /* at eof in current source; resume parent if there is one */ + if (ctx->tokcxlin->linpar) + { + lindef *parent; + + parent = ctx->tokcxlin->linpar; /* remember parent */ + lincls(ctx->tokcxlin); /* close included file */ + if (!ctx->tokcxdbg) /* if no debug context... */ + mchfre(ctx->tokcxlin); /* free line source */ + ctx->tokcxlin = parent; /* reset to parent line source */ + if (parent->linflg & LINFCMODE) + ctx->tokcxflg |= TOKCXFCMODE; + else + ctx->tokcxflg &= ~TOKCXFCMODE; + continue; /* back for another attempt */ + } + else + { + /* check for outstanding #if/#ifdef */ + if (ctx->tokcxifcnt) + errlog(ctx->tokcxerr, ERR_NOENDIF); - /* return end-of-file indication */ - return TRUE; - } - } - - /* if this is a multi-segment line, copy it into our own buffer */ - if (ctx->tokcxlin->linflg & LINFMORE) - { - char *p; - uint rem; - int done; - - if (!ctx->tokcxbuf) - { - /* allocate 1k as a default buffer */ - ctx->tokcxbuf = (char *)mchalo(ctx->tokcxerr, 1024, - "tok"); - ctx->tokcxbsz = 1024; - } - ctx->tokcxlen = 0; - - for (done = FALSE, p = ctx->tokcxbuf, rem = ctx->tokcxbsz ; - !done ; ) - { - size_t len = ctx->tokcxlin->linlen; + /* return end-of-file indication */ + return TRUE; + } + } + + /* if this is a multi-segment line, copy it into our own buffer */ + if (ctx->tokcxlin->linflg & LINFMORE) + { + char *p; + uint rem; + int done; + + if (!ctx->tokcxbuf) + { + /* allocate 1k as a default buffer */ + ctx->tokcxbuf = (char *)mchalo(ctx->tokcxerr, 1024, + "tok"); + ctx->tokcxbsz = 1024; + } + ctx->tokcxlen = 0; + + for (done = FALSE, p = ctx->tokcxbuf, rem = ctx->tokcxbsz ; + !done ; ) + { + size_t len = ctx->tokcxlin->linlen; - /* add the current segment's length into line length */ - ctx->tokcxlen += len; - - /* we're done after this piece if the last fetch was all */ - done = !(ctx->tokcxlin->linflg & LINFMORE); - if (len + 1 > rem) - { - char *newp; + /* add the current segment's length into line length */ + ctx->tokcxlen += len; + + /* we're done after this piece if the last fetch was all */ + done = !(ctx->tokcxlin->linflg & LINFMORE); + if (len + 1 > rem) + { + char *newp; - /* increase the size of the buffer */ - if (ctx->tokcxbsz > (unsigned)0x8000) - errsig(ctx->tokcxerr, ERR_LONGLIN); - rem += 4096; - ctx->tokcxbsz += 4096; - - /* allocate a new buffer and copy line into it */ - newp = (char *)mchalo(ctx->tokcxerr, ctx->tokcxbsz, "tok"); - memcpy(newp, ctx->tokcxbuf, (size_t)(p - ctx->tokcxbuf)); - - /* free the original buffer, and use the new one */ - p = (p - ctx->tokcxbuf) + newp; - mchfre(ctx->tokcxbuf); - ctx->tokcxbuf = newp; - } - - /* add the line to the buffer */ - memcpy(p, ctx->tokcxlin->linbuf, len); - p += len; - rem -= len; - - /* get the next piece of the line if there is one */ - if (!done) - { - if (linget(ctx->tokcxlin)) break; - } - } - - /* null-terminate the buffer, and use it for input */ - *p = '\0'; - ctx->tokcxptr = ctx->tokcxbuf; - } - else - { - ctx->tokcxptr = ctx->tokcxlin->linbuf; - ctx->tokcxlen = ctx->tokcxlin->linlen; - } - - /* check for preprocessor directives */ - if (dopound && ctx->tokcxlen != 0 && ctx->tokcxptr[0] == '#' - && !(ctx->tokcxlin->linflg & LINFNOINC)) - { - const char *p; - int len; - static const struct - { - const char *nm; - int len; - int ok_in_if; - void (*fn)(tokcxdef *, const char *, int); - } - *dirp, dir[] = - { - { "include", 7, FALSE, tokinclude }, - { "pragma", 6, FALSE, tokpragma }, - { "define", 6, FALSE, tokdefine }, - { "ifdef", 5, TRUE, tokifdef }, - { "ifndef", 6, TRUE, tokifndef }, - { "if", 2, TRUE, tokif }, - { "else", 4, TRUE, tokelse }, - { "elif", 4, TRUE, tokelif }, - { "endif", 5, TRUE, tokendif }, - { "undef", 5, FALSE, tokundef }, - { "error", 5, FALSE, tok_p_error } - }; - int i; + /* increase the size of the buffer */ + if (ctx->tokcxbsz > (unsigned)0x8000) + errsig(ctx->tokcxerr, ERR_LONGLIN); + rem += 4096; + ctx->tokcxbsz += 4096; + + /* allocate a new buffer and copy line into it */ + newp = (char *)mchalo(ctx->tokcxerr, ctx->tokcxbsz, "tok"); + memcpy(newp, ctx->tokcxbuf, (size_t)(p - ctx->tokcxbuf)); + + /* free the original buffer, and use the new one */ + p = (p - ctx->tokcxbuf) + newp; + mchfre(ctx->tokcxbuf); + ctx->tokcxbuf = newp; + } + + /* add the line to the buffer */ + memcpy(p, ctx->tokcxlin->linbuf, len); + p += len; + rem -= len; + + /* get the next piece of the line if there is one */ + if (!done) + { + if (linget(ctx->tokcxlin)) break; + } + } + + /* null-terminate the buffer, and use it for input */ + *p = '\0'; + ctx->tokcxptr = ctx->tokcxbuf; + } + else + { + ctx->tokcxptr = ctx->tokcxlin->linbuf; + ctx->tokcxlen = ctx->tokcxlin->linlen; + } + + /* check for preprocessor directives */ + if (dopound && ctx->tokcxlen != 0 && ctx->tokcxptr[0] == '#' + && !(ctx->tokcxlin->linflg & LINFNOINC)) + { + const char *p; + int len; + static const struct + { + const char *nm; + int len; + int ok_in_if; + void (*fn)(tokcxdef *, const char *, int); + } + *dirp, dir[] = + { + { "include", 7, FALSE, tokinclude }, + { "pragma", 6, FALSE, tokpragma }, + { "define", 6, FALSE, tokdefine }, + { "ifdef", 5, TRUE, tokifdef }, + { "ifndef", 6, TRUE, tokifndef }, + { "if", 2, TRUE, tokif }, + { "else", 4, TRUE, tokelse }, + { "elif", 4, TRUE, tokelif }, + { "endif", 5, TRUE, tokendif }, + { "undef", 5, FALSE, tokundef }, + { "error", 5, FALSE, tok_p_error } + }; + int i; - /* scan off spaces between '#' and directive */ - for (len = ctx->tokcxlen - 1, p = &ctx->tokcxptr[1] ; - len && t_isspace(*p) ; --len, ++p) ; + /* scan off spaces between '#' and directive */ + for (len = ctx->tokcxlen - 1, p = &ctx->tokcxptr[1] ; + len && t_isspace(*p) ; --len, ++p) ; - /* find and process the directive */ - for (dirp = dir, i = sizeof(dir)/sizeof(dir[0]) ; i ; --i, ++dirp) - { - /* compare this directive; if it wins, call its function */ - if (len >= dirp->len && !memcmp(p, dirp->nm, (size_t)dirp->len) - && (len == dirp->len || t_isspace(*(p + dirp->len)))) - { - int cnt; - int stat; - - /* - * if we're not in a #if's false part, or if the - * directive is processed even in #if false parts, - * process the line, otherwise skip it - */ - cnt = ctx->tokcxifcnt; - if (dirp->ok_in_if || cnt == 0 - || ((stat = ctx->tokcxifcur) == TOKIF_IF_YES - || stat == TOKIF_ELSE_YES)) - { - /* skip whitespace following the directive */ - for (p += dirp->len, len -= dirp->len ; - len && t_isspace(*p) ; - --len, ++p) ; + /* find and process the directive */ + for (dirp = dir, i = sizeof(dir)/sizeof(dir[0]) ; i ; --i, ++dirp) + { + /* compare this directive; if it wins, call its function */ + if (len >= dirp->len && !memcmp(p, dirp->nm, (size_t)dirp->len) + && (len == dirp->len || t_isspace(*(p + dirp->len)))) + { + int cnt; + int stat; + + /* + * if we're not in a #if's false part, or if the + * directive is processed even in #if false parts, + * process the line, otherwise skip it + */ + cnt = ctx->tokcxifcnt; + if (dirp->ok_in_if || cnt == 0 + || ((stat = ctx->tokcxifcur) == TOKIF_IF_YES + || stat == TOKIF_ELSE_YES)) + { + /* skip whitespace following the directive */ + for (p += dirp->len, len -= dirp->len ; + len && t_isspace(*p) ; + --len, ++p) ; - /* invoke the function to process this directive */ - (*dirp->fn)(ctx, p, len); - } + /* invoke the function to process this directive */ + (*dirp->fn)(ctx, p, len); + } - /* there's no need to look at more directives */ - break; - } - } + /* there's no need to look at more directives */ + break; + } + } - /* if we didn't find anything, flag the error */ - if (i == 0) - errlog(ctx->tokcxerr, ERR_PRPDIR); + /* if we didn't find anything, flag the error */ + if (i == 0) + errlog(ctx->tokcxerr, ERR_PRPDIR); - /* ignore this line */ - continue; - } - else - { - /* - * Check the #if level. If we're in an #if, and we're to - * ignore lines (because of a false condition or an #else - * part for a true condition), skip this line. - */ - if (ctx->tokcxifcnt != 0) - { - switch(ctx->tokcxifcur) - { - case TOKIF_IF_NO: - case TOKIF_ELSE_NO: - /* ignore this line */ - continue; + /* ignore this line */ + continue; + } + else + { + /* + * Check the #if level. If we're in an #if, and we're to + * ignore lines (because of a false condition or an #else + * part for a true condition), skip this line. + */ + if (ctx->tokcxifcnt != 0) + { + switch(ctx->tokcxifcur) + { + case TOKIF_IF_NO: + case TOKIF_ELSE_NO: + /* ignore this line */ + continue; - default: - /* we're in a true part - keep the line */ - break; - } - } - - ctx->tokcxlin->linflg &= ~LINFDBG; /* no debug record yet */ - return(FALSE); /* return the line we found */ - } - } + default: + /* we're in a true part - keep the line */ + break; + } + } + + ctx->tokcxlin->linflg &= ~LINFDBG; /* no debug record yet */ + return(FALSE); /* return the line we found */ + } + } } /* get the next token, removing it from the input stream */ int toknext(tokcxdef *ctx) { - const char *p; - tokdef *tok = &ctx->tokcxcur; - int len; + const char *p; + tokdef *tok = &ctx->tokcxcur; + int len; - /* - * Check for the special case that we pushed an open paren prior to - * a string containing an embedded expression. If this is the case, - * immediately return the string we previously parsed. - */ - if ((ctx->tokcxflg & TOKCXF_EMBED_PAREN_PRE) != 0) - { - /* - * convert the token to a string - note that the offset - * information for the string is already in the current token - * structure, since we set everything up for it on the previous - * call where we actually parsed the beginning of the string - */ - tok->toktyp = TOKTDSTRING; + /* + * Check for the special case that we pushed an open paren prior to + * a string containing an embedded expression. If this is the case, + * immediately return the string we previously parsed. + */ + if ((ctx->tokcxflg & TOKCXF_EMBED_PAREN_PRE) != 0) + { + /* + * convert the token to a string - note that the offset + * information for the string is already in the current token + * structure, since we set everything up for it on the previous + * call where we actually parsed the beginning of the string + */ + tok->toktyp = TOKTDSTRING; - /* clear the special flag - we've now consumed the pushed string */ - ctx->tokcxflg &= ~TOKCXF_EMBED_PAREN_PRE; + /* clear the special flag - we've now consumed the pushed string */ + ctx->tokcxflg &= ~TOKCXF_EMBED_PAREN_PRE; - /* immediately return the string */ - return tok->toktyp; - } + /* immediately return the string */ + return tok->toktyp; + } - /* set up at the current scanning position */ - p = ctx->tokcxptr; - len = ctx->tokcxlen; + /* set up at the current scanning position */ + p = ctx->tokcxptr; + len = ctx->tokcxlen; - /* scan off whitespace and comments until we find something */ - do - { - skipblanks: - /* if there's nothing on this line, get the next one */ - if (len == 0) - { - /* if we're in a macro expansion, continue after it */ - if (ctx->tokcxmlvl) - { - ctx->tokcxmlvl--; - p = ctx->tokcxmsav[ctx->tokcxmlvl]; - len = ctx->tokcxmsvl[ctx->tokcxmlvl]; - } - else - { - if (tokgetlin(ctx, TRUE)) - { - tok->toktyp = TOKTEOF; - goto done; - } - p = ctx->tokcxptr; - len = ctx->tokcxlen; - } - } - while (len && t_isspace(*p)) ++p, --len; /* scan off whitespace */ - - /* check for comments, and remove if present */ - if (len >= 2 && *p == '/' && *(p+1) == '/') - len = 0; - else if (len >= 2 && *p == '/' && *(p+1) == '*') - { - while (len < 2 || *p != '*' || *(p+1) != '/') - { - if (len != 0) - ++p, --len; + /* scan off whitespace and comments until we find something */ + do + { + skipblanks: + /* if there's nothing on this line, get the next one */ + if (len == 0) + { + /* if we're in a macro expansion, continue after it */ + if (ctx->tokcxmlvl) + { + ctx->tokcxmlvl--; + p = ctx->tokcxmsav[ctx->tokcxmlvl]; + len = ctx->tokcxmsvl[ctx->tokcxmlvl]; + } + else + { + if (tokgetlin(ctx, TRUE)) + { + tok->toktyp = TOKTEOF; + goto done; + } + p = ctx->tokcxptr; + len = ctx->tokcxlen; + } + } + while (len && t_isspace(*p)) ++p, --len; /* scan off whitespace */ + + /* check for comments, and remove if present */ + if (len >= 2 && *p == '/' && *(p+1) == '/') + len = 0; + else if (len >= 2 && *p == '/' && *(p+1) == '*') + { + while (len < 2 || *p != '*' || *(p+1) != '/') + { + if (len != 0) + ++p, --len; - if (len == 0) - { - if (ctx->tokcxmlvl != 0) - { - ctx->tokcxmlvl--; - p = ctx->tokcxmsav[ctx->tokcxmlvl]; - len = ctx->tokcxmsvl[ctx->tokcxmlvl]; - } - else - { - if (tokgetlin(ctx, FALSE)) - { - ctx->tokcxptr = p; - tok->toktyp = TOKTEOF; - goto done; - } - p = ctx->tokcxptr; - len = ctx->tokcxlen; - } - } - } - p += 2; - len -= 2; - goto skipblanks; - } - } while (len == 0); - + if (len == 0) + { + if (ctx->tokcxmlvl != 0) + { + ctx->tokcxmlvl--; + p = ctx->tokcxmsav[ctx->tokcxmlvl]; + len = ctx->tokcxmsvl[ctx->tokcxmlvl]; + } + else + { + if (tokgetlin(ctx, FALSE)) + { + ctx->tokcxptr = p; + tok->toktyp = TOKTEOF; + goto done; + } + p = ctx->tokcxptr; + len = ctx->tokcxlen; + } + } + } + p += 2; + len -= 2; + goto skipblanks; + } + } while (len == 0); + nexttoken: - if (Common::isAlpha((uchar)*p) || *p == '_' || *p == '$') - { - int l; - int hash; - const char *q; + if (Common::isAlpha((uchar)*p) || *p == '_' || *p == '$') + { + int l; + int hash; + const char *q; char *tq; - toktdef *tab; - int found = FALSE; - uchar thischar; - tokdfdef *df; - - for (hash = 0, l = 0, tq = tok->toknam ; - len != 0 && TOKISSYM(*p) && l < TOKNAMMAX ; - (thischar = ((Common::isUpper((uchar)*p) - && (ctx->tokcxflg & TOKCXCASEFOLD)) - ? Common::isLower((uchar)*p) : *p)), - (hash = ((hash + thischar) & (TOKHASHSIZE - 1))), - (*tq++ = thischar), ++p, --len, ++l) ; - *tq = '\0'; - if (len != 0 && TOKISSYM(*p)) - { - while (len != 0 && TOKISSYM(*p)) ++p, --len; - errlog1(ctx->tokcxerr, ERR_TRUNC, ERRTSTR, - errstr(ctx->tokcxerr, tok->toknam, tok->toklen)); - } - tok->toklen = l; - tok->tokhash = hash; + toktdef *tab; + int found = FALSE; + uchar thischar; + tokdfdef *df; + + for (hash = 0, l = 0, tq = tok->toknam ; + len != 0 && TOKISSYM(*p) && l < TOKNAMMAX ; + (thischar = ((Common::isUpper((uchar)*p) + && (ctx->tokcxflg & TOKCXCASEFOLD)) + ? Common::isLower((uchar)*p) : *p)), + (hash = ((hash + thischar) & (TOKHASHSIZE - 1))), + (*tq++ = thischar), ++p, --len, ++l) ; + *tq = '\0'; + if (len != 0 && TOKISSYM(*p)) + { + while (len != 0 && TOKISSYM(*p)) ++p, --len; + errlog1(ctx->tokcxerr, ERR_TRUNC, ERRTSTR, + errstr(ctx->tokcxerr, tok->toknam, tok->toklen)); + } + tok->toklen = l; + tok->tokhash = hash; - /* - * check for the special defined() preprocessor operator - */ - if (l == 9 && !memcmp(tok->toknam, - ((ctx->tokcxflg & TOKCXCASEFOLD) - ? "__defined" : "__DEFINED"), - (size_t)9) - && len > 2 && *p == '(' && TOKISSYM(*(p+1)) - && !Common::isDigit((uchar)*(p+1))) - { - int symlen; - char mysym[TOKNAMMAX]; - - /* find the matching ')', allowing only symbolic characters */ - ++p, --len; - for (symlen = 0, q = p ; len && *p != ')' && TOKISSYM(*p) ; - ++p, --len, ++symlen) ; + /* + * check for the special defined() preprocessor operator + */ + if (l == 9 && !memcmp(tok->toknam, + ((ctx->tokcxflg & TOKCXCASEFOLD) + ? "__defined" : "__DEFINED"), + (size_t)9) + && len > 2 && *p == '(' && TOKISSYM(*(p+1)) + && !Common::isDigit((uchar)*(p+1))) + { + int symlen; + char mysym[TOKNAMMAX]; + + /* find the matching ')', allowing only symbolic characters */ + ++p, --len; + for (symlen = 0, q = p ; len && *p != ')' && TOKISSYM(*p) ; + ++p, --len, ++symlen) ; - /* make sure we found the closing paren */ - if (!len || *p != ')') - errsig(ctx->tokcxerr, ERR_BADISDEF); - ++p, --len; + /* make sure we found the closing paren */ + if (!len || *p != ')') + errsig(ctx->tokcxerr, ERR_BADISDEF); + ++p, --len; - /* if we're folding case, convert the symbol to lower case */ - q = tok_casefold_defsym(ctx, mysym, q, symlen); + /* if we're folding case, convert the symbol to lower case */ + q = tok_casefold_defsym(ctx, mysym, q, symlen); - /* check to see if it's defined */ - tok->toktyp = TOKTNUMBER; - tok->tokval = (tok_find_define(ctx, q, symlen) != 0); - goto done; - } + /* check to see if it's defined */ + tok->toktyp = TOKTNUMBER; + tok->tokval = (tok_find_define(ctx, q, symlen) != 0); + goto done; + } - /* substitute the preprocessor #define, if any */ - if ((df = tok_find_define(ctx, tok->toknam, l)) != 0) - { - /* save the current parsing position */ - if (ctx->tokcxmlvl >= TOKMACNEST) - errsig(ctx->tokcxerr, ERR_MACNEST); - ctx->tokcxmsav[ctx->tokcxmlvl] = p; - ctx->tokcxmsvl[ctx->tokcxmlvl] = len; - ctx->tokcxmlvl++; + /* substitute the preprocessor #define, if any */ + if ((df = tok_find_define(ctx, tok->toknam, l)) != 0) + { + /* save the current parsing position */ + if (ctx->tokcxmlvl >= TOKMACNEST) + errsig(ctx->tokcxerr, ERR_MACNEST); + ctx->tokcxmsav[ctx->tokcxmlvl] = p; + ctx->tokcxmsvl[ctx->tokcxmlvl] = len; + ctx->tokcxmlvl++; - /* point to the token's expansion and keep going */ - p = df->expan; - len = df->explen; - goto nexttoken; - } - - /* look up in symbol table(s), if any */ - for (tab = ctx->tokcxstab ; tab ; tab = tab->toktnxt) - { - if ((found = (*tab->toktfsea)(tab, tok->toknam, l, hash, - &tok->toksym)) != 0) - break; - } - - if (found && tok->toksym.tokstyp == TOKSTKW) - tok->toktyp = tok->toksym.toksval; - else - { - tok->toktyp = TOKTSYMBOL; - if (!found) tok->toksym.tokstyp = TOKSTUNK; - } - goto done; - } - else if (Common::isDigit((uchar)*p)) - { - long acc = 0; - - /* check for octal/hex */ - if (*p == '0') - { - ++p, --len; - if (len && (*p == 'x' || *p == 'X')) - { - /* hex */ - ++p, --len; - while (len && TOKISHEX(*p)) - { - acc = (acc << 4) + TOKHEX2INT(*p); - ++p, --len; - } - } - else - { - /* octal */ - while (len && TOKISOCT(*p)) - { - acc = (acc << 3) + TOKOCT2INT(*p); - ++p, --len; - } - } - } - else - { - /* decimal */ - while (len && Common::isDigit((uchar)*p)) - { - acc = (acc << 1) + (acc << 3) + TOKDEC2INT(*p); - ++p, --len; - } - } - tok->tokval = acc; - tok->toktyp = TOKTNUMBER; - goto done; - } - else if (*p == '"' || *p == '\'') - { - char delim; /* closing delimiter we're looking for */ - const char *strstart; /* pointer to start of string */ - int warned; - - delim = *p; - --len; - strstart = ++p; + /* point to the token's expansion and keep going */ + p = df->expan; + len = df->explen; + goto nexttoken; + } + + /* look up in symbol table(s), if any */ + for (tab = ctx->tokcxstab ; tab ; tab = tab->toktnxt) + { + if ((found = (*tab->toktfsea)(tab, tok->toknam, l, hash, + &tok->toksym)) != 0) + break; + } + + if (found && tok->toksym.tokstyp == TOKSTKW) + tok->toktyp = tok->toksym.toksval; + else + { + tok->toktyp = TOKTSYMBOL; + if (!found) tok->toksym.tokstyp = TOKSTUNK; + } + goto done; + } + else if (Common::isDigit((uchar)*p)) + { + long acc = 0; + + /* check for octal/hex */ + if (*p == '0') + { + ++p, --len; + if (len && (*p == 'x' || *p == 'X')) + { + /* hex */ + ++p, --len; + while (len && TOKISHEX(*p)) + { + acc = (acc << 4) + TOKHEX2INT(*p); + ++p, --len; + } + } + else + { + /* octal */ + while (len && TOKISOCT(*p)) + { + acc = (acc << 3) + TOKOCT2INT(*p); + ++p, --len; + } + } + } + else + { + /* decimal */ + while (len && Common::isDigit((uchar)*p)) + { + acc = (acc << 1) + (acc << 3) + TOKDEC2INT(*p); + ++p, --len; + } + } + tok->tokval = acc; + tok->toktyp = TOKTNUMBER; + goto done; + } + else if (*p == '"' || *p == '\'') + { + char delim; /* closing delimiter we're looking for */ + const char *strstart; /* pointer to start of string */ + int warned; + + delim = *p; + --len; + strstart = ++p; - if (delim == '"' && len >= 2 && *p == '<' && *(p+1) == '<') - { - /* save the current parsing position */ - if (ctx->tokcxmlvl >= TOKMACNEST) - errsig(ctx->tokcxerr, ERR_MACNEST); - ctx->tokcxmsav[ctx->tokcxmlvl] = p + 2; - ctx->tokcxmsvl[ctx->tokcxmlvl] = len - 2; - ctx->tokcxmlvl++; + if (delim == '"' && len >= 2 && *p == '<' && *(p+1) == '<') + { + /* save the current parsing position */ + if (ctx->tokcxmlvl >= TOKMACNEST) + errsig(ctx->tokcxerr, ERR_MACNEST); + ctx->tokcxmsav[ctx->tokcxmlvl] = p + 2; + ctx->tokcxmsvl[ctx->tokcxmlvl] = len - 2; + ctx->tokcxmlvl++; - /* - * read from the special "<<" expansion string - use the - * version for a "<<" at the very beginning of the string - */ - p = tokmac1s; - len = strlen(p); - ctx->tokcxflg |= TOKCXFINMAC; - goto nexttoken; - } - tok->toktyp = (delim == '"' ? TOKTDSTRING : TOKTSSTRING); - - tok->tokofs = (*ctx->tokcxsst)(ctx->tokcxscx); /* start the string */ - for (warned = FALSE ;; ) - { - if (len >= 2 && *p == '\\') - { - if (*(p+1) == '"' || *(p+1) == '\'') - { - (*ctx->tokcxsad)(ctx->tokcxscx, strstart, - (ushort)(p - strstart)); - strstart = p + 1; - } - p += 2; - len -= 2; - } - else if (len == 0 || *p == delim || - (delim == '"' && len >= 2 && *p == '<' && *(p+1) == '<' - && !(ctx->tokcxflg & TOKCXFINMAC))) - { - (*ctx->tokcxsad)(ctx->tokcxscx, strstart, - (ushort)(p - strstart)); - if (len == 0) - { - if (ctx->tokcxmlvl) - { - ctx->tokcxmlvl--; - p = ctx->tokcxmsav[ctx->tokcxmlvl]; - len = ctx->tokcxmsvl[ctx->tokcxmlvl]; - } - else - (*ctx->tokcxsad)(ctx->tokcxscx, " ", (ushort)1); - - while (len == 0) - { - if (tokgetlin(ctx, FALSE)) - errsig(ctx->tokcxerr, ERR_STREOF); - p = ctx->tokcxptr; - len = ctx->tokcxlen; + /* + * read from the special "<<" expansion string - use the + * version for a "<<" at the very beginning of the string + */ + p = tokmac1s; + len = strlen(p); + ctx->tokcxflg |= TOKCXFINMAC; + goto nexttoken; + } + tok->toktyp = (delim == '"' ? TOKTDSTRING : TOKTSSTRING); + + tok->tokofs = (*ctx->tokcxsst)(ctx->tokcxscx); /* start the string */ + for (warned = FALSE ;; ) + { + if (len >= 2 && *p == '\\') + { + if (*(p+1) == '"' || *(p+1) == '\'') + { + (*ctx->tokcxsad)(ctx->tokcxscx, strstart, + (ushort)(p - strstart)); + strstart = p + 1; + } + p += 2; + len -= 2; + } + else if (len == 0 || *p == delim || + (delim == '"' && len >= 2 && *p == '<' && *(p+1) == '<' + && !(ctx->tokcxflg & TOKCXFINMAC))) + { + (*ctx->tokcxsad)(ctx->tokcxscx, strstart, + (ushort)(p - strstart)); + if (len == 0) + { + if (ctx->tokcxmlvl) + { + ctx->tokcxmlvl--; + p = ctx->tokcxmsav[ctx->tokcxmlvl]; + len = ctx->tokcxmsvl[ctx->tokcxmlvl]; + } + else + (*ctx->tokcxsad)(ctx->tokcxscx, " ", (ushort)1); + + while (len == 0) + { + if (tokgetlin(ctx, FALSE)) + errsig(ctx->tokcxerr, ERR_STREOF); + p = ctx->tokcxptr; + len = ctx->tokcxlen; - /* warn if it looks like the end of an object */ - if (!warned && len && (*p == ';' || *p == '}')) - { - errlog(ctx->tokcxerr, ERR_STREND); - warned = TRUE; /* warn only once per string */ - } + /* warn if it looks like the end of an object */ + if (!warned && len && (*p == ';' || *p == '}')) + { + errlog(ctx->tokcxerr, ERR_STREND); + warned = TRUE; /* warn only once per string */ + } - /* scan past whitespace at start of line */ - while (len && t_isspace(*p)) ++p, --len; - } - strstart = p; - } - else break; - } - else - ++p, --len; - } + /* scan past whitespace at start of line */ + while (len && t_isspace(*p)) ++p, --len; + } + strstart = p; + } + else break; + } + else + ++p, --len; + } - /* end the string */ - (*ctx->tokcxsend)(ctx->tokcxscx); + /* end the string */ + (*ctx->tokcxsend)(ctx->tokcxscx); - /* check to see how it ended */ - if (len != 0 && *p == delim) - { - /* - * We ended with the matching delimiter. Move past the - * closing delimiter. - */ - ++p; - --len; + /* check to see how it ended */ + if (len != 0 && *p == delim) + { + /* + * We ended with the matching delimiter. Move past the + * closing delimiter. + */ + ++p; + --len; - /* - * If we have a pending close paren we need to put in - * because of an embedded expression that occurred earlier - * in the string, parse the macro to provide the paren. - */ - if ((ctx->tokcxflg & TOKCXF_EMBED_PAREN_AFT) != 0 - && !(ctx->tokcxflg & TOKCXFINMAC)) - { - /* clear the flag */ - ctx->tokcxflg &= ~TOKCXF_EMBED_PAREN_AFT; + /* + * If we have a pending close paren we need to put in + * because of an embedded expression that occurred earlier + * in the string, parse the macro to provide the paren. + */ + if ((ctx->tokcxflg & TOKCXF_EMBED_PAREN_AFT) != 0 + && !(ctx->tokcxflg & TOKCXFINMAC)) + { + /* clear the flag */ + ctx->tokcxflg &= ~TOKCXF_EMBED_PAREN_AFT; - /* push the current parsing position */ - if (ctx->tokcxmlvl >= TOKMACNEST) - errsig(ctx->tokcxerr, ERR_MACNEST); - ctx->tokcxmsav[ctx->tokcxmlvl] = p; - ctx->tokcxmsvl[ctx->tokcxmlvl] = len; - ctx->tokcxmlvl++; + /* push the current parsing position */ + if (ctx->tokcxmlvl >= TOKMACNEST) + errsig(ctx->tokcxerr, ERR_MACNEST); + ctx->tokcxmsav[ctx->tokcxmlvl] = p; + ctx->tokcxmsvl[ctx->tokcxmlvl] = len; + ctx->tokcxmlvl++; - /* parse the macro */ - p = tokmac4; - len = strlen(p); - } - } - else if (len != 0 && *p == '<') - { - /* save the current parsing position */ - if (ctx->tokcxmlvl >= TOKMACNEST) - errsig(ctx->tokcxerr, ERR_MACNEST); - ctx->tokcxmsav[ctx->tokcxmlvl] = p + 2; - ctx->tokcxmsvl[ctx->tokcxmlvl] = len - 2; - ctx->tokcxmlvl++; + /* parse the macro */ + p = tokmac4; + len = strlen(p); + } + } + else if (len != 0 && *p == '<') + { + /* save the current parsing position */ + if (ctx->tokcxmlvl >= TOKMACNEST) + errsig(ctx->tokcxerr, ERR_MACNEST); + ctx->tokcxmsav[ctx->tokcxmlvl] = p + 2; + ctx->tokcxmsvl[ctx->tokcxmlvl] = len - 2; + ctx->tokcxmlvl++; - /* read from the "<<" expansion */ - p = tokmac1; - len = strlen(p); - ctx->tokcxflg |= TOKCXFINMAC; + /* read from the "<<" expansion */ + p = tokmac1; + len = strlen(p); + ctx->tokcxflg |= TOKCXFINMAC; - /* - * Set the special push-a-paren flag: we'll return an open - * paren now, so that we have an open paren before the - * string, and then on the next call to toknext() we'll - * immediately return the string we've already parsed here. - * This will ensure that everything in the string is - * properly grouped together as a single indivisible - * expression. - * - * Note that we only need to do this for the first embedded - * expression in a string. Once we have a close paren - * pending, we don't need more open parens. - */ - if (!(ctx->tokcxflg & TOKCXF_EMBED_PAREN_AFT)) - { - ctx->tokcxflg |= TOKCXF_EMBED_PAREN_PRE; - tok->toktyp = TOKTLPAR; - } - } - goto done; - } - else if (len >= 2 && *p == '>' && *(p+1) == '>' - && (ctx->tokcxflg & TOKCXFINMAC) != 0) - { - /* skip the ">>" */ - ctx->tokcxflg &= ~TOKCXFINMAC; - p += 2; - len -= 2; + /* + * Set the special push-a-paren flag: we'll return an open + * paren now, so that we have an open paren before the + * string, and then on the next call to toknext() we'll + * immediately return the string we've already parsed here. + * This will ensure that everything in the string is + * properly grouped together as a single indivisible + * expression. + * + * Note that we only need to do this for the first embedded + * expression in a string. Once we have a close paren + * pending, we don't need more open parens. + */ + if (!(ctx->tokcxflg & TOKCXF_EMBED_PAREN_AFT)) + { + ctx->tokcxflg |= TOKCXF_EMBED_PAREN_PRE; + tok->toktyp = TOKTLPAR; + } + } + goto done; + } + else if (len >= 2 && *p == '>' && *(p+1) == '>' + && (ctx->tokcxflg & TOKCXFINMAC) != 0) + { + /* skip the ">>" */ + ctx->tokcxflg &= ~TOKCXFINMAC; + p += 2; + len -= 2; - /* save the current parsing position */ - if (ctx->tokcxmlvl >= TOKMACNEST) - errsig(ctx->tokcxerr, ERR_MACNEST); - ctx->tokcxmsav[ctx->tokcxmlvl] = p; - ctx->tokcxmsvl[ctx->tokcxmlvl] = len; - ctx->tokcxmlvl++; + /* save the current parsing position */ + if (ctx->tokcxmlvl >= TOKMACNEST) + errsig(ctx->tokcxerr, ERR_MACNEST); + ctx->tokcxmsav[ctx->tokcxmlvl] = p; + ctx->tokcxmsvl[ctx->tokcxmlvl] = len; + ctx->tokcxmlvl++; - if (*p == '"') - { - ++(ctx->tokcxmsav[ctx->tokcxmlvl - 1]); - --(ctx->tokcxmsvl[ctx->tokcxmlvl - 1]); - p = tokmac3; + if (*p == '"') + { + ++(ctx->tokcxmsav[ctx->tokcxmlvl - 1]); + --(ctx->tokcxmsvl[ctx->tokcxmlvl - 1]); + p = tokmac3; - /* - * we won't need an extra closing paren now, since tokmac3 - * provides it - */ - ctx->tokcxflg &= ~TOKCXF_EMBED_PAREN_AFT; - } - else - { - /* - * The string is continuing. Set a flag to note that we - * need to provide a close paren after the end of the - * string, and parse the glue (tokmac2) that goes between - * the expression and the resumption of the string. - */ - ctx->tokcxflg |= TOKCXF_EMBED_PAREN_AFT; - p = tokmac2; - } + /* + * we won't need an extra closing paren now, since tokmac3 + * provides it + */ + ctx->tokcxflg &= ~TOKCXF_EMBED_PAREN_AFT; + } + else + { + /* + * The string is continuing. Set a flag to note that we + * need to provide a close paren after the end of the + * string, and parse the glue (tokmac2) that goes between + * the expression and the resumption of the string. + */ + ctx->tokcxflg |= TOKCXF_EMBED_PAREN_AFT; + p = tokmac2; + } - len = strlen(p); - goto nexttoken; - } - else - { - tokscdef *sc; - - for (sc = ctx->tokcxsc[ctx->tokcxinx[(uchar)*p]] ; sc ; - sc = sc->tokscnxt) - { - if (toksceq(sc->tokscstr, p, sc->toksclen, len)) - { - tok->toktyp = sc->toksctyp; - p += sc->toksclen; - len -= sc->toksclen; - goto done; - } - } - errsig(ctx->tokcxerr, ERR_INVTOK); - } - + len = strlen(p); + goto nexttoken; + } + else + { + tokscdef *sc; + + for (sc = ctx->tokcxsc[ctx->tokcxinx[(uchar)*p]] ; sc ; + sc = sc->tokscnxt) + { + if (toksceq(sc->tokscstr, p, sc->toksclen, len)) + { + tok->toktyp = sc->toksctyp; + p += sc->toksclen; + len -= sc->toksclen; + goto done; + } + } + errsig(ctx->tokcxerr, ERR_INVTOK); + } + done: - ctx->tokcxptr = p; - ctx->tokcxlen = len; - return(tok->toktyp); + ctx->tokcxptr = p; + ctx->tokcxlen = len; + return(tok->toktyp); } /* initialize a linear symbol table */ void toktlini(errcxdef *errctx, toktldef *toktab, uchar *mem, uint siz) { - CLRSTRUCT(*toktab); - - /* initialize superclass data */ - toktab->toktlsc.toktfadd = toktladd; /* set add-symbol method */ - toktab->toktlsc.toktfsea = toktlsea; /* set search-table method */ - toktab->toktlsc.toktfeach = toktleach; /* set 'each' method */ - toktab->toktlsc.toktfset = toktlset; /* set 'update' method */ - toktab->toktlsc.tokterr = errctx; /* set error handling context */ - - /* initialize class data */ - toktab->toktlptr = mem; - toktab->toktlnxt = mem; - toktab->toktlsiz = siz; + CLRSTRUCT(*toktab); + + /* initialize superclass data */ + toktab->toktlsc.toktfadd = toktladd; /* set add-symbol method */ + toktab->toktlsc.toktfsea = toktlsea; /* set search-table method */ + toktab->toktlsc.toktfeach = toktleach; /* set 'each' method */ + toktab->toktlsc.toktfset = toktlset; /* set 'update' method */ + toktab->toktlsc.tokterr = errctx; /* set error handling context */ + + /* initialize class data */ + toktab->toktlptr = mem; + toktab->toktlnxt = mem; + toktab->toktlsiz = siz; } /* add a symbol to a linear symbol table */ void toktladd(toktdef *toktab1, char *name, int namel, - int typ, int val, int hash) + int typ, int val, int hash) { - uint siz = sizeof(toks1def) + namel; - toksdef *sym; - toktldef *toktab = (toktldef *)toktab1; - - VARUSED(hash); - - if (toktab->toktlsiz < siz) - errsig(toktab->toktlsc.tokterr, ERR_NOLCLSY); - - sym = (toksdef *)toktab->toktlnxt; - siz = osrndsz(siz); - toktab->toktlnxt += siz; - if (siz > toktab->toktlsiz) toktab->toktlsiz = 0; - else toktab->toktlsiz -= siz; + uint siz = sizeof(toks1def) + namel; + toksdef *sym; + toktldef *toktab = (toktldef *)toktab1; + + VARUSED(hash); + + if (toktab->toktlsiz < siz) + errsig(toktab->toktlsc.tokterr, ERR_NOLCLSY); + + sym = (toksdef *)toktab->toktlnxt; + siz = osrndsz(siz); + toktab->toktlnxt += siz; + if (siz > toktab->toktlsiz) toktab->toktlsiz = 0; + else toktab->toktlsiz -= siz; - /* set up symbol */ - sym->toksval = val; - sym->tokslen = namel; - sym->tokstyp = typ; - sym->toksfr = 0; - memcpy(sym->toksnam, name, (size_t)(namel + 1)); - - /* indicate there's one more symbol in the table */ - ++(toktab->toktlcnt); + /* set up symbol */ + sym->toksval = val; + sym->tokslen = namel; + sym->tokstyp = typ; + sym->toksfr = 0; + memcpy(sym->toksnam, name, (size_t)(namel + 1)); + + /* indicate there's one more symbol in the table */ + ++(toktab->toktlcnt); } /* delete all symbols from a linear symbol table */ void toktldel(toktldef *tab) { - tab->toktlcnt = 0; - tab->toktlsiz += tab->toktlnxt - tab->toktlptr; - tab->toktlnxt = tab->toktlptr; + tab->toktlcnt = 0; + tab->toktlsiz += tab->toktlnxt - tab->toktlptr; + tab->toktlnxt = tab->toktlptr; } /* call a function for every symbol in a linear symbol table */ void toktleach(toktdef *tab1, - void (*cb)(void *ctx, toksdef *sym), void *ctx) + void (*cb)(void *ctx, toksdef *sym), void *ctx) { - toksdef *p; - uint cnt; - toktldef *tab = (toktldef *)tab1; - - for (p = (toksdef *)tab->toktlptr, cnt = tab->toktlcnt ; cnt ; --cnt ) - { - (*cb)(ctx, p); - p = (toksdef *)(((uchar *)p) - + osrndsz(p->tokslen + sizeof(toks1def))); - } + toksdef *p; + uint cnt; + toktldef *tab = (toktldef *)tab1; + + for (p = (toksdef *)tab->toktlptr, cnt = tab->toktlcnt ; cnt ; --cnt ) + { + (*cb)(ctx, p); + p = (toksdef *)(((uchar *)p) + + osrndsz(p->tokslen + sizeof(toks1def))); + } } /* search a linear symbol table */ int toktlsea(toktdef *tab1, char *name, int namel, int hash, toksdef *ret) { - toksdef *p; - uint cnt; - toktldef *tab = (toktldef *)tab1; - - VARUSED(hash); - - for (p = (toksdef *)tab->toktlptr, cnt = tab->toktlcnt ; cnt ; --cnt ) - { - if (p->tokslen == namel && !memcmp(p->toksnam, name, (size_t)namel)) - { - memcpy(ret, p, (size_t)(sizeof(toks1def) + namel)); - return(TRUE); - } - - p = (toksdef *)(((uchar *)p) - + osrndsz(p->tokslen + sizeof(toks1def))); - } + toksdef *p; + uint cnt; + toktldef *tab = (toktldef *)tab1; + + VARUSED(hash); + + for (p = (toksdef *)tab->toktlptr, cnt = tab->toktlcnt ; cnt ; --cnt ) + { + if (p->tokslen == namel && !memcmp(p->toksnam, name, (size_t)namel)) + { + memcpy(ret, p, (size_t)(sizeof(toks1def) + namel)); + return(TRUE); + } + + p = (toksdef *)(((uchar *)p) + + osrndsz(p->tokslen + sizeof(toks1def))); + } - /* nothing found - indicate by returning FALSE */ - return(FALSE); + /* nothing found - indicate by returning FALSE */ + return(FALSE); } /* update a symbol in a linear symbol table */ void toktlset(toktdef *tab1, toksdef *newsym) { - toksdef *p; - uint cnt; - toktldef *tab = (toktldef *)tab1; - - for (p = (toksdef *)tab->toktlptr, cnt = tab->toktlcnt ; cnt ; --cnt ) - { - if (p->tokslen == newsym->tokslen - && !memcmp(p->toksnam, newsym->toksnam, (size_t)newsym->tokslen)) - { - p->toksval = newsym->toksval; - p->tokstyp = newsym->tokstyp; - return; - } - - p = (toksdef *)(((uchar *)p) - + osrndsz(p->tokslen + sizeof(toks1def))); - } + toksdef *p; + uint cnt; + toktldef *tab = (toktldef *)tab1; + + for (p = (toksdef *)tab->toktlptr, cnt = tab->toktlcnt ; cnt ; --cnt ) + { + if (p->tokslen == newsym->tokslen + && !memcmp(p->toksnam, newsym->toksnam, (size_t)newsym->tokslen)) + { + p->toksval = newsym->toksval; + p->tokstyp = newsym->tokstyp; + return; + } + + p = (toksdef *)(((uchar *)p) + + osrndsz(p->tokslen + sizeof(toks1def))); + } } tokcxdef *tokcxini(errcxdef *errctx, mcmcxdef *mcmctx, tokldef *sctab) { - int i; - int cnt; - tokldef *p; - uchar c; - uchar index[256]; - tokcxdef *ret; - tokscdef *sc; - ushort siz; - - /* set up index table: finds tokcxsc entry from character value */ - memset(index, 0, (size_t)sizeof(index)); - for (i = cnt = 0, p = sctab ; (c = p->toklstr[0]) != 0 ; ++cnt, ++p) - if (!index[c]) index[c] = ++i; - - /* allocate memory for table plus the tokscdef's */ - siz = sizeof(tokcxdef) + (i * sizeof(tokscdef *)) - + ((cnt + 1) * sizeof(tokscdef)); - ret = (tokcxdef *)mchalo(errctx, siz, "tokcxini"); - memset(ret, 0, (size_t)siz); - - /* copy the index, set up fixed part */ - memcpy(ret->tokcxinx, index, sizeof(ret->tokcxinx)); - ret->tokcxerr = errctx; - ret->tokcxmem = mcmctx; + int i; + int cnt; + tokldef *p; + uchar c; + uchar index[256]; + tokcxdef *ret; + tokscdef *sc; + ushort siz; + + /* set up index table: finds tokcxsc entry from character value */ + memset(index, 0, (size_t)sizeof(index)); + for (i = cnt = 0, p = sctab ; (c = p->toklstr[0]) != 0 ; ++cnt, ++p) + if (!index[c]) index[c] = ++i; + + /* allocate memory for table plus the tokscdef's */ + siz = sizeof(tokcxdef) + (i * sizeof(tokscdef *)) + + ((cnt + 1) * sizeof(tokscdef)); + ret = (tokcxdef *)mchalo(errctx, siz, "tokcxini"); + memset(ret, 0, (size_t)siz); + + /* copy the index, set up fixed part */ + memcpy(ret->tokcxinx, index, sizeof(ret->tokcxinx)); + ret->tokcxerr = errctx; + ret->tokcxmem = mcmctx; - /* start out without an #if */ - ret->tokcxifcur = TOKIF_IF_YES; - - /* force the first toknext() to read a line */ - ret->tokcxptr = "\000"; - - /* figure where the tokscdef's go (right after sc pointer array) */ - sc = (tokscdef *)&ret->tokcxsc[i+1]; - - /* set up the individual tokscdef entries, and link into lists */ - for (p = sctab ; (c = p->toklstr[0]) != 0 ; ++p, ++sc) - { - size_t len; - - sc->toksctyp = p->tokltyp; - len = sc->toksclen = strlen(p->toklstr); - memcpy(sc->tokscstr, p->toklstr, len); - sc->tokscnxt = ret->tokcxsc[index[c]]; - ret->tokcxsc[index[c]] = sc; - } - - return(ret); + /* start out without an #if */ + ret->tokcxifcur = TOKIF_IF_YES; + + /* force the first toknext() to read a line */ + ret->tokcxptr = "\000"; + + /* figure where the tokscdef's go (right after sc pointer array) */ + sc = (tokscdef *)&ret->tokcxsc[i+1]; + + /* set up the individual tokscdef entries, and link into lists */ + for (p = sctab ; (c = p->toklstr[0]) != 0 ; ++p, ++sc) + { + size_t len; + + sc->toksctyp = p->tokltyp; + len = sc->toksclen = strlen(p->toklstr); + memcpy(sc->tokscstr, p->toklstr, len); + sc->tokscnxt = ret->tokcxsc[index[c]]; + ret->tokcxsc[index[c]] = sc; + } + + return(ret); } /* add an include path to a tokdef */ void tokaddinc(tokcxdef *ctx, char *path, int pathlen) { - tokpdef *newpath; - tokpdef *last; - - /* find the tail of the include path list, if any */ - for (last = ctx->tokcxinc ; last && last->tokpnxt ; - last = last->tokpnxt) ; - - /* allocate storage for and set up a new path structure */ - newpath = (tokpdef *)mchalo(ctx->tokcxerr, - (sizeof(tokpdef) + pathlen - 1), - "tokaddinc"); - newpath->tokplen = pathlen; - newpath->tokpnxt = (tokpdef *)0; - memcpy(newpath->tokpdir, path, (size_t)pathlen); - - /* link in at end of list (if no list yet, newpath becomes first entry) */ - if (last) - last->tokpnxt = newpath; - else - ctx->tokcxinc = newpath; + tokpdef *newpath; + tokpdef *last; + + /* find the tail of the include path list, if any */ + for (last = ctx->tokcxinc ; last && last->tokpnxt ; + last = last->tokpnxt) ; + + /* allocate storage for and set up a new path structure */ + newpath = (tokpdef *)mchalo(ctx->tokcxerr, + (sizeof(tokpdef) + pathlen - 1), + "tokaddinc"); + newpath->tokplen = pathlen; + newpath->tokpnxt = (tokpdef *)0; + memcpy(newpath->tokpdir, path, (size_t)pathlen); + + /* link in at end of list (if no list yet, newpath becomes first entry) */ + if (last) + last->tokpnxt = newpath; + else + ctx->tokcxinc = newpath; } } // End of namespace TADS2 diff --git a/engines/glk/tads/tads2/tokenizer.h b/engines/glk/tads/tads2/tokenizer.h index d1965407995..f177b42f9de 100644 --- a/engines/glk/tads/tads2/tokenizer.h +++ b/engines/glk/tads/tads2/tokenizer.h @@ -168,37 +168,37 @@ namespace TADS2 { /* symbol table entry */ struct toksdef { - uchar tokstyp; /* type of the symbol */ - uchar tokshsh; /* hash value of symbol */ - ushort toksval; /* value of the symbol (depends on type) */ - ushort toksfr; /* frame offset of symbol (for debugger) */ - uchar tokslen; /* length of the symbol's name */ - char toksnam[TOKNAMMAX]; /* name of symbol */ + uchar tokstyp; /* type of the symbol */ + uchar tokshsh; /* hash value of symbol */ + ushort toksval; /* value of the symbol (depends on type) */ + ushort toksfr; /* frame offset of symbol (for debugger) */ + uchar tokslen; /* length of the symbol's name */ + char toksnam[TOKNAMMAX]; /* name of symbol */ }; /* symbol table entry without 'name' portion - for allocation purposes */ struct toks1def { - uchar tokstyp; - uchar tokshsh; - ushort toksval; - ushort toksfr; - uchar tokslen; - char toksnam[1]; + uchar tokstyp; + uchar tokshsh; + ushort toksval; + ushort toksfr; + uchar tokslen; + char toksnam[1]; }; /* generic symbol table object - other symbol tables are subclasses */ struct toktdef { - void (*toktfadd)(toktdef *tab, char *name, int namel, int typ, - int val, int hash); /* add symbol */ - int (*toktfsea)(toktdef *tab, char *name, int namel, int hash, - toksdef *ret); /* search symbol table */ - void (*toktfset)(toktdef *tab, toksdef *sym); - /* update val & typ of symbol to those in *sym */ - void (*toktfeach)(toktdef *tab, - void (*fn)(void *ctx, toksdef *sym), - void *fnctx); /* call fn for each sym */ - toktdef *toktnxt; /* next symbol table to be searched */ - errcxdef *tokterr; /* error handling context */ + void (*toktfadd)(toktdef *tab, char *name, int namel, int typ, + int val, int hash); /* add symbol */ + int (*toktfsea)(toktdef *tab, char *name, int namel, int hash, + toksdef *ret); /* search symbol table */ + void (*toktfset)(toktdef *tab, toksdef *sym); + /* update val & typ of symbol to those in *sym */ + void (*toktfeach)(toktdef *tab, + void (*fn)(void *ctx, toksdef *sym), + void *fnctx); /* call fn for each sym */ + toktdef *toktnxt; /* next symbol table to be searched */ + errcxdef *tokterr; /* error handling context */ }; /* maximum number of pools (TOKTSIZE bytes each) for symbols */ @@ -206,27 +206,27 @@ struct toktdef { /* pointer to a symbol in a hashed symbol table */ struct tokthpdef { - mcmon tokthpobj; /* cache manager object number of page */ - uint tokthpofs; /* offset within page of this symbol */ + mcmon tokthpobj; /* cache manager object number of page */ + uint tokthpofs; /* offset within page of this symbol */ }; /* extended symbol entry in a hashed symbol table */ struct tokshdef { - tokthpdef tokshnxt; /* pointer to next symbol in the table */ - toksdef tokshsc; /* superclass - normal symbol entry */ + tokthpdef tokshnxt; /* pointer to next symbol in the table */ + toksdef tokshsc; /* superclass - normal symbol entry */ }; /* hashing symbol table (subclass of generic symbol table) */ struct tokthdef { - toktdef tokthsc; /* generic symbol table superclass data */ - mcmcxdef *tokthmem; /* memory manager context */ - tokthpdef tokthhsh[TOKHASHSIZE]; /* hash table */ - uint tokthpcnt; /* number of memory pools for toksdef's */ - mcmon tokthpool[TOKPOOLMAX]; /* memory pools for toksdef's */ - uint tokthfinal[TOKPOOLMAX]; /* actual sizes of these pools */ - uchar *tokthcpool; /* current pool pointer */ - ushort tokthsize; /* remaining size of top memory pool */ - ushort tokthofs; /* allocation offset in top memory pool */ + toktdef tokthsc; /* generic symbol table superclass data */ + mcmcxdef *tokthmem; /* memory manager context */ + tokthpdef tokthhsh[TOKHASHSIZE]; /* hash table */ + uint tokthpcnt; /* number of memory pools for toksdef's */ + mcmon tokthpool[TOKPOOLMAX]; /* memory pools for toksdef's */ + uint tokthfinal[TOKPOOLMAX]; /* actual sizes of these pools */ + uchar *tokthcpool; /* current pool pointer */ + ushort tokthsize; /* remaining size of top memory pool */ + ushort tokthofs; /* allocation offset in top memory pool */ }; /* size of toksdef pools to allocate for hashed symbol tables */ @@ -240,30 +240,30 @@ struct tokthdef { * in code. */ struct toktldef { - toktdef toktlsc; /* generic symbol table superclass data */ - uchar *toktlptr; /* base of linear symbol table */ - uchar *toktlnxt; /* next free byte in table */ - uint toktlcnt; /* number of objects in the table */ - uint toktlsiz; /* bytes remaining in the table */ + toktdef toktlsc; /* generic symbol table superclass data */ + uchar *toktlptr; /* base of linear symbol table */ + uchar *toktlnxt; /* next free byte in table */ + uint toktlcnt; /* number of objects in the table */ + uint toktlsiz; /* bytes remaining in the table */ }; struct tokdef { - int toktyp; /* type of the token */ - int toklen; /* length of token text, if a symbolic token */ - long tokval; /* numeric value, if applicable */ - ushort tokofs; - uint tokhash; /* token hash value, if a symbolic token */ - char toknam[TOKNAMMAX+1]; /* text of token, if a symbolic token */ - toksdef toksym; /* symbol from table matching token */ + int toktyp; /* type of the token */ + int toklen; /* length of token text, if a symbolic token */ + long tokval; /* numeric value, if applicable */ + ushort tokofs; + uint tokhash; /* token hash value, if a symbolic token */ + char toknam[TOKNAMMAX+1]; /* text of token, if a symbolic token */ + toksdef toksym; /* symbol from table matching token */ }; /* special character sequence */ #define TOKSCMAX 3 /* maximum length of a special char sequence */ struct tokscdef { - tokscdef *tokscnxt; /* next sequence with same first character */ - int toksctyp; /* token type corresponding to sequence */ - int toksclen; /* length of the sequence */ - char tokscstr[TOKSCMAX+1]; /* the sequence itself */ + tokscdef *tokscnxt; /* next sequence with same first character */ + int toksctyp; /* token type corresponding to sequence */ + int toksclen; /* length of the sequence */ + char tokscstr[TOKSCMAX+1]; /* the sequence itself */ }; /* @@ -275,11 +275,11 @@ struct tokscdef { */ #if TOKSCMAX == 3 # define toksceq(str1, str2, len1, len2) \ - ((len2) >= (len1) \ - && ((len1) == 1 \ - || ((str1)[1] == (str2)[1] \ - && ((len1) == 2 \ - || (str1)[2] == (str2)[2])))) + ((len2) >= (len1) \ + && ((len1) == 1 \ + || ((str1)[1] == (str2)[1] \ + && ((len1) == 2 \ + || (str1)[2] == (str2)[2])))) #endif /* TOKSCMAX == 3 */ #ifndef toksceq # define toksceq(str1, str2, len) (!memcmp(str1, str2, (size_t)(len))) @@ -287,24 +287,24 @@ struct tokscdef { /* special character sequence list table entry */ struct tokldef { - int tokltyp; /* token type corresponding to sequence */ - char toklstr[TOKSCMAX+1]; /* the text of the sequence */ + int tokltyp; /* token type corresponding to sequence */ + char toklstr[TOKSCMAX+1]; /* the text of the sequence */ }; /* include path structure */ struct tokpdef { - tokpdef *tokpnxt; /* next path in list */ - int tokplen; /* length of directory name */ - char tokpdir[1]; /* directory to search */ + tokpdef *tokpnxt; /* next path in list */ + int tokplen; /* length of directory name */ + char tokpdir[1]; /* directory to search */ }; /* #define symbol structure */ struct tokdfdef { - tokdfdef *nxt; /* next symbol in the same hash chain */ - char *nm; /* name of the symbol */ - int len; /* length of the symbol */ - int explen; /* length of the expansion */ - char expan[1]; /* expansion buffer */ + tokdfdef *nxt; /* next symbol in the same hash chain */ + char *nm; /* name of the symbol */ + int len; /* length of the symbol */ + int explen; /* length of the expansion */ + char expan[1]; /* expansion buffer */ }; /* #define hash table information */ @@ -325,40 +325,40 @@ struct tokdfdef { /* lexical analysis context */ struct tokcxdef { - errcxdef *tokcxerr; /* error handling context */ - mcmcxdef *tokcxmem; /* cache manager context */ - struct dbgcxdef *tokcxdbg; /* debugger context */ - lindef *tokcxlin; /* line source */ - tokpdef *tokcxinc; /* head of include path list */ - toktdef *tokcxstab; /* current head of symbol table chain */ - void *tokcxscx; /* context for string storage callback functions */ - ushort (*tokcxsst)(void *ctx); - /* start storing a string; return offset of string's storage */ - void (*tokcxsad)(void *ctx, const char *str, ushort len); - /* add characters to a string */ - void (*tokcxsend)(void *ctx); /* finish storing string */ - const char *tokcxmsav[TOKMACNEST]; /* saved positions for macro expansion */ - ushort tokcxmsvl[TOKMACNEST]; /* saved lengths for macro expansion */ - int tokcxmlvl; /* macro nesting level */ - int tokcxflg; /* flags */ + errcxdef *tokcxerr; /* error handling context */ + mcmcxdef *tokcxmem; /* cache manager context */ + struct dbgcxdef *tokcxdbg; /* debugger context */ + lindef *tokcxlin; /* line source */ + tokpdef *tokcxinc; /* head of include path list */ + toktdef *tokcxstab; /* current head of symbol table chain */ + void *tokcxscx; /* context for string storage callback functions */ + ushort (*tokcxsst)(void *ctx); + /* start storing a string; return offset of string's storage */ + void (*tokcxsad)(void *ctx, const char *str, ushort len); + /* add characters to a string */ + void (*tokcxsend)(void *ctx); /* finish storing string */ + const char *tokcxmsav[TOKMACNEST]; /* saved positions for macro expansion */ + ushort tokcxmsvl[TOKMACNEST]; /* saved lengths for macro expansion */ + int tokcxmlvl; /* macro nesting level */ + int tokcxflg; /* flags */ # define TOKCXFINMAC 0x01 /* doing <> macro expansion */ # define TOKCXCASEFOLD 0x02 /* fold upper and lower case */ # define TOKCXFCMODE 0x04 /* parse using C operators */ # define TOKCXF_EMBED_PAREN_PRE 0x08 /* embedded expr - did '(' */ # define TOKCXF_EMBED_PAREN_AFT 0x10 /* embedded expr - must do ')' */ # define TOKCXFLIN2 0x20 /* new-style line records */ - tokdef tokcxcur; /* current token */ - char *tokcxbuf; /* buffer for long lines */ - ushort tokcxbsz; /* size of long line buffer */ - const char *tokcxptr; /* pointer into line source */ - ushort tokcxlen; /* length of text in buffer */ - uchar tokcxinx[256]; /* special character indices */ - tokdfdef *tokcxdf[TOKDFHSHSIZ]; /* hash table for #define symbols */ - int tokcxifcnt; /* number of #endif's we expect to find */ - char tokcxif[TOKIFNEST]; /* #if state for each nesting level */ - int tokcxifcur; /* current #if state, obeying nesting */ - linfdef *tokcxhdr; /* list of previously included headers */ - tokscdef *tokcxsc[1]; /* special character table */ + tokdef tokcxcur; /* current token */ + char *tokcxbuf; /* buffer for long lines */ + ushort tokcxbsz; /* size of long line buffer */ + const char *tokcxptr; /* pointer into line source */ + ushort tokcxlen; /* length of text in buffer */ + uchar tokcxinx[256]; /* special character indices */ + tokdfdef *tokcxdf[TOKDFHSHSIZ]; /* hash table for #define symbols */ + int tokcxifcnt; /* number of #endif's we expect to find */ + char tokcxif[TOKIFNEST]; /* #if state for each nesting level */ + int tokcxifcur; /* current #if state, obeying nesting */ + linfdef *tokcxhdr; /* list of previously included headers */ + tokscdef *tokcxsc[1]; /* special character table */ }; @@ -384,40 +384,40 @@ void tokthini(errcxdef *errctx, mcmcxdef *memctx, toktdef *toktab1); /* add a symbol to a hashed symbol table */ void tokthadd(toktdef *toktab, char *name, int namel, - int typ, int val, int hash); + int typ, int val, int hash); /* update a symbol in a hashed symbol table */ void tokthset(toktdef *toktab, toksdef *sym); /* search a hashed symbol table for a symbol */ int tokthsea(toktdef *tab, char *name, int namel, int hash, - toksdef *ret); + toksdef *ret); /* call a function for each symbol in a hashed symbol table */ void toktheach(toktdef *tab, void (*cb)(void *ctx, toksdef *sym), - void *ctx); + void *ctx); /* find a symbol given type and value */ int tokthfind(toktdef *tab, int typ, uint val, toksdef *sym); /* initialize a linear symbol table */ void toktlini(errcxdef *errctx, toktldef *toktab, - uchar *mem, uint siz); + uchar *mem, uint siz); /* add a symbol to a linear symbol table */ void toktladd(toktdef *toktab, char *name, int namel, - int typ, int val, int hash); - + int typ, int val, int hash); + /* search a linear symbol table */ int toktlsea(toktdef *tab, char *name, int namel, int hash, - toksdef *ret); + toksdef *ret); /* update a symbol in a linear symbol table */ void toktlset(toktdef *toktab, toksdef *sym); /* call a function for each symbol in a local symbol table */ void toktleach(toktdef *tab, void (*cb)(void *ctx, toksdef *sym), - void *ctx); + void *ctx); /* delete all symbols from a linear table */ void toktldel(toktldef *tab); @@ -430,14 +430,14 @@ int tokget1(tokcxdef *ctx, tokdef *tok, int consume); /* add a symbol to the #define symbol table */ void tok_add_define(tokcxdef *ctx, const char *sym, int len, - const char *expan, int explen); + const char *expan, int explen); /* * add a symbol to the #define symbol table, folding case if we're * operating in case-insensitive mode */ void tok_add_define_cvtcase(tokcxdef *ctx, const char *sym, int len, - const char *expan, int explen); + const char *expan, int explen); /* add a symbol to the #define symbol table as a number */ void tok_add_define_num_cvtcase(tokcxdef *ctx, const char *sym, int len, int num); @@ -454,16 +454,16 @@ void tok_write_defines(tokcxdef *ctx, osfildef *fp, errcxdef *ec); /* determine if a char is a valid non-initial character in a symbol name */ #define TOKISSYM(c) \ - (Common::isAlpha((uchar)(c)) || Common::isDigit((uchar)(c)) || (c)=='_' || (c)=='$') + (Common::isAlpha((uchar)(c)) || Common::isDigit((uchar)(c)) || (c)=='_' || (c)=='$') /* numeric conversion and checking macros */ #define TOKISHEX(c) \ - (Common::isDigit((uchar)(c))||((c)>='a'&&(c)<='f')||((c)>='A'&&(c)<='F')) + (Common::isDigit((uchar)(c))||((c)>='a'&&(c)<='f')||((c)>='A'&&(c)<='F')) #define TOKISOCT(c) \ - (Common::isDigit((uchar)(c))&&!((c)=='8'||(c)=='9')) + (Common::isDigit((uchar)(c))&&!((c)=='8'||(c)=='9')) #define TOKHEX2INT(c) \ - (Common::isDigit((uchar)c)?(c)-'0':((c)>='a'?(c)-'a'+10:(c)-'A'+10)) + (Common::isDigit((uchar)c)?(c)-'0':((c)>='a'?(c)-'a'+10:(c)-'A'+10)) #define TOKOCT2INT(c) ((c)-'0') #define TOKDEC2INT(c) ((c)-'0') diff --git a/engines/glk/tads/tads2/tokenizer_hash.cpp b/engines/glk/tads/tads2/tokenizer_hash.cpp index 2cbdcc26f75..105a4b18af7 100644 --- a/engines/glk/tads/tads2/tokenizer_hash.cpp +++ b/engines/glk/tads/tads2/tokenizer_hash.cpp @@ -44,91 +44,91 @@ namespace TADS2 { /* compute a hash value */ uint tokhsh(char *nam) { - uint hash = 0; - - while (*nam) hash = ((hash + *nam++) & (TOKHASHSIZE - 1)); - return(hash); + uint hash = 0; + + while (*nam) hash = ((hash + *nam++) & (TOKHASHSIZE - 1)); + return(hash); } /* for allocation - size of tokshdef without name portion */ struct toksh1def { - tokthpdef tokshnxt; - toks1def tokshsc; + tokthpdef tokshnxt; + toks1def tokshsc; }; typedef struct toksh1def toksh1def; /* initialize a hashed symbol table */ void tokthini(errcxdef *errctx, mcmcxdef *memctx, toktdef *toktab1) { - tokthdef *toktab = (tokthdef *)toktab1; /* convert to correct type */ - int i; + tokthdef *toktab = (tokthdef *)toktab1; /* convert to correct type */ + int i; - CLRSTRUCT(*toktab); - toktab->tokthsc.toktfadd = tokthadd; /* set add-symbol method */ - toktab->tokthsc.toktfsea = tokthsea; /* set search-table method */ - toktab->tokthsc.toktfset = tokthset; /* update symbol */ - toktab->tokthsc.toktfeach = toktheach; /* call fn for all symbols */ - toktab->tokthsc.tokterr = errctx; /* set error handling context */ - toktab->tokthmem = memctx; /* memory manager context */ - toktab->tokthcpool = mcmalo(memctx, (ushort)TOKTHSIZE, - &toktab->tokthpool[0]); - toktab->tokthpcnt = 0; - toktab->tokthsize = TOKTHSIZE; + CLRSTRUCT(*toktab); + toktab->tokthsc.toktfadd = tokthadd; /* set add-symbol method */ + toktab->tokthsc.toktfsea = tokthsea; /* set search-table method */ + toktab->tokthsc.toktfset = tokthset; /* update symbol */ + toktab->tokthsc.toktfeach = toktheach; /* call fn for all symbols */ + toktab->tokthsc.tokterr = errctx; /* set error handling context */ + toktab->tokthmem = memctx; /* memory manager context */ + toktab->tokthcpool = mcmalo(memctx, (ushort)TOKTHSIZE, + &toktab->tokthpool[0]); + toktab->tokthpcnt = 0; + toktab->tokthsize = TOKTHSIZE; - /* set hash table entries to point to nothing (MCMONINV) */ - for (i = 0 ; i < TOKHASHSIZE ; ++i) - toktab->tokthhsh[i].tokthpobj = MCMONINV; + /* set hash table entries to point to nothing (MCMONINV) */ + for (i = 0 ; i < TOKHASHSIZE ; ++i) + toktab->tokthhsh[i].tokthpobj = MCMONINV; } /* add a symbol to a hashed symbol table */ void tokthadd(toktdef *toktab1, char *name, int namel, - int typ, int val, int hash) + int typ, int val, int hash) { - int siz = sizeof(toksh1def) + namel; - toksdef *sym; - tokshdef *symh; - tokthdef *toktab = (tokthdef *)toktab1; - - if (toktab->tokthsize < siz) - { - mcmcxdef *mctx = toktab->tokthmem; - - /* insufficient space in current pool; add a new pool */ - if (toktab->tokthpcnt >= TOKPOOLMAX) - errsig(toktab->tokthsc.tokterr, ERR_MANYSYM); + int siz = sizeof(toksh1def) + namel; + toksdef *sym; + tokshdef *symh; + tokthdef *toktab = (tokthdef *)toktab1; + + if (toktab->tokthsize < siz) + { + mcmcxdef *mctx = toktab->tokthmem; + + /* insufficient space in current pool; add a new pool */ + if (toktab->tokthpcnt >= TOKPOOLMAX) + errsig(toktab->tokthsc.tokterr, ERR_MANYSYM); - /* unlock current pool page, and note its final size */ - mcmunlck(mctx, toktab->tokthpool[toktab->tokthpcnt]); - toktab->tokthfinal[toktab->tokthpcnt] = toktab->tokthofs; + /* unlock current pool page, and note its final size */ + mcmunlck(mctx, toktab->tokthpool[toktab->tokthpcnt]); + toktab->tokthfinal[toktab->tokthpcnt] = toktab->tokthofs; - /* allocate a new pool page, and leave it locked */ - toktab->tokthcpool = mcmalo(mctx, (ushort)TOKTHSIZE, - &toktab->tokthpool[++(toktab->tokthpcnt)]); - toktab->tokthsize = TOKTHSIZE; - toktab->tokthofs = 0; - } - symh = (tokshdef *)(toktab->tokthcpool + toktab->tokthofs); - sym = &symh->tokshsc; - - /* link into list for this hash value */ - OSCPYSTRUCT(symh->tokshnxt, toktab->tokthhsh[hash]); - toktab->tokthhsh[hash].tokthpobj = toktab->tokthpool[toktab->tokthpcnt]; - toktab->tokthhsh[hash].tokthpofs = toktab->tokthofs; - - /* fill in rest of toksdef */ - sym->toksval = val; - sym->tokslen = namel; - sym->tokstyp = typ; - sym->tokshsh = hash; - sym->toksfr = 0; - memcpy(sym->toksnam, name, (size_t)namel); - - /* update free pool pointer */ - siz = osrndsz(siz); - toktab->tokthofs += siz; - if (siz > toktab->tokthsize) toktab->tokthsize = 0; - else toktab->tokthsize -= siz; + /* allocate a new pool page, and leave it locked */ + toktab->tokthcpool = mcmalo(mctx, (ushort)TOKTHSIZE, + &toktab->tokthpool[++(toktab->tokthpcnt)]); + toktab->tokthsize = TOKTHSIZE; + toktab->tokthofs = 0; + } + symh = (tokshdef *)(toktab->tokthcpool + toktab->tokthofs); + sym = &symh->tokshsc; + + /* link into list for this hash value */ + OSCPYSTRUCT(symh->tokshnxt, toktab->tokthhsh[hash]); + toktab->tokthhsh[hash].tokthpobj = toktab->tokthpool[toktab->tokthpcnt]; + toktab->tokthhsh[hash].tokthpofs = toktab->tokthofs; + + /* fill in rest of toksdef */ + sym->toksval = val; + sym->tokslen = namel; + sym->tokstyp = typ; + sym->tokshsh = hash; + sym->toksfr = 0; + memcpy(sym->toksnam, name, (size_t)namel); + + /* update free pool pointer */ + siz = osrndsz(siz); + toktab->tokthofs += siz; + if (siz > toktab->tokthsize) toktab->tokthsize = 0; + else toktab->tokthsize -= siz; } /* @@ -138,197 +138,197 @@ void tokthadd(toktdef *toktab1, char *name, int namel, * callback returns FALSE for all symbols, we return FALSE. */ static int tokthscan(tokthdef *tab, uint hash, - int (*cb)(void *, toksdef *, mcmon), - void *cbctx) + int (*cb)(void *, toksdef *, mcmon), + void *cbctx) { - tokshdef *symh; - toksdef *sym; - tokthpdef p; - tokthpdef nxt; + tokshdef *symh; + toksdef *sym; + tokthpdef p; + tokthpdef nxt; uchar *pg = nullptr; - mcmcxdef *mctx = tab->tokthmem; - mcmon curobj; + mcmcxdef *mctx = tab->tokthmem; + mcmon curobj; - /* get first object, and lock its page if there is one */ - OSCPYSTRUCT(p, tab->tokthhsh[hash]); - if ((curobj = p.tokthpobj) != MCMONINV) - pg = mcmlck(mctx, curobj); + /* get first object, and lock its page if there is one */ + OSCPYSTRUCT(p, tab->tokthhsh[hash]); + if ((curobj = p.tokthpobj) != MCMONINV) + pg = mcmlck(mctx, curobj); - /* look for a match using the callback */ - for ( ; p.tokthpobj != MCMONINV ; OSCPYSTRUCT(p, nxt)) - { - symh = (tokshdef *)(pg + p.tokthpofs); - sym = &symh->tokshsc; - OSCPYSTRUCT(nxt, symh->tokshnxt); + /* look for a match using the callback */ + for ( ; p.tokthpobj != MCMONINV ; OSCPYSTRUCT(p, nxt)) + { + symh = (tokshdef *)(pg + p.tokthpofs); + sym = &symh->tokshsc; + OSCPYSTRUCT(nxt, symh->tokshnxt); - /* check for a match; copy to return buffer if found */ - if ((*cb)(cbctx, sym, p.tokthpobj)) - { - mcmunlck(mctx, p.tokthpobj); - return(TRUE); - } - - /* if the next page is different from this one, get new lock */ - if (nxt.tokthpobj != curobj && nxt.tokthpobj != MCMONINV) - { - mcmunlck(mctx, curobj); - curobj = nxt.tokthpobj; - pg = mcmlck(mctx, curobj); - } - } + /* check for a match; copy to return buffer if found */ + if ((*cb)(cbctx, sym, p.tokthpobj)) + { + mcmunlck(mctx, p.tokthpobj); + return(TRUE); + } + + /* if the next page is different from this one, get new lock */ + if (nxt.tokthpobj != curobj && nxt.tokthpobj != MCMONINV) + { + mcmunlck(mctx, curobj); + curobj = nxt.tokthpobj; + pg = mcmlck(mctx, curobj); + } + } - /* unlock last object, if we had a lock at all */ - if (curobj != MCMONINV) mcmunlck(mctx, curobj); - return(FALSE); + /* unlock last object, if we had a lock at all */ + if (curobj != MCMONINV) mcmunlck(mctx, curobj); + return(FALSE); } struct tokseadef { - char *tokseanam; - toksdef tokseasym; - toksdef *toksearet; - mcmcxdef *tokseamctx; + char *tokseanam; + toksdef tokseasym; + toksdef *toksearet; + mcmcxdef *tokseamctx; }; typedef struct tokseadef tokseadef; /* search callback */ static int tokthsea1(void *ctx0, toksdef *sym, mcmon objn) { - tokseadef *ctx = (tokseadef *)ctx0; - - VARUSED(objn); - - if (sym->tokslen == ctx->tokseasym.tokslen && - !memcmp(sym->toksnam, ctx->tokseanam, ctx->tokseasym.tokslen)) - { - memcpy(ctx->toksearet, sym, - (size_t)(sizeof(toks1def) + ctx->tokseasym.tokslen)); - return(TRUE); - } - else - return(FALSE); + tokseadef *ctx = (tokseadef *)ctx0; + + VARUSED(objn); + + if (sym->tokslen == ctx->tokseasym.tokslen && + !memcmp(sym->toksnam, ctx->tokseanam, ctx->tokseasym.tokslen)) + { + memcpy(ctx->toksearet, sym, + (size_t)(sizeof(toks1def) + ctx->tokseasym.tokslen)); + return(TRUE); + } + else + return(FALSE); } /* search a hashed symbol table for a symbol */ int tokthsea(toktdef *tab1, char *name, int namel, int hash, toksdef *ret) { - tokseadef ctx; + tokseadef ctx; - ctx.tokseanam = name; - ctx.tokseasym.tokslen = namel; - ctx.toksearet = ret; - return(tokthscan((tokthdef *)tab1, hash, tokthsea1, &ctx)); + ctx.tokseanam = name; + ctx.tokseasym.tokslen = namel; + ctx.toksearet = ret; + return(tokthscan((tokthdef *)tab1, hash, tokthsea1, &ctx)); } /* callback for tokthset */ static int tokthset1(void *ctx0, toksdef *sym, mcmon objn) { - tokseadef *ctx = (tokseadef *)ctx0; - - if (sym->tokslen == ctx->tokseasym.tokslen - && !memcmp(sym->toksnam, ctx->tokseasym.toksnam, - ctx->tokseasym.tokslen)) - { - sym->toksval = ctx->tokseasym.toksval; - sym->tokstyp = ctx->tokseasym.tokstyp; - - /* touch object, since it's been changed */ - mcmtch(ctx->tokseamctx, objn); - return(TRUE); - } - else - return(FALSE); + tokseadef *ctx = (tokseadef *)ctx0; + + if (sym->tokslen == ctx->tokseasym.tokslen + && !memcmp(sym->toksnam, ctx->tokseasym.toksnam, + ctx->tokseasym.tokslen)) + { + sym->toksval = ctx->tokseasym.toksval; + sym->tokstyp = ctx->tokseasym.tokstyp; + + /* touch object, since it's been changed */ + mcmtch(ctx->tokseamctx, objn); + return(TRUE); + } + else + return(FALSE); } /* update a symbol in a hashed symbol table */ void tokthset(toktdef *tab1, toksdef *newsym) { - tokseadef ctx; - tokthdef *tab = (tokthdef *)tab1; - - OSCPYSTRUCT(ctx.tokseasym, *newsym); - ctx.tokseamctx = tab->tokthmem; - tokthscan((tokthdef *)tab1, newsym->tokshsh, tokthset1, &ctx); + tokseadef ctx; + tokthdef *tab = (tokthdef *)tab1; + + OSCPYSTRUCT(ctx.tokseasym, *newsym); + ctx.tokseamctx = tab->tokthmem; + tokthscan((tokthdef *)tab1, newsym->tokshsh, tokthset1, &ctx); } /* callback for tokthfind */ static int tokthfind1(void *ctx0, toksdef *sym, mcmon objn) { - tokseadef *ctx = (tokseadef *)ctx0; - - VARUSED(objn); - - if (sym->toksval == ctx->tokseasym.toksval - && sym->tokstyp == ctx->tokseasym.tokstyp) - { - memcpy(ctx->toksearet, sym, - (size_t)(sizeof(toks1def) + sym->tokslen)); - return(TRUE); - } - else - return(FALSE); + tokseadef *ctx = (tokseadef *)ctx0; + + VARUSED(objn); + + if (sym->toksval == ctx->tokseasym.toksval + && sym->tokstyp == ctx->tokseasym.tokstyp) + { + memcpy(ctx->toksearet, sym, + (size_t)(sizeof(toks1def) + sym->tokslen)); + return(TRUE); + } + else + return(FALSE); } /* find a symbol of a particular type and value */ int tokthfind(toktdef *tab1, int typ, uint val, toksdef *ret) { - tokseadef ctx; - int i; - - ctx.tokseasym.tokstyp = typ; - ctx.tokseasym.toksval = val; - ctx.toksearet = ret; - - for (i = 0 ; i < TOKHASHSIZE ; ++i) - { - if (tokthscan((tokthdef *)tab1, i, tokthfind1, &ctx)) - return(TRUE); - } - return(FALSE); + tokseadef ctx; + int i; + + ctx.tokseasym.tokstyp = typ; + ctx.tokseasym.toksval = val; + ctx.toksearet = ret; + + for (i = 0 ; i < TOKHASHSIZE ; ++i) + { + if (tokthscan((tokthdef *)tab1, i, tokthfind1, &ctx)) + return(TRUE); + } + return(FALSE); } /* call a callback for each function in a hashed symbol table */ void toktheach(toktdef *tab1, - void (*cb)(void *, toksdef *), void *ctx) + void (*cb)(void *, toksdef *), void *ctx) { - tokthdef *tab = (tokthdef *)tab1; - uchar *p; - uint max; - uint ofs; - tokshdef *symh; - toksdef *sym; - uint siz; - uint i; - - for (i = 0 ; i <= tab->tokthpcnt ; ++i) - { - /* lock the current page */ - p = mcmlck(tab->tokthmem, tab->tokthpool[i]); - - ERRBEGIN(tab1->tokterr) + tokthdef *tab = (tokthdef *)tab1; + uchar *p; + uint max; + uint ofs; + tokshdef *symh; + toksdef *sym; + uint siz; + uint i; + + for (i = 0 ; i <= tab->tokthpcnt ; ++i) + { + /* lock the current page */ + p = mcmlck(tab->tokthmem, tab->tokthpool[i]); + + ERRBEGIN(tab1->tokterr) - max = (i == tab->tokthpcnt ? tab->tokthofs : tab->tokthfinal[i]); - for (ofs = 0 ; ofs < max ; ) - { - /* get this symbol */ - symh = (tokshdef *)(p + ofs); - sym = &symh->tokshsc; - - /* call the user callback */ - (*cb)(ctx, sym); - - /* advance to the next symbol on this page */ - siz = sizeof(toksh1def) + sym->tokslen; - ofs += osrndsz(siz); - } - - ERRCLEAN(tab1->tokterr) - mcmunlck(tab->tokthmem, tab->tokthpool[i]); - ERRENDCLN(tab1->tokterr) - - /* done with current page; unlock it */ - mcmunlck(tab->tokthmem, tab->tokthpool[i]); - } + max = (i == tab->tokthpcnt ? tab->tokthofs : tab->tokthfinal[i]); + for (ofs = 0 ; ofs < max ; ) + { + /* get this symbol */ + symh = (tokshdef *)(p + ofs); + sym = &symh->tokshsc; + + /* call the user callback */ + (*cb)(ctx, sym); + + /* advance to the next symbol on this page */ + siz = sizeof(toksh1def) + sym->tokslen; + ofs += osrndsz(siz); + } + + ERRCLEAN(tab1->tokterr) + mcmunlck(tab->tokthmem, tab->tokthpool[i]); + ERRENDCLN(tab1->tokterr) + + /* done with current page; unlock it */ + mcmunlck(tab->tokthmem, tab->tokthpool[i]); + } } } // End of namespace TADS2 diff --git a/engines/glk/tads/tads2/vocabulary.cpp b/engines/glk/tads/tads2/vocabulary.cpp index e04dcb557d9..034b871d14c 100644 --- a/engines/glk/tads/tads2/vocabulary.cpp +++ b/engines/glk/tads/tads2/vocabulary.cpp @@ -41,519 +41,519 @@ voccxdef *main_voc_ctx = 0; #ifdef VOCW_IN_CACHE vocwdef *vocwget(voccxdef *ctx, uint idx) { - uint pg; - - if (idx == VOCCXW_NONE) - return 0; + uint pg; + + if (idx == VOCCXW_NONE) + return 0; - /* get the page we need */ - pg = idx/VOCWPGSIZ; + /* get the page we need */ + pg = idx/VOCWPGSIZ; - /* if it's not locked, lock it */ - if (pg != ctx->voccxwplck) - { - /* unlock the old page */ - if (ctx->voccxwplck != MCMONINV) - mcmunlck(ctx->voccxmem, ctx->voccxwp[ctx->voccxwplck]); + /* if it's not locked, lock it */ + if (pg != ctx->voccxwplck) + { + /* unlock the old page */ + if (ctx->voccxwplck != MCMONINV) + mcmunlck(ctx->voccxmem, ctx->voccxwp[ctx->voccxwplck]); - /* lock the new page */ - ctx->voccxwpgptr = (vocwdef *)mcmlck(ctx->voccxmem, - ctx->voccxwp[pg]); - ctx->voccxwplck = pg; - } + /* lock the new page */ + ctx->voccxwpgptr = (vocwdef *)mcmlck(ctx->voccxmem, + ctx->voccxwp[pg]); + ctx->voccxwplck = pg; + } - /* return the entry on that page */ - return ctx->voccxwpgptr + (idx % VOCWPGSIZ); + /* return the entry on that page */ + return ctx->voccxwpgptr + (idx % VOCWPGSIZ); } #endif /*VOCW_IN_CACHE */ /* hash value is based on first 6 characters only to allow match-in-6 */ uint vochsh(const uchar *t, int len) { - uint ret = 0; - - if (len > 6) len = 6; - for ( ; len ; --len, ++t) - ret = (ret + (uint)(vocisupper(*t) ? tolower(*t) : *t)) - & (VOCHASHSIZ - 1); - return(ret); + uint ret = 0; + + if (len > 6) len = 6; + for ( ; len ; --len, ++t) + ret = (ret + (uint)(vocisupper(*t) ? tolower(*t) : *t)) + & (VOCHASHSIZ - 1); + return(ret); } /* copy vocabulary word, and convert to lower case */ static void voccpy(uchar *dst, const uchar *src, int len) { - for ( ; len ; --len, ++dst, ++src) - *dst = vocisupper(*src) ? tolower(*src) : *src; + for ( ; len ; --len, ++dst, ++src) + *dst = vocisupper(*src) ? tolower(*src) : *src; } /* allocate and set up a new vocwdef record, linking into a vocdef's list */ static void vocwset(voccxdef *ctx, vocdef *v, prpnum p, objnum objn, - int classflg) + int classflg) { - vocwdef *vw; - uint inx; - vocwdef *vw2; + vocwdef *vw; + uint inx; + vocwdef *vw2; - /* - * look through the vocdef list to see if there's an existing entry - * with the DELETED marker -- if so, simply undelete it - */ - for (inx = v->vocwlst, vw = vocwget(ctx, inx) ; vw ; - inx = vw->vocwnxt, vw = vocwget(ctx, inx)) - { - /* if this entry was deleted, and otherwise matches, undelete it */ - if ((vw->vocwflg & VOCFDEL) - && vw->vocwobj == objn && vw->vocwtyp == p) - { - /* - * Remove the deleted flag. We will otherwise leave the - * flags unchanged, since the VOCFDEL flag applies only to - * statically allocated objects, and hence the original - * flags should take precedence over any run-time flags. - */ - vw->vocwflg &= ~VOCFDEL; + /* + * look through the vocdef list to see if there's an existing entry + * with the DELETED marker -- if so, simply undelete it + */ + for (inx = v->vocwlst, vw = vocwget(ctx, inx) ; vw ; + inx = vw->vocwnxt, vw = vocwget(ctx, inx)) + { + /* if this entry was deleted, and otherwise matches, undelete it */ + if ((vw->vocwflg & VOCFDEL) + && vw->vocwobj == objn && vw->vocwtyp == p) + { + /* + * Remove the deleted flag. We will otherwise leave the + * flags unchanged, since the VOCFDEL flag applies only to + * statically allocated objects, and hence the original + * flags should take precedence over any run-time flags. + */ + vw->vocwflg &= ~VOCFDEL; - /* we're done */ - return; - } - } + /* we're done */ + return; + } + } - /* make sure the word+object+type record isn't already defined */ - for (inx = v->vocwlst, vw = vocwget(ctx, inx) ; vw ; - inx = vw->vocwnxt, vw = vocwget(ctx, inx)) - { - if (vw->vocwobj == objn && vw->vocwtyp == p - && (vw->vocwflg & VOCFCLASS) == (classflg & VOCFCLASS)) - { - /* it matches - don't add a redundant record */ - return; - } - } - - /* look in the free list for an available vocwdef */ - if (ctx->voccxwfre != VOCCXW_NONE) - { - inx = ctx->voccxwfre; - vw = vocwget(ctx, inx); /* get the free vocwdef */ - ctx->voccxwfre = vw->vocwnxt; /* unlink from free list */ - } - else - { - /* allocate another page of vocwdef's if necssary */ - if ((ctx->voccxwalocnt % VOCWPGSIZ) == 0) - { - int pg = ctx->voccxwalocnt / VOCWPGSIZ; - - /* make sure we haven't exceeded the available page count */ - if (pg >= VOCWPGMAX) errsig(ctx->voccxerr, ERR_VOCMNPG); - - /* allocate on the new page */ + /* make sure the word+object+type record isn't already defined */ + for (inx = v->vocwlst, vw = vocwget(ctx, inx) ; vw ; + inx = vw->vocwnxt, vw = vocwget(ctx, inx)) + { + if (vw->vocwobj == objn && vw->vocwtyp == p + && (vw->vocwflg & VOCFCLASS) == (classflg & VOCFCLASS)) + { + /* it matches - don't add a redundant record */ + return; + } + } + + /* look in the free list for an available vocwdef */ + if (ctx->voccxwfre != VOCCXW_NONE) + { + inx = ctx->voccxwfre; + vw = vocwget(ctx, inx); /* get the free vocwdef */ + ctx->voccxwfre = vw->vocwnxt; /* unlink from free list */ + } + else + { + /* allocate another page of vocwdef's if necssary */ + if ((ctx->voccxwalocnt % VOCWPGSIZ) == 0) + { + int pg = ctx->voccxwalocnt / VOCWPGSIZ; + + /* make sure we haven't exceeded the available page count */ + if (pg >= VOCWPGMAX) errsig(ctx->voccxerr, ERR_VOCMNPG); + + /* allocate on the new page */ #ifdef VOCW_IN_CACHE - mcmalo(ctx->voccxmem, (ushort)(VOCWPGSIZ * sizeof(vocwdef)), - &ctx->voccxwp[pg]); - mcmunlck(ctx->voccxmem, ctx->voccxwp[pg]); + mcmalo(ctx->voccxmem, (ushort)(VOCWPGSIZ * sizeof(vocwdef)), + &ctx->voccxwp[pg]); + mcmunlck(ctx->voccxmem, ctx->voccxwp[pg]); #else - ctx->voccxwp[pg] = - (vocwdef *)mchalo(ctx->voccxerr, - (VOCWPGSIZ * sizeof(vocwdef)), - "vocwset"); + ctx->voccxwp[pg] = + (vocwdef *)mchalo(ctx->voccxerr, + (VOCWPGSIZ * sizeof(vocwdef)), + "vocwset"); #endif - } + } - /* get the next entry, and increment count of used entries */ - inx = ctx->voccxwalocnt++; - vw = vocwget(ctx, inx); - } + /* get the next entry, and increment count of used entries */ + inx = ctx->voccxwalocnt++; + vw = vocwget(ctx, inx); + } - /* link the new vocwdef into the vocdef's relation list */ - vw->vocwnxt = v->vocwlst; - v->vocwlst = inx; + /* link the new vocwdef into the vocdef's relation list */ + vw->vocwnxt = v->vocwlst; + v->vocwlst = inx; - /* set up the new vocwdef */ - vw->vocwtyp = (uchar)p; - vw->vocwobj = objn; - vw->vocwflg = classflg; + /* set up the new vocwdef */ + vw->vocwtyp = (uchar)p; + vw->vocwobj = objn; + vw->vocwflg = classflg; - /* - * Scan the list and make sure we're not adding a redundant verb. - * Don't bother with the warning if this is a class. - */ - if (p == PRP_VERB && (ctx->voccxflg & VOCCXFVWARN) - && (vw->vocwflg & VOCFCLASS) == 0) - { - for (vw2 = vocwget(ctx, v->vocwlst) ; vw2 ; - vw2 = vocwget(ctx, vw2->vocwnxt)) - { - /* - * if this is a different object, and it's not a class, and - * it's defined as a verb, warn about it - */ - if (vw2 != vw - && (vw2->vocwflg & VOCFCLASS) == 0 - && vw2->vocwtyp == PRP_VERB) - { - if (v->vocln2 != 0) - errlog2(ctx->voccxerr, ERR_VOCREVB, - ERRTSTR, - errstr(ctx->voccxerr, - (char *)v->voctxt, v->voclen), - ERRTSTR, - errstr(ctx->voccxerr, - (char *)v->voctxt + v->voclen, v->vocln2)); - else - errlog1(ctx->voccxerr, ERR_VOCREVB, - ERRTSTR, - errstr(ctx->voccxerr, - (char *)v->voctxt, v->voclen)); - break; - } - } - } + /* + * Scan the list and make sure we're not adding a redundant verb. + * Don't bother with the warning if this is a class. + */ + if (p == PRP_VERB && (ctx->voccxflg & VOCCXFVWARN) + && (vw->vocwflg & VOCFCLASS) == 0) + { + for (vw2 = vocwget(ctx, v->vocwlst) ; vw2 ; + vw2 = vocwget(ctx, vw2->vocwnxt)) + { + /* + * if this is a different object, and it's not a class, and + * it's defined as a verb, warn about it + */ + if (vw2 != vw + && (vw2->vocwflg & VOCFCLASS) == 0 + && vw2->vocwtyp == PRP_VERB) + { + if (v->vocln2 != 0) + errlog2(ctx->voccxerr, ERR_VOCREVB, + ERRTSTR, + errstr(ctx->voccxerr, + (char *)v->voctxt, v->voclen), + ERRTSTR, + errstr(ctx->voccxerr, + (char *)v->voctxt + v->voclen, v->vocln2)); + else + errlog1(ctx->voccxerr, ERR_VOCREVB, + ERRTSTR, + errstr(ctx->voccxerr, + (char *)v->voctxt, v->voclen)); + break; + } + } + } } /* set up a vocdef record, and link into hash table */ static void vocset(voccxdef *ctx, vocdef *v, prpnum p, objnum objn, - int classflg, uchar *wrdtxt, int len, - uchar *wrd2, int len2) + int classflg, uchar *wrdtxt, int len, + uchar *wrd2, int len2) { - uint hshval = vochsh(wrdtxt, len); - - v->vocnxt = ctx->voccxhsh[hshval]; - ctx->voccxhsh[hshval] = v; - - v->voclen = len; - v->vocln2 = len2; - voccpy(v->voctxt, wrdtxt, len); - if (wrd2) voccpy(v->voctxt + len, wrd2, len2); + uint hshval = vochsh(wrdtxt, len); + + v->vocnxt = ctx->voccxhsh[hshval]; + ctx->voccxhsh[hshval] = v; + + v->voclen = len; + v->vocln2 = len2; + voccpy(v->voctxt, wrdtxt, len); + if (wrd2) voccpy(v->voctxt + len, wrd2, len2); - /* allocate and initialize a vocwdef for the object */ - vocwset(ctx, v, p, objn, classflg); + /* allocate and initialize a vocwdef for the object */ + vocwset(ctx, v, p, objn, classflg); } /* internal addword - already parsed into two words and have lengths */ void vocadd2(voccxdef *ctx, prpnum p, objnum objn, int classflg, - uchar *wrdtxt, int len, uchar *wrd2, int len2) + uchar *wrdtxt, int len, uchar *wrd2, int len2) { - vocdef *v; - vocdef *prv; - uint need; - uint hshval; + vocdef *v; + vocdef *prv; + uint need; + uint hshval; - /* if the word is null, ignore it entirely */ - if (len == 0 && len2 == 0) - return; + /* if the word is null, ignore it entirely */ + if (len == 0 && len2 == 0) + return; - /* look for a vocdef entry with the same word text */ - hshval = vochsh(wrdtxt, len); - for (v = ctx->voccxhsh[hshval] ; v ; v = v->vocnxt) - { - /* if it matches on both words, use this entry */ - if (v->voclen == len && !memcmp(wrdtxt, v->voctxt, (size_t)len) - && ((!wrd2 && v->vocln2 == 0) - || (v->vocln2 == len2 && - !memcmp(wrd2, v->voctxt + len, (size_t)len2)))) - { - vocwset(ctx, v, p, objn, classflg); - return; - } - } + /* look for a vocdef entry with the same word text */ + hshval = vochsh(wrdtxt, len); + for (v = ctx->voccxhsh[hshval] ; v ; v = v->vocnxt) + { + /* if it matches on both words, use this entry */ + if (v->voclen == len && !memcmp(wrdtxt, v->voctxt, (size_t)len) + && ((!wrd2 && v->vocln2 == 0) + || (v->vocln2 == len2 && + !memcmp(wrd2, v->voctxt + len, (size_t)len2)))) + { + vocwset(ctx, v, p, objn, classflg); + return; + } + } - /* look for a free vocdef entry of the same size */ - for (prv = (vocdef *)0, v = ctx->voccxfre ; v ; prv = v, v = v->vocnxt) - if (v->voclen == len + len2) break; - - if (v) - { - /* we found something - unlink from free list */ - if (prv) prv->vocnxt = v->vocnxt; - else ctx->voccxfre = v->vocnxt; - - /* reuse the entry */ - v->vocwlst = VOCCXW_NONE; - vocset(ctx, v, p, objn, classflg, wrdtxt, len, wrd2, len2); - return; - } - - /* didn't find an existing vocdef; allocate a new one */ - need = sizeof(vocdef) + len + len2 - 1; - if (ctx->voccxrem < need) - { - /* not enough space in current page; allocate a new one */ - ctx->voccxpool = mchalo(ctx->voccxerr, VOCPGSIZ, "vocadd2"); - ctx->voccxrem = VOCPGSIZ; - } - - /* use top of current pool, and update pool pointer and size */ - v = (vocdef *)ctx->voccxpool; - need = osrndsz(need); - ctx->voccxpool += need; - if (ctx->voccxrem > need) ctx->voccxrem -= need; - else ctx->voccxrem = 0; - - /* set up new vocdef */ - v->vocwlst = VOCCXW_NONE; - vocset(ctx, v, p, objn, classflg, wrdtxt, len, wrd2, len2); + /* look for a free vocdef entry of the same size */ + for (prv = (vocdef *)0, v = ctx->voccxfre ; v ; prv = v, v = v->vocnxt) + if (v->voclen == len + len2) break; + + if (v) + { + /* we found something - unlink from free list */ + if (prv) prv->vocnxt = v->vocnxt; + else ctx->voccxfre = v->vocnxt; + + /* reuse the entry */ + v->vocwlst = VOCCXW_NONE; + vocset(ctx, v, p, objn, classflg, wrdtxt, len, wrd2, len2); + return; + } + + /* didn't find an existing vocdef; allocate a new one */ + need = sizeof(vocdef) + len + len2 - 1; + if (ctx->voccxrem < need) + { + /* not enough space in current page; allocate a new one */ + ctx->voccxpool = mchalo(ctx->voccxerr, VOCPGSIZ, "vocadd2"); + ctx->voccxrem = VOCPGSIZ; + } + + /* use top of current pool, and update pool pointer and size */ + v = (vocdef *)ctx->voccxpool; + need = osrndsz(need); + ctx->voccxpool += need; + if (ctx->voccxrem > need) ctx->voccxrem -= need; + else ctx->voccxrem = 0; + + /* set up new vocdef */ + v->vocwlst = VOCCXW_NONE; + vocset(ctx, v, p, objn, classflg, wrdtxt, len, wrd2, len2); } static void voc_parse_words(char **wrdtxt, int *len, char **wrd2, int *len2) { - /* get length and pointer to actual text */ - *len = osrp2(*wrdtxt) - 2; - *wrdtxt += 2; - - /* see if there's a second word - look for a space */ - for (*wrd2 = *wrdtxt, *len2 = *len ; *len2 && !vocisspace(**wrd2) ; - ++*wrd2, --*len2) ; - if (*len2) - { - *len -= *len2; - while (*len2 && vocisspace(**wrd2)) ++*wrd2, --*len2; - } - else - { - /* no space ==> no second word */ - *wrd2 = (char *)0; - } + /* get length and pointer to actual text */ + *len = osrp2(*wrdtxt) - 2; + *wrdtxt += 2; + + /* see if there's a second word - look for a space */ + for (*wrd2 = *wrdtxt, *len2 = *len ; *len2 && !vocisspace(**wrd2) ; + ++*wrd2, --*len2) ; + if (*len2) + { + *len -= *len2; + while (*len2 && vocisspace(**wrd2)) ++*wrd2, --*len2; + } + else + { + /* no space ==> no second word */ + *wrd2 = (char *)0; + } } void vocadd(voccxdef *ctx, prpnum p, objnum objn, int classflg, char *wrdtxt) { - int len; - char *wrd2; - int len2; + int len; + char *wrd2; + int len2; - voc_parse_words(&wrdtxt, &len, &wrd2, &len2); - vocadd2(ctx, p, objn, classflg, (uchar *)wrdtxt, len, (uchar *)wrd2, len2); + voc_parse_words(&wrdtxt, &len, &wrd2, &len2); + vocadd2(ctx, p, objn, classflg, (uchar *)wrdtxt, len, (uchar *)wrd2, len2); } /* make sure we have a page table entry for an object, allocating one if not */ void vocialo(voccxdef *ctx, objnum obj) { - if (!ctx->voccxinh[obj >> 8]) - { - ctx->voccxinh[obj >> 8] = - (vocidef **)mchalo(ctx->voccxerr, - (256 * sizeof(vocidef *)), "vocialo"); - memset(ctx->voccxinh[obj >> 8], 0, (size_t)(256 * sizeof(vocidef *))); - } + if (!ctx->voccxinh[obj >> 8]) + { + ctx->voccxinh[obj >> 8] = + (vocidef **)mchalo(ctx->voccxerr, + (256 * sizeof(vocidef *)), "vocialo"); + memset(ctx->voccxinh[obj >> 8], 0, (size_t)(256 * sizeof(vocidef *))); + } } /* add an inheritance/location record */ void vociadd(voccxdef *ctx, objnum obj, objnum loc, - int numsc, objnum *sc, int flags) + int numsc, objnum *sc, int flags) { - vocidef *v; - vocidef *min; - vocidef *prv; + vocidef *v; + vocidef *min; + vocidef *prv; vocidef *minprv = nullptr; - /* make sure we have a page table entry for this object */ - vocialo(ctx, obj); + /* make sure we have a page table entry for this object */ + vocialo(ctx, obj); - /* look in free list for an entry that's big enough */ - for (prv = (vocidef *)0, min = (vocidef *)0, v = ctx->voccxifr ; v ; - prv = v, v = v->vocinxt) - { - if (v->vocinsc == numsc) - { - min = v; - minprv = prv; - break; - } - else if (v->vocinsc > numsc) - { - if (!min || v->vocinsc < min->vocinsc) - { - min = v; - minprv = prv; - } - } - } - - if (!min) - { - uint need; - - /* nothing in free list; allocate a new entry */ - need = osrndsz(sizeof(vocidef) + (numsc - 1)*sizeof(objnum)); - if (ctx->voccxilst + need >= VOCISIZ) - { - /* nothing left on current page; allocate a new page */ - ctx->voccxip[++(ctx->voccxiplst)] = - mchalo(ctx->voccxerr, VOCISIZ, "vociadd"); - ctx->voccxilst = 0; - } + /* look in free list for an entry that's big enough */ + for (prv = (vocidef *)0, min = (vocidef *)0, v = ctx->voccxifr ; v ; + prv = v, v = v->vocinxt) + { + if (v->vocinsc == numsc) + { + min = v; + minprv = prv; + break; + } + else if (v->vocinsc > numsc) + { + if (!min || v->vocinsc < min->vocinsc) + { + min = v; + minprv = prv; + } + } + } + + if (!min) + { + uint need; + + /* nothing in free list; allocate a new entry */ + need = osrndsz(sizeof(vocidef) + (numsc - 1)*sizeof(objnum)); + if (ctx->voccxilst + need >= VOCISIZ) + { + /* nothing left on current page; allocate a new page */ + ctx->voccxip[++(ctx->voccxiplst)] = + mchalo(ctx->voccxerr, VOCISIZ, "vociadd"); + ctx->voccxilst = 0; + } - /* allocate space out of current page */ - v = (vocidef *)(ctx->voccxip[ctx->voccxiplst] + ctx->voccxilst); - ctx->voccxilst += need; - } - else - { - /* unlink from chain and use */ - v = min; - if (minprv) - minprv->vocinxt = v->vocinxt; - else - ctx->voccxifr = v->vocinxt; - } + /* allocate space out of current page */ + v = (vocidef *)(ctx->voccxip[ctx->voccxiplst] + ctx->voccxilst); + ctx->voccxilst += need; + } + else + { + /* unlink from chain and use */ + v = min; + if (minprv) + minprv->vocinxt = v->vocinxt; + else + ctx->voccxifr = v->vocinxt; + } - /* set up the entry */ - if (vocinh(ctx, obj) != (vocidef *)0) errsig(ctx->voccxerr, ERR_VOCINUS); - v->vociloc = loc; - v->vociilc = MCMONINV; - v->vociflg = (flags & ~VOCIFXLAT); - v->vocinsc = numsc; - if (numsc) - { - if (flags & VOCIFXLAT) - { - int i; - - for (i = 0 ; i < numsc ; ++i) - v->vocisc[i] = osrp2(&sc[i]); - } - else - memcpy(v->vocisc, sc, (size_t)(numsc * sizeof(objnum))); - } - vocinh(ctx, obj) = v; /* set page table entry */ + /* set up the entry */ + if (vocinh(ctx, obj) != (vocidef *)0) errsig(ctx->voccxerr, ERR_VOCINUS); + v->vociloc = loc; + v->vociilc = MCMONINV; + v->vociflg = (flags & ~VOCIFXLAT); + v->vocinsc = numsc; + if (numsc) + { + if (flags & VOCIFXLAT) + { + int i; + + for (i = 0 ; i < numsc ; ++i) + v->vocisc[i] = osrp2(&sc[i]); + } + else + memcpy(v->vocisc, sc, (size_t)(numsc * sizeof(objnum))); + } + vocinh(ctx, obj) = v; /* set page table entry */ } /* revert all objects to original state, using inheritance records */ void vocrevert(voccxdef *vctx) { - vocidef ***vpg; - vocidef **v; - int i; - int j; - objnum obj; + vocidef ***vpg; + vocidef **v; + int i; + int j; + objnum obj; - /* - * Go through the inheritance records. Delete each dynamically - * allocated object, and revert each static object to its original - * load state. - */ - for (vpg = vctx->voccxinh, i = 0 ; i < VOCINHMAX ; ++vpg, ++i) - { - if (!*vpg) continue; - for (v = *vpg, obj = (i << 8), j = 0 ; j < 256 ; ++v, ++obj, ++j) - { - if (*v) - { - /* if the object was dynamically allocated, delete it */ - if ((*v)->vociflg & VOCIFNEW) - { - /* delete vocabulary and inheritance data for the object */ - vocidel(vctx, obj); - vocdel(vctx, obj); + /* + * Go through the inheritance records. Delete each dynamically + * allocated object, and revert each static object to its original + * load state. + */ + for (vpg = vctx->voccxinh, i = 0 ; i < VOCINHMAX ; ++vpg, ++i) + { + if (!*vpg) continue; + for (v = *vpg, obj = (i << 8), j = 0 ; j < 256 ; ++v, ++obj, ++j) + { + if (*v) + { + /* if the object was dynamically allocated, delete it */ + if ((*v)->vociflg & VOCIFNEW) + { + /* delete vocabulary and inheritance data for the object */ + vocidel(vctx, obj); + vocdel(vctx, obj); - /* delete the object */ - mcmfre(vctx->voccxmem, (mcmon)obj); - } - else - { - /* revert the object */ - mcmrevert(vctx->voccxmem, (mcmon)obj); - } - } - } - } + /* delete the object */ + mcmfre(vctx->voccxmem, (mcmon)obj); + } + else + { + /* revert the object */ + mcmrevert(vctx->voccxmem, (mcmon)obj); + } + } + } + } - /* - * Revert the vocabulary list: delete all newly added words, and - * undelete all original words marked as deleted. - */ - vocdel1(vctx, MCMONINV, (char *)0, 0, TRUE, TRUE, FALSE); + /* + * Revert the vocabulary list: delete all newly added words, and + * undelete all original words marked as deleted. + */ + vocdel1(vctx, MCMONINV, (char *)0, 0, TRUE, TRUE, FALSE); } /* initialize voc context */ void vocini(voccxdef *vocctx, errcxdef *errctx, mcmcxdef *memctx, - runcxdef *runctx, objucxdef *undoctx, - int fuses, int daemons, int notifiers) + runcxdef *runctx, objucxdef *undoctx, + int fuses, int daemons, int notifiers) { - CLRSTRUCT(*vocctx); - vocctx->voccxerr = errctx; - vocctx->voccxiplst = (uint)-1; - vocctx->voccxilst = VOCISIZ; - vocctx->voccxmem = memctx; - vocctx->voccxrun = runctx; - vocctx->voccxundo = undoctx; + CLRSTRUCT(*vocctx); + vocctx->voccxerr = errctx; + vocctx->voccxiplst = (uint)-1; + vocctx->voccxilst = VOCISIZ; + vocctx->voccxmem = memctx; + vocctx->voccxrun = runctx; + vocctx->voccxundo = undoctx; - vocctx->voccxme = - vocctx->voccxme_init = - vocctx->voccxvtk = - vocctx->voccxstr = - vocctx->voccxnum = - vocctx->voccxit = - vocctx->voccxhim = - vocctx->voccxprd = - vocctx->voccxpre = - vocctx->voccxpre2 = - vocctx->voccxppc = - vocctx->voccxlsv = - vocctx->voccxpreinit = - vocctx->voccxper = - vocctx->voccxprom = - vocctx->voccxpostprom = - vocctx->voccxpdis = - vocctx->voccxper2 = - vocctx->voccxperp = - vocctx->voccxpdef = - vocctx->voccxpdef2 = - vocctx->voccxpask = - vocctx->voccxpask2 = - vocctx->voccxpask3 = - vocctx->voccxinitrestore = - vocctx->voccxpuv = - vocctx->voccxpnp = - vocctx->voccxpostact = - vocctx->voccxendcmd = - vocctx->voccxher = MCMONINV; - vocctx->voccxthc = 0; + vocctx->voccxme = + vocctx->voccxme_init = + vocctx->voccxvtk = + vocctx->voccxstr = + vocctx->voccxnum = + vocctx->voccxit = + vocctx->voccxhim = + vocctx->voccxprd = + vocctx->voccxpre = + vocctx->voccxpre2 = + vocctx->voccxppc = + vocctx->voccxlsv = + vocctx->voccxpreinit = + vocctx->voccxper = + vocctx->voccxprom = + vocctx->voccxpostprom = + vocctx->voccxpdis = + vocctx->voccxper2 = + vocctx->voccxperp = + vocctx->voccxpdef = + vocctx->voccxpdef2 = + vocctx->voccxpask = + vocctx->voccxpask2 = + vocctx->voccxpask3 = + vocctx->voccxinitrestore = + vocctx->voccxpuv = + vocctx->voccxpnp = + vocctx->voccxpostact = + vocctx->voccxendcmd = + vocctx->voccxher = MCMONINV; + vocctx->voccxthc = 0; #ifdef VOCW_IN_CACHE - vocctx->voccxwplck = MCMONINV; + vocctx->voccxwplck = MCMONINV; #endif - vocctx->voccxactor = MCMONINV; - vocctx->voccxverb = MCMONINV; - vocctx->voccxprep = MCMONINV; - vocctx->voccxdobj = 0; - vocctx->voccxiobj = 0; + vocctx->voccxactor = MCMONINV; + vocctx->voccxverb = MCMONINV; + vocctx->voccxprep = MCMONINV; + vocctx->voccxdobj = 0; + vocctx->voccxiobj = 0; - vocctx->voccxunknown = 0; - vocctx->voccxlastunk = 0; + vocctx->voccxunknown = 0; + vocctx->voccxlastunk = 0; - vocctx->voc_stk_ptr = 0; - vocctx->voc_stk_cur = 0; - vocctx->voc_stk_end = 0; + vocctx->voc_stk_ptr = 0; + vocctx->voc_stk_cur = 0; + vocctx->voc_stk_end = 0; - /* allocate fuses, daemons, notifiers */ - vocinialo(vocctx, &vocctx->voccxfus, (vocctx->voccxfuc = fuses)); - vocinialo(vocctx, &vocctx->voccxdmn, (vocctx->voccxdmc = daemons)); - vocinialo(vocctx, &vocctx->voccxalm, (vocctx->voccxalc = notifiers)); + /* allocate fuses, daemons, notifiers */ + vocinialo(vocctx, &vocctx->voccxfus, (vocctx->voccxfuc = fuses)); + vocinialo(vocctx, &vocctx->voccxdmn, (vocctx->voccxdmc = daemons)); + vocinialo(vocctx, &vocctx->voccxalm, (vocctx->voccxalc = notifiers)); - /* no entries in vocwdef free list yet */ - vocctx->voccxwfre = VOCCXW_NONE; + /* no entries in vocwdef free list yet */ + vocctx->voccxwfre = VOCCXW_NONE; } /* uninitialize the voc context */ void vocterm(voccxdef *ctx) { - /* delete the fuses, daemons, and notifiers */ - voctermfree(ctx->voccxfus); - voctermfree(ctx->voccxdmn); - voctermfree(ctx->voccxalm); + /* delete the fuses, daemons, and notifiers */ + voctermfree(ctx->voccxfus); + voctermfree(ctx->voccxdmn); + voctermfree(ctx->voccxalm); - /* delete the private stack */ - if (ctx->voc_stk_ptr != 0) - mchfre(ctx->voc_stk_ptr); + /* delete the private stack */ + if (ctx->voc_stk_ptr != 0) + mchfre(ctx->voc_stk_ptr); } /* clean up the vocab context */ void voctermfree(vocddef *what) { - if (what != 0) - mchfre(what); + if (what != 0) + mchfre(what); } /* @@ -562,62 +562,62 @@ void voctermfree(vocddef *what) * the callback for every word. */ void voc_iterate(voccxdef *ctx, objnum objn, - void (*fn)(void *, vocdef *, vocwdef *), void *fnctx) + void (*fn)(void *, vocdef *, vocwdef *), void *fnctx) { - int i; - vocdef *v; - vocdef **vp; - vocwdef *vw; - uint idx; + int i; + vocdef *v; + vocdef **vp; + vocwdef *vw; + uint idx; - /* go through each hash value looking for matching words */ - for (i = VOCHASHSIZ, vp = ctx->voccxhsh ; i ; ++vp, --i) - { - /* go through all words in this hash chain */ - for (v = *vp ; v ; v = v->vocnxt) - { - /* go through each object relation for this word */ - for (idx = v->vocwlst, vw = vocwget(ctx, idx) ; vw ; - idx = vw->vocwnxt, vw = vocwget(ctx, idx)) - { - /* - * if this word is for this object, call the callback - */ - if (objn == MCMONINV || vw->vocwobj == objn) - (*fn)(fnctx, v, vw); - } - } - } + /* go through each hash value looking for matching words */ + for (i = VOCHASHSIZ, vp = ctx->voccxhsh ; i ; ++vp, --i) + { + /* go through all words in this hash chain */ + for (v = *vp ; v ; v = v->vocnxt) + { + /* go through each object relation for this word */ + for (idx = v->vocwlst, vw = vocwget(ctx, idx) ; vw ; + idx = vw->vocwnxt, vw = vocwget(ctx, idx)) + { + /* + * if this word is for this object, call the callback + */ + if (objn == MCMONINV || vw->vocwobj == objn) + (*fn)(fnctx, v, vw); + } + } + } } /* callback context for voc_count */ struct voc_count_ctx { - int cnt; - int siz; - prpnum prp; + int cnt; + int siz; + prpnum prp; }; /* callback for voc_count */ static void voc_count_cb(void *ctx0, vocdef *voc, vocwdef *vocw) { - struct voc_count_ctx *ctx = (struct voc_count_ctx *)ctx0; - - VARUSED(vocw); + struct voc_count_ctx *ctx = (struct voc_count_ctx *)ctx0; + + VARUSED(vocw); - /* - * If it matches the property (or we want all properties), count - * it. Don't count deleted objects. - */ - if ((ctx->prp == 0 || ctx->prp == vocw->vocwtyp) - && !(vocw->vocwflg & VOCFDEL)) - { - /* count the word */ - ctx->cnt++; - - /* count the size */ - ctx->siz += voc->voclen + voc->vocln2; - } + /* + * If it matches the property (or we want all properties), count + * it. Don't count deleted objects. + */ + if ((ctx->prp == 0 || ctx->prp == vocw->vocwtyp) + && !(vocw->vocwflg & VOCFDEL)) + { + /* count the word */ + ctx->cnt++; + + /* count the size */ + ctx->siz += voc->voclen + voc->vocln2; + } } /* @@ -627,19 +627,19 @@ static void voc_count_cb(void *ctx0, vocdef *voc, vocwdef *vocw) */ void voc_count(voccxdef *ctx, objnum objn, prpnum prp, int *cnt, int *siz) { - struct voc_count_ctx fnctx; + struct voc_count_ctx fnctx; - /* set up the context with zero initial counts */ - fnctx.cnt = 0; - fnctx.siz = 0; - fnctx.prp = prp; + /* set up the context with zero initial counts */ + fnctx.cnt = 0; + fnctx.siz = 0; + fnctx.prp = prp; - /* iterate over all words for the object with our callback */ - voc_iterate(ctx, objn, voc_count_cb, &fnctx); + /* iterate over all words for the object with our callback */ + voc_iterate(ctx, objn, voc_count_cb, &fnctx); - /* return the data */ - if (cnt) *cnt = fnctx.cnt; - if (siz) *siz = fnctx.siz; + /* return the data */ + if (cnt) *cnt = fnctx.cnt; + if (siz) *siz = fnctx.siz; } @@ -654,184 +654,184 @@ void voc_count(voccxdef *ctx, objnum objn, prpnum prp, int *cnt, int *siz) * that were in the original vocabulary. */ void vocdel1(voccxdef *ctx, objnum objn, char *wrd1, prpnum prp, - int really_delete, int revert, int keep_undo) + int really_delete, int revert, int keep_undo) { - int i; - vocdef *v; - vocdef *prv; - vocdef *nxt; - vocdef **vp; - vocwdef *vw; - vocwdef *prvw; - vocwdef *nxtw; - uint nxtidx; - uint idx; - int deleted_vocdef; + int i; + vocdef *v; + vocdef *prv; + vocdef *nxt; + vocdef **vp; + vocwdef *vw; + vocwdef *prvw; + vocwdef *nxtw; + uint nxtidx; + uint idx; + int deleted_vocdef; char *wrd2 = nullptr; - int len1 = 0, len2 = 0; - int do_del; - char *orgwrd; + int len1 = 0, len2 = 0; + int do_del; + char *orgwrd; - /* parse the word if provided */ - orgwrd = wrd1; - if (wrd1) - voc_parse_words(&wrd1, &len1, &wrd2, &len2); - - /* go through each hash value looking for matching words */ - for (i = VOCHASHSIZ, vp = ctx->voccxhsh ; i ; ++vp, --i) - { - /* go through all words in this hash chain */ - for (prv = (vocdef *)0, v = *vp ; v ; v = nxt) - { - /* remember next word in hash chain */ - nxt = v->vocnxt; + /* parse the word if provided */ + orgwrd = wrd1; + if (wrd1) + voc_parse_words(&wrd1, &len1, &wrd2, &len2); + + /* go through each hash value looking for matching words */ + for (i = VOCHASHSIZ, vp = ctx->voccxhsh ; i ; ++vp, --i) + { + /* go through all words in this hash chain */ + for (prv = (vocdef *)0, v = *vp ; v ; v = nxt) + { + /* remember next word in hash chain */ + nxt = v->vocnxt; - /* if this word doesn't match, skip it */ - if (wrd1) - { - /* compare the first word */ - if (v->voclen != len1 - || memicmp((char *)v->voctxt, wrd1, (size_t)len1)) - { - prv = v; - continue; - } + /* if this word doesn't match, skip it */ + if (wrd1) + { + /* compare the first word */ + if (v->voclen != len1 + || memicmp((char *)v->voctxt, wrd1, (size_t)len1)) + { + prv = v; + continue; + } - /* if there's a second word, compare it as well */ - if (wrd2 && (v->vocln2 != len2 - || memicmp((char *)v->voctxt + len1, - wrd2, (size_t)len2))) - { - prv = v; - continue; - } - } + /* if there's a second word, compare it as well */ + if (wrd2 && (v->vocln2 != len2 + || memicmp((char *)v->voctxt + len1, + wrd2, (size_t)len2))) + { + prv = v; + continue; + } + } - /* presume we're not going to delete this vocdef */ - deleted_vocdef = FALSE; - - /* go through all object relations for this word */ - for (prvw = 0, idx = v->vocwlst, vw = vocwget(ctx, idx) ; vw ; - vw = nxtw, idx = nxtidx) - { - /* remember next word in relation list */ - nxtidx = vw->vocwnxt; - nxtw = vocwget(ctx, nxtidx); + /* presume we're not going to delete this vocdef */ + deleted_vocdef = FALSE; + + /* go through all object relations for this word */ + for (prvw = 0, idx = v->vocwlst, vw = vocwget(ctx, idx) ; vw ; + vw = nxtw, idx = nxtidx) + { + /* remember next word in relation list */ + nxtidx = vw->vocwnxt; + nxtw = vocwget(ctx, nxtidx); - /* - * figure out whether to delete this word, based on the - * caller's specified operating mode - */ - if (revert) - { - /* if reverting, delete all new words */ - do_del = (vw->vocwflg & VOCFNEW); + /* + * figure out whether to delete this word, based on the + * caller's specified operating mode + */ + if (revert) + { + /* if reverting, delete all new words */ + do_del = (vw->vocwflg & VOCFNEW); - /* also, remove the DELETED flag if present */ - vw->vocwflg &= ~VOCFDEL; - } - else - { - /* - * delete the word if the object number matches, - * AND either we're not searching for a specific - * vocabulary word (in which case wrd1 will be null) - * or the word matches the vocabulary word we're - * seeking (in which case the part of speech must - * match) - */ - do_del = (vw->vocwobj == objn - && (wrd1 == 0 || vw->vocwtyp == prp)); + /* also, remove the DELETED flag if present */ + vw->vocwflg &= ~VOCFDEL; + } + else + { + /* + * delete the word if the object number matches, + * AND either we're not searching for a specific + * vocabulary word (in which case wrd1 will be null) + * or the word matches the vocabulary word we're + * seeking (in which case the part of speech must + * match) + */ + do_del = (vw->vocwobj == objn + && (wrd1 == 0 || vw->vocwtyp == prp)); - /* - * if we're not in really_delete mode, and the word - * matches and it wasn't dynamically added at - * run-time, simply mark it as deleted -- this will - * allow it to be undeleted if the game is reverted - * to RESTART conditions - */ - if (do_del && !really_delete && !(vw->vocwflg & VOCFNEW)) - { - /* geneate undo for the operation */ - if (keep_undo && orgwrd) - vocdusave_delwrd(ctx, objn, prp, - vw->vocwflg, orgwrd); - - /* just mark the word for deletion, but keep vw */ - vw->vocwflg |= VOCFDEL; - do_del = FALSE; - } - } + /* + * if we're not in really_delete mode, and the word + * matches and it wasn't dynamically added at + * run-time, simply mark it as deleted -- this will + * allow it to be undeleted if the game is reverted + * to RESTART conditions + */ + if (do_del && !really_delete && !(vw->vocwflg & VOCFNEW)) + { + /* geneate undo for the operation */ + if (keep_undo && orgwrd) + vocdusave_delwrd(ctx, objn, prp, + vw->vocwflg, orgwrd); + + /* just mark the word for deletion, but keep vw */ + vw->vocwflg |= VOCFDEL; + do_del = FALSE; + } + } - /* now delete the structure if we decided we should */ - if (do_del) - { - /* geneate undo for the operation */ - if (keep_undo && orgwrd) - vocdusave_delwrd(ctx, objn, prp, vw->vocwflg, orgwrd); - - /* unlink this vocwdef from the vocdef's list */ - if (prvw) - prvw->vocwnxt = vw->vocwnxt; - else - v->vocwlst = vw->vocwnxt; + /* now delete the structure if we decided we should */ + if (do_del) + { + /* geneate undo for the operation */ + if (keep_undo && orgwrd) + vocdusave_delwrd(ctx, objn, prp, vw->vocwflg, orgwrd); + + /* unlink this vocwdef from the vocdef's list */ + if (prvw) + prvw->vocwnxt = vw->vocwnxt; + else + v->vocwlst = vw->vocwnxt; - /* link the vocwdef into the vocwdef free list */ - vw->vocwnxt = ctx->voccxwfre; - ctx->voccxwfre = idx; + /* link the vocwdef into the vocwdef free list */ + vw->vocwnxt = ctx->voccxwfre; + ctx->voccxwfre = idx; - /* - * if there's nothing left in the vocdef's list, - * delete the entire vocdef as well - */ - if (v->vocwlst == VOCCXW_NONE) - { - if (prv) prv->vocnxt = v->vocnxt; - else *vp = v->vocnxt; - - /* link into free chain */ - v->vocnxt = ctx->voccxfre; - ctx->voccxfre = v; + /* + * if there's nothing left in the vocdef's list, + * delete the entire vocdef as well + */ + if (v->vocwlst == VOCCXW_NONE) + { + if (prv) prv->vocnxt = v->vocnxt; + else *vp = v->vocnxt; + + /* link into free chain */ + v->vocnxt = ctx->voccxfre; + ctx->voccxfre = v; - /* note that it's been deleted */ - deleted_vocdef = TRUE; - } - } - else - { - /* we're not deleting the word, so move prvw forward */ - prvw = vw; - } - } + /* note that it's been deleted */ + deleted_vocdef = TRUE; + } + } + else + { + /* we're not deleting the word, so move prvw forward */ + prvw = vw; + } + } - /* if we didn't delete this vocdef, move prv forward onto it */ - if (!deleted_vocdef) - prv = v; - } - } + /* if we didn't delete this vocdef, move prv forward onto it */ + if (!deleted_vocdef) + prv = v; + } + } } /* delete all vocabulary for an object */ void vocdel(voccxdef *ctx, objnum objn) { - vocdel1(ctx, objn, (char *)0, (prpnum)0, TRUE, FALSE, FALSE); + vocdel1(ctx, objn, (char *)0, (prpnum)0, TRUE, FALSE, FALSE); } /* delete object inheritance records for a particular object */ void vocidel(voccxdef *ctx, objnum obj) { - vocidef *v; - - /* get entry out of page table, and clear page table slot */ - v = vocinh(ctx, obj); - vocinh(ctx, obj) = (vocidef *)0; - - /* link into free list */ - if (v) - { - v->vocinxt = ctx->voccxifr; - ctx->voccxifr = v; - } + vocidef *v; + + /* get entry out of page table, and clear page table slot */ + v = vocinh(ctx, obj); + vocinh(ctx, obj) = (vocidef *)0; + + /* link into free list */ + if (v) + { + v->vocinxt = ctx->voccxifr; + ctx->voccxifr = v; + } } /* @@ -839,83 +839,83 @@ void vocidel(voccxdef *ctx, objnum obj) * if a suitable template is found, FALSE otherwise. */ int voctplfnd(voccxdef *ctx, objnum verb_in, objnum prep, - uchar *tplout, int *newstyle) + uchar *tplout, int *newstyle) { - uchar *tplptr; - uchar *thistpl; - int found; - int tplcnt; - uint tplofs; - objnum verb; + uchar *tplptr; + uchar *thistpl; + int found; + int tplcnt; + uint tplofs; + objnum verb; - /* look for a new-style template first */ - tplofs = objgetap(ctx->voccxmem, verb_in, PRP_TPL2, &verb, FALSE); - if (tplofs) - { - /* flag the presence of the new-style template */ - *newstyle = TRUE; - } - else - { - /* no new-style template - look for old version */ - tplofs = objgetap(ctx->voccxmem, verb_in, PRP_TPL, &verb, FALSE); - *newstyle = FALSE; - } + /* look for a new-style template first */ + tplofs = objgetap(ctx->voccxmem, verb_in, PRP_TPL2, &verb, FALSE); + if (tplofs) + { + /* flag the presence of the new-style template */ + *newstyle = TRUE; + } + else + { + /* no new-style template - look for old version */ + tplofs = objgetap(ctx->voccxmem, verb_in, PRP_TPL, &verb, FALSE); + *newstyle = FALSE; + } - /* inherit templates until we run out of them */ - for (;;) - { - /* if we found something already, use it */ - if (tplofs) - { - size_t siz; + /* inherit templates until we run out of them */ + for (;;) + { + /* if we found something already, use it */ + if (tplofs) + { + size_t siz; - /* figure the size of this template style */ - siz = (*newstyle ? VOCTPL2SIZ : VOCTPLSIZ); - - /* lock the verb object, and get the property value pointer */ - tplptr = mcmlck(ctx->voccxmem, verb); - thistpl = prpvalp(tplptr + tplofs); - - /* first byte is number of templates in array */ - tplcnt = *thistpl++; - - /* look for a template that matches the preposition object */ - for (found = FALSE ; tplcnt ; thistpl += siz, --tplcnt) - { - if (voctplpr(thistpl) == prep) - { - found = TRUE; - break; - } - } - - /* unlock the object and return the value if we found one */ - mcmunlck(ctx->voccxmem, verb); - if (found) - { - memcpy(tplout, thistpl, siz); - return(TRUE); - } - } + /* figure the size of this template style */ + siz = (*newstyle ? VOCTPL2SIZ : VOCTPLSIZ); + + /* lock the verb object, and get the property value pointer */ + tplptr = mcmlck(ctx->voccxmem, verb); + thistpl = prpvalp(tplptr + tplofs); + + /* first byte is number of templates in array */ + tplcnt = *thistpl++; + + /* look for a template that matches the preposition object */ + for (found = FALSE ; tplcnt ; thistpl += siz, --tplcnt) + { + if (voctplpr(thistpl) == prep) + { + found = TRUE; + break; + } + } + + /* unlock the object and return the value if we found one */ + mcmunlck(ctx->voccxmem, verb); + if (found) + { + memcpy(tplout, thistpl, siz); + return(TRUE); + } + } - /* try inheriting a template (new-style, then old-style) */ - tplofs = objgetap(ctx->voccxmem, verb_in, PRP_TPL2, &verb, TRUE); - if (tplofs) - *newstyle = TRUE; - else - { - tplofs = objgetap(ctx->voccxmem, verb_in, PRP_TPL, &verb, TRUE); - *newstyle = FALSE; - } + /* try inheriting a template (new-style, then old-style) */ + tplofs = objgetap(ctx->voccxmem, verb_in, PRP_TPL2, &verb, TRUE); + if (tplofs) + *newstyle = TRUE; + else + { + tplofs = objgetap(ctx->voccxmem, verb_in, PRP_TPL, &verb, TRUE); + *newstyle = FALSE; + } - /* return not-found if we couldn't inherit it */ - if (!tplofs) - return FALSE; + /* return not-found if we couldn't inherit it */ + if (!tplofs) + return FALSE; - /* use the newly found verb */ - verb_in = verb; - } + /* use the newly found verb */ + verb_in = verb; + } } /* @@ -923,11 +923,11 @@ int voctplfnd(voccxdef *ctx, objnum verb_in, objnum prep, */ void voc_set_me(voccxdef *ctx, objnum new_me) { - /* save undo for the change */ - vocdusave_me(ctx, ctx->voccxme); + /* save undo for the change */ + vocdusave_me(ctx, ctx->voccxme); - /* set the new "Me" object */ - ctx->voccxme = new_me; + /* set the new "Me" object */ + ctx->voccxme = new_me; } } // End of namespace TADS2 diff --git a/engines/glk/tads/tads2/vocabulary.h b/engines/glk/tads/tads2/vocabulary.h index 01fcbf38c39..1c228352b4d 100644 --- a/engines/glk/tads/tads2/vocabulary.h +++ b/engines/glk/tads/tads2/vocabulary.h @@ -58,10 +58,10 @@ namespace TADS2 { * meanings. */ struct vocwdef { - uint vocwnxt; /* index of next vocwdef attached to the same word */ - objnum vocwobj; /* object associated with the word */ - uchar vocwtyp; /* property associated with the word (part of speech) */ - uchar vocwflg; /* flags for the word */ + uint vocwnxt; /* index of next vocwdef attached to the same word */ + objnum vocwobj; /* object associated with the word */ + uchar vocwtyp; /* property associated with the word (part of speech) */ + uchar vocwflg; /* flags for the word */ #define VOCFCLASS 1 /* word is for a class object */ #define VOCFINH 2 /* word is inherited from a superclass */ #define VOCFNEW 4 /* word was added at run-time */ @@ -70,30 +70,30 @@ struct vocwdef { /* vocabulary word structure */ struct vocdef { - vocdef *vocnxt; /* next word at same hash value */ - uchar voclen; /* length of the word */ - uchar vocln2; /* length of second word (0 if no second word) */ - uint vocwlst; /* head of list of vocwdef's attached to the word */ - uchar voctxt[1]; /* text of the word */ + vocdef *vocnxt; /* next word at same hash value */ + uchar voclen; /* length of the word */ + uchar vocln2; /* length of second word (0 if no second word) */ + uint vocwlst; /* head of list of vocwdef's attached to the word */ + uchar voctxt[1]; /* text of the word */ }; /* vocabulary inheritance cell */ struct vocidef { - uchar vocinsc; /* # of superclasses (gives size of record) */ - union { - struct { - uchar vociusflg; /* flags for entry */ + uchar vocinsc; /* # of superclasses (gives size of record) */ + union { + struct { + uchar vociusflg; /* flags for entry */ #define VOCIFCLASS 1 /* entry refers to a class object (loc records only) */ #define VOCIFVOC 2 /* entry has vocabulary words defined */ #define VOCIFXLAT 4 /* superclasses must be translated from portable fmt */ #define VOCIFLOCNIL 8 /* location is explicitly set to nil */ #define VOCIFNEW 16 /* object was allocated at run-time with "new" */ - objnum vociusloc; /* location of the object */ - objnum vociusilc; /* inherited location */ - objnum vociussc[1]; /* array of superclasses */ - } vocius; - vocidef *vociunxt; - } vociu; + objnum vociusloc; /* location of the object */ + objnum vociusilc; /* inherited location */ + objnum vociussc[1]; /* array of superclasses */ + } vocius; + vocidef *vociunxt; + } vociu; #define vociflg vociu.vocius.vociusflg #define vociloc vociu.vocius.vociusloc #define vociilc vociu.vocius.vociusilc @@ -142,8 +142,8 @@ struct vocidef { vocwdef *vocwget(struct voccxdef *ctx, uint idx); #else #define vocwget(ctx, idx) \ - ((idx) == VOCCXW_NONE ? (vocwdef *)0 : \ - ((ctx)->voccxwp[(idx)/VOCWPGSIZ] + ((idx) % VOCWPGSIZ))) + ((idx) == VOCCXW_NONE ? (vocwdef *)0 : \ + ((ctx)->voccxwp[(idx)/VOCWPGSIZ] + ((idx) % VOCWPGSIZ))) #endif /* @@ -154,149 +154,149 @@ vocwdef *vocwget(struct voccxdef *ctx, uint idx); /* daemon/fuse/alarm slot */ struct vocddef { - objnum vocdfn; /* object number of function to be invoked */ - runsdef vocdarg; /* argument for daemon/fuse function */ - prpnum vocdprp; /* property number (used only for alarms) */ - uint vocdtim; /* time for fuses/alarms (0xffff -> each-turn alarm) */ + objnum vocdfn; /* object number of function to be invoked */ + runsdef vocdarg; /* argument for daemon/fuse function */ + prpnum vocdprp; /* property number (used only for alarms) */ + uint vocdtim; /* time for fuses/alarms (0xffff -> each-turn alarm) */ }; /* vocabulary object list entry */ struct vocoldef { - objnum vocolobj; /* object matching the word */ - const char *vocolfst; /* first word in cmd[] that identified object */ - const char *vocollst; /* last word in cmd[] that identified object */ - char *vocolhlst; /* hypothetical last word, if we trimmed a prep */ - int vocolflg; /* special flags (ALL, etc) */ + objnum vocolobj; /* object matching the word */ + const char *vocolfst; /* first word in cmd[] that identified object */ + const char *vocollst; /* last word in cmd[] that identified object */ + char *vocolhlst; /* hypothetical last word, if we trimmed a prep */ + int vocolflg; /* special flags (ALL, etc) */ }; /* vocabulary context */ struct voccxdef { - errcxdef *voccxerr; /* error handling context */ - tiocxdef *voccxtio; /* text i/o context */ - runcxdef *voccxrun; /* execution context */ - mcmcxdef *voccxmem; /* memory manager context */ - objucxdef *voccxundo; /* undo context */ - uchar *voccxpool; /* next free byte in vocdef pool */ - vocdef *voccxfre; /* head of vocdef free list */ - char *voccxcpp; /* pointer to compound word area */ - int voccxcpl; /* length of compound word area */ - char *voccxspp; /* pointer to special word area */ - int voccxspl; /* length of special word area */ - uint voccxrem; /* number of bytes remaining in vocdef pool */ - vocidef **voccxinh[VOCINHMAX]; /* vocidef page table: 256 per page */ - uchar *voccxip[VOCIPGMAX]; /* inheritance cell pool */ - vocidef *voccxifr; /* head of inheritance cell free list */ - uint voccxiplst; /* last inheritance cell page allocated */ - uint voccxilst; /* next unused byte in last inheritance page */ - int voccxredo; /* flag: redo command in buffer */ + errcxdef *voccxerr; /* error handling context */ + tiocxdef *voccxtio; /* text i/o context */ + runcxdef *voccxrun; /* execution context */ + mcmcxdef *voccxmem; /* memory manager context */ + objucxdef *voccxundo; /* undo context */ + uchar *voccxpool; /* next free byte in vocdef pool */ + vocdef *voccxfre; /* head of vocdef free list */ + char *voccxcpp; /* pointer to compound word area */ + int voccxcpl; /* length of compound word area */ + char *voccxspp; /* pointer to special word area */ + int voccxspl; /* length of special word area */ + uint voccxrem; /* number of bytes remaining in vocdef pool */ + vocidef **voccxinh[VOCINHMAX]; /* vocidef page table: 256 per page */ + uchar *voccxip[VOCIPGMAX]; /* inheritance cell pool */ + vocidef *voccxifr; /* head of inheritance cell free list */ + uint voccxiplst; /* last inheritance cell page allocated */ + uint voccxilst; /* next unused byte in last inheritance page */ + int voccxredo; /* flag: redo command in buffer */ - /* - * redo buffer - if voccxredo is set, and this buffer is not empty, - * we'll redo the command in this buffer rather than the one in our - * internal stack buffer - */ - char voccxredobuf[VOCBUFSIZ]; + /* + * redo buffer - if voccxredo is set, and this buffer is not empty, + * we'll redo the command in this buffer rather than the one in our + * internal stack buffer + */ + char voccxredobuf[VOCBUFSIZ]; - /* - * "again" buffer - when we save the last command for repeating via - * the "again" command, we'll save the direct and indirect object - * words here, so that they can be recovered if "again" is used - */ - char voccxagainbuf[VOCBUFSIZ]; + /* + * "again" buffer - when we save the last command for repeating via + * the "again" command, we'll save the direct and indirect object + * words here, so that they can be recovered if "again" is used + */ + char voccxagainbuf[VOCBUFSIZ]; - vocdef *voccxhsh[VOCHASHSIZ]; /* hash table */ + vocdef *voccxhsh[VOCHASHSIZ]; /* hash table */ #ifdef VOCW_IN_CACHE - mcmon voccxwp[VOCWPGMAX]; /* list of pages of vocab records */ - mcmon voccxwplck; /* locked page of vocab records */ - vocwdef *voccxwpgptr; /* pointer to currently locked page */ + mcmon voccxwp[VOCWPGMAX]; /* list of pages of vocab records */ + mcmon voccxwplck; /* locked page of vocab records */ + vocwdef *voccxwpgptr; /* pointer to currently locked page */ #else - vocwdef *voccxwp[VOCWPGMAX]; /* vocabulary word pool */ + vocwdef *voccxwp[VOCWPGMAX]; /* vocabulary word pool */ #endif - uint voccxwalocnt; /* number of vocwdef's used so far */ - uint voccxwfre; /* index of first vocwdef in free list */ + uint voccxwalocnt; /* number of vocwdef's used so far */ + uint voccxwfre; /* index of first vocwdef in free list */ #define VOCCXW_NONE ((uint)(-1)) /* index value indicating end of list */ - vocddef *voccxdmn; /* array of daemon slots */ - uint voccxdmc; /* number of slots in daemon array */ - vocddef *voccxfus; /* array of fuse slots */ - uint voccxfuc; /* number of slots in fuse array */ - vocddef *voccxalm; /* array of alarm slots */ - uint voccxalc; /* number of slots in alarm array */ - char voccxtim[26]; /* game's timestamp (asctime value) */ - - objnum voccxvtk; /* object number of "take" deepverb */ - objnum voccxme; /* object number of "Me" actor */ - objnum voccxme_init; /* initial setting of "Me" */ - objnum voccxstr; /* object number of "strObj" */ - objnum voccxnum; /* object number of "numObj" */ - objnum voccxit; /* last "it" value */ - objnum voccxhim; /* last "him" value */ - objnum voccxher; /* last "her" value */ - objnum voccxthc; /* count of items in "them" list */ - objnum voccxthm[VOCMAXAMBIG]; /* list of items in "them" */ - objnum voccxprd; /* "pardon" function object number */ - objnum voccxpre; /* "preparse" function object number */ - objnum voccxppc; /* "preparseCmd" function object number */ - objnum voccxpre2; /* "preparseExt" function object number */ - objnum voccxvag; /* "again" verb object */ - objnum voccxini; /* "init" function */ - objnum voccxper; /* "parseError" function object number */ - objnum voccxprom; /* "cmdPrompt" function object number */ - objnum voccxpostprom; /* "cmdPostPrompt" function object number */ - objnum voccxpdis; /* parseDisambig function */ - objnum voccxper2; /* parseError2 function */ - objnum voccxperp; /* parseErrorParam function */ - objnum voccxpdef; /* parseDefault function */ - objnum voccxpdef2; /* parseDefaultExt function */ - objnum voccxpask; /* parseAskobj function */ - objnum voccxpask2; /* parseAskobjActor function */ - objnum voccxpask3; /* parseAskobjIndirect function */ - objnum voccxinitrestore; /* "initRestore" function object number */ - objnum voccxpuv; /* parseUnknownVerb function object number */ - objnum voccxpnp; /* parseNounPhrase function object number */ - objnum voccxpostact; /* postAction function object number */ - objnum voccxprecmd; /* preCommand function object number */ - objnum voccxendcmd; /* endCommand function object number */ + vocddef *voccxdmn; /* array of daemon slots */ + uint voccxdmc; /* number of slots in daemon array */ + vocddef *voccxfus; /* array of fuse slots */ + uint voccxfuc; /* number of slots in fuse array */ + vocddef *voccxalm; /* array of alarm slots */ + uint voccxalc; /* number of slots in alarm array */ + char voccxtim[26]; /* game's timestamp (asctime value) */ + + objnum voccxvtk; /* object number of "take" deepverb */ + objnum voccxme; /* object number of "Me" actor */ + objnum voccxme_init; /* initial setting of "Me" */ + objnum voccxstr; /* object number of "strObj" */ + objnum voccxnum; /* object number of "numObj" */ + objnum voccxit; /* last "it" value */ + objnum voccxhim; /* last "him" value */ + objnum voccxher; /* last "her" value */ + objnum voccxthc; /* count of items in "them" list */ + objnum voccxthm[VOCMAXAMBIG]; /* list of items in "them" */ + objnum voccxprd; /* "pardon" function object number */ + objnum voccxpre; /* "preparse" function object number */ + objnum voccxppc; /* "preparseCmd" function object number */ + objnum voccxpre2; /* "preparseExt" function object number */ + objnum voccxvag; /* "again" verb object */ + objnum voccxini; /* "init" function */ + objnum voccxper; /* "parseError" function object number */ + objnum voccxprom; /* "cmdPrompt" function object number */ + objnum voccxpostprom; /* "cmdPostPrompt" function object number */ + objnum voccxpdis; /* parseDisambig function */ + objnum voccxper2; /* parseError2 function */ + objnum voccxperp; /* parseErrorParam function */ + objnum voccxpdef; /* parseDefault function */ + objnum voccxpdef2; /* parseDefaultExt function */ + objnum voccxpask; /* parseAskobj function */ + objnum voccxpask2; /* parseAskobjActor function */ + objnum voccxpask3; /* parseAskobjIndirect function */ + objnum voccxinitrestore; /* "initRestore" function object number */ + objnum voccxpuv; /* parseUnknownVerb function object number */ + objnum voccxpnp; /* parseNounPhrase function object number */ + objnum voccxpostact; /* postAction function object number */ + objnum voccxprecmd; /* preCommand function object number */ + objnum voccxendcmd; /* endCommand function object number */ - /* current command word list values */ - vocoldef *voccxdobj; /* current direct object word list */ - vocoldef *voccxiobj; /* current indirect object word list */ + /* current command word list values */ + vocoldef *voccxdobj; /* current direct object word list */ + vocoldef *voccxiobj; /* current indirect object word list */ - /* current command objects */ - objnum voccxactor; /* current actor */ - objnum voccxverb; /* current command deepverb */ - objnum voccxprep; /* current command preposition */ - - /* previous command values - used by "again" */ - objnum voccxlsa; /* previous actor */ - objnum voccxlsv; /* previous verb */ - vocoldef voccxlsd; /* previous direct object */ - vocoldef voccxlsi; /* previous indirect object */ - objnum voccxlsp; /* preposition */ - int voccxlssty; /* style (new/old) of last template */ - uchar voccxlst[VOCTPL2SIZ]; /* template */ + /* current command objects */ + objnum voccxactor; /* current actor */ + objnum voccxverb; /* current command deepverb */ + objnum voccxprep; /* current command preposition */ + + /* previous command values - used by "again" */ + objnum voccxlsa; /* previous actor */ + objnum voccxlsv; /* previous verb */ + vocoldef voccxlsd; /* previous direct object */ + vocoldef voccxlsi; /* previous indirect object */ + objnum voccxlsp; /* preposition */ + int voccxlssty; /* style (new/old) of last template */ + uchar voccxlst[VOCTPL2SIZ]; /* template */ - objnum voccxpreinit; /* preinit function */ + objnum voccxpreinit; /* preinit function */ - /* special flags */ - uchar voccxflg; + /* special flags */ + uchar voccxflg; #define VOCCXFCLEAR 1 /* ignore remainder of command line (restore) */ #define VOCCXFVWARN 2 /* generate redundant verb warnings */ #define VOCCXFDBG 4 /* debug mode: show parsing information */ #define VOCCXAGAINDEL 8 /* "again" lost due to object deletion */ - /* number of remaining unresolved unknown words in the command */ - int voccxunknown; + /* number of remaining unresolved unknown words in the command */ + int voccxunknown; - /* total number of unresolved words in the last command */ - int voccxlastunk; + /* total number of unresolved words in the last command */ + int voccxlastunk; - /* parser stack area */ - uchar *voc_stk_ptr; - uchar *voc_stk_cur; - uchar *voc_stk_end; + /* parser stack area */ + uchar *voc_stk_ptr; + uchar *voc_stk_cur; + uchar *voc_stk_end; }; /* allocate and push a list, returning a pointer to the list's memory */ @@ -313,18 +313,18 @@ void voc_set_me(voccxdef *ctx, objnum new_me); /* add a vocabulary word */ void vocadd(voccxdef *ctx, prpnum p, objnum objn, - int classflag, char *wrdval); + int classflag, char *wrdval); /* internal addword - must already be split into two words and lengths */ void vocadd2(voccxdef *ctx, prpnum p, objnum objn, int classflg, - uchar *wrd1, int len1, uchar *wrd2, int len2); + uchar *wrd1, int len1, uchar *wrd2, int len2); /* delete vocabulary for a given object */ void vocdel(voccxdef *ctx, objnum objn); /* lower-level vocabulary deletion routine */ void vocdel1(voccxdef *ctx, objnum objn, char *wrd, prpnum prp, - int really_delete, int revert, int keep_undo); + int really_delete, int revert, int keep_undo); /* delete all inherited vocabulary */ void vocdelinh(voccxdef *ctx); @@ -334,7 +334,7 @@ void vocialo(voccxdef *ctx, objnum obj); /* add an inheritance/location record */ void vociadd(voccxdef *ctx, objnum obj, objnum loc, - int numsc, objnum *sc, int flags); + int numsc, objnum *sc, int flags); /* delete inheritance records for an object */ void vocidel(voccxdef *ctx, objnum chi); @@ -344,24 +344,24 @@ void vociren(voccxdef *ctx, objnum oldnum, objnum newnum); /* caller-provided context structure for vocffw/vocfnw searches */ struct vocseadef { - vocdef *v; - vocwdef *vw; - const uchar *wrd1; - int len1; - const uchar *wrd2; - int len2; + vocdef *v; + vocwdef *vw; + const uchar *wrd1; + int len1; + const uchar *wrd2; + int len2; }; /* find first word matching a given word */ vocwdef *vocffw(voccxdef *ctx, const char *wrd, int len, const char *wrd2, int len2, - int p, vocseadef *search_ctx); + int p, vocseadef *search_ctx); /* find next word */ vocwdef *vocfnw(voccxdef *voccx, vocseadef *search_ctx); /* read a line of input text */ int vocread(voccxdef *ctx, objnum actor, objnum verb, - char *buf, int bufl, int type); + char *buf, int bufl, int type); #define VOCREAD_OK 0 #define VOCREAD_REDO 1 @@ -370,7 +370,7 @@ int voclistlen(vocoldef *lst); /* tokenize an input buffer */ int voctok(voccxdef *ctx, char *cmd, char *outbuf, - char **wrd, int lower, int cvt_ones, int show_errors); + char **wrd, int lower, int cvt_ones, int show_errors); /* get types for a word list */ int vocgtyp(voccxdef *ctx, char **cmd, int *types, char *orgbuf); @@ -380,30 +380,30 @@ int voccmd(voccxdef *ctx, char *cmd, uint cmdlen); /* disambiguator */ int vocdisambig(voccxdef *ctx, vocoldef *outlist, vocoldef *inlist, - prpnum defprop, prpnum accprop, prpnum verprop, - char *cmd[], objnum otherobj, objnum cmdActor, - objnum cmdVerb, objnum cmdPrep, char *cmdbuf, - int silent); + prpnum defprop, prpnum accprop, prpnum verprop, + char *cmd[], objnum otherobj, objnum cmdActor, + objnum cmdVerb, objnum cmdPrep, char *cmdbuf, + int silent); /* display a multiple-object prefix */ void voc_multi_prefix(voccxdef *ctx, objnum objn, - int show_prefix, int multi_flags, - int cur_index, int count); + int show_prefix, int multi_flags, + int cur_index, int count); /* low-level executor */ int execmd(voccxdef *ctx, objnum actor, objnum prep, - char *vverb, char *vprep, vocoldef *dolist, vocoldef *iolist, - char **cmd, int *typelist, - char *cmdbuf, int wrdcnt, uchar **preparse_list, int *next_start); + char *vverb, char *vprep, vocoldef *dolist, vocoldef *iolist, + char **cmd, int *typelist, + char *cmdbuf, int wrdcnt, uchar **preparse_list, int *next_start); /* recursive command execution */ int execmd_recurs(voccxdef *ctx, objnum actor, objnum verb, - objnum dobj, objnum prep, objnum iobj, - int validate_dobj, int validate_iobj); + objnum dobj, objnum prep, objnum iobj, + int validate_dobj, int validate_iobj); /* try running preparseCmd user function */ int try_preparse_cmd(voccxdef *ctx, char **cmd, int wrdcnt, - uchar **preparse_list); + uchar **preparse_list); /* * Handle an unknown verb or sentence structure. We'll call this when @@ -434,18 +434,18 @@ int try_preparse_cmd(voccxdef *ctx, char **cmd, int wrdcnt, * remainder of the command should be aborted. */ int try_unknown_verb(voccxdef *ctx, objnum actor, - char **cmd, int *typelist, int wrdcnt, int *next_start, - int do_fuses, int err, const char *msg, ...); + char **cmd, int *typelist, int wrdcnt, int *next_start, + int do_fuses, int err, const char *msg, ...); /* find a template */ int voctplfnd(voccxdef *ctx, objnum verb_in, objnum prep, - uchar *tplout, int *newstyle); + uchar *tplout, int *newstyle); /* build a printable name for an object from the words in a command list */ void voc_make_obj_name(voccxdef *ctx, char *namebuf, char *cmd[], - int firstwrd, int lastwrd); + int firstwrd, int lastwrd); void voc_make_obj_name_from_list(voccxdef *ctx, char *namebuf, - char *cmd[], const char *firstwrd, const char *lastwrd); + char *cmd[], const char *firstwrd, const char *lastwrd); /* * check noun - determines whether the next set of words is a valid noun @@ -454,7 +454,7 @@ void voc_make_obj_name_from_list(voccxdef *ctx, char *namebuf, * simple; we just call vocgobj() with the complaint flag turned off. */ /* int vocchknoun(voccxdef *ctx, char **cmd, int *typelist, int cur, - int *next, vocoldef *nounlist, int chkact); */ + int *next, vocoldef *nounlist, int chkact); */ #define vocchknoun(ctx, cmd, typelist, cur, next, nounlist, chkact) \ vocgobj(ctx, cmd, typelist, cur, next, FALSE, nounlist, TRUE, chkact, 0) #define vocchknoun2(ctx, cmd, typlst, cur, next, nounlist, chkact, nomatch) \ @@ -465,14 +465,14 @@ void voc_make_obj_name_from_list(voccxdef *ctx, char *namebuf, * complaint and multiple-noun flags turned on. */ /* int vocgetnoun(voccxdef *ctx, char **cmd, int *typelist, int cur, - int *next, vocoldef *nounlist); */ + int *next, vocoldef *nounlist); */ #define vocgetnoun(ctx, cmd, typelist, cur, next, nounlist) \ vocgobj(ctx, cmd, typelist, cur, next, TRUE, nounlist, TRUE, FALSE, 0) /* get object */ int vocgobj(voccxdef *ctx, char **cmd, int *typelist, int cur, - int *next, int complain, vocoldef *nounlist, - int multi, int chkact, int *nomatch); + int *next, int complain, vocoldef *nounlist, + int multi, int chkact, int *nomatch); /* tokenize a string - TADS program code interface */ void voc_parse_tok(voccxdef *ctx); @@ -494,20 +494,20 @@ void voc_parse_replace_cmd(voccxdef *ctx); /* check access to an object */ int vocchkaccess(voccxdef *ctx, objnum obj, prpnum verprop, - int seqno, objnum actor, objnum verb); + int seqno, objnum actor, objnum verb); /* check to see if an object is visible */ int vocchkvis(voccxdef *ctx, objnum obj, objnum cmdActor); /* display an appropriate message for an unreachable object */ void vocnoreach(voccxdef *ctx, objnum *list1, int cnt, - objnum actor, objnum verb, objnum prep, prpnum defprop, - int show_multi_prefix, int multi_flags, - int multi_base_index, int multi_total_count); + objnum actor, objnum verb, objnum prep, prpnum defprop, + int show_multi_prefix, int multi_flags, + int multi_base_index, int multi_total_count); /* set {numObj | strObj}.value, as appropriate */ void vocsetobj(voccxdef *ctx, objnum obj, dattyp typ, const void *val, - vocoldef *inobj, vocoldef *outobj); + vocoldef *inobj, vocoldef *outobj); /* macros to read values out of templates */ #define voctplpr(tpl) ((objnum)osrp2(((uchar *)tpl))) /* preposition */ @@ -565,8 +565,8 @@ void vocsetobj(voccxdef *ctx, objnum obj, dattyp typ, const void *val, /* structure for special internal word table */ struct vocspdef { - const char *vocspin; - char vocspout; + const char *vocspin; + char vocspout; }; /* check if a word is a special word - true if word is given special word */ @@ -577,19 +577,19 @@ struct vocspdef { * Set a fuse/daemon/notifier. */ void vocsetfd(voccxdef *ctx, vocddef *what, objnum func, prpnum prop, - uint tm, runsdef *val, int err); + uint tm, runsdef *val, int err); /* remove a fuse/daemon/notifier */ void vocremfd(voccxdef *ctx, vocddef *what, objnum func, prpnum prop, - runsdef *val, int err); + runsdef *val, int err); /* count a turn (down all fuse/notifier timers) */ void vocturn(voccxdef *ctx, int turncnt, int do_fuses); /* initialize voc context */ void vocini(voccxdef *vocctx, errcxdef *errctx, mcmcxdef *memctx, - runcxdef *runctx, objucxdef *undoctx, int fuses, - int daemons, int notifiers); + runcxdef *runctx, objucxdef *undoctx, int fuses, + int daemons, int notifiers); /* clean up the voc context - frees memory allocated by vocini() */ void vocterm(voccxdef *vocctx); @@ -630,11 +630,11 @@ void vocdusave_newobj(voccxdef *ctx, objnum objn); /* save undo for adding a word */ void vocdusave_addwrd(voccxdef *ctx, objnum objn, prpnum typ, int flags, - char *wrd); + char *wrd); /* save undo for deleting a word */ void vocdusave_delwrd(voccxdef *ctx, objnum objn, prpnum typ, int flags, - char *wrd); + char *wrd); /* save undo for object deletion */ void vocdusave_delobj(voccxdef *ctx, objnum objn); @@ -685,17 +685,17 @@ void voc_stk_ini(voccxdef *ctx, uint siz); /* return a value */ #define VOC_RETVAL(ctx, marker, retval) \ - voc_leave(ctx, marker); return retval + voc_leave(ctx, marker); return retval /* allocate space from the stack */ void *voc_stk_alo(voccxdef *ctx, uint siz); /* allocation cover macros */ #define VOC_STK_ARRAY(ctx, typ, var, cnt) \ - (var = (typ *)voc_stk_alo(ctx, (uint)((cnt) * sizeof(typ)))) + (var = (typ *)voc_stk_alo(ctx, (uint)((cnt) * sizeof(typ)))) #define VOC_MAX_ARRAY(ctx, typ, var) \ - VOC_STK_ARRAY(ctx, typ, var, VOCMAXAMBIG) + VOC_STK_ARRAY(ctx, typ, var, VOCMAXAMBIG) /* * Stack size for the vocab stack. We'll scale our stack needs based @@ -718,9 +718,9 @@ void *voc_stk_alo(voccxdef *ctx, uint siz); * If 'do_fuses' is true, we'll run fuses and daemons. Otherwise, */ int exe_fuses_and_daemons(voccxdef *ctx, int err, int do_fuses, - objnum actor, objnum verb, - vocoldef *dobj_list, int do_cnt, - objnum prep, objnum iobj); + objnum actor, objnum verb, + vocoldef *dobj_list, int do_cnt, + objnum prep, objnum iobj); /* * Execute any pending fuses. Return TRUE if any fuses were executed, @@ -746,7 +746,7 @@ void voc_count(voccxdef *ctx, objnum objn, prpnum prp, int *cnt, int *siz); * the callback for every word. */ void voc_iterate(voccxdef *ctx, objnum objn, - void (*fn)(void *, vocdef *, vocwdef *), void *fnctx); + void (*fn)(void *, vocdef *, vocwdef *), void *fnctx); /* ------------------------------------------------------------------------ */ /* diff --git a/engines/glk/tads/tads2/vocabulary_parser.cpp b/engines/glk/tads/tads2/vocabulary_parser.cpp index fba515e7971..dd983ba0f79 100644 --- a/engines/glk/tads/tads2/vocabulary_parser.cpp +++ b/engines/glk/tads/tads2/vocabulary_parser.cpp @@ -34,8 +34,8 @@ namespace TADS2 { static const char *type_names[] = { - "article", "adj", "noun", "prep", "verb", "special", "plural", - "unknown" + "article", "adj", "noun", "prep", "verb", "special", "plural", + "unknown" }; /* array of flag values for words by part of speech */ @@ -49,32 +49,32 @@ static int voctype[] = */ uchar *voc_push_list_siz(voccxdef *ctx, uint lstsiz) { - runcxdef *rcx = ctx->voccxrun; - runsdef val; - uchar *lstp; + runcxdef *rcx = ctx->voccxrun; + runsdef val; + uchar *lstp; - /* add in the size needed for the list's length prefix */ - lstsiz += 2; + /* add in the size needed for the list's length prefix */ + lstsiz += 2; - /* allocate space in the heap */ - runhres(rcx, lstsiz, 0); + /* allocate space in the heap */ + runhres(rcx, lstsiz, 0); - /* set up a stack value to push */ - val.runstyp = DAT_LIST; - val.runsv.runsvstr = lstp = ctx->voccxrun->runcxhp; + /* set up a stack value to push */ + val.runstyp = DAT_LIST; + val.runsv.runsvstr = lstp = ctx->voccxrun->runcxhp; - /* set up the list's length prefix */ - oswp2(lstp, lstsiz); - lstp += 2; + /* set up the list's length prefix */ + oswp2(lstp, lstsiz); + lstp += 2; - /* commit the space in the heap */ - rcx->runcxhp += lstsiz; + /* commit the space in the heap */ + rcx->runcxhp += lstsiz; - /* push the list value (repush, since we can use the original copy) */ - runrepush(rcx, &val); + /* push the list value (repush, since we can use the original copy) */ + runrepush(rcx, &val); - /* return the list element pointer */ - return lstp; + /* return the list element pointer */ + return lstp; } /* @@ -83,17 +83,17 @@ uchar *voc_push_list_siz(voccxdef *ctx, uint lstsiz) */ static uchar *voc_push_list(voccxdef *ctx, int ele_count, int ele_size) { - uint lstsiz; + uint lstsiz; - /* - * Figure the list size - we need space for the given number of - * elements of the given size; in addition, each element requires - * one byte of overhead for its type prefix. - */ - lstsiz = (uint)(ele_count * (1 + ele_size)); + /* + * Figure the list size - we need space for the given number of + * elements of the given size; in addition, each element requires + * one byte of overhead for its type prefix. + */ + lstsiz = (uint)(ele_count * (1 + ele_size)); - /* allocate and return the list */ - return voc_push_list_siz(ctx, lstsiz); + /* allocate and return the list */ + return voc_push_list_siz(ctx, lstsiz); } /* @@ -101,22 +101,22 @@ static uchar *voc_push_list(voccxdef *ctx, int ele_count, int ele_size) */ static void voc_push_numlist(voccxdef *ctx, uint numlist[], int cnt) { - int i; - uchar *lstp; + int i; + uchar *lstp; - /* allocate space for the list of numbers */ - lstp = voc_push_list(ctx, cnt, 4); + /* allocate space for the list of numbers */ + lstp = voc_push_list(ctx, cnt, 4); - /* enter the list elements */ - for (i = 0 ; i < cnt ; ++i) - { - /* add the type prefix */ - *lstp++ = DAT_NUMBER; + /* enter the list elements */ + for (i = 0 ; i < cnt ; ++i) + { + /* add the type prefix */ + *lstp++ = DAT_NUMBER; - /* add the value */ - oswp4(lstp, numlist[i]); - lstp += 4; - } + /* add the value */ + oswp4(lstp, numlist[i]); + lstp += 4; + } } /* @@ -124,38 +124,38 @@ static void voc_push_numlist(voccxdef *ctx, uint numlist[], int cnt) */ void voc_push_vocoldef_list(voccxdef *ctx, vocoldef *objlist, int cnt) { - int i; - uchar *lstp; - uint lstsiz; + int i; + uchar *lstp; + uint lstsiz; - /* - * count the size - we need 3 bytes per object (1 for type plus 2 - * for the value), and 1 byte per nil - */ - for (lstsiz = 0, i = 0 ; i < cnt ; ++i) - lstsiz += (objlist[i].vocolobj == MCMONINV ? 1 : 3); + /* + * count the size - we need 3 bytes per object (1 for type plus 2 + * for the value), and 1 byte per nil + */ + for (lstsiz = 0, i = 0 ; i < cnt ; ++i) + lstsiz += (objlist[i].vocolobj == MCMONINV ? 1 : 3); - /* allocate space for the list */ - lstp = voc_push_list_siz(ctx, lstsiz); + /* allocate space for the list */ + lstp = voc_push_list_siz(ctx, lstsiz); - /* enter the list elements */ - for (i = 0 ; i < cnt ; ++i) - { - if (objlist[i].vocolobj == MCMONINV) - { - /* store the nil */ - *lstp++ = DAT_NIL; - } - else - { - /* add the type prefix */ - *lstp++ = DAT_OBJECT; + /* enter the list elements */ + for (i = 0 ; i < cnt ; ++i) + { + if (objlist[i].vocolobj == MCMONINV) + { + /* store the nil */ + *lstp++ = DAT_NIL; + } + else + { + /* add the type prefix */ + *lstp++ = DAT_OBJECT; - /* add the value */ - oswp2(lstp, objlist[i].vocolobj); - lstp += 2; - } - } + /* add the value */ + oswp2(lstp, objlist[i].vocolobj); + lstp += 2; + } + } } /* @@ -163,38 +163,38 @@ void voc_push_vocoldef_list(voccxdef *ctx, vocoldef *objlist, int cnt) */ void voc_push_objlist(voccxdef *ctx, objnum objlist[], int cnt) { - int i; - uchar *lstp; - uint lstsiz; + int i; + uchar *lstp; + uint lstsiz; - /* - * count the size - we need 3 bytes per object (1 for type plus 2 - * for the value), and 1 byte per nil - */ - for (lstsiz = 0, i = 0 ; i < cnt ; ++i) - lstsiz += (objlist[i] == MCMONINV ? 1 : 3); + /* + * count the size - we need 3 bytes per object (1 for type plus 2 + * for the value), and 1 byte per nil + */ + for (lstsiz = 0, i = 0 ; i < cnt ; ++i) + lstsiz += (objlist[i] == MCMONINV ? 1 : 3); - /* allocate space for the list */ - lstp = voc_push_list_siz(ctx, lstsiz); + /* allocate space for the list */ + lstp = voc_push_list_siz(ctx, lstsiz); - /* enter the list elements */ - for (i = 0 ; i < cnt ; ++i) - { - if (objlist[i] == MCMONINV) - { - /* store the nil */ - *lstp++ = DAT_NIL; - } - else - { - /* add the type prefix */ - *lstp++ = DAT_OBJECT; - - /* add the value */ - oswp2(lstp, objlist[i]); - lstp += 2; - } - } + /* enter the list elements */ + for (i = 0 ; i < cnt ; ++i) + { + if (objlist[i] == MCMONINV) + { + /* store the nil */ + *lstp++ = DAT_NIL; + } + else + { + /* add the type prefix */ + *lstp++ = DAT_OBJECT; + + /* add the value */ + oswp2(lstp, objlist[i]); + lstp += 2; + } + } } /* @@ -205,40 +205,40 @@ void voc_push_objlist(voccxdef *ctx, objnum objlist[], int cnt) */ static void voc_push_strlist(voccxdef *ctx, const char *firstwrd, const char *lastwrd) { - size_t curlen; - const char *p; - uint lstsiz; - uchar *lstp; + size_t curlen; + const char *p; + uint lstsiz; + uchar *lstp; - /* - * Determine how much space we need for the word list. For each - * entry, we need one byte for the type prefix, two bytes for the - * length prefix, and the bytes of the string itself. - */ - for (lstsiz = 0, p = firstwrd ; p != 0 && p <= lastwrd ; p += curlen + 1) - { - curlen = strlen(p); - lstsiz += curlen + (1+2); - } + /* + * Determine how much space we need for the word list. For each + * entry, we need one byte for the type prefix, two bytes for the + * length prefix, and the bytes of the string itself. + */ + for (lstsiz = 0, p = firstwrd ; p != 0 && p <= lastwrd ; p += curlen + 1) + { + curlen = strlen(p); + lstsiz += curlen + (1+2); + } - /* allocate space for the word list */ - lstp = voc_push_list_siz(ctx, lstsiz); + /* allocate space for the word list */ + lstp = voc_push_list_siz(ctx, lstsiz); - /* enter the list elements */ - for (p = firstwrd ; p != 0 && p <= lastwrd ; p += curlen + 1) - { - /* add the type prefix */ - *lstp++ = DAT_SSTRING; + /* enter the list elements */ + for (p = firstwrd ; p != 0 && p <= lastwrd ; p += curlen + 1) + { + /* add the type prefix */ + *lstp++ = DAT_SSTRING; - /* add the length prefix for this string */ - curlen = strlen(p); - oswp2(lstp, curlen + 2); - lstp += 2; + /* add the length prefix for this string */ + curlen = strlen(p); + oswp2(lstp, curlen + 2); + lstp += 2; - /* add this string */ - memcpy(lstp, p, curlen); - lstp += curlen; - } + /* add this string */ + memcpy(lstp, p, curlen); + lstp += curlen; + } } /* @@ -246,39 +246,39 @@ static void voc_push_strlist(voccxdef *ctx, const char *firstwrd, const char *la */ static void voc_push_strlist_arr(voccxdef *ctx, char *wordlist[], int cnt) { - int i; - char **p; - uint lstsiz; - uchar *lstp; + int i; + char **p; + uint lstsiz; + uchar *lstp; - /* - * Add up the lengths of the strings in the array. For each - * element, we need space for the string's bytes, plus two bytes for - * the length prefix, plus one byte for the type prefix. - */ - for (lstsiz = 0, p = wordlist, i = 0 ; i < cnt ; ++i, ++p) - lstsiz += strlen(*p) + 3; + /* + * Add up the lengths of the strings in the array. For each + * element, we need space for the string's bytes, plus two bytes for + * the length prefix, plus one byte for the type prefix. + */ + for (lstsiz = 0, p = wordlist, i = 0 ; i < cnt ; ++i, ++p) + lstsiz += strlen(*p) + 3; - /* allocate space for the list */ - lstp = voc_push_list_siz(ctx, lstsiz); + /* allocate space for the list */ + lstp = voc_push_list_siz(ctx, lstsiz); - /* enter the list elements */ - for (p = wordlist, i = 0 ; i < cnt ; ++i, ++p) - { - size_t curlen; + /* enter the list elements */ + for (p = wordlist, i = 0 ; i < cnt ; ++i, ++p) + { + size_t curlen; - /* add the type prefix */ - *lstp++ = DAT_SSTRING; + /* add the type prefix */ + *lstp++ = DAT_SSTRING; - /* add the length prefix for this string */ - curlen = strlen(*p); - oswp2(lstp, curlen + 2); - lstp += 2; + /* add the length prefix for this string */ + curlen = strlen(*p); + oswp2(lstp, curlen + 2); + lstp += 2; - /* add this string */ - memcpy(lstp, *p, curlen); - lstp += curlen; - } + /* add this string */ + memcpy(lstp, *p, curlen); + lstp += curlen; + } } /* @@ -289,97 +289,97 @@ static void voc_push_strlist_arr(voccxdef *ctx, char *wordlist[], int cnt) */ static void voc_push_toklist(voccxdef *ctx, char *wordlist[], int cnt) { - int i; - char **p; - uint lstsiz; - uchar *lstp; - size_t cur_len; + int i; + char **p; + uint lstsiz; + uchar *lstp; + size_t cur_len; - /* - * Add up the lengths of the strings in the array. For each - * element, we need space for the string's bytes, plus two bytes for - * the length prefix, plus one byte for the type prefix. - */ - for (lstsiz = 0, p = wordlist, i = 0 ; i < cnt ; ++i, ++p) - { - /* - * get the length of the current token - check what kind of - * token we have, since we must sense the length of different - * token types in different ways - */ - if (**p == '"') - { - /* - * It's a string token - the string follows with a two-byte - * length prefix; add two bytes for the open and close quote - * characters that we'll add to the output string. Note - * that we must deduct two bytes from the prefix length, - * because the prefix includes the size of the prefix - * itself, which we're not copying and will account for - * separately in the result string. - */ - cur_len = osrp2(*p + 1) - 2 + 2; - } - else - { - /* for anything else, it's just a null-terminated string */ - cur_len = strlen(*p); - } + /* + * Add up the lengths of the strings in the array. For each + * element, we need space for the string's bytes, plus two bytes for + * the length prefix, plus one byte for the type prefix. + */ + for (lstsiz = 0, p = wordlist, i = 0 ; i < cnt ; ++i, ++p) + { + /* + * get the length of the current token - check what kind of + * token we have, since we must sense the length of different + * token types in different ways + */ + if (**p == '"') + { + /* + * It's a string token - the string follows with a two-byte + * length prefix; add two bytes for the open and close quote + * characters that we'll add to the output string. Note + * that we must deduct two bytes from the prefix length, + * because the prefix includes the size of the prefix + * itself, which we're not copying and will account for + * separately in the result string. + */ + cur_len = osrp2(*p + 1) - 2 + 2; + } + else + { + /* for anything else, it's just a null-terminated string */ + cur_len = strlen(*p); + } - /* add the current length to the total so far */ - lstsiz += cur_len + 3; - } + /* add the current length to the total so far */ + lstsiz += cur_len + 3; + } - /* allocate space for the list */ - lstp = voc_push_list_siz(ctx, lstsiz); + /* allocate space for the list */ + lstp = voc_push_list_siz(ctx, lstsiz); - /* enter the list elements */ - for (p = wordlist, i = 0 ; i < cnt ; ++i, ++p) - { - char *cur_ptr; - size_t copy_len; - - /* add the type prefix */ - *lstp++ = DAT_SSTRING; + /* enter the list elements */ + for (p = wordlist, i = 0 ; i < cnt ; ++i, ++p) + { + char *cur_ptr; + size_t copy_len; + + /* add the type prefix */ + *lstp++ = DAT_SSTRING; - /* get the information for the string based on the type */ - if (**p == '"') - { - /* - * it's a string - use the length prefix (deducting two - * bytes for the prefix itself, which we're not copying) - */ - copy_len = osrp2(*p + 1) - 2; + /* get the information for the string based on the type */ + if (**p == '"') + { + /* + * it's a string - use the length prefix (deducting two + * bytes for the prefix itself, which we're not copying) + */ + copy_len = osrp2(*p + 1) - 2; - /* add space in the result for the open and close quotes */ - cur_len = copy_len + 2; + /* add space in the result for the open and close quotes */ + cur_len = copy_len + 2; - /* the string itself follows the length prefix and '"' flag */ - cur_ptr = *p + 3; - } - else - { - /* for anything else, it's just a null-terminated string */ - cur_len = copy_len = strlen(*p); - cur_ptr = *p; - } + /* the string itself follows the length prefix and '"' flag */ + cur_ptr = *p + 3; + } + else + { + /* for anything else, it's just a null-terminated string */ + cur_len = copy_len = strlen(*p); + cur_ptr = *p; + } - /* write the length prefix for this string */ - oswp2(lstp, cur_len + 2); - lstp += 2; + /* write the length prefix for this string */ + oswp2(lstp, cur_len + 2); + lstp += 2; - /* add the open quote if this is a quoted string */ - if (**p == '"') - *lstp++ = '"'; + /* add the open quote if this is a quoted string */ + if (**p == '"') + *lstp++ = '"'; - /* add this string */ - memcpy(lstp, cur_ptr, copy_len); - lstp += copy_len; + /* add this string */ + memcpy(lstp, cur_ptr, copy_len); + lstp += copy_len; - /* add the close quote if it's a quoted string */ - if (**p == '"') - *lstp++ = '"'; - } + /* add the close quote if it's a quoted string */ + if (**p == '"') + *lstp++ = '"'; + } } /* ------------------------------------------------------------------------ */ @@ -388,138 +388,138 @@ static void voc_push_toklist(voccxdef *ctx, char *wordlist[], int cnt) * and prompting. */ int vocread(voccxdef *ctx, objnum actor, objnum verb, - char *buf, int bufl, int type) + char *buf, int bufl, int type) { - const char *prompt; - int ret; + const char *prompt; + int ret; - /* presume we'll return success */ - ret = VOCREAD_OK; + /* presume we'll return success */ + ret = VOCREAD_OK; - /* make sure output capturing is off */ - tiocapture(ctx->voccxtio, (mcmcxdef *)0, FALSE); - tioclrcapture(ctx->voccxtio); + /* make sure output capturing is off */ + tiocapture(ctx->voccxtio, (mcmcxdef *)0, FALSE); + tioclrcapture(ctx->voccxtio); - /* - * Clear out the command buffer. This is important for the - * timeout-based command reader, since it will take what's in the - * buffer as the initial contents of the command line; this lets us - * remember any partial line that the player entered before a - * timeout interrupted their typing and redisplay the original - * partial line on the next command line. Initially, there's no - * partial line, so clear it out. - */ - buf[0] = '\0'; + /* + * Clear out the command buffer. This is important for the + * timeout-based command reader, since it will take what's in the + * buffer as the initial contents of the command line; this lets us + * remember any partial line that the player entered before a + * timeout interrupted their typing and redisplay the original + * partial line on the next command line. Initially, there's no + * partial line, so clear it out. + */ + buf[0] = '\0'; - /* show the game-defined prompt, if appropriate */ - if (ctx->voccxprom != MCMONINV) - { - runpnum(ctx->voccxrun, (long)type); - runfn(ctx->voccxrun, ctx->voccxprom, 1); - tioflushn(ctx->voccxtio, 0); - prompt = ""; - } - else - { - /* there's no game-defined prompt - use our default */ - tioblank(tio); - prompt = ">"; - } - - /* get a line of input */ - if (tiogets(ctx->voccxtio, prompt, buf, bufl)) - errsig(ctx->voccxerr, ERR_RUNQUIT); - - /* abort immediately if we see the special panic command */ - if (!strcmp(buf, "$$ABEND")) - { - /* make sure any script file is closed */ - qasclose(); - - /* use the OS-level termination */ - os_term(OSEXFAIL); + /* show the game-defined prompt, if appropriate */ + if (ctx->voccxprom != MCMONINV) + { + runpnum(ctx->voccxrun, (long)type); + runfn(ctx->voccxrun, ctx->voccxprom, 1); + tioflushn(ctx->voccxtio, 0); + prompt = ""; + } + else + { + /* there's no game-defined prompt - use our default */ + tioblank(tio); + prompt = ">"; + } + + /* get a line of input */ + if (tiogets(ctx->voccxtio, prompt, buf, bufl)) + errsig(ctx->voccxerr, ERR_RUNQUIT); + + /* abort immediately if we see the special panic command */ + if (!strcmp(buf, "$$ABEND")) + { + /* make sure any script file is closed */ + qasclose(); + + /* use the OS-level termination */ + os_term(OSEXFAIL); - /* if that returned, signal a quit */ - errsig(ctx->voccxerr, ERR_RUNQUIT); - } - - /* call the post-prompt function if defined */ - if (ctx->voccxpostprom != MCMONINV) - { - runpnum(ctx->voccxrun, (long)type); - runfn(ctx->voccxrun, ctx->voccxpostprom, 1); - } + /* if that returned, signal a quit */ + errsig(ctx->voccxerr, ERR_RUNQUIT); + } + + /* call the post-prompt function if defined */ + if (ctx->voccxpostprom != MCMONINV) + { + runpnum(ctx->voccxrun, (long)type); + runfn(ctx->voccxrun, ctx->voccxpostprom, 1); + } - /* - * If this isn't a type "0" input, and preparseExt() is defined, call - * it. Don't call preparseExt() for type "0" inputs, since these will - * be handled via the conventional preparse(). - */ - if (ctx->voccxpre2 != MCMONINV && type != 0) - { - uchar *s; - size_t len; + /* + * If this isn't a type "0" input, and preparseExt() is defined, call + * it. Don't call preparseExt() for type "0" inputs, since these will + * be handled via the conventional preparse(). + */ + if (ctx->voccxpre2 != MCMONINV && type != 0) + { + uchar *s; + size_t len; - /* push the arguments - actor, verb, str, type */ - runpnum(ctx->voccxrun, (long)type); - runpstr(ctx->voccxrun, buf, (int)strlen(buf), 0); - runpobj(ctx->voccxrun, verb); - runpobj(ctx->voccxrun, actor); + /* push the arguments - actor, verb, str, type */ + runpnum(ctx->voccxrun, (long)type); + runpstr(ctx->voccxrun, buf, (int)strlen(buf), 0); + runpobj(ctx->voccxrun, verb); + runpobj(ctx->voccxrun, actor); - /* call preparseExt() */ - runfn(ctx->voccxrun, ctx->voccxpre2, 4); + /* call preparseExt() */ + runfn(ctx->voccxrun, ctx->voccxpre2, 4); - /* check the result */ - switch(runtostyp(ctx->voccxrun)) - { - case DAT_SSTRING: - /* - * They returned a string. Replace the input buffer we read - * with the new string. Pop the new string and scan its length - * prefix. - */ - s = runpopstr(ctx->voccxrun); - len = osrp2(s) - 2; - s += 2; + /* check the result */ + switch(runtostyp(ctx->voccxrun)) + { + case DAT_SSTRING: + /* + * They returned a string. Replace the input buffer we read + * with the new string. Pop the new string and scan its length + * prefix. + */ + s = runpopstr(ctx->voccxrun); + len = osrp2(s) - 2; + s += 2; - /* - * limit the size we copy to our buffer length (leaving space - * for null termination) - */ - if (len > (size_t)bufl - 1) - len = bufl - 1; + /* + * limit the size we copy to our buffer length (leaving space + * for null termination) + */ + if (len > (size_t)bufl - 1) + len = bufl - 1; - /* copy the new command string into our buffer */ - memcpy(buf, s, len); + /* copy the new command string into our buffer */ + memcpy(buf, s, len); - /* null-terminate the result */ - buf[len] = '\0'; + /* null-terminate the result */ + buf[len] = '\0'; - /* proceed as normal with the new string */ - break; + /* proceed as normal with the new string */ + break; - case DAT_TRUE: - /* - * they simply want to keep the current string as it is - - * proceed as normal - */ - break; + case DAT_TRUE: + /* + * they simply want to keep the current string as it is - + * proceed as normal + */ + break; - case DAT_NIL: - /* - * They want to skip the special interpretation of the input - * and proceed directly to treating the input as a brand new - * command. The caller will have to take care of the details; - * we need only indicate this to the caller through our "redo" - * result code. - */ - ret = VOCREAD_REDO; - break; - } - } + case DAT_NIL: + /* + * They want to skip the special interpretation of the input + * and proceed directly to treating the input as a brand new + * command. The caller will have to take care of the details; + * we need only indicate this to the caller through our "redo" + * result code. + */ + ret = VOCREAD_REDO; + break; + } + } - /* return our result */ - return ret; + /* return our result */ + return ret; } /* @@ -530,130 +530,130 @@ int vocread(voccxdef *ctx, objnum actor, objnum verb, */ static int voceq(const uchar *s1, uint l1, uchar *s2, uint l2) { - uint i; + uint i; - if (l1 == 0 && l2 == 0) return(TRUE); /* both NULL - a match */ - if (l1 == 0 || l2 == 0) return(FALSE); /* one NULL only - not a match */ - if (l1 >= 6 && l2 >= l1) l2 = l1; - if (l1 != l2) return(FALSE); /* ==> not equal */ - for (i = 0 ; i < l1 ; i++) - if (*s1++ != *s2++) return(FALSE); - return(TRUE); /* strings match */ + if (l1 == 0 && l2 == 0) return(TRUE); /* both NULL - a match */ + if (l1 == 0 || l2 == 0) return(FALSE); /* one NULL only - not a match */ + if (l1 >= 6 && l2 >= l1) l2 = l1; + if (l1 != l2) return(FALSE); /* ==> not equal */ + for (i = 0 ; i < l1 ; i++) + if (*s1++ != *s2++) return(FALSE); + return(TRUE); /* strings match */ } /* find the next word in a search */ vocwdef *vocfnw(voccxdef *voccx, vocseadef *search_ctx) { - vocdef *v, *vf; - vocwdef *vw, *vwf = nullptr; - vocdef *c = search_ctx->v; - int first; + vocdef *v, *vf; + vocwdef *vw, *vwf = nullptr; + vocdef *c = search_ctx->v; + int first; - /* continue with current word's vocwdef list if anything is left */ - first = TRUE; - vw = vocwget(voccx, search_ctx->vw->vocwnxt); + /* continue with current word's vocwdef list if anything is left */ + first = TRUE; + vw = vocwget(voccx, search_ctx->vw->vocwnxt); - /* keep going until we run out of hash chain entries or find a match */ - for (v = c, vf = 0 ; v != 0 && vf == 0 ; v = v->vocnxt, first = FALSE) - { - /* if this word matches, look at the objects in its list */ - if (first - || (voceq(search_ctx->wrd1, search_ctx->len1, - v->voctxt, v->voclen) - && voceq(search_ctx->wrd2, search_ctx->len2, - v->voctxt + v->voclen, v->vocln2))) - { - /* - * on the first time through, vw has already been set up - * with the next vocwdef in the current list; on subsequent - * times through the loop, start at the head of the current - * word's list - */ - if (!first) - vw = vocwget(voccx, v->vocwlst); + /* keep going until we run out of hash chain entries or find a match */ + for (v = c, vf = 0 ; v != 0 && vf == 0 ; v = v->vocnxt, first = FALSE) + { + /* if this word matches, look at the objects in its list */ + if (first + || (voceq(search_ctx->wrd1, search_ctx->len1, + v->voctxt, v->voclen) + && voceq(search_ctx->wrd2, search_ctx->len2, + v->voctxt + v->voclen, v->vocln2))) + { + /* + * on the first time through, vw has already been set up + * with the next vocwdef in the current list; on subsequent + * times through the loop, start at the head of the current + * word's list + */ + if (!first) + vw = vocwget(voccx, v->vocwlst); - /* search the list from vw forward */ - for ( ; vw ; vw = vocwget(voccx, vw->vocwnxt)) - { - if (search_ctx->vw->vocwtyp == vw->vocwtyp - && !(vw->vocwflg & VOCFCLASS) - && !(vw->vocwflg & VOCFDEL)) - { - /* - * remember the first vocdef that we found, and - * remember this, the first matching vocwdef, then - * stop scanning - */ - vf = v; - vwf = vw; - break; - } - } - } - } + /* search the list from vw forward */ + for ( ; vw ; vw = vocwget(voccx, vw->vocwnxt)) + { + if (search_ctx->vw->vocwtyp == vw->vocwtyp + && !(vw->vocwflg & VOCFCLASS) + && !(vw->vocwflg & VOCFDEL)) + { + /* + * remember the first vocdef that we found, and + * remember this, the first matching vocwdef, then + * stop scanning + */ + vf = v; + vwf = vw; + break; + } + } + } + } - /* return the first vocwdef in this word's list */ - search_ctx->v = vf; - search_ctx->vw = (vf ? vwf : 0); - return(search_ctx->vw); + /* return the first vocwdef in this word's list */ + search_ctx->v = vf; + search_ctx->vw = (vf ? vwf : 0); + return(search_ctx->vw); } /* find the first vocdef matching a set of words */ vocwdef *vocffw(voccxdef *ctx, const char *wrd, int len, const char *wrd2, int len2, - int p, vocseadef *search_ctx) + int p, vocseadef *search_ctx) { - uint hshval; - vocdef *v, *vf; - vocwdef *vw, *vwf = nullptr; + uint hshval; + vocdef *v, *vf; + vocwdef *vw, *vwf = nullptr; - /* get the word's hash value */ - hshval = vochsh((const uchar *)wrd, len); + /* get the word's hash value */ + hshval = vochsh((const uchar *)wrd, len); - /* scan the hash list until we run out of entries, or find a match */ - for (v = ctx->voccxhsh[hshval], vf = 0 ; v != 0 && vf == 0 ; - v = v->vocnxt) - { - /* if this word matches, look at the objects in its list */ - if (voceq((const uchar *)wrd, len, v->voctxt, v->voclen) - && voceq((const uchar *)wrd2, len2, v->voctxt + v->voclen, v->vocln2)) - { - /* look for a suitable object in the vocwdef list */ - for (vw = vocwget(ctx, v->vocwlst) ; vw ; - vw = vocwget(ctx, vw->vocwnxt)) - { - if (vw->vocwtyp == p && !(vw->vocwflg & VOCFCLASS) - && !(vw->vocwflg & VOCFDEL)) - { - /* - * remember the first vocdef that we found, and - * remember this, the first matching vocwdef; then - * stop scanning, since we have a match - */ - vf = v; - vwf = vw; - break; - } - } - } - } + /* scan the hash list until we run out of entries, or find a match */ + for (v = ctx->voccxhsh[hshval], vf = 0 ; v != 0 && vf == 0 ; + v = v->vocnxt) + { + /* if this word matches, look at the objects in its list */ + if (voceq((const uchar *)wrd, len, v->voctxt, v->voclen) + && voceq((const uchar *)wrd2, len2, v->voctxt + v->voclen, v->vocln2)) + { + /* look for a suitable object in the vocwdef list */ + for (vw = vocwget(ctx, v->vocwlst) ; vw ; + vw = vocwget(ctx, vw->vocwnxt)) + { + if (vw->vocwtyp == p && !(vw->vocwflg & VOCFCLASS) + && !(vw->vocwflg & VOCFDEL)) + { + /* + * remember the first vocdef that we found, and + * remember this, the first matching vocwdef; then + * stop scanning, since we have a match + */ + vf = v; + vwf = vw; + break; + } + } + } + } - /* set up the caller-provided search structure for next time */ - vw = (vf != 0 ? vwf : 0); - if (search_ctx) - { - /* save the search position */ - search_ctx->v = vf; - search_ctx->vw = vw; + /* set up the caller-provided search structure for next time */ + vw = (vf != 0 ? vwf : 0); + if (search_ctx) + { + /* save the search position */ + search_ctx->v = vf; + search_ctx->vw = vw; - /* save the search criteria */ - search_ctx->wrd1 = (const uchar *)wrd; - search_ctx->len1 = len; - search_ctx->wrd2 = (const uchar *)wrd2; - search_ctx->len2 = len2; - } + /* save the search criteria */ + search_ctx->wrd1 = (const uchar *)wrd; + search_ctx->len1 = len; + search_ctx->wrd2 = (const uchar *)wrd2; + search_ctx->len2 = len2; + } - /* return the match */ - return vw; + /* return the match */ + return vw; } /* ------------------------------------------------------------------------ */ @@ -663,21 +663,21 @@ vocwdef *vocffw(voccxdef *ctx, const char *wrd, int len, const char *wrd2, int l */ struct vocerr_va_info { - /* parseError/parseErrorParam result */ - char user_msg[400]; + /* parseError/parseErrorParam result */ + char user_msg[400]; - /* the sprintf-style format string to display */ - const char *fmt; + /* the sprintf-style format string to display */ + const char *fmt; - /* - * Pointer to the output buffer to use to format the string 'fmt' with - * its arguments, using vsprintf. The prep function will set this up - * to point to user_msg[]. - */ - char *outp; + /* + * Pointer to the output buffer to use to format the string 'fmt' with + * its arguments, using vsprintf. The prep function will set this up + * to point to user_msg[]. + */ + char *outp; - /* size of the output buffer, in bytes */ - size_t outsiz; + /* size of the output buffer, in bytes */ + size_t outsiz; }; /* @@ -686,180 +686,180 @@ struct vocerr_va_info * vocerr_va(). */ static void vocerr_va_prep(voccxdef *ctx, struct vocerr_va_info *info, - int err, const char *f, va_list argptr) + int err, const char *f, va_list argptr) { - /* - * presume that we'll use the given format string, instead of one - * provided by the program - */ - info->fmt = f; + /* + * presume that we'll use the given format string, instead of one + * provided by the program + */ + info->fmt = f; - /* use the output buffer from the info structure */ - info->outp = info->user_msg; - info->outsiz = sizeof(info->user_msg); + /* use the output buffer from the info structure */ + info->outp = info->user_msg; + info->outsiz = sizeof(info->user_msg); - /* - * if the user has a parseError or parseErrorParam function, see if it - * provides a msg - */ - if (ctx->voccxper != MCMONINV || ctx->voccxperp != MCMONINV) - { - runcxdef *rcx = ctx->voccxrun; - dattyp typ; - size_t len; - int argc; + /* + * if the user has a parseError or parseErrorParam function, see if it + * provides a msg + */ + if (ctx->voccxper != MCMONINV || ctx->voccxperp != MCMONINV) + { + runcxdef *rcx = ctx->voccxrun; + dattyp typ; + size_t len; + int argc; - /* start off with the two arguments that are always present */ - argc = 2; + /* start off with the two arguments that are always present */ + argc = 2; - /* - * if we're calling parseErrorParam, and we have additional - * arguments, push them as well - */ - if (ctx->voccxperp != MCMONINV) - { - enum typ_t - { - ARGBUF_STR, ARGBUF_INT, ARGBUF_CHAR - }; - struct argbuf_t - { - enum typ_t typ; - union - { - char *strval; - int intval; - char charval; - } val; - }; - struct argbuf_t args[5]; - struct argbuf_t *argp; - const char *p; + /* + * if we're calling parseErrorParam, and we have additional + * arguments, push them as well + */ + if (ctx->voccxperp != MCMONINV) + { + enum typ_t + { + ARGBUF_STR, ARGBUF_INT, ARGBUF_CHAR + }; + struct argbuf_t + { + enum typ_t typ; + union + { + char *strval; + int intval; + char charval; + } val; + }; + struct argbuf_t args[5]; + struct argbuf_t *argp; + const char *p; - /* - * Retrieve the arguments by examining the format string. We - * must buffer up the arguments before pushing them, because - * we need to push them in reverse order (last to first); so, - * we must scan all arguments before we push the first one. - */ - for (p = f, argp = args ; *p != '\0' ; ++p) - { - /* check if this is a parameter */ - if (*p == '%') - { - /* find out what type it is */ - switch(*++p) - { - case 's': - /* string - save the char pointer */ - argp->val.strval = va_arg(argptr, char *); - argp->typ = ARGBUF_STR; + /* + * Retrieve the arguments by examining the format string. We + * must buffer up the arguments before pushing them, because + * we need to push them in reverse order (last to first); so, + * we must scan all arguments before we push the first one. + */ + for (p = f, argp = args ; *p != '\0' ; ++p) + { + /* check if this is a parameter */ + if (*p == '%') + { + /* find out what type it is */ + switch(*++p) + { + case 's': + /* string - save the char pointer */ + argp->val.strval = va_arg(argptr, char *); + argp->typ = ARGBUF_STR; - /* consume an argument slot */ - ++argp; - break; + /* consume an argument slot */ + ++argp; + break; - case 'd': - /* integer - save the integer */ - argp->val.intval = va_arg(argptr, int); - argp->typ = ARGBUF_INT; + case 'd': + /* integer - save the integer */ + argp->val.intval = va_arg(argptr, int); + argp->typ = ARGBUF_INT; - /* consume an argument slot */ - ++argp; - break; + /* consume an argument slot */ + ++argp; + break; - case 'c': - /* character */ - argp->val.charval = (char)va_arg(argptr, int); - argp->typ = ARGBUF_CHAR; + case 'c': + /* character */ + argp->val.charval = (char)va_arg(argptr, int); + argp->typ = ARGBUF_CHAR; - /* consume an argument slot */ - ++argp; - break; + /* consume an argument slot */ + ++argp; + break; - default: - /* - * ignore other types (there shouldn't be any - * other types anyway) - */ - break; - } - } - } + default: + /* + * ignore other types (there shouldn't be any + * other types anyway) + */ + break; + } + } + } - /* - * Push the arguments - keep looping until we get back to the - * first argument slot - */ - while (argp != args) - { - /* move to the next argument, working backwards */ - --argp; + /* + * Push the arguments - keep looping until we get back to the + * first argument slot + */ + while (argp != args) + { + /* move to the next argument, working backwards */ + --argp; - /* push this argument */ - switch(argp->typ) - { - case ARGBUF_STR: - /* push the string value */ - runpstr(rcx, argp->val.strval, - (int)strlen(argp->val.strval), 0); - break; + /* push this argument */ + switch(argp->typ) + { + case ARGBUF_STR: + /* push the string value */ + runpstr(rcx, argp->val.strval, + (int)strlen(argp->val.strval), 0); + break; - case ARGBUF_INT: - /* push the number value */ - runpnum(rcx, argp->val.intval); - break; + case ARGBUF_INT: + /* push the number value */ + runpnum(rcx, argp->val.intval); + break; - case ARGBUF_CHAR: - /* push the character as a one-character string */ - runpstr(rcx, &argp->val.charval, 1, 0); - break; - } + case ARGBUF_CHAR: + /* push the character as a one-character string */ + runpstr(rcx, &argp->val.charval, 1, 0); + break; + } - /* count the argument */ - ++argc; - } - } + /* count the argument */ + ++argc; + } + } - /* push standard arguments: error code and default message */ - runpstr(rcx, f, (int)strlen(f), 0); /* 2nd arg: default msg */ - runpnum(rcx, (long)err); /* 1st arg: error number */ + /* push standard arguments: error code and default message */ + runpstr(rcx, f, (int)strlen(f), 0); /* 2nd arg: default msg */ + runpnum(rcx, (long)err); /* 1st arg: error number */ - /* invoke parseErrorParam if it's defined, otherwise parseError */ - runfn(rcx, (objnum)(ctx->voccxperp == MCMONINV - ? ctx->voccxper : ctx->voccxperp), argc); + /* invoke parseErrorParam if it's defined, otherwise parseError */ + runfn(rcx, (objnum)(ctx->voccxperp == MCMONINV + ? ctx->voccxper : ctx->voccxperp), argc); - /* see what the function returned */ - typ = runtostyp(rcx); - if (typ == DAT_SSTRING) - { - char *p; - - /* - * they returned a string - use it as the error message - * instead of the default message - */ - p = (char *)runpopstr(rcx); - len = osrp2(p) - 2; - p += 2; - if (len > sizeof(info->user_msg) - 1) - len = sizeof(info->user_msg) - 1; - memcpy(info->user_msg, p, len); - info->user_msg[len] = '\0'; + /* see what the function returned */ + typ = runtostyp(rcx); + if (typ == DAT_SSTRING) + { + char *p; + + /* + * they returned a string - use it as the error message + * instead of the default message + */ + p = (char *)runpopstr(rcx); + len = osrp2(p) - 2; + p += 2; + if (len > sizeof(info->user_msg) - 1) + len = sizeof(info->user_msg) - 1; + memcpy(info->user_msg, p, len); + info->user_msg[len] = '\0'; - /* use the returned string as the message to display */ - info->fmt = info->user_msg; + /* use the returned string as the message to display */ + info->fmt = info->user_msg; - /* use the remainder of the buffer for the final formatting */ - info->outp = info->user_msg + len + 1; - info->outsiz = sizeof(info->user_msg) - len - 1; - } - else - { - /* ignore other return values */ - rundisc(rcx); - } - } + /* use the remainder of the buffer for the final formatting */ + info->outp = info->user_msg + len + 1; + info->outsiz = sizeof(info->user_msg) - len - 1; + } + else + { + /* ignore other return values */ + rundisc(rcx); + } + } } @@ -874,22 +874,22 @@ static void vocerr_va_prep(voccxdef *ctx, struct vocerr_va_info *info, * property re-initialized for the call to this routine. */ static void vocerr_va(voccxdef *ctx, struct vocerr_va_info *info, - int err, const char *f, va_list argptr) + int err, const char *f, va_list argptr) { - char *buf; - - /* turn on output */ - (void)tioshow(ctx->voccxtio); + char *buf; + + /* turn on output */ + (void)tioshow(ctx->voccxtio); - /* build the string to display */ - if (os_vasprintf(&buf, info->fmt, argptr) >= 0) - { - /* display it */ - tioputs(ctx->voccxtio, buf); + /* build the string to display */ + if (os_vasprintf(&buf, info->fmt, argptr) >= 0) + { + /* display it */ + tioputs(ctx->voccxtio, buf); - /* free the buffer */ - osfree(buf); - } + /* free the buffer */ + osfree(buf); + } } /* ------------------------------------------------------------------------ */ @@ -898,18 +898,18 @@ static void vocerr_va(voccxdef *ctx, struct vocerr_va_info *info, */ void vocerr_info(voccxdef *ctx, int err, const char *f, ...) { - va_list argptr; - struct vocerr_va_info info; + va_list argptr; + struct vocerr_va_info info; - /* prepare to format the message */ - va_start(argptr, f); - vocerr_va_prep(ctx, &info, err, f, argptr); - va_end(argptr); + /* prepare to format the message */ + va_start(argptr, f); + vocerr_va_prep(ctx, &info, err, f, argptr); + va_end(argptr); /* call the general vocerr formatter */ - va_start(argptr, f); - vocerr_va(ctx, &info, err, f, argptr); - va_end(argptr); + va_start(argptr, f); + vocerr_va(ctx, &info, err, f, argptr); + va_end(argptr); } /* @@ -917,26 +917,26 @@ void vocerr_info(voccxdef *ctx, int err, const char *f, ...) */ void vocerr(voccxdef *ctx, int err, const char *f, ...) { - va_list argptr; - struct vocerr_va_info info; + va_list argptr; + struct vocerr_va_info info; - /* - * If the unknown word flag is set, suppress this error, because - * we're going to be trying the whole parsing from the beginning - * again anyway. - */ - if (ctx->voccxunknown > 0) - return; + /* + * If the unknown word flag is set, suppress this error, because + * we're going to be trying the whole parsing from the beginning + * again anyway. + */ + if (ctx->voccxunknown > 0) + return; - /* prepare to format the message */ - va_start(argptr, f); - vocerr_va_prep(ctx, &info, err, f, argptr); - va_end(argptr); + /* prepare to format the message */ + va_start(argptr, f); + vocerr_va_prep(ctx, &info, err, f, argptr); + va_end(argptr); - /* call the general vocerr formatter */ - va_start(argptr, f); - vocerr_va(ctx, &info, err, f, argptr); - va_end(argptr); + /* call the general vocerr formatter */ + va_start(argptr, f); + vocerr_va(ctx, &info, err, f, argptr); + va_end(argptr); } /* @@ -969,198 +969,198 @@ void vocerr(voccxdef *ctx, int err, const char *f, ...) * parsing after the part parsed by the function. */ int try_unknown_verb(voccxdef *ctx, objnum actor, - char **cmd, int *typelist, int wrdcnt, int *next_start, - int do_fuses, int vocerr_err, const char *vocerr_msg, ...) + char **cmd, int *typelist, int wrdcnt, int *next_start, + int do_fuses, int vocerr_err, const char *vocerr_msg, ...) { - int show_msg; - va_list argptr; + int show_msg; + va_list argptr; - /* presume we won't show the message */ - show_msg = FALSE; + /* presume we won't show the message */ + show_msg = FALSE; - /* determine the word count if the caller passed in zero */ - if (wrdcnt == 0) - { - /* count the words before the terminating null entry */ - for ( ; cmd[wrdcnt] != 0 ; ++wrdcnt) ; - } + /* determine the word count if the caller passed in zero */ + if (wrdcnt == 0) + { + /* count the words before the terminating null entry */ + for ( ; cmd[wrdcnt] != 0 ; ++wrdcnt) ; + } - /* if parseUnknownVerb exists, call it */ - if (ctx->voccxpuv != MCMONINV) - { - int err; - int i; - //int do_fuses; + /* if parseUnknownVerb exists, call it */ + if (ctx->voccxpuv != MCMONINV) + { + int err; + int i; + //int do_fuses; - /* no error has occurred yet */ - err = 0; + /* no error has occurred yet */ + err = 0; - /* presume we will run the fuses */ - do_fuses = TRUE; + /* presume we will run the fuses */ + do_fuses = TRUE; - /* push the error number argument */ - runpnum(ctx->voccxrun, (long)vocerr_err); + /* push the error number argument */ + runpnum(ctx->voccxrun, (long)vocerr_err); - /* push a list of the word types */ - voc_push_numlist(ctx, (uint *)typelist, wrdcnt); + /* push a list of the word types */ + voc_push_numlist(ctx, (uint *)typelist, wrdcnt); - /* push a list of the words */ - voc_push_toklist(ctx, cmd, wrdcnt); + /* push a list of the words */ + voc_push_toklist(ctx, cmd, wrdcnt); - /* use "Me" as the default actor */ - if (actor == MCMONINV) - actor = ctx->voccxme; + /* use "Me" as the default actor */ + if (actor == MCMONINV) + actor = ctx->voccxme; - /* push the actor argument */ - runpobj(ctx->voccxrun, actor); + /* push the actor argument */ + runpobj(ctx->voccxrun, actor); - /* catch any errors that occur while calling the function */ - ERRBEGIN(ctx->voccxerr) - { - /* invoke the function */ - runfn(ctx->voccxrun, ctx->voccxpuv, 4); + /* catch any errors that occur while calling the function */ + ERRBEGIN(ctx->voccxerr) + { + /* invoke the function */ + runfn(ctx->voccxrun, ctx->voccxpuv, 4); - /* get the return value */ - switch(runtostyp(ctx->voccxrun)) - { - case DAT_TRUE: - /* the command was handled */ - rundisc(ctx->voccxrun); + /* get the return value */ + switch(runtostyp(ctx->voccxrun)) + { + case DAT_TRUE: + /* the command was handled */ + rundisc(ctx->voccxrun); - /* consume the entire command */ - *next_start = wrdcnt; + /* consume the entire command */ + *next_start = wrdcnt; - /* - * since the command has now been handled, forget about - * any unknown words - */ - ctx->voccxunknown = 0; - break; + /* + * since the command has now been handled, forget about + * any unknown words + */ + ctx->voccxunknown = 0; + break; - case DAT_NUMBER: - /* - * The command was handled, and the function indicated - * the number of words it wants to skip. Communicate - * this information back to the caller in *next_start. - * Since the routine returns the 1-based index of the - * next entry, we must subtract one to get the number of - * words actually consumed. - */ - *next_start = runpopnum(ctx->voccxrun); - if (*next_start > 0) - --(*next_start); + case DAT_NUMBER: + /* + * The command was handled, and the function indicated + * the number of words it wants to skip. Communicate + * this information back to the caller in *next_start. + * Since the routine returns the 1-based index of the + * next entry, we must subtract one to get the number of + * words actually consumed. + */ + *next_start = runpopnum(ctx->voccxrun); + if (*next_start > 0) + --(*next_start); - /* make sure the value is in range */ - if (*next_start < 0) - *next_start = 0; - else if (*next_start > wrdcnt) - *next_start = wrdcnt; + /* make sure the value is in range */ + if (*next_start < 0) + *next_start = 0; + else if (*next_start > wrdcnt) + *next_start = wrdcnt; - /* - * forget about any unknown words in the list up to the - * next word - */ - for (i = 0 ; i < *next_start ; ++i) - { - /* if this word was unknown, forget about that now */ - if ((typelist[i] & VOCT_UNKNOWN) != 0 - && ctx->voccxunknown > 0) - --(ctx->voccxunknown); - } - break; + /* + * forget about any unknown words in the list up to the + * next word + */ + for (i = 0 ; i < *next_start ; ++i) + { + /* if this word was unknown, forget about that now */ + if ((typelist[i] & VOCT_UNKNOWN) != 0 + && ctx->voccxunknown > 0) + --(ctx->voccxunknown); + } + break; - default: - /* treat anything else like nil */ + default: + /* treat anything else like nil */ - case DAT_NIL: - /* nil - command not handled; show the message */ - rundisc(ctx->voccxrun); - show_msg = TRUE; - break; - } - } - ERRCATCH(ctx->voccxerr, err) - { - /* check the error */ - switch(err) - { - case ERR_RUNEXIT: - case ERR_RUNEXITOBJ: - /* - * Exit or exitobj was executed - skip to the fuses. - * Forget about any unknown words, since we've finished - * processing this command and we don't want to allow - * "oops" processing. - */ - ctx->voccxunknown = 0; - break; + case DAT_NIL: + /* nil - command not handled; show the message */ + rundisc(ctx->voccxrun); + show_msg = TRUE; + break; + } + } + ERRCATCH(ctx->voccxerr, err) + { + /* check the error */ + switch(err) + { + case ERR_RUNEXIT: + case ERR_RUNEXITOBJ: + /* + * Exit or exitobj was executed - skip to the fuses. + * Forget about any unknown words, since we've finished + * processing this command and we don't want to allow + * "oops" processing. + */ + ctx->voccxunknown = 0; + break; - case ERR_RUNABRT: - /* - * abort was executed - skip to the end of the command, - * but do not execute the fuses - */ - do_fuses = FALSE; + case ERR_RUNABRT: + /* + * abort was executed - skip to the end of the command, + * but do not execute the fuses + */ + do_fuses = FALSE; - /* - * Since we're aborting the command, ignore any - * remaining unknown words - we're skipping out of the - * command entirely, so we don't care that there were - * unknown words in the command. - */ - ctx->voccxunknown = 0; - break; + /* + * Since we're aborting the command, ignore any + * remaining unknown words - we're skipping out of the + * command entirely, so we don't care that there were + * unknown words in the command. + */ + ctx->voccxunknown = 0; + break; - default: - /* re-throw any other errors */ - errrse(ctx->voccxerr); - } - } - ERREND(ctx->voccxerr); + default: + /* re-throw any other errors */ + errrse(ctx->voccxerr); + } + } + ERREND(ctx->voccxerr); - /* if we're not showing the message, process fuses and daemons */ - if (!show_msg) - { - /* execute fuses and daemons */ - if (exe_fuses_and_daemons(ctx, err, do_fuses, - actor, MCMONINV, 0, 0, - MCMONINV, MCMONINV) != 0) - { - /* - * aborted from fuses and daemons - return false to tell - * the caller not to execute anything left on the - * command line - */ - return FALSE; - } + /* if we're not showing the message, process fuses and daemons */ + if (!show_msg) + { + /* execute fuses and daemons */ + if (exe_fuses_and_daemons(ctx, err, do_fuses, + actor, MCMONINV, 0, 0, + MCMONINV, MCMONINV) != 0) + { + /* + * aborted from fuses and daemons - return false to tell + * the caller not to execute anything left on the + * command line + */ + return FALSE; + } - /* indicate that the game code successfully handled the command */ - return TRUE; - } - } + /* indicate that the game code successfully handled the command */ + return TRUE; + } + } - /* - * If we made it here, it means we're showing the default message. - * If we have unknown words, suppress the message so that we show - * the unknown word error instead after returning. - */ - if (ctx->voccxunknown == 0) - { - struct vocerr_va_info info; + /* + * If we made it here, it means we're showing the default message. + * If we have unknown words, suppress the message so that we show + * the unknown word error instead after returning. + */ + if (ctx->voccxunknown == 0) + { + struct vocerr_va_info info; - /* prepare to format the message */ - va_start(argptr, vocerr_msg); - vocerr_va_prep(ctx, &info, vocerr_err, vocerr_msg, argptr); - va_end(argptr); + /* prepare to format the message */ + va_start(argptr, vocerr_msg); + vocerr_va_prep(ctx, &info, vocerr_err, vocerr_msg, argptr); + va_end(argptr); - /* format the mesage */ - va_start(argptr, vocerr_msg); - vocerr_va(ctx, &info, vocerr_err, vocerr_msg, argptr); - va_end(argptr); - } + /* format the mesage */ + va_start(argptr, vocerr_msg); + vocerr_va(ctx, &info, vocerr_err, vocerr_msg, argptr); + va_end(argptr); + } - /* indicate that the remainder of the command should be aborted */ - return FALSE; + /* indicate that the remainder of the command should be aborted */ + return FALSE; } @@ -1171,302 +1171,302 @@ int try_unknown_verb(voccxdef *ctx, objnum actor, static const vocspdef vocsptab[] = { - { "of", VOCW_OF }, - { "and", VOCW_AND }, - { "then", VOCW_THEN }, - { "all", VOCW_ALL }, - { "everyt", VOCW_ALL }, - { "both", VOCW_BOTH }, - { "but", VOCW_BUT }, - { "except", VOCW_BUT }, - { "one", VOCW_ONE }, - { "ones", VOCW_ONES }, - { "it", VOCW_IT }, - { "them", VOCW_THEM }, - { "him", VOCW_HIM }, - { "her", VOCW_HER }, - { "any", VOCW_ANY }, - { "either", VOCW_ANY }, - { 0, 0 } + { "of", VOCW_OF }, + { "and", VOCW_AND }, + { "then", VOCW_THEN }, + { "all", VOCW_ALL }, + { "everyt", VOCW_ALL }, + { "both", VOCW_BOTH }, + { "but", VOCW_BUT }, + { "except", VOCW_BUT }, + { "one", VOCW_ONE }, + { "ones", VOCW_ONES }, + { "it", VOCW_IT }, + { "them", VOCW_THEM }, + { "him", VOCW_HIM }, + { "her", VOCW_HER }, + { "any", VOCW_ANY }, + { "either", VOCW_ANY }, + { 0, 0 } }; /* test a word to see if it's a particular special word */ static int voc_check_special(voccxdef *ctx, const char *wrd, int checktyp) { - /* search the user or built-in special table, as appropriate */ - if (ctx->voccxspp) - { - char *p; - char *endp; - char typ; - int len; - int wrdlen = strlen(wrd); - - for (p = ctx->voccxspp, endp = p + ctx->voccxspl ; - p < endp ; ) - { - typ = *p++; - len = *p++; + /* search the user or built-in special table, as appropriate */ + if (ctx->voccxspp) + { + char *p; + char *endp; + char typ; + int len; + int wrdlen = strlen(wrd); + + for (p = ctx->voccxspp, endp = p + ctx->voccxspl ; + p < endp ; ) + { + typ = *p++; + len = *p++; - /* if this word matches in type and text, we have a match */ - if (typ == checktyp - && len == wrdlen && !memcmp(p, wrd, (size_t)len)) - return TRUE; + /* if this word matches in type and text, we have a match */ + if (typ == checktyp + && len == wrdlen && !memcmp(p, wrd, (size_t)len)) + return TRUE; - /* no match - keep going */ - p += len; - } - } - else - { - const vocspdef *x; - - for (x = vocsptab ; x->vocspin ; ++x) - { - /* if it matches in type and text, we have a match */ - if (x->vocspout == checktyp - && !strncmp((const char *)wrd, x->vocspin, (size_t)6)) - return TRUE; - } - } + /* no match - keep going */ + p += len; + } + } + else + { + const vocspdef *x; + + for (x = vocsptab ; x->vocspin ; ++x) + { + /* if it matches in type and text, we have a match */ + if (x->vocspout == checktyp + && !strncmp((const char *)wrd, x->vocspin, (size_t)6)) + return TRUE; + } + } - /* didn't find a match for the text and type */ - return FALSE; + /* didn't find a match for the text and type */ + return FALSE; } /* tokenize a command line - returns number of words in command */ int voctok(voccxdef *ctx, char *cmd, char *outbuf, char **wrd, - int lower, int cvt_ones, int show_errors) + int lower, int cvt_ones, int show_errors) { - int i; - const vocspdef *x; - int l; - char *p; - char *w; - uint len; + int i; + const vocspdef *x; + int l; + char *p; + char *w; + uint len; - for (i = 0 ;; ) - { - while (vocisspace(*cmd)) cmd++; - if (!*cmd) - { - wrd[i] = outbuf; - *outbuf = '\0'; - return(i); - } + for (i = 0 ;; ) + { + while (vocisspace(*cmd)) cmd++; + if (!*cmd) + { + wrd[i] = outbuf; + *outbuf = '\0'; + return(i); + } - wrd[i++] = outbuf; - if (vocisalpha(*cmd) || *cmd == '-') - { - while(vocisalpha(*cmd) || vocisdigit(*cmd) || - *cmd=='\'' || *cmd=='-') - { - *outbuf++ = (vocisupper(*cmd) && lower) ? tolower(*cmd) : *cmd; - ++cmd; - } - - /* - * Check for a special case: abbreviations that end in a - * period. For example, "Mr. Patrick J. Wayne." We wish - * to absorb the period after "Mr" and the one after "J" - * into the respective words; we detect this condition by - * actually trying to find a word in the dictionary that - * has the period. - */ - w = wrd[i-1]; - len = outbuf - w; - if (*cmd == '.') - { - *outbuf++ = *cmd++; /* add the period to the word */ - *outbuf = '\0'; /* null-terminate it */ - ++len; - if (!vocffw(ctx, (char *)w, len, 0, 0, PRP_NOUN, - (vocseadef *)0) - && !vocffw(ctx, (char *)w, len, 0, 0, PRP_ADJ, - (vocseadef *)0)) - { - /* no word with period in dictionary - remove period */ - --outbuf; - --cmd; - --len; - } - } + wrd[i++] = outbuf; + if (vocisalpha(*cmd) || *cmd == '-') + { + while(vocisalpha(*cmd) || vocisdigit(*cmd) || + *cmd=='\'' || *cmd=='-') + { + *outbuf++ = (vocisupper(*cmd) && lower) ? tolower(*cmd) : *cmd; + ++cmd; + } + + /* + * Check for a special case: abbreviations that end in a + * period. For example, "Mr. Patrick J. Wayne." We wish + * to absorb the period after "Mr" and the one after "J" + * into the respective words; we detect this condition by + * actually trying to find a word in the dictionary that + * has the period. + */ + w = wrd[i-1]; + len = outbuf - w; + if (*cmd == '.') + { + *outbuf++ = *cmd++; /* add the period to the word */ + *outbuf = '\0'; /* null-terminate it */ + ++len; + if (!vocffw(ctx, (char *)w, len, 0, 0, PRP_NOUN, + (vocseadef *)0) + && !vocffw(ctx, (char *)w, len, 0, 0, PRP_ADJ, + (vocseadef *)0)) + { + /* no word with period in dictionary - remove period */ + --outbuf; + --cmd; + --len; + } + } - /* null-terminate the buffer */ - *outbuf = '\0'; + /* null-terminate the buffer */ + *outbuf = '\0'; - /* find compound words and glue them together */ - for (p = ctx->voccxcpp, l = ctx->voccxcpl ; l ; ) - { - uint l1 = osrp2(p); - char *p2 = p + l1; /* get second word */ - uint l2 = osrp2(p2); - char *p3 = p2 + l2; /* get compound word */ - uint l3 = osrp2(p3); - - if (i > 1 && len == (l2 - 2) - && !memcmp(w, p2 + 2, (size_t)len) - && strlen((char *)wrd[i-2]) == (l1 - 2) - && !memcmp(wrd[i-2], p + 2, (size_t)(l1 - 2))) - { - memcpy(wrd[i-2], p3 + 2, (size_t)(l3 - 2)); - *(wrd[i-2] + l3 - 2) = '\0'; - --i; - break; - } + /* find compound words and glue them together */ + for (p = ctx->voccxcpp, l = ctx->voccxcpl ; l ; ) + { + uint l1 = osrp2(p); + char *p2 = p + l1; /* get second word */ + uint l2 = osrp2(p2); + char *p3 = p2 + l2; /* get compound word */ + uint l3 = osrp2(p3); + + if (i > 1 && len == (l2 - 2) + && !memcmp(w, p2 + 2, (size_t)len) + && strlen((char *)wrd[i-2]) == (l1 - 2) + && !memcmp(wrd[i-2], p + 2, (size_t)(l1 - 2))) + { + memcpy(wrd[i-2], p3 + 2, (size_t)(l3 - 2)); + *(wrd[i-2] + l3 - 2) = '\0'; + --i; + break; + } - /* move on to the next word */ - l -= l1 + l2 + l3; - p = p3 + l3; - } + /* move on to the next word */ + l -= l1 + l2 + l3; + p = p3 + l3; + } - /* - * Find any special keywords, and set to appropriate flag - * char. Note that we no longer convert "of" in this - * fashion; "of" is now handled separately in order to - * facilitate its use as an ordinary preposition. - */ - if (ctx->voccxspp) - { - //char *p; - char *endp; - char typ; - //int len; - uint wrdlen = strlen((char *)wrd[i-1]); - - for (p = ctx->voccxspp, endp = p + ctx->voccxspl ; - p < endp ; ) - { - typ = *p++; - len = *p++; - if (len == wrdlen && !memcmp(p, wrd[i-1], (size_t)len) - && (cvt_ones || (typ != VOCW_ONE && typ != VOCW_ONES)) - && typ != VOCW_OF) - { - *wrd[i-1] = typ; - *(wrd[i-1] + 1) = '\0'; - break; - } - p += len; - } - } - else - { - for (x = vocsptab ; x->vocspin ; ++x) - { - if (!strncmp((char *)wrd[i-1], x->vocspin, (size_t)6) - && (cvt_ones || - (x->vocspout != VOCW_ONE - && x->vocspout != VOCW_ONES)) - && x->vocspout != VOCW_OF) - { - *wrd[i-1] = x->vocspout; - *(wrd[i-1] + 1) = '\0'; - break; - } - } - } + /* + * Find any special keywords, and set to appropriate flag + * char. Note that we no longer convert "of" in this + * fashion; "of" is now handled separately in order to + * facilitate its use as an ordinary preposition. + */ + if (ctx->voccxspp) + { + //char *p; + char *endp; + char typ; + //int len; + uint wrdlen = strlen((char *)wrd[i-1]); + + for (p = ctx->voccxspp, endp = p + ctx->voccxspl ; + p < endp ; ) + { + typ = *p++; + len = *p++; + if (len == wrdlen && !memcmp(p, wrd[i-1], (size_t)len) + && (cvt_ones || (typ != VOCW_ONE && typ != VOCW_ONES)) + && typ != VOCW_OF) + { + *wrd[i-1] = typ; + *(wrd[i-1] + 1) = '\0'; + break; + } + p += len; + } + } + else + { + for (x = vocsptab ; x->vocspin ; ++x) + { + if (!strncmp((char *)wrd[i-1], x->vocspin, (size_t)6) + && (cvt_ones || + (x->vocspout != VOCW_ONE + && x->vocspout != VOCW_ONES)) + && x->vocspout != VOCW_OF) + { + *wrd[i-1] = x->vocspout; + *(wrd[i-1] + 1) = '\0'; + break; + } + } + } - /* make sure the output pointer is fixed up to the right spot */ - outbuf = wrd[i-1]; - outbuf += strlen((char *)outbuf); - } - else if (vocisdigit( *cmd )) - { - while(vocisdigit(*cmd) || vocisalpha(*cmd) - || *cmd == '\'' || *cmd == '-') - *outbuf++ = *cmd++; - } - else switch( *cmd ) - { - case '.': - case '!': - case '?': - case ';': - *outbuf++ = VOCW_THEN; - ++cmd; - break; + /* make sure the output pointer is fixed up to the right spot */ + outbuf = wrd[i-1]; + outbuf += strlen((char *)outbuf); + } + else if (vocisdigit( *cmd )) + { + while(vocisdigit(*cmd) || vocisalpha(*cmd) + || *cmd == '\'' || *cmd == '-') + *outbuf++ = *cmd++; + } + else switch( *cmd ) + { + case '.': + case '!': + case '?': + case ';': + *outbuf++ = VOCW_THEN; + ++cmd; + break; - case ',': - case ':': - *outbuf++ = VOCW_AND; - ++cmd; - break; + case ',': + case ':': + *outbuf++ = VOCW_AND; + ++cmd; + break; - case '"': - case '\'': - { - char *lenptr; - char quote = *cmd++; + case '"': + case '\'': + { + char *lenptr; + char quote = *cmd++; - /* - * remember that this is a quoted string (it doesn't - * matter whether they're actually using single or - * double quotes - in either case, we use '"' as the - * flag to indicate that it's a quote string) - */ - *outbuf++ = '"'; + /* + * remember that this is a quoted string (it doesn't + * matter whether they're actually using single or + * double quotes - in either case, we use '"' as the + * flag to indicate that it's a quote string) + */ + *outbuf++ = '"'; - /* make room for the length prefix */ - lenptr = outbuf; - outbuf += 2; + /* make room for the length prefix */ + lenptr = outbuf; + outbuf += 2; - /* copy up to the matching close quote */ - while (*cmd && *cmd != quote) - { - char c; + /* copy up to the matching close quote */ + while (*cmd && *cmd != quote) + { + char c; - /* get this character */ - c = *cmd++; - - /* escape the character if necessary */ - switch(c) - { - case '\\': - *outbuf++ = '\\'; - break; - } + /* get this character */ + c = *cmd++; + + /* escape the character if necessary */ + switch(c) + { + case '\\': + *outbuf++ = '\\'; + break; + } - /* copy this character */ - *outbuf++ = c; - } - - oswp2(lenptr, ((int)(outbuf - lenptr))); - if (*cmd == quote) cmd++; - break; - } + /* copy this character */ + *outbuf++ = c; + } + + oswp2(lenptr, ((int)(outbuf - lenptr))); + if (*cmd == quote) cmd++; + break; + } - default: - /* display an error if appropriate */ - if (show_errors) - { - int hmode = tio_is_html_mode(); + default: + /* display an error if appropriate */ + if (show_errors) + { + int hmode = tio_is_html_mode(); - /* - * if we're in HTML mode, switch out momentarily, so that - * we show the character literally, even if it's a - * markup-significant character (such as '<' or '&') - */ - if (hmode) - tioputs(ctx->voccxtio, "\\H-"); - - /* show the message */ - vocerr(ctx, VOCERR(1), - "I don't understand the punctuation \"%c\".", *cmd); + /* + * if we're in HTML mode, switch out momentarily, so that + * we show the character literally, even if it's a + * markup-significant character (such as '<' or '&') + */ + if (hmode) + tioputs(ctx->voccxtio, "\\H-"); + + /* show the message */ + vocerr(ctx, VOCERR(1), + "I don't understand the punctuation \"%c\".", *cmd); - /* restore HTML mode if appropriate */ - if (hmode) - tioputs(ctx->voccxtio, "\\H+"); - } + /* restore HTML mode if appropriate */ + if (hmode) + tioputs(ctx->voccxtio, "\\H+"); + } - /* return failure */ - return -1; - } + /* return failure */ + return -1; + } - /* null-terminate the result */ - *outbuf++ = '\0'; - } + /* null-terminate the result */ + *outbuf++ = '\0'; + } } @@ -1477,69 +1477,69 @@ int voctok(voccxdef *ctx, char *cmd, char *outbuf, char **wrd, */ static int voc_lookup_type(voccxdef *ctx, char *p, int len, int of_is_spec) { - int t; - - /* check for a special word */ - if (vocisspec(p)) - { - /* it's a special word - this is its type */ - t = VOCT_SPEC; - } - else - { - vocwdef *vw; - vocdef *v; + int t; + + /* check for a special word */ + if (vocisspec(p)) + { + /* it's a special word - this is its type */ + t = VOCT_SPEC; + } + else + { + vocwdef *vw; + vocdef *v; - /* - * Now check the various entries of this word to get the word - * type flag bits. The Noun and Adjective flags can be set for - * any word which matches this word in the first six letters (or - * more if more were provided by the player), but the Plural - * flag can only be set if the plural word matches exactly. - * Note that this pass only matches the first word in two-word - * verbs; the second word is considered later during the - * semantic analysis. - */ - for (t = 0, v = ctx->voccxhsh[vochsh((uchar *)p, len)] ; v != 0 ; - v = v->vocnxt) - { - /* if this hash chain entry matches, add it to our types */ - if (voceq((uchar *)p, len, v->voctxt, v->voclen)) - { - /* we have a match - look through relation list for word */ - for (vw = vocwget(ctx, v->vocwlst) ; vw != 0 ; - vw = vocwget(ctx, vw->vocwnxt)) - { - /* skip this word if it's been deleted */ - if (vw->vocwflg & VOCFDEL) - continue; + /* + * Now check the various entries of this word to get the word + * type flag bits. The Noun and Adjective flags can be set for + * any word which matches this word in the first six letters (or + * more if more were provided by the player), but the Plural + * flag can only be set if the plural word matches exactly. + * Note that this pass only matches the first word in two-word + * verbs; the second word is considered later during the + * semantic analysis. + */ + for (t = 0, v = ctx->voccxhsh[vochsh((uchar *)p, len)] ; v != 0 ; + v = v->vocnxt) + { + /* if this hash chain entry matches, add it to our types */ + if (voceq((uchar *)p, len, v->voctxt, v->voclen)) + { + /* we have a match - look through relation list for word */ + for (vw = vocwget(ctx, v->vocwlst) ; vw != 0 ; + vw = vocwget(ctx, vw->vocwnxt)) + { + /* skip this word if it's been deleted */ + if (vw->vocwflg & VOCFDEL) + continue; - /* we need a special check for plurals */ - if (vw->vocwtyp == PRP_PLURAL) - { - /* plurals must be exact (non-truncated) match */ - if (len == v->voclen) - { - /* plurals also count as nouns */ - t |= (VOCT_NOUN | VOCT_PLURAL); - } - } - else - { - /* add this type bit to our type value */ - t |= voctype[vw->vocwtyp]; - } - } - } - } - } + /* we need a special check for plurals */ + if (vw->vocwtyp == PRP_PLURAL) + { + /* plurals must be exact (non-truncated) match */ + if (len == v->voclen) + { + /* plurals also count as nouns */ + t |= (VOCT_NOUN | VOCT_PLURAL); + } + } + else + { + /* add this type bit to our type value */ + t |= voctype[vw->vocwtyp]; + } + } + } + } + } - /* check for "of" if the caller wants us to */ - if (of_is_spec && t == 0 && voc_check_special(ctx, p, VOCW_OF)) - t = VOCT_SPEC; + /* check for "of" if the caller wants us to */ + if (of_is_spec && t == 0 && voc_check_special(ctx, p, VOCW_OF)) + t = VOCT_SPEC; - /* return the type */ - return t; + /* return the type */ + return t; } @@ -1552,61 +1552,61 @@ static int voc_lookup_type(voccxdef *ctx, char *p, int len, int of_is_spec) * simply entered a new command. */ static char *voc_read_oops(voccxdef *ctx, char *oopsbuf, size_t oopsbuflen, - const char *unknown_word) + const char *unknown_word) { - char *p; - - /* display the error */ - vocerr(ctx, VOCERR(2), "I don't know the word \"%s\".", unknown_word); + char *p; + + /* display the error */ + vocerr(ctx, VOCERR(2), "I don't know the word \"%s\".", unknown_word); - /* read a new command */ - if (vocread(ctx, MCMONINV, MCMONINV, - oopsbuf, (int)oopsbuflen, 1) == VOCREAD_REDO) - { - /* - * we've already decided it's not an OOPS input - return null to - * indicate to the caller that we have a new command - */ - return 0; - } + /* read a new command */ + if (vocread(ctx, MCMONINV, MCMONINV, + oopsbuf, (int)oopsbuflen, 1) == VOCREAD_REDO) + { + /* + * we've already decided it's not an OOPS input - return null to + * indicate to the caller that we have a new command + */ + return 0; + } - /* lower-case the string */ - for (p = oopsbuf ; *p != '\0' ; ++p) - *p = (vocisupper(*p) ? tolower(*p) : *p); + /* lower-case the string */ + for (p = oopsbuf ; *p != '\0' ; ++p) + *p = (vocisupper(*p) ? tolower(*p) : *p); - /* skip leading spaces */ - for (p = oopsbuf ; vocisspace(*p) ; ++p) ; + /* skip leading spaces */ + for (p = oopsbuf ; vocisspace(*p) ; ++p) ; - /* - * See if they are saying "oops". Allow "oops" or simply "o", - * followed by either a space or a comma. - */ - if ((strlen(p) > 5 && memcmp(p, "oops ", 5) == 0) - || (strlen(p) > 5 && memcmp(p, "oops,", 5) == 0)) - { - /* we found "OOPS" - move to the next character */ - p += 5; - } - else if ((strlen(p) > 2 && memcmp(p, "o ", 2) == 0) - || (strlen(p) > 2 && memcmp(p, "o,", 2) == 0)) - { - /* we found "O" - move to the next character */ - p += 2; - } - else - { - /* - * we didn't find any form of "OOPS" response - return null to - * indicate to the caller that the player entered a new command - */ - return 0; - } + /* + * See if they are saying "oops". Allow "oops" or simply "o", + * followed by either a space or a comma. + */ + if ((strlen(p) > 5 && memcmp(p, "oops ", 5) == 0) + || (strlen(p) > 5 && memcmp(p, "oops,", 5) == 0)) + { + /* we found "OOPS" - move to the next character */ + p += 5; + } + else if ((strlen(p) > 2 && memcmp(p, "o ", 2) == 0) + || (strlen(p) > 2 && memcmp(p, "o,", 2) == 0)) + { + /* we found "O" - move to the next character */ + p += 2; + } + else + { + /* + * we didn't find any form of "OOPS" response - return null to + * indicate to the caller that the player entered a new command + */ + return 0; + } - /* skip spaces before the replacement text */ - for ( ; vocisspace(*p) ; ++p) ; + /* skip spaces before the replacement text */ + for ( ; vocisspace(*p) ; ++p) ; - /* return a pointer to the start of the replacement text */ - return p; + /* return a pointer to the start of the replacement text */ + return p; } /* ------------------------------------------------------------------------ */ @@ -1616,264 +1616,264 @@ static char *voc_read_oops(voccxdef *ctx, char *oopsbuf, size_t oopsbuflen, */ int vocgtyp(voccxdef *ctx, char *cmd[], int types[], char *orgbuf) { - int cur; - int t; - char *p; - int len; - int unknown_count = 0; - + int cur; + int t; + char *p; + int len; + int unknown_count = 0; + startover: - if (ctx->voccxflg & VOCCXFDBG) - tioputs(ctx->vocxtio, ". Checking words:\\n"); + if (ctx->voccxflg & VOCCXFDBG) + tioputs(ctx->vocxtio, ". Checking words:\\n"); - for (cur = 0 ; cmd[cur] ; ++cur) - { - /* get the word */ - p = cmd[cur]; - len = strlen(p); + for (cur = 0 ; cmd[cur] ; ++cur) + { + /* get the word */ + p = cmd[cur]; + len = strlen(p); - /* look it up */ - t = voc_lookup_type(ctx, p, len, FALSE); - - /* see if the word was found */ - if (t == 0 && !voc_check_special(ctx, p, VOCW_OF)) - { - /* - * We didn't find the word. For now, set its type to - * "unknown". - */ - t = VOCT_UNKNOWN; + /* look it up */ + t = voc_lookup_type(ctx, p, len, FALSE); + + /* see if the word was found */ + if (t == 0 && !voc_check_special(ctx, p, VOCW_OF)) + { + /* + * We didn't find the word. For now, set its type to + * "unknown". + */ + t = VOCT_UNKNOWN; - /* - * If the unknown word count is already non-zero, it means - * that we've tried to let the game resolve this word using - * the parseUnknownDobj/Iobj mechanism, but it wasn't able - * to do so, thus we've come back here to use the normal - * "oops" processing instead. - * - * Don't generate a message until we get to the first - * unknown word from the original list that we weren't able - * to resolve. We may have been able to handle one or more - * of the original list of unknown words (through - * parseNounPhrase or other means), so we don't want to - * generate a message for any words we ended up handling. - * The number we resolved is the last full unknown count - * minus the remaining unknown count. - */ - if (ctx->voccxunknown != 0 - && unknown_count >= ctx->voccxlastunk - ctx->voccxunknown) - { - char oopsbuf[VOCBUFSIZ]; - char *p1; - - /* - * we can try using the parseUnknownDobj/Iobj again - * after this, so clear the unknown word count for now - */ - ctx->voccxunknown = 0; + /* + * If the unknown word count is already non-zero, it means + * that we've tried to let the game resolve this word using + * the parseUnknownDobj/Iobj mechanism, but it wasn't able + * to do so, thus we've come back here to use the normal + * "oops" processing instead. + * + * Don't generate a message until we get to the first + * unknown word from the original list that we weren't able + * to resolve. We may have been able to handle one or more + * of the original list of unknown words (through + * parseNounPhrase or other means), so we don't want to + * generate a message for any words we ended up handling. + * The number we resolved is the last full unknown count + * minus the remaining unknown count. + */ + if (ctx->voccxunknown != 0 + && unknown_count >= ctx->voccxlastunk - ctx->voccxunknown) + { + char oopsbuf[VOCBUFSIZ]; + char *p1; + + /* + * we can try using the parseUnknownDobj/Iobj again + * after this, so clear the unknown word count for now + */ + ctx->voccxunknown = 0; - /* display an error, and ask for a new command */ - p1 = voc_read_oops(ctx, oopsbuf, sizeof(oopsbuf), p); + /* display an error, and ask for a new command */ + p1 = voc_read_oops(ctx, oopsbuf, sizeof(oopsbuf), p); - /* if they responded with replacement text, apply it */ - if (p1 != 0) - { - char redobuf[200]; - char *q; - int i; - int wc; - char **w; - char *outp; - - /* - * copy words from the original string, replacing - * the unknown word with what follows the "oops" in - * the new command - */ - for (outp = redobuf, i = 0, w = cmd ; *w != 0 ; ++i, ++w) - { - - /* see what we have */ - if (i == cur) - { - /* - * We've reached the word to be replaced. - * Ignore the original token, and replace it - * with the word or words from the OOPS - * command - */ - for (q = p1, len = 0 ; - *q != '\0' && *q != '.' && *q != ',' - && *q != '?' && *q != '!' ; ++q, ++len) ; - memcpy(outp, p1, (size_t)len); - outp += len; - } - else if (**w == '"') - { - char *strp; - char *p2; - char qu; - int rem; + /* if they responded with replacement text, apply it */ + if (p1 != 0) + { + char redobuf[200]; + char *q; + int i; + int wc; + char **w; + char *outp; + + /* + * copy words from the original string, replacing + * the unknown word with what follows the "oops" in + * the new command + */ + for (outp = redobuf, i = 0, w = cmd ; *w != 0 ; ++i, ++w) + { + + /* see what we have */ + if (i == cur) + { + /* + * We've reached the word to be replaced. + * Ignore the original token, and replace it + * with the word or words from the OOPS + * command + */ + for (q = p1, len = 0 ; + *q != '\0' && *q != '.' && *q != ',' + && *q != '?' && *q != '!' ; ++q, ++len) ; + memcpy(outp, p1, (size_t)len); + outp += len; + } + else if (**w == '"') + { + char *strp; + char *p2; + char qu; + int rem; - /* - * It's a string - add a quote mark, then - * copy the string as indicated by the - * length prefix, then add another quote - * mark. Get the length by reading the - * length prefix following the quote mark, - * and get a pointer to the text of the - * string, which immediately follows the - * length prefix. - */ - len = osrp2(*w + 1) - 2; - strp = *w + 3; + /* + * It's a string - add a quote mark, then + * copy the string as indicated by the + * length prefix, then add another quote + * mark. Get the length by reading the + * length prefix following the quote mark, + * and get a pointer to the text of the + * string, which immediately follows the + * length prefix. + */ + len = osrp2(*w + 1) - 2; + strp = *w + 3; - /* - * We need to figure out what kind of quote - * mark to use. If the string contains any - * embedded double quotes, use single quotes - * to delimit the string; otherwise, use - * double quotes. Presume we'll use double - * quotes as the delimiter, then scan the - * string for embedded double quotes. - */ - for (qu = '"', p2 = strp, rem = len ; rem != 0 ; - --rem, ++p2) - { - /* - * if this is an embedded double quote, - * use single quotes to delimite the - * string - */ - if (*p2 == '"') - { - /* use single quotes as delimiters */ - qu = '\''; + /* + * We need to figure out what kind of quote + * mark to use. If the string contains any + * embedded double quotes, use single quotes + * to delimit the string; otherwise, use + * double quotes. Presume we'll use double + * quotes as the delimiter, then scan the + * string for embedded double quotes. + */ + for (qu = '"', p2 = strp, rem = len ; rem != 0 ; + --rem, ++p2) + { + /* + * if this is an embedded double quote, + * use single quotes to delimite the + * string + */ + if (*p2 == '"') + { + /* use single quotes as delimiters */ + qu = '\''; - /* no need to look any further */ - break; - } - } + /* no need to look any further */ + break; + } + } - /* add the open quote */ - *outp++ = qu; + /* add the open quote */ + *outp++ = qu; - /* copy the string */ - memcpy(outp, strp, len); - outp += len; + /* copy the string */ + memcpy(outp, strp, len); + outp += len; - /* add the close quote */ - *outp++ = qu; - } - else - { - /* - * it's an ordinary token - copy the - * null-terminated string for the token from - * the original command list - */ - len = strlen(*w); - memcpy(outp, *w, (size_t)len); - outp += len; - } + /* add the close quote */ + *outp++ = qu; + } + else + { + /* + * it's an ordinary token - copy the + * null-terminated string for the token from + * the original command list + */ + len = strlen(*w); + memcpy(outp, *w, (size_t)len); + outp += len; + } - /* add a space between words */ - *outp++ = ' '; - } - - /* terminate the new string */ - *outp = '\0'; - - /* try tokenizing the string */ - *(cmd[0]) = '\0'; - if ((wc = voctok(ctx, redobuf, cmd[0], - cmd, FALSE, FALSE, TRUE)) <= 0) - return 1; - cmd[wc] = 0; + /* add a space between words */ + *outp++ = ' '; + } + + /* terminate the new string */ + *outp = '\0'; + + /* try tokenizing the string */ + *(cmd[0]) = '\0'; + if ((wc = voctok(ctx, redobuf, cmd[0], + cmd, FALSE, FALSE, TRUE)) <= 0) + return 1; + cmd[wc] = 0; - /* start over with the typing */ - goto startover; - } - else - { - /* - * They didn't start the command with "oops", so - * this must be a brand new command. Replace the - * original command with the new command. - */ - strcpy(orgbuf, oopsbuf); + /* start over with the typing */ + goto startover; + } + else + { + /* + * They didn't start the command with "oops", so + * this must be a brand new command. Replace the + * original command with the new command. + */ + strcpy(orgbuf, oopsbuf); - /* - * forget we had an unknown word so that we're sure - * to start over with a new command - */ - ctx->voccxunknown = 0; - - /* - * set the "redo" flag to start over with the new - * command - */ - ctx->voccxredo = 1; - - /* - * return an error to indicate the current command - * has been aborted - */ - return 1; - } - } - else - { - /* - * We've now encountered an unknown word, and we're - * going to defer resolution. Remember this; we'll - * count the unknown word in the context when we return - * (do so only locally for now, since we may encounter - * more unknown words before we return, in which case we - * want to know that this is still the first pass). - */ - ++unknown_count; - } - } + /* + * forget we had an unknown word so that we're sure + * to start over with a new command + */ + ctx->voccxunknown = 0; + + /* + * set the "redo" flag to start over with the new + * command + */ + ctx->voccxredo = 1; + + /* + * return an error to indicate the current command + * has been aborted + */ + return 1; + } + } + else + { + /* + * We've now encountered an unknown word, and we're + * going to defer resolution. Remember this; we'll + * count the unknown word in the context when we return + * (do so only locally for now, since we may encounter + * more unknown words before we return, in which case we + * want to know that this is still the first pass). + */ + ++unknown_count; + } + } - /* display if in debug mode */ - if (ctx->voccxflg & VOCCXFDBG) - { - char buf[128]; - size_t i; - //char *p; - int cnt; - - (void)tioshow(ctx->voccxtio); - sprintf(buf, "... %s (", cmd[cur]); - p = buf + strlen(buf); - cnt = 0; - for (i = 0 ; i < sizeof(type_names)/sizeof(type_names[0]) ; ++i) - { - if (t & (1 << i)) - { - if (cnt) *p++ = ','; - strcpy(p, type_names[i]); - p += strlen(p); - ++cnt; - } - } - *p++ = ')'; - *p++ = '\\'; - *p++ = 'n'; - *p = '\0'; - tioputs(ctx->voccxtio, buf); - } - - types[cur] = t; /* record type of this word */ - } + /* display if in debug mode */ + if (ctx->voccxflg & VOCCXFDBG) + { + char buf[128]; + size_t i; + //char *p; + int cnt; + + (void)tioshow(ctx->voccxtio); + sprintf(buf, "... %s (", cmd[cur]); + p = buf + strlen(buf); + cnt = 0; + for (i = 0 ; i < sizeof(type_names)/sizeof(type_names[0]) ; ++i) + { + if (t & (1 << i)) + { + if (cnt) *p++ = ','; + strcpy(p, type_names[i]); + p += strlen(p); + ++cnt; + } + } + *p++ = ')'; + *p++ = '\\'; + *p++ = 'n'; + *p = '\0'; + tioputs(ctx->voccxtio, buf); + } + + types[cur] = t; /* record type of this word */ + } - /* if we found any unknown words, note this in our context */ - ctx->voccxunknown = unknown_count; - ctx->voccxlastunk = unknown_count; - - /* successful acquisition of types */ - return 0; + /* if we found any unknown words, note this in our context */ + ctx->voccxunknown = unknown_count; + ctx->voccxlastunk = unknown_count; + + /* successful acquisition of types */ + return 0; } /* @@ -1882,21 +1882,21 @@ startover: */ static int vocisect(objnum *list1, objnum *list2) { - int i, j, k; + int i, j, k; - for (i = k = 0 ; list1[i] != MCMONINV ; ++i) - { - for (j = 0 ; list2[j] != MCMONINV ; ++j) - { - if (list1[i] == list2[j]) - { - list1[k++] = list1[i]; - break; - } - } - } - list1[k] = MCMONINV; - return(k); + for (i = k = 0 ; list1[i] != MCMONINV ; ++i) + { + for (j = 0 ; list2[j] != MCMONINV ; ++j) + { + if (list1[i] == list2[j]) + { + list1[k++] = list1[i]; + break; + } + } + } + list1[k] = MCMONINV; + return(k); } /* @@ -1904,25 +1904,25 @@ static int vocisect(objnum *list1, objnum *list2) * two lists for any matching object are OR'd together. */ static int vocisect_flags(objnum *list1, uint *flags1, - objnum *list2, uint *flags2) + objnum *list2, uint *flags2) { - int i, j, k; + int i, j, k; - for (i = k = 0 ; list1[i] != MCMONINV ; ++i) - { - for (j = 0 ; list2[j] != MCMONINV ; ++j) - { - if (list1[i] == list2[j]) - { - list1[k] = list1[i]; - flags1[k] = flags1[i] | flags2[j]; - ++k; - break; - } - } - } - list1[k] = MCMONINV; - return(k); + for (i = k = 0 ; list1[i] != MCMONINV ; ++i) + { + for (j = 0 ; list2[j] != MCMONINV ; ++j) + { + if (list1[i] == list2[j]) + { + list1[k] = list1[i]; + flags1[k] = flags1[i] | flags2[j]; + ++k; + break; + } + } + } + list1[k] = MCMONINV; + return(k); } /* @@ -1930,263 +1930,263 @@ static int vocisect_flags(objnum *list1, uint *flags1, * given word of player input. */ static int vocgol(voccxdef *ctx, objnum *list, uint *flags, char **wrdlst, - int *typlst, int first, int cur, int last, int ofword) + int *typlst, int first, int cur, int last, int ofword) { - const char *wrd; - int typ; - vocwdef *v; - int cnt; - int len; - vocseadef search_ctx; - int try_plural; - int try_noun_before_num; - int try_endadj; - int trying_endadj; - int wrdtyp; + const char *wrd; + int typ; + vocwdef *v; + int cnt; + int len; + vocseadef search_ctx; + int try_plural; + int try_noun_before_num; + int try_endadj; + int trying_endadj; + int wrdtyp; - /* get the current word and its type */ - wrd = wrdlst[cur]; - typ = typlst[cur]; + /* get the current word and its type */ + wrd = wrdlst[cur]; + typ = typlst[cur]; - /* get the length of the word */ - len = strlen(wrd); + /* get the length of the word */ + len = strlen(wrd); - /* - * Get word type: figure out the correct part of speech, given by - * context, for a given word. If it could count as only a - * noun/plural or only an adjective, we use that. If it could count - * as either a noun/plural or an adjective, we will treat it as a - * noun/plural if it is the last word in the name or the last word - * before "of", otherwise as an adjective. - * - * If the word is unknown, treat it as a noun or adjective - treat - * it as part of the current noun phrase. One unknown word renders - * the whole noun phrase unknown. - */ - try_plural = (typ & VOCT_PLURAL); + /* + * Get word type: figure out the correct part of speech, given by + * context, for a given word. If it could count as only a + * noun/plural or only an adjective, we use that. If it could count + * as either a noun/plural or an adjective, we will treat it as a + * noun/plural if it is the last word in the name or the last word + * before "of", otherwise as an adjective. + * + * If the word is unknown, treat it as a noun or adjective - treat + * it as part of the current noun phrase. One unknown word renders + * the whole noun phrase unknown. + */ + try_plural = (typ & VOCT_PLURAL); - /* presume we won't retry this word as an adjective */ - try_endadj = FALSE; + /* presume we won't retry this word as an adjective */ + try_endadj = FALSE; - /* presume we won't retry this as a noun before a number */ - try_noun_before_num = FALSE; + /* presume we won't retry this as a noun before a number */ + try_noun_before_num = FALSE; - /* we're not yet trying with adjective-at-end */ - trying_endadj = FALSE; + /* we're not yet trying with adjective-at-end */ + trying_endadj = FALSE; - /* check to see what parts of speech are defined for this word */ - if ((typ & (VOCT_NOUN | VOCT_PLURAL)) && (typ & VOCT_ADJ)) - { - /* - * This can be either an adjective or a plural/noun. If this is - * the last word in the noun phrase, treat it as a noun/plural if - * possible. Otherwise, treat it as an adjective. - */ - if (cur + 1 == last || cur == ofword - 1) - { - /* - * This is the last word in the entire phrase, or the last word - * before an 'of' (which makes it the last word of its - * subphrase). Treat it as a noun if possible, otherwise as a - * plural - */ - wrdtyp = ((typ & VOCT_NOUN) ? PRP_NOUN : PRP_PLURAL); + /* check to see what parts of speech are defined for this word */ + if ((typ & (VOCT_NOUN | VOCT_PLURAL)) && (typ & VOCT_ADJ)) + { + /* + * This can be either an adjective or a plural/noun. If this is + * the last word in the noun phrase, treat it as a noun/plural if + * possible. Otherwise, treat it as an adjective. + */ + if (cur + 1 == last || cur == ofword - 1) + { + /* + * This is the last word in the entire phrase, or the last word + * before an 'of' (which makes it the last word of its + * subphrase). Treat it as a noun if possible, otherwise as a + * plural + */ + wrdtyp = ((typ & VOCT_NOUN) ? PRP_NOUN : PRP_PLURAL); - /* - * If this can be an adjective, too, make a note to come back - * and try it again as an adjective. We prefer not to end a - * noun phrase with an adjective, but we allow it, since it's - * often convenient to abbreviate a noun phrase to just the - * adjectives (as in TAKE RED, where there's only one object - * nearby to which RED applies). - */ - if ((typ & VOCT_ADJ) != 0) - try_endadj = TRUE; - } - else if ((cur + 2 == last || cur == ofword - 2) - && vocisdigit(wrdlst[cur+1][0])) - { - /* - * This is the second-to-last word, and the last word is - * numeric. In this case, try this word as BOTH a noun and an - * adjective. Try it as an adjective first, but make a note to - * go back and try it again as a noun. - */ - wrdtyp = PRP_ADJ; - try_noun_before_num = TRUE; - } - else - { - /* - * This isn't the last word, so it can only be an adjective. - * Look at it only as an adjective. - */ - wrdtyp = PRP_ADJ; - } - } - else if (typ & VOCT_NOUN) - wrdtyp = PRP_NOUN; - else if (typ & VOCT_UNKNOWN) - wrdtyp = PRP_UNKNOWN; - else - { - /* it's just an adjective */ - wrdtyp = PRP_ADJ; + /* + * If this can be an adjective, too, make a note to come back + * and try it again as an adjective. We prefer not to end a + * noun phrase with an adjective, but we allow it, since it's + * often convenient to abbreviate a noun phrase to just the + * adjectives (as in TAKE RED, where there's only one object + * nearby to which RED applies). + */ + if ((typ & VOCT_ADJ) != 0) + try_endadj = TRUE; + } + else if ((cur + 2 == last || cur == ofword - 2) + && vocisdigit(wrdlst[cur+1][0])) + { + /* + * This is the second-to-last word, and the last word is + * numeric. In this case, try this word as BOTH a noun and an + * adjective. Try it as an adjective first, but make a note to + * go back and try it again as a noun. + */ + wrdtyp = PRP_ADJ; + try_noun_before_num = TRUE; + } + else + { + /* + * This isn't the last word, so it can only be an adjective. + * Look at it only as an adjective. + */ + wrdtyp = PRP_ADJ; + } + } + else if (typ & VOCT_NOUN) + wrdtyp = PRP_NOUN; + else if (typ & VOCT_UNKNOWN) + wrdtyp = PRP_UNKNOWN; + else + { + /* it's just an adjective */ + wrdtyp = PRP_ADJ; - /* - * if this is the last word in the phrase, flag it as an ending - * adjective - */ - if (cur + 1 == last || cur == ofword - 1) - trying_endadj = TRUE; - } + /* + * if this is the last word in the phrase, flag it as an ending + * adjective + */ + if (cur + 1 == last || cur == ofword - 1) + trying_endadj = TRUE; + } - /* display debugger information if appropriate */ - if (ctx->voccxflg & VOCCXFDBG) - { - char buf[128]; + /* display debugger information if appropriate */ + if (ctx->voccxflg & VOCCXFDBG) + { + char buf[128]; - sprintf(buf, "... %s (treating as %s%s)\\n", wrd, - (wrdtyp == PRP_ADJ ? "adjective" : - wrdtyp == PRP_NOUN ? "noun" : - wrdtyp == PRP_INVALID ? "unknown" : "plural"), - (wrdtyp == PRP_NOUN && try_plural ? " + plural" : "")); - tioputs(ctx->vocxtio, buf); - } + sprintf(buf, "... %s (treating as %s%s)\\n", wrd, + (wrdtyp == PRP_ADJ ? "adjective" : + wrdtyp == PRP_NOUN ? "noun" : + wrdtyp == PRP_INVALID ? "unknown" : "plural"), + (wrdtyp == PRP_NOUN && try_plural ? " + plural" : "")); + tioputs(ctx->vocxtio, buf); + } - /* if this is an unknown word, it doesn't have any objects */ - if (wrdtyp == PRP_UNKNOWN) - { - list[0] = MCMONINV; - return 0; - } + /* if this is an unknown word, it doesn't have any objects */ + if (wrdtyp == PRP_UNKNOWN) + { + list[0] = MCMONINV; + return 0; + } - /* we have nothing in the list yet */ - cnt = 0; + /* we have nothing in the list yet */ + cnt = 0; add_words: - for (v = vocffw(ctx, wrd, len, (char *)0, 0, wrdtyp, &search_ctx) - ; v != 0 ; v = vocfnw(ctx, &search_ctx)) - { - int i; + for (v = vocffw(ctx, wrd, len, (char *)0, 0, wrdtyp, &search_ctx) + ; v != 0 ; v = vocfnw(ctx, &search_ctx)) + { + int i; - /* add the matching object to the output list */ - list[cnt] = v->vocwobj; + /* add the matching object to the output list */ + list[cnt] = v->vocwobj; - /* clear the flags */ - flags[cnt] = 0; + /* clear the flags */ + flags[cnt] = 0; - /* set the PLURAL flag if this is the plural vocabulary usage */ - if (wrdtyp == PRP_PLURAL) - flags[cnt] |= VOCS_PLURAL; + /* set the PLURAL flag if this is the plural vocabulary usage */ + if (wrdtyp == PRP_PLURAL) + flags[cnt] |= VOCS_PLURAL; - /* set the ADJECTIVE AT END flag if appropriate */ - if (wrdtyp == PRP_ADJ && trying_endadj) - flags[cnt] |= VOCS_ENDADJ; + /* set the ADJECTIVE AT END flag if appropriate */ + if (wrdtyp == PRP_ADJ && trying_endadj) + flags[cnt] |= VOCS_ENDADJ; - /* - * if this is not an exact match for the word, but is merely a - * long-enough leading substring, flag it as truncated - */ - if (len < search_ctx.v->voclen) - flags[cnt] |= VOCS_TRUNC; + /* + * if this is not an exact match for the word, but is merely a + * long-enough leading substring, flag it as truncated + */ + if (len < search_ctx.v->voclen) + flags[cnt] |= VOCS_TRUNC; - /* count the additional word in the list */ - ++cnt; + /* count the additional word in the list */ + ++cnt; - /* - * if this object is already in the list with the same flags, - * don't add it again - */ - for (i = 0 ; i < cnt - 1 ; ++i) - { - /* check for an identical entry */ - if (list[i] == list[cnt-1] && flags[i] == flags[cnt-1]) - { - /* take it back out of the list */ - --cnt; + /* + * if this object is already in the list with the same flags, + * don't add it again + */ + for (i = 0 ; i < cnt - 1 ; ++i) + { + /* check for an identical entry */ + if (list[i] == list[cnt-1] && flags[i] == flags[cnt-1]) + { + /* take it back out of the list */ + --cnt; - /* no need to continue looking for the duplicate */ - break; - } - } + /* no need to continue looking for the duplicate */ + break; + } + } - /* make sure we haven't overflowed the list */ - if (cnt >= VOCMAXAMBIG) - { - vocerr(ctx, VOCERR(3), - "The word \"%s\" refers to too many objects.", wrd); - list[0] = MCMONINV; - return -1; - } - } + /* make sure we haven't overflowed the list */ + if (cnt >= VOCMAXAMBIG) + { + vocerr(ctx, VOCERR(3), + "The word \"%s\" refers to too many objects.", wrd); + list[0] = MCMONINV; + return -1; + } + } - /* - * if we want to go back and try the word again as a noun before a - * number (as in "button 5"), do so now - */ - if (try_noun_before_num && wrdtyp == PRP_ADJ) - { - /* change the word type to noun */ - wrdtyp = PRP_NOUN; + /* + * if we want to go back and try the word again as a noun before a + * number (as in "button 5"), do so now + */ + if (try_noun_before_num && wrdtyp == PRP_ADJ) + { + /* change the word type to noun */ + wrdtyp = PRP_NOUN; - /* don't try this again */ - try_noun_before_num = FALSE; + /* don't try this again */ + try_noun_before_num = FALSE; - /* add the words for the noun usage */ - goto add_words; - } + /* add the words for the noun usage */ + goto add_words; + } - /* - * if we're interpreting the word as a noun, and the word can be a - * plural, add in the plural interpretation as well - */ - if (try_plural && wrdtyp != PRP_PLURAL) - { - /* change the word type to plural */ - wrdtyp = PRP_PLURAL; + /* + * if we're interpreting the word as a noun, and the word can be a + * plural, add in the plural interpretation as well + */ + if (try_plural && wrdtyp != PRP_PLURAL) + { + /* change the word type to plural */ + wrdtyp = PRP_PLURAL; - /* don't try plurals again */ - try_plural = FALSE; + /* don't try plurals again */ + try_plural = FALSE; - /* add the words for the plural usage */ - goto add_words; - } + /* add the words for the plural usage */ + goto add_words; + } - /* - * if this was the last word in the phrase, and it could have been - * an adjective, try it again as an adjective - */ - if (try_endadj && wrdtyp != PRP_ADJ) - { - /* change the word type to adjective */ - wrdtyp = PRP_ADJ; + /* + * if this was the last word in the phrase, and it could have been + * an adjective, try it again as an adjective + */ + if (try_endadj && wrdtyp != PRP_ADJ) + { + /* change the word type to adjective */ + wrdtyp = PRP_ADJ; - /* note that we're retrying as an adjective */ - trying_endadj = TRUE; + /* note that we're retrying as an adjective */ + trying_endadj = TRUE; - /* don't try this again */ - try_endadj = FALSE; + /* don't try this again */ + try_endadj = FALSE; - /* add the words for the adjective usage */ - goto add_words; - } + /* add the words for the adjective usage */ + goto add_words; + } - /* - * If we're interpreting the word as an adjective, and it's - * numeric, include objects with "#" in their adjective list -- - * these objects allow arbitrary numbers as adjectives. Don't do - * this if there's only the one word. - */ - if (vocisdigit(wrd[0]) && wrdtyp == PRP_ADJ && first + 1 != last) - { - wrd = "#"; - len = 1; - goto add_words; - } + /* + * If we're interpreting the word as an adjective, and it's + * numeric, include objects with "#" in their adjective list -- + * these objects allow arbitrary numbers as adjectives. Don't do + * this if there's only the one word. + */ + if (vocisdigit(wrd[0]) && wrdtyp == PRP_ADJ && first + 1 != last) + { + wrd = "#"; + len = 1; + goto add_words; + } - list[cnt] = MCMONINV; - return cnt; + list[cnt] = MCMONINV; + return cnt; } /* @@ -2195,15 +2195,15 @@ add_words: */ static void vocaddof(voccxdef *ctx, char *buf) { - if (ctx->voccxspp) - { - size_t len = ctx->voccxspp[1]; - size_t oldlen = strlen(buf); - memcpy(buf + oldlen, ctx->voccxspp + 2, len); - buf[len + oldlen] = '\0'; - } - else - strcat(buf, "of"); + if (ctx->voccxspp) + { + size_t len = ctx->voccxspp[1]; + size_t oldlen = strlen(buf); + memcpy(buf + oldlen, ctx->voccxspp + 2, len); + buf[len + oldlen] = '\0'; + } + else + strcat(buf, "of"); } /* ------------------------------------------------------------------------ */ @@ -2217,194 +2217,194 @@ static void vocaddof(voccxdef *ctx, char *buf) * list to use. */ static int voc_pnp_hook(voccxdef *ctx, char *cmd[], int typelist[], - int cur, int *next, int complain, - vocoldef *out_nounlist, int *out_nouncount, - int chkact, int *no_match) + int cur, int *next, int complain, + vocoldef *out_nounlist, int *out_nouncount, + int chkact, int *no_match) { - runcxdef *rcx = ctx->voccxrun; - runsdef val; - int wordcnt; - char **cmdp; - int outcnt; - vocoldef *outp; - int i; + runcxdef *rcx = ctx->voccxrun; + runsdef val; + int wordcnt; + char **cmdp; + int outcnt; + vocoldef *outp; + int i; - /* if parseNounPhrase isn't defined, use the default handling */ - if (ctx->voccxpnp == MCMONINV) - return VOC_PNP_DEFAULT; + /* if parseNounPhrase isn't defined, use the default handling */ + if (ctx->voccxpnp == MCMONINV) + return VOC_PNP_DEFAULT; - /* push the actor-check flag */ - val.runstyp = (chkact ? DAT_TRUE : DAT_NIL); - runpush(rcx, val.runstyp, &val); + /* push the actor-check flag */ + val.runstyp = (chkact ? DAT_TRUE : DAT_NIL); + runpush(rcx, val.runstyp, &val); - /* push the complain flag */ - val.runstyp = (complain ? DAT_TRUE : DAT_NIL); - runpush(rcx, val.runstyp, &val); + /* push the complain flag */ + val.runstyp = (complain ? DAT_TRUE : DAT_NIL); + runpush(rcx, val.runstyp, &val); - /* push the current index (adjusted to 1-based user convention) */ - runpnum(rcx, cur + 1); + /* push the current index (adjusted to 1-based user convention) */ + runpnum(rcx, cur + 1); - /* count the entries in the command list */ - for (wordcnt = 0, cmdp = cmd ; *cmdp != 0 && **cmdp != '\0' ; - ++wordcnt, ++cmdp) ; + /* count the entries in the command list */ + for (wordcnt = 0, cmdp = cmd ; *cmdp != 0 && **cmdp != '\0' ; + ++wordcnt, ++cmdp) ; - /* push the type list */ - voc_push_numlist(ctx, (uint *)typelist, wordcnt); + /* push the type list */ + voc_push_numlist(ctx, (uint *)typelist, wordcnt); - /* push the command word list */ - voc_push_strlist_arr(ctx, cmd, wordcnt); + /* push the command word list */ + voc_push_strlist_arr(ctx, cmd, wordcnt); - /* call the method */ - runfn(rcx, ctx->voccxpnp, 5); + /* call the method */ + runfn(rcx, ctx->voccxpnp, 5); - /* check the return value */ - if (runtostyp(rcx) == DAT_NUMBER) - { - /* return the status code directly from the hook function */ - return (int)runpopnum(rcx); - } - else if (runtostyp(rcx) == DAT_LIST) - { - uchar *lstp; - uint lstsiz; - - /* pop the list */ - lstp = runpoplst(rcx); + /* check the return value */ + if (runtostyp(rcx) == DAT_NUMBER) + { + /* return the status code directly from the hook function */ + return (int)runpopnum(rcx); + } + else if (runtostyp(rcx) == DAT_LIST) + { + uchar *lstp; + uint lstsiz; + + /* pop the list */ + lstp = runpoplst(rcx); - /* read and skip the size prefix */ - lstsiz = osrp2(lstp); - lstsiz -= 2; - lstp += 2; + /* read and skip the size prefix */ + lstsiz = osrp2(lstp); + lstsiz -= 2; + lstp += 2; - /* the first element should be the next index */ - if (lstsiz > 1 && *lstp == DAT_NUMBER) - { - /* set the 'next' pointer, adjusting to 0-based indexing */ - *next = osrp4(lstp+1) - 1; + /* the first element should be the next index */ + if (lstsiz > 1 && *lstp == DAT_NUMBER) + { + /* set the 'next' pointer, adjusting to 0-based indexing */ + *next = osrp4(lstp+1) - 1; - /* - * If 'next' is out of range, force it into range. We can't - * go backwards (so 'next' must always be at least 'cur'), - * and we can't go past the null element at the end of the - * list. - */ - if (*next < cur) - *next = cur; - else if (*next > wordcnt) - *next = wordcnt; + /* + * If 'next' is out of range, force it into range. We can't + * go backwards (so 'next' must always be at least 'cur'), + * and we can't go past the null element at the end of the + * list. + */ + if (*next < cur) + *next = cur; + else if (*next > wordcnt) + *next = wordcnt; - /* skip the list entry */ - lstadv(&lstp, &lstsiz); - } - else - { - /* ignore the list and use the default parsing */ - return VOC_PNP_DEFAULT; - } + /* skip the list entry */ + lstadv(&lstp, &lstsiz); + } + else + { + /* ignore the list and use the default parsing */ + return VOC_PNP_DEFAULT; + } - /* read the list entries and store them in the output array */ - for (outcnt = 0, outp = out_nounlist ; lstsiz > 0 ; ) - { - /* make sure we have room for another entry */ - if (outcnt >= VOCMAXAMBIG - 1) - break; - - /* get the next list entry, and store it in the output array */ - if (*lstp == DAT_NIL) - { - /* set the list entry */ - outp->vocolobj = MCMONINV; + /* read the list entries and store them in the output array */ + for (outcnt = 0, outp = out_nounlist ; lstsiz > 0 ; ) + { + /* make sure we have room for another entry */ + if (outcnt >= VOCMAXAMBIG - 1) + break; + + /* get the next list entry, and store it in the output array */ + if (*lstp == DAT_NIL) + { + /* set the list entry */ + outp->vocolobj = MCMONINV; - /* skip the entry */ - lstadv(&lstp, &lstsiz); - } - else if (*lstp == DAT_OBJECT) - { - /* set the list entry */ - outp->vocolobj = osrp2(lstp+1); + /* skip the entry */ + lstadv(&lstp, &lstsiz); + } + else if (*lstp == DAT_OBJECT) + { + /* set the list entry */ + outp->vocolobj = osrp2(lstp+1); - /* skip the list entry */ - lstadv(&lstp, &lstsiz); - } - else - { - /* ignore other types in the list */ - lstadv(&lstp, &lstsiz); - continue; - } + /* skip the list entry */ + lstadv(&lstp, &lstsiz); + } + else + { + /* ignore other types in the list */ + lstadv(&lstp, &lstsiz); + continue; + } - /* check for a flag entry */ - if (lstsiz > 0 && *lstp == DAT_NUMBER) - { - /* set the flags */ - outp->vocolflg = (int)osrp4(lstp+1); - - /* skip the number */ - lstadv(&lstp, &lstsiz); - } - else - { - /* no flags were specified - use the default */ - outp->vocolflg = 0; - } + /* check for a flag entry */ + if (lstsiz > 0 && *lstp == DAT_NUMBER) + { + /* set the flags */ + outp->vocolflg = (int)osrp4(lstp+1); + + /* skip the number */ + lstadv(&lstp, &lstsiz); + } + else + { + /* no flags were specified - use the default */ + outp->vocolflg = 0; + } - /* set the word list boundaries */ - outp->vocolfst = cmd[cur]; - outp->vocollst = cmd[*next - 1]; + /* set the word list boundaries */ + outp->vocolfst = cmd[cur]; + outp->vocollst = cmd[*next - 1]; - /* count the entry */ - ++outp; - ++outcnt; - } + /* count the entry */ + ++outp; + ++outcnt; + } - /* terminate the list */ - outp->vocolobj = MCMONINV; - outp->vocolflg = 0; + /* terminate the list */ + outp->vocolobj = MCMONINV; + outp->vocolflg = 0; - /* set the output count */ - *out_nouncount = outcnt; + /* set the output count */ + *out_nouncount = outcnt; - /* - * set "no_match" appropriately -- set "no_match" true if we're - * returning an empty list and we parsed one or more words - */ - if (no_match != 0) - *no_match = (outcnt == 0 && *next > cur); + /* + * set "no_match" appropriately -- set "no_match" true if we're + * returning an empty list and we parsed one or more words + */ + if (no_match != 0) + *no_match = (outcnt == 0 && *next > cur); - /* - * Adjust the unknown word count in the context. If the routine - * parsed any unknown words, decrement the unknown word count in - * the context by the number of unknown words parsed, since - * these have now been dealt with. If the return list contains - * any objects flagged as having unknown words, add the count of - * such objects back into the context, since we must still - * resolve these at disambiguation time. - */ - for (i = cur ; i < *next ; ++i) - { - /* if this parsed word was unknown, remove it from the count */ - if ((typelist[i] & VOCT_UNKNOWN) != 0) - --(ctx->voccxunknown); - } - for (i = 0, outp = out_nounlist ; i < outcnt ; ++i) - { - /* if this object has the unknown flag, count it */ - if ((outp->vocolflg & VOCS_UNKNOWN) != 0) - ++(ctx->voccxunknown); - } + /* + * Adjust the unknown word count in the context. If the routine + * parsed any unknown words, decrement the unknown word count in + * the context by the number of unknown words parsed, since + * these have now been dealt with. If the return list contains + * any objects flagged as having unknown words, add the count of + * such objects back into the context, since we must still + * resolve these at disambiguation time. + */ + for (i = cur ; i < *next ; ++i) + { + /* if this parsed word was unknown, remove it from the count */ + if ((typelist[i] & VOCT_UNKNOWN) != 0) + --(ctx->voccxunknown); + } + for (i = 0, outp = out_nounlist ; i < outcnt ; ++i) + { + /* if this object has the unknown flag, count it */ + if ((outp->vocolflg & VOCS_UNKNOWN) != 0) + ++(ctx->voccxunknown); + } - /* indicate that the hook provided a list */ - return VOC_PNP_SUCCESS; - } - else - { - /* - * ignore any other return value - consider others equivalent to - * DEFAULT - */ - rundisc(rcx); - return VOC_PNP_DEFAULT; - } + /* indicate that the hook provided a list */ + return VOC_PNP_SUCCESS; + } + else + { + /* + * ignore any other return value - consider others equivalent to + * DEFAULT + */ + rundisc(rcx); + return VOC_PNP_DEFAULT; + } } /* ------------------------------------------------------------------------ */ @@ -2412,45 +2412,45 @@ static int voc_pnp_hook(voccxdef *ctx, char *cmd[], int typelist[], * Build an object name from the words in a command */ void voc_make_obj_name(voccxdef *ctx, char *namebuf, char *cmd[], - int firstwrd, int lastwrd) + int firstwrd, int lastwrd) { - int i; - - /* run through the range of words, and add them to the buffer */ - for (i = firstwrd, namebuf[0] = '\0' ; i < lastwrd ; ++i) - { - if (voc_check_special(ctx, cmd[i], VOCW_OF)) - vocaddof(ctx, namebuf); - else - strcat(namebuf, cmd[i]); - - if (cmd[i][strlen(cmd[i])-1] == '.' && i + 1 < lastwrd) - strcat(namebuf, "\\"); + int i; + + /* run through the range of words, and add them to the buffer */ + for (i = firstwrd, namebuf[0] = '\0' ; i < lastwrd ; ++i) + { + if (voc_check_special(ctx, cmd[i], VOCW_OF)) + vocaddof(ctx, namebuf); + else + strcat(namebuf, cmd[i]); + + if (cmd[i][strlen(cmd[i])-1] == '.' && i + 1 < lastwrd) + strcat(namebuf, "\\"); - if (i + 1 < lastwrd) - strcat(namebuf, " "); - } + if (i + 1 < lastwrd) + strcat(namebuf, " "); + } } /* * Make an object name from a list entry */ void voc_make_obj_name_from_list(voccxdef *ctx, char *namebuf, - char *cmd[], const char *firstwrd, const char *lastwrd) + char *cmd[], const char *firstwrd, const char *lastwrd) { - int i, i1, i2; - - /* find the cmd indices */ - for (i = i1 = i2 = 0 ; cmd[i] != 0 && *cmd[i] != 0 ; ++i) - { - if (cmd[i] == firstwrd) - i1 = i; - if (cmd[i] == lastwrd) - i2 = i + 1; - } + int i, i1, i2; + + /* find the cmd indices */ + for (i = i1 = i2 = 0 ; cmd[i] != 0 && *cmd[i] != 0 ; ++i) + { + if (cmd[i] == firstwrd) + i1 = i; + if (cmd[i] == lastwrd) + i2 = i + 1; + } - /* build the name */ - voc_make_obj_name(ctx, namebuf, cmd, i1, i2); + /* build the name */ + voc_make_obj_name(ctx, namebuf, cmd, i1, i2); } @@ -2475,621 +2475,621 @@ void voc_make_obj_name_from_list(voccxdef *ctx, char *namebuf, * syntax but no matching objects, false otherwise. */ static int vocg1o(voccxdef *ctx, char *cmd[], int typelist[], - int cur, int *next, int complain, vocoldef *nounlist, - int chkact, int *no_match) + int cur, int *next, int complain, vocoldef *nounlist, + int chkact, int *no_match) { - int l1; - int firstwrd; - int i; - int ofword = -1; - int hypothetical_last = -1; - int trim_flags = 0; - int outcnt = 0; - objnum *list1; - uint *flags1; - objnum *list2; - uint *flags2; - char *namebuf; - int has_any = FALSE; - uchar *save_sp; - int found_plural; - int unknown_count; - int trying_count = FALSE; - int retry_with_count; + int l1; + int firstwrd; + int i; + int ofword = -1; + int hypothetical_last = -1; + int trim_flags = 0; + int outcnt = 0; + objnum *list1; + uint *flags1; + objnum *list2; + uint *flags2; + char *namebuf; + int has_any = FALSE; + uchar *save_sp; + int found_plural; + int unknown_count; + int trying_count = FALSE; + int retry_with_count; - voc_enter(ctx, &save_sp); - VOC_MAX_ARRAY(ctx, objnum, list1); - VOC_MAX_ARRAY(ctx, uint, flags1); - VOC_MAX_ARRAY(ctx, objnum, list2); - VOC_MAX_ARRAY(ctx, uint, flags2); - VOC_STK_ARRAY(ctx, char, namebuf, VOCBUFSIZ); + voc_enter(ctx, &save_sp); + VOC_MAX_ARRAY(ctx, objnum, list1); + VOC_MAX_ARRAY(ctx, uint, flags1); + VOC_MAX_ARRAY(ctx, objnum, list2); + VOC_MAX_ARRAY(ctx, uint, flags2); + VOC_STK_ARRAY(ctx, char, namebuf, VOCBUFSIZ); - /* presume we'll find a match */ - if (no_match != 0) - *no_match = FALSE; + /* presume we'll find a match */ + if (no_match != 0) + *no_match = FALSE; - /* start at the first word */ - *next = cur; + /* start at the first word */ + *next = cur; - /* if we're at the end of the command, return no objects in list */ - if (cur == -1 || !cmd[cur]) { VOC_RETVAL(ctx, save_sp, 0); } + /* if we're at the end of the command, return no objects in list */ + if (cur == -1 || !cmd[cur]) { VOC_RETVAL(ctx, save_sp, 0); } - /* show trace message if in debug mode */ + /* show trace message if in debug mode */ if (ctx->voccxflg & VOCCXFDBG) { tioputs(ctx->vocxtio, chkact ? ". Checking for actor\\n" : ". Reading noun phrase\\n"); } - /* try the user parseNounPhrase hook */ - switch(voc_pnp_hook(ctx, cmd, typelist, cur, next, complain, - nounlist, &outcnt, chkact, no_match)) - { - case VOC_PNP_DEFAULT: - /* continue on to the default processing */ - break; + /* try the user parseNounPhrase hook */ + switch(voc_pnp_hook(ctx, cmd, typelist, cur, next, complain, + nounlist, &outcnt, chkact, no_match)) + { + case VOC_PNP_DEFAULT: + /* continue on to the default processing */ + break; - case VOC_PNP_ERROR: - default: - /* return an error */ - VOC_RETVAL(ctx, save_sp, -1); + case VOC_PNP_ERROR: + default: + /* return an error */ + VOC_RETVAL(ctx, save_sp, -1); - case VOC_PNP_SUCCESS: - /* use their list */ - VOC_RETVAL(ctx, save_sp, outcnt); - } + case VOC_PNP_SUCCESS: + /* use their list */ + VOC_RETVAL(ctx, save_sp, outcnt); + } - /* check for a quoted string */ - if (*cmd[cur] == '"') - { - /* can't use a quoted string as an actor */ - if (chkact) { VOC_RETVAL(ctx, save_sp, 0); } - - if (ctx->voccxflg & VOCCXFDBG) - tioputs(ctx->vocxtio, "... found quoted string\\n"); + /* check for a quoted string */ + if (*cmd[cur] == '"') + { + /* can't use a quoted string as an actor */ + if (chkact) { VOC_RETVAL(ctx, save_sp, 0); } + + if (ctx->voccxflg & VOCCXFDBG) + tioputs(ctx->vocxtio, "... found quoted string\\n"); - nounlist[outcnt].vocolobj = MCMONINV; - nounlist[outcnt].vocolflg = VOCS_STR; - nounlist[outcnt].vocolfst = nounlist[outcnt].vocollst = cmd[cur]; - *next = ++cur; - ++outcnt; - VOC_RETVAL(ctx, save_sp, outcnt); - } + nounlist[outcnt].vocolobj = MCMONINV; + nounlist[outcnt].vocolflg = VOCS_STR; + nounlist[outcnt].vocolfst = nounlist[outcnt].vocollst = cmd[cur]; + *next = ++cur; + ++outcnt; + VOC_RETVAL(ctx, save_sp, outcnt); + } - /* check for ALL/ANY/BOTH/EITHER [OF] contruction */ - if ((vocspec(cmd[cur], VOCW_ALL) - || vocspec(cmd[cur], VOCW_BOTH) - || vocspec(cmd[cur], VOCW_ANY)) && - cmd[cur+1] != (char *)0) - { - int nxt; - int n = cur+1; - int has_of; + /* check for ALL/ANY/BOTH/EITHER [OF] contruction */ + if ((vocspec(cmd[cur], VOCW_ALL) + || vocspec(cmd[cur], VOCW_BOTH) + || vocspec(cmd[cur], VOCW_ANY)) && + cmd[cur+1] != (char *)0) + { + int nxt; + int n = cur+1; + int has_of; - /* can't use ALL as an actor */ - if (chkact) { VOC_RETVAL(ctx, save_sp, 0); } + /* can't use ALL as an actor */ + if (chkact) { VOC_RETVAL(ctx, save_sp, 0); } - /* remember whether we have "any" or "either" */ - has_any = vocspec(cmd[cur], VOCW_ANY); + /* remember whether we have "any" or "either" */ + has_any = vocspec(cmd[cur], VOCW_ANY); - /* check for optional 'of' */ - if (voc_check_special(ctx, cmd[n], VOCW_OF)) - { - if (ctx->voccxflg & VOCCXFDBG) - tioputs(ctx->vocxtio, "... found ALL/ANY/BOTH/EITHER OF\\n"); + /* check for optional 'of' */ + if (voc_check_special(ctx, cmd[n], VOCW_OF)) + { + if (ctx->voccxflg & VOCCXFDBG) + tioputs(ctx->vocxtio, "... found ALL/ANY/BOTH/EITHER OF\\n"); - has_of = TRUE; - n++; - if (!cmd[n]) - { - const char *p; - int ver; - - if (vocspec(cmd[cur], VOCW_ALL)) - { - ver = VOCERR(4); - p = "I think you left something out after \"all of\"."; - } - else if (vocspec(cmd[cur], VOCW_ANY)) - { - ver = VOCERR(29); - p = "I think you left something out after \"any of\"."; - } - else - { - ver = VOCERR(5); - p = "There's something missing after \"both of\"."; - } - vocerr(ctx, ver, p); - VOC_RETVAL(ctx, save_sp, -1); - } - } - else - has_of = FALSE; + has_of = TRUE; + n++; + if (!cmd[n]) + { + const char *p; + int ver; + + if (vocspec(cmd[cur], VOCW_ALL)) + { + ver = VOCERR(4); + p = "I think you left something out after \"all of\"."; + } + else if (vocspec(cmd[cur], VOCW_ANY)) + { + ver = VOCERR(29); + p = "I think you left something out after \"any of\"."; + } + else + { + ver = VOCERR(5); + p = "There's something missing after \"both of\"."; + } + vocerr(ctx, ver, p); + VOC_RETVAL(ctx, save_sp, -1); + } + } + else + has_of = FALSE; - nxt = n; - if (typelist[n] & VOCT_ARTICLE) ++n; /* skip leading article */ - for ( ;; ) - { - if (!cmd[n]) - break; + nxt = n; + if (typelist[n] & VOCT_ARTICLE) ++n; /* skip leading article */ + for ( ;; ) + { + if (!cmd[n]) + break; - if (voc_check_special(ctx, cmd[n], VOCW_OF)) - { - ++n; - if (!cmd[n]) - { - vocerr(ctx, VOCERR(6), "I expected a noun after \"of\"."); - VOC_RETVAL(ctx, save_sp, -1); - } - if (*cmd[n] & VOCT_ARTICLE) ++n; - } - else if (typelist[n] & (VOCT_ADJ | VOCT_NOUN)) - ++n; - else - break; - } + if (voc_check_special(ctx, cmd[n], VOCW_OF)) + { + ++n; + if (!cmd[n]) + { + vocerr(ctx, VOCERR(6), "I expected a noun after \"of\"."); + VOC_RETVAL(ctx, save_sp, -1); + } + if (*cmd[n] & VOCT_ARTICLE) ++n; + } + else if (typelist[n] & (VOCT_ADJ | VOCT_NOUN)) + ++n; + else + break; + } - /* - * Accept the ALL if the last word is a plural. Accept the ANY - * if either we don't have an OF (ANY NOUN is okay even without - * a plural), or if we have OF and a plural. (More simply put, - * accept the ALL or ANY if the last word is a plural, or if we - * have ANY but not OF). - */ - if (n > cur && ((typelist[n-1] & VOCT_PLURAL) - || (has_any && !has_of))) - { - if (ctx->voccxflg & VOCCXFDBG) - tioputs(ctx->vocxtio, - "... found ALL/ANY/BOTH/EITHER + noun phrase\\n"); + /* + * Accept the ALL if the last word is a plural. Accept the ANY + * if either we don't have an OF (ANY NOUN is okay even without + * a plural), or if we have OF and a plural. (More simply put, + * accept the ALL or ANY if the last word is a plural, or if we + * have ANY but not OF). + */ + if (n > cur && ((typelist[n-1] & VOCT_PLURAL) + || (has_any && !has_of))) + { + if (ctx->voccxflg & VOCCXFDBG) + tioputs(ctx->vocxtio, + "... found ALL/ANY/BOTH/EITHER + noun phrase\\n"); - cur = nxt; - } - } - - if (vocspec(cmd[cur], VOCW_ALL) && !has_any) - { - /* can't use ALL as an actor */ - if (chkact) - { - VOC_RETVAL(ctx, save_sp, 0); - } - - if (ctx->voccxflg & VOCCXFDBG) - tioputs(ctx->vocxtio, "... found ALL\\n"); + cur = nxt; + } + } + + if (vocspec(cmd[cur], VOCW_ALL) && !has_any) + { + /* can't use ALL as an actor */ + if (chkact) + { + VOC_RETVAL(ctx, save_sp, 0); + } + + if (ctx->voccxflg & VOCCXFDBG) + tioputs(ctx->vocxtio, "... found ALL\\n"); - nounlist[outcnt].vocolobj = MCMONINV; - nounlist[outcnt].vocolflg = VOCS_ALL; - nounlist[outcnt].vocolfst = nounlist[outcnt].vocollst = cmd[cur]; - ++outcnt; - ++cur; + nounlist[outcnt].vocolobj = MCMONINV; + nounlist[outcnt].vocolflg = VOCS_ALL; + nounlist[outcnt].vocolfst = nounlist[outcnt].vocollst = cmd[cur]; + ++outcnt; + ++cur; - if (cmd[cur] && vocspec(cmd[cur], VOCW_BUT)) - { - int cnt; - //int i; - vocoldef *xlist; - uchar *inner_save_sp; + if (cmd[cur] && vocspec(cmd[cur], VOCW_BUT)) + { + int cnt; + //int i; + vocoldef *xlist; + uchar *inner_save_sp; - if (ctx->voccxflg & VOCCXFDBG) - tioputs(ctx->vocxtio, "... found ALL EXCEPT\\n"); + if (ctx->voccxflg & VOCCXFDBG) + tioputs(ctx->vocxtio, "... found ALL EXCEPT\\n"); - voc_enter(ctx, &inner_save_sp); - VOC_MAX_ARRAY(ctx, vocoldef, xlist); + voc_enter(ctx, &inner_save_sp); + VOC_MAX_ARRAY(ctx, vocoldef, xlist); - cur++; - cnt = vocgobj(ctx, cmd, typelist, cur, next, complain, xlist, 1, - chkact, 0); - if (cnt < 0) - { - /* - * An error occurred - return it. Note that, since - * we're returning from the entire function, we're - * popping the save_sp frame, NOT the inner_save_sp - * frame -- the inner frame is nested within the save_sp - * frame, and we want to pop the entire way out since - * we're exiting the entire function. - */ - VOC_RETVAL(ctx, save_sp, cnt); - } - cur = *next; - for (i = 0 ; i < cnt ; ++i) - { - OSCPYSTRUCT(nounlist[outcnt], xlist[i]); - nounlist[outcnt].vocolflg |= VOCS_EXCEPT; - ++outcnt; - } + cur++; + cnt = vocgobj(ctx, cmd, typelist, cur, next, complain, xlist, 1, + chkact, 0); + if (cnt < 0) + { + /* + * An error occurred - return it. Note that, since + * we're returning from the entire function, we're + * popping the save_sp frame, NOT the inner_save_sp + * frame -- the inner frame is nested within the save_sp + * frame, and we want to pop the entire way out since + * we're exiting the entire function. + */ + VOC_RETVAL(ctx, save_sp, cnt); + } + cur = *next; + for (i = 0 ; i < cnt ; ++i) + { + OSCPYSTRUCT(nounlist[outcnt], xlist[i]); + nounlist[outcnt].vocolflg |= VOCS_EXCEPT; + ++outcnt; + } - voc_leave(ctx, inner_save_sp); - } - *next = cur; - nounlist[outcnt].vocolobj = MCMONINV; - nounlist[outcnt].vocolflg = 0; - VOC_RETVAL(ctx, save_sp, outcnt); - } - - switch(*cmd[cur]) - { - case VOCW_IT: - nounlist[outcnt].vocolflg = VOCS_IT; - goto do_special; - case VOCW_THEM: - nounlist[outcnt].vocolflg = VOCS_THEM; - goto do_special; - case VOCW_HIM: - nounlist[outcnt].vocolflg = VOCS_HIM; - goto do_special; - case VOCW_HER: - nounlist[outcnt].vocolflg = VOCS_HER; - /* FALLTHRU */ - do_special: - if (ctx->voccxflg & VOCCXFDBG) - tioputs(ctx->vocxtio, "... found pronoun\\n"); + voc_leave(ctx, inner_save_sp); + } + *next = cur; + nounlist[outcnt].vocolobj = MCMONINV; + nounlist[outcnt].vocolflg = 0; + VOC_RETVAL(ctx, save_sp, outcnt); + } + + switch(*cmd[cur]) + { + case VOCW_IT: + nounlist[outcnt].vocolflg = VOCS_IT; + goto do_special; + case VOCW_THEM: + nounlist[outcnt].vocolflg = VOCS_THEM; + goto do_special; + case VOCW_HIM: + nounlist[outcnt].vocolflg = VOCS_HIM; + goto do_special; + case VOCW_HER: + nounlist[outcnt].vocolflg = VOCS_HER; + /* FALLTHRU */ + do_special: + if (ctx->voccxflg & VOCCXFDBG) + tioputs(ctx->vocxtio, "... found pronoun\\n"); - *next = cur + 1; - nounlist[outcnt].vocolobj = MCMONINV; - nounlist[outcnt].vocolfst = nounlist[outcnt].vocollst = cmd[cur]; - ++outcnt; - VOC_RETVAL(ctx, save_sp, outcnt); - default: - break; - } + *next = cur + 1; + nounlist[outcnt].vocolobj = MCMONINV; + nounlist[outcnt].vocolfst = nounlist[outcnt].vocollst = cmd[cur]; + ++outcnt; + VOC_RETVAL(ctx, save_sp, outcnt); + default: + break; + } - if (((typelist[cur] - & (VOCT_ARTICLE | VOCT_ADJ | VOCT_NOUN | VOCT_UNKNOWN)) == 0) - && !vocisdigit(*cmd[cur])) - { - VOC_RETVAL(ctx, save_sp, 0); - } + if (((typelist[cur] + & (VOCT_ARTICLE | VOCT_ADJ | VOCT_NOUN | VOCT_UNKNOWN)) == 0) + && !vocisdigit(*cmd[cur])) + { + VOC_RETVAL(ctx, save_sp, 0); + } - if (typelist[cur] & VOCT_ARTICLE) - { - ++cur; - if (cmd[cur] == (char *)0 - || ((typelist[cur] & (VOCT_ADJ | VOCT_NOUN | VOCT_UNKNOWN)) == 0 - && !vocisdigit(*cmd[cur]))) - { - vocerr(ctx, VOCERR(7), "An article must be followed by a noun."); - *next = cur; - VOC_RETVAL(ctx, save_sp, -1); - } - } + if (typelist[cur] & VOCT_ARTICLE) + { + ++cur; + if (cmd[cur] == (char *)0 + || ((typelist[cur] & (VOCT_ADJ | VOCT_NOUN | VOCT_UNKNOWN)) == 0 + && !vocisdigit(*cmd[cur]))) + { + vocerr(ctx, VOCERR(7), "An article must be followed by a noun."); + *next = cur; + VOC_RETVAL(ctx, save_sp, -1); + } + } - /* start at the current word */ - firstwrd = cur; + /* start at the current word */ + firstwrd = cur; - /* scan words for inclusion in this noun phrase */ - for (found_plural = FALSE, unknown_count = 0, l1 = 0 ; ; ) - { - if (cmd[cur] == (char *)0) - break; + /* scan words for inclusion in this noun phrase */ + for (found_plural = FALSE, unknown_count = 0, l1 = 0 ; ; ) + { + if (cmd[cur] == (char *)0) + break; - if (typelist[cur] & VOCT_ADJ) - ++cur; - else if (typelist[cur] & VOCT_UNKNOWN) - { - /* - * Remember that we found an unknown word, but include it in - * the noun phrase - this will render the entire noun phrase - * unknown, but we'll resolve that later. - */ - ++unknown_count; - ++cur; - } - else if (typelist[cur] & VOCT_NOUN) - { - ++cur; - if (cmd[cur] == (char *)0) break; - if (vocisdigit(*cmd[cur])) ++cur; - if (cmd[cur] == (char *)0) break; - if (!voc_check_special(ctx, cmd[cur], VOCW_OF)) break; - } - else if (vocisdigit(*cmd[cur])) - ++cur; - else if (voc_check_special(ctx, cmd[cur], VOCW_OF)) - { - ++cur; - if (ofword != -1) - { - /* there's already one 'of' - we must be done */ - --cur; - break; - } - ofword = cur-1; - if (typelist[cur] & VOCT_ARTICLE) /* allow article after "of" */ - ++cur; - } - else - break; + if (typelist[cur] & VOCT_ADJ) + ++cur; + else if (typelist[cur] & VOCT_UNKNOWN) + { + /* + * Remember that we found an unknown word, but include it in + * the noun phrase - this will render the entire noun phrase + * unknown, but we'll resolve that later. + */ + ++unknown_count; + ++cur; + } + else if (typelist[cur] & VOCT_NOUN) + { + ++cur; + if (cmd[cur] == (char *)0) break; + if (vocisdigit(*cmd[cur])) ++cur; + if (cmd[cur] == (char *)0) break; + if (!voc_check_special(ctx, cmd[cur], VOCW_OF)) break; + } + else if (vocisdigit(*cmd[cur])) + ++cur; + else if (voc_check_special(ctx, cmd[cur], VOCW_OF)) + { + ++cur; + if (ofword != -1) + { + /* there's already one 'of' - we must be done */ + --cur; + break; + } + ofword = cur-1; + if (typelist[cur] & VOCT_ARTICLE) /* allow article after "of" */ + ++cur; + } + else + break; - /* note whether we found anything that might be a plural */ - if (cmd[cur] != 0 && (typelist[cur] & VOCT_PLURAL) != 0) - found_plural = TRUE; - } + /* note whether we found anything that might be a plural */ + if (cmd[cur] != 0 && (typelist[cur] & VOCT_PLURAL) != 0) + found_plural = TRUE; + } try_again: - /* - * build a printable string consisting of the words in the noun - * phrase, for displaying error messages - */ - voc_make_obj_name(ctx, namebuf, cmd, firstwrd, cur); + /* + * build a printable string consisting of the words in the noun + * phrase, for displaying error messages + */ + voc_make_obj_name(ctx, namebuf, cmd, firstwrd, cur); - /* remember the next word after this noun phrase */ - *next = cur; + /* remember the next word after this noun phrase */ + *next = cur; - /* - * If we have any unknown words, we won't be able to match any - * objects for the noun phrase. Return with one entry in the list, - * but use an invalid object and mark the object as containing - * unknown words. - */ - if (unknown_count > 0) - { - /* - * Add one unknown object for each unknown word. This lets us - * communicate the number of unknown words that we found to the - * disambiguator, which will later attempt to resolve the - * reference. Each object we add is the same; they're here only - * for the word count. - */ - for ( ; unknown_count > 0 ; --unknown_count) - { - nounlist[outcnt].vocolobj = MCMONINV; - nounlist[outcnt].vocolflg = VOCS_UNKNOWN; - nounlist[outcnt].vocolfst = cmd[firstwrd]; - nounlist[outcnt].vocollst = cmd[cur-1]; - ++outcnt; - } - nounlist[outcnt].vocolobj = MCMONINV; - nounlist[outcnt].vocolflg = 0; - VOC_RETVAL(ctx, save_sp, outcnt); - } + /* + * If we have any unknown words, we won't be able to match any + * objects for the noun phrase. Return with one entry in the list, + * but use an invalid object and mark the object as containing + * unknown words. + */ + if (unknown_count > 0) + { + /* + * Add one unknown object for each unknown word. This lets us + * communicate the number of unknown words that we found to the + * disambiguator, which will later attempt to resolve the + * reference. Each object we add is the same; they're here only + * for the word count. + */ + for ( ; unknown_count > 0 ; --unknown_count) + { + nounlist[outcnt].vocolobj = MCMONINV; + nounlist[outcnt].vocolflg = VOCS_UNKNOWN; + nounlist[outcnt].vocolfst = cmd[firstwrd]; + nounlist[outcnt].vocollst = cmd[cur-1]; + ++outcnt; + } + nounlist[outcnt].vocolobj = MCMONINV; + nounlist[outcnt].vocolflg = 0; + VOC_RETVAL(ctx, save_sp, outcnt); + } - /* get the list of objects that match the first word */ - l1 = vocgol(ctx, list1, flags1, cmd, typelist, - firstwrd, firstwrd, cur, ofword); + /* get the list of objects that match the first word */ + l1 = vocgol(ctx, list1, flags1, cmd, typelist, + firstwrd, firstwrd, cur, ofword); - /* - * Allow retrying with a count plus a plural if the first word is a - * number, and we have something plural in the list. Only treat "1" - * this way if more words follow in the noun phrase. - */ - retry_with_count = ((vocisdigit(*cmd[firstwrd]) && found_plural) - || (vocisdigit(*cmd[firstwrd]) - && cur != firstwrd+1 - && atoi(cmd[firstwrd]) == 1)); + /* + * Allow retrying with a count plus a plural if the first word is a + * number, and we have something plural in the list. Only treat "1" + * this way if more words follow in the noun phrase. + */ + retry_with_count = ((vocisdigit(*cmd[firstwrd]) && found_plural) + || (vocisdigit(*cmd[firstwrd]) + && cur != firstwrd+1 + && atoi(cmd[firstwrd]) == 1)); - /* see if we found anything on the first word */ - if (l1 <= 0) - { - if (chkact) { VOC_RETVAL(ctx, save_sp, 0); } + /* see if we found anything on the first word */ + if (l1 <= 0) + { + if (chkact) { VOC_RETVAL(ctx, save_sp, 0); } - if (vocisdigit(*cmd[firstwrd])) - { - if (retry_with_count) - { - /* interpret it as a count plus a plural */ - trying_count = TRUE; + if (vocisdigit(*cmd[firstwrd])) + { + if (retry_with_count) + { + /* interpret it as a count plus a plural */ + trying_count = TRUE; - /* don't try this again */ - retry_with_count = FALSE; - } - else - { - /* not a plural - take the number as the entire noun phrase */ - nounlist[outcnt].vocolobj = MCMONINV; - nounlist[outcnt].vocolflg = VOCS_NUM; - nounlist[outcnt].vocolfst = nounlist[outcnt].vocollst = - cmd[firstwrd]; - *next = firstwrd + 1; - ++outcnt; - nounlist[outcnt].vocolobj = MCMONINV; - nounlist[outcnt].vocolflg = 0; - VOC_RETVAL(ctx, save_sp, outcnt); - } - } - else - { - /* - * display a message if we didn't already (if vocgol - * returned less than zero, it already displayed its own - * error message) - */ - if (l1 == 0) - vocerr(ctx, VOCERR(9), "I don't see any %s here.", namebuf); + /* don't try this again */ + retry_with_count = FALSE; + } + else + { + /* not a plural - take the number as the entire noun phrase */ + nounlist[outcnt].vocolobj = MCMONINV; + nounlist[outcnt].vocolflg = VOCS_NUM; + nounlist[outcnt].vocolfst = nounlist[outcnt].vocollst = + cmd[firstwrd]; + *next = firstwrd + 1; + ++outcnt; + nounlist[outcnt].vocolobj = MCMONINV; + nounlist[outcnt].vocolflg = 0; + VOC_RETVAL(ctx, save_sp, outcnt); + } + } + else + { + /* + * display a message if we didn't already (if vocgol + * returned less than zero, it already displayed its own + * error message) + */ + if (l1 == 0) + vocerr(ctx, VOCERR(9), "I don't see any %s here.", namebuf); - /* return failure */ - VOC_RETVAL(ctx, save_sp, -1); - } - } + /* return failure */ + VOC_RETVAL(ctx, save_sp, -1); + } + } retry_exclude_first: - for (i = firstwrd + 1 ; i < cur ; ++i) - { - int l2; - - if (voc_check_special(ctx, cmd[i], VOCW_OF) - || (typelist[i] & VOCT_ARTICLE)) - continue; + for (i = firstwrd + 1 ; i < cur ; ++i) + { + int l2; + + if (voc_check_special(ctx, cmd[i], VOCW_OF) + || (typelist[i] & VOCT_ARTICLE)) + continue; - /* get the list for this new object */ - l2 = vocgol(ctx, list2, flags2, cmd, typelist, - firstwrd, i, cur, ofword); + /* get the list for this new object */ + l2 = vocgol(ctx, list2, flags2, cmd, typelist, + firstwrd, i, cur, ofword); - /* if that failed and displayed an error, return failure */ - if (l2 < 0) - { - /* return failure */ - VOC_RETVAL(ctx, save_sp, -1); - } + /* if that failed and displayed an error, return failure */ + if (l2 < 0) + { + /* return failure */ + VOC_RETVAL(ctx, save_sp, -1); + } - /* - * Intersect the last list with the new list. If the previous - * list didn't have anything in it, it must mean that the word - * list started with a number, in which case we're trying to - * interpret this as a count plus a plural. So, don't intersect - * the list if there was nothing in the first list. - */ - if (l1 == 0) - { - /* just copy the new list */ - l1 = l2; - memcpy(list1, list2, (size_t)((l1+1) * sizeof(list1[0]))); - memcpy(flags1, flags2, (size_t)(l1 * sizeof(flags1[0]))); - } - else - { - /* intersect the two lists */ - l1 = vocisect_flags(list1, flags1, list2, flags2); - } + /* + * Intersect the last list with the new list. If the previous + * list didn't have anything in it, it must mean that the word + * list started with a number, in which case we're trying to + * interpret this as a count plus a plural. So, don't intersect + * the list if there was nothing in the first list. + */ + if (l1 == 0) + { + /* just copy the new list */ + l1 = l2; + memcpy(list1, list2, (size_t)((l1+1) * sizeof(list1[0]))); + memcpy(flags1, flags2, (size_t)(l1 * sizeof(flags1[0]))); + } + else + { + /* intersect the two lists */ + l1 = vocisect_flags(list1, flags1, list2, flags2); + } - /* - * If there's nothing in the list, it means that there's no - * object that defines all of these words. - */ - if (l1 == 0) - { - if (ctx->voccxflg & VOCCXFDBG) - tioputs(ctx->vocxtio, - "... can't find any objects matching these words\\n"); - /* - * If there's an "of", remove the "of" and everything that - * follows, and go back and reprocess the part up to the - * "of" -- treat it as a sentence that has two objects, with - * "of" as the preposition introducing the indirect object. - */ - if (ofword != -1) - { - if (ctx->voccxflg & VOCCXFDBG) - tioputs(ctx->vocxtio, - "... dropping the part after OF and retrying\\n"); + /* + * If there's nothing in the list, it means that there's no + * object that defines all of these words. + */ + if (l1 == 0) + { + if (ctx->voccxflg & VOCCXFDBG) + tioputs(ctx->vocxtio, + "... can't find any objects matching these words\\n"); + /* + * If there's an "of", remove the "of" and everything that + * follows, and go back and reprocess the part up to the + * "of" -- treat it as a sentence that has two objects, with + * "of" as the preposition introducing the indirect object. + */ + if (ofword != -1) + { + if (ctx->voccxflg & VOCCXFDBG) + tioputs(ctx->vocxtio, + "... dropping the part after OF and retrying\\n"); - /* - * drop the part from 'of' on - scan only from firstwrd - * to the word before 'of' - */ - hypothetical_last = cur; - trim_flags |= VOCS_TRIMPREP; - cur = ofword; + /* + * drop the part from 'of' on - scan only from firstwrd + * to the word before 'of' + */ + hypothetical_last = cur; + trim_flags |= VOCS_TRIMPREP; + cur = ofword; - /* forget that we have an 'of' phrase at all */ - ofword = -1; + /* forget that we have an 'of' phrase at all */ + ofword = -1; - /* retry with the new, shortened phrase */ - goto try_again; - } + /* retry with the new, shortened phrase */ + goto try_again; + } - /* - * Try again with the count + plural interpretation, if - * possible - */ - if (retry_with_count) - { - if (ctx->voccxflg & VOCCXFDBG) - tioputs(ctx->vocxtio, - "... treating the number as a count and retrying\\n"); + /* + * Try again with the count + plural interpretation, if + * possible + */ + if (retry_with_count) + { + if (ctx->voccxflg & VOCCXFDBG) + tioputs(ctx->vocxtio, + "... treating the number as a count and retrying\\n"); - /* we've exhausted our retries */ - retry_with_count = FALSE; - trying_count = TRUE; + /* we've exhausted our retries */ + retry_with_count = FALSE; + trying_count = TRUE; - /* go try it */ - goto retry_exclude_first; - } + /* go try it */ + goto retry_exclude_first; + } - /* - * If one of the words will work as a preposition, and we - * took it as an adjective, go back and try the word again - * as a preposition. - */ - for (i = cur - 1; i > firstwrd ; --i) - { - if (typelist[i] & VOCT_PREP) - { - if (ctx->voccxflg & VOCCXFDBG) - tioputs(ctx->vocxtio, - "... changing word to prep and retrying\\n"); + /* + * If one of the words will work as a preposition, and we + * took it as an adjective, go back and try the word again + * as a preposition. + */ + for (i = cur - 1; i > firstwrd ; --i) + { + if (typelist[i] & VOCT_PREP) + { + if (ctx->voccxflg & VOCCXFDBG) + tioputs(ctx->vocxtio, + "... changing word to prep and retrying\\n"); - hypothetical_last = cur; - trim_flags |= VOCS_TRIMPREP; - cur = i; - goto try_again; - } - } + hypothetical_last = cur; + trim_flags |= VOCS_TRIMPREP; + cur = i; + goto try_again; + } + } - /* if just checking actor, don't display an error */ - if (chkact) { VOC_RETVAL(ctx, save_sp, 0); } + /* if just checking actor, don't display an error */ + if (chkact) { VOC_RETVAL(ctx, save_sp, 0); } - /* - * tell the player about it unless supressing complaints, - * and return an error - */ - if (complain) - vocerr(ctx, VOCERR(9), "I don't see any %s here.", namebuf); - if (no_match != 0) - *no_match = TRUE; - VOC_RETVAL(ctx, save_sp, 0); - } - } + /* + * tell the player about it unless supressing complaints, + * and return an error + */ + if (complain) + vocerr(ctx, VOCERR(9), "I don't see any %s here.", namebuf); + if (no_match != 0) + *no_match = TRUE; + VOC_RETVAL(ctx, save_sp, 0); + } + } - /* - * We have one or more objects, so make a note of how we found - * them. - */ - if (ctx->voccxflg & VOCCXFDBG) - tioputs(ctx->vocxtio, "... found objects matching vocabulary:\\n"); + /* + * We have one or more objects, so make a note of how we found + * them. + */ + if (ctx->voccxflg & VOCCXFDBG) + tioputs(ctx->vocxtio, "... found objects matching vocabulary:\\n"); - /* store the list of objects that match all of our words */ - for (i = 0 ; i < l1 ; ++i) - { - if (ctx->voccxflg & VOCCXFDBG) - { - tioputs(ctx->voccxtio, "..... "); - runppr(ctx->voccxrun, list1[i], PRP_SDESC, 0); - tioflushn(ctx->voccxtio, 1); - } + /* store the list of objects that match all of our words */ + for (i = 0 ; i < l1 ; ++i) + { + if (ctx->voccxflg & VOCCXFDBG) + { + tioputs(ctx->voccxtio, "..... "); + runppr(ctx->voccxrun, list1[i], PRP_SDESC, 0); + tioflushn(ctx->voccxtio, 1); + } - nounlist[outcnt].vocolfst = cmd[firstwrd]; - nounlist[outcnt].vocollst = cmd[cur-1]; - nounlist[outcnt].vocolflg = - flags1[i] | (trying_count ? VOCS_COUNT : 0) | trim_flags; - if (trim_flags) - nounlist[outcnt].vocolhlst = cmd[hypothetical_last - 1]; - if (has_any) - nounlist[outcnt].vocolflg |= VOCS_ANY; - nounlist[outcnt++].vocolobj = list1[i]; - if (outcnt > VOCMAXAMBIG) - { - vocerr(ctx, VOCERR(10), - "You're referring to too many objects with \"%s\".", - namebuf); - VOC_RETVAL(ctx, save_sp, -2); - } - } + nounlist[outcnt].vocolfst = cmd[firstwrd]; + nounlist[outcnt].vocollst = cmd[cur-1]; + nounlist[outcnt].vocolflg = + flags1[i] | (trying_count ? VOCS_COUNT : 0) | trim_flags; + if (trim_flags) + nounlist[outcnt].vocolhlst = cmd[hypothetical_last - 1]; + if (has_any) + nounlist[outcnt].vocolflg |= VOCS_ANY; + nounlist[outcnt++].vocolobj = list1[i]; + if (outcnt > VOCMAXAMBIG) + { + vocerr(ctx, VOCERR(10), + "You're referring to too many objects with \"%s\".", + namebuf); + VOC_RETVAL(ctx, save_sp, -2); + } + } - /* - * If we have a one-word noun phrase, and the word is a number, add - * the number object into the list of objects we're considering, - * even though we found an object that matches. We'll probably - * easily disambiguate this later, but we need to keep open the - * possibility that they're just referring to a number rather than a - * numbered adjective for now. - */ - if (firstwrd + 1 == cur && vocisdigit(*cmd[firstwrd])) - { - /* add just the number as an object */ - nounlist[outcnt].vocolobj = ctx->voccxnum; - nounlist[outcnt].vocolflg = VOCS_NUM; - nounlist[outcnt].vocolfst = nounlist[outcnt].vocollst = - cmd[firstwrd]; - ++outcnt; - } + /* + * If we have a one-word noun phrase, and the word is a number, add + * the number object into the list of objects we're considering, + * even though we found an object that matches. We'll probably + * easily disambiguate this later, but we need to keep open the + * possibility that they're just referring to a number rather than a + * numbered adjective for now. + */ + if (firstwrd + 1 == cur && vocisdigit(*cmd[firstwrd])) + { + /* add just the number as an object */ + nounlist[outcnt].vocolobj = ctx->voccxnum; + nounlist[outcnt].vocolflg = VOCS_NUM; + nounlist[outcnt].vocolfst = nounlist[outcnt].vocollst = + cmd[firstwrd]; + ++outcnt; + } - /* terminate the list */ - nounlist[outcnt].vocolobj = MCMONINV; - nounlist[outcnt].vocolflg = 0; + /* terminate the list */ + nounlist[outcnt].vocolobj = MCMONINV; + nounlist[outcnt].vocolflg = 0; - /* return the number of objects in our match list */ - VOC_RETVAL(ctx, save_sp, outcnt); + /* return the number of objects in our match list */ + VOC_RETVAL(ctx, save_sp, outcnt); } /* @@ -3102,88 +3102,88 @@ retry_exclude_first: * but we didn't find any match for the list of words, false otherwise. */ int vocgobj(voccxdef *ctx, char *cmd[], int typelist[], - int cur, int *next, int complain, vocoldef *nounlist, - int multi, int chkact, int *no_match) + int cur, int *next, int complain, vocoldef *nounlist, + int multi, int chkact, int *no_match) { - int cnt; - int outcnt = 0; - int i; - int again = FALSE; + int cnt; + int outcnt = 0; + int i; + int again = FALSE; int lastcur = 0; - vocoldef *tmplist; - uchar *save_sp; + vocoldef *tmplist; + uchar *save_sp; - voc_enter(ctx, &save_sp); - VOC_MAX_ARRAY(ctx, vocoldef, tmplist); + voc_enter(ctx, &save_sp); + VOC_MAX_ARRAY(ctx, vocoldef, tmplist); - for ( ;; ) - { - /* try getting a single object */ - cnt = vocg1o(ctx, cmd, typelist, cur, next, complain, - tmplist, chkact, no_match); + for ( ;; ) + { + /* try getting a single object */ + cnt = vocg1o(ctx, cmd, typelist, cur, next, complain, + tmplist, chkact, no_match); - /* if we encountered a syntax error, return failure */ - if (cnt < 0) - { - VOC_RETVAL(ctx, save_sp, cnt); - } + /* if we encountered a syntax error, return failure */ + if (cnt < 0) + { + VOC_RETVAL(ctx, save_sp, cnt); + } - /* if we got any objects, store them in our output list */ - if (cnt > 0) - { - for (i = 0 ; i < cnt ; ++i) - { - OSCPYSTRUCT(nounlist[outcnt], tmplist[i]); - if (++outcnt > VOCMAXAMBIG) - { - vocerr(ctx, VOCERR(11), - "You're referring to too many objects."); - VOC_RETVAL(ctx, save_sp, -1); - } - } - } + /* if we got any objects, store them in our output list */ + if (cnt > 0) + { + for (i = 0 ; i < cnt ; ++i) + { + OSCPYSTRUCT(nounlist[outcnt], tmplist[i]); + if (++outcnt > VOCMAXAMBIG) + { + vocerr(ctx, VOCERR(11), + "You're referring to too many objects."); + VOC_RETVAL(ctx, save_sp, -1); + } + } + } - /* if we didn't find any objects, stop looking */ - if (cnt == 0) - { - if (again) - *next = lastcur; - break; - } + /* if we didn't find any objects, stop looking */ + if (cnt == 0) + { + if (again) + *next = lastcur; + break; + } - /* - * if the caller only wanted a single object (or is getting an - * actor, in which case they implicitly want only a single - * object), stop looking for additional noun phrases - */ - if (!multi || chkact) - break; + /* + * if the caller only wanted a single object (or is getting an + * actor, in which case they implicitly want only a single + * object), stop looking for additional noun phrases + */ + if (!multi || chkact) + break; - /* skip past the previous noun phrase */ - cur = *next; + /* skip past the previous noun phrase */ + cur = *next; - /* - * if we're looking at a noun phrase separator ("and" or a - * comma), get the next noun phrase; otherwise, we're done - */ - if (cur != -1 && cmd[cur] != 0 && vocspec(cmd[cur], VOCW_AND)) - { - lastcur = cur; - while (cmd[cur] && vocspec(cmd[cur], VOCW_AND)) ++cur; - again = TRUE; - if (complain) complain = 2; - } - else - { - /* end of line, or not at a separator - we're done */ - break; - } - } + /* + * if we're looking at a noun phrase separator ("and" or a + * comma), get the next noun phrase; otherwise, we're done + */ + if (cur != -1 && cmd[cur] != 0 && vocspec(cmd[cur], VOCW_AND)) + { + lastcur = cur; + while (cmd[cur] && vocspec(cmd[cur], VOCW_AND)) ++cur; + again = TRUE; + if (complain) complain = 2; + } + else + { + /* end of line, or not at a separator - we're done */ + break; + } + } - /* terminate the list and return the number of objects we found */ - nounlist[outcnt].vocolobj = MCMONINV; - nounlist[outcnt].vocolflg = 0; - VOC_RETVAL(ctx, save_sp, outcnt); + /* terminate the list and return the number of objects we found */ + nounlist[outcnt].vocolobj = MCMONINV; + nounlist[outcnt].vocolflg = 0; + VOC_RETVAL(ctx, save_sp, outcnt); } @@ -3194,57 +3194,57 @@ int vocgobj(voccxdef *ctx, char *cmd[], int typelist[], */ void voc_parse_tok(voccxdef *ctx) { - uchar *save_sp; - runcxdef *rcx = ctx->voccxrun; - char **cmd; - char *inbuf; - char *outbuf; - uchar *p; - uint len; - int cnt; + uchar *save_sp; + runcxdef *rcx = ctx->voccxrun; + char **cmd; + char *inbuf; + char *outbuf; + uchar *p; + uint len; + int cnt; - /* enter our stack frame */ - voc_enter(ctx, &save_sp); + /* enter our stack frame */ + voc_enter(ctx, &save_sp); - /* get the string argument */ - p = runpopstr(rcx); + /* get the string argument */ + p = runpopstr(rcx); - /* get and skip the length prefix */ - len = osrp2(p) - 2; - p += 2; + /* get and skip the length prefix */ + len = osrp2(p) - 2; + p += 2; - /* - * Allocate space for the original string, and space for the token - * pointers and the tokenized string buffer. We could potentially - * have one token per character in the original string, and we could - * potentially need one extra null terminator for each character in - * the original string; allocate accordingly. - */ - VOC_STK_ARRAY(ctx, char, inbuf, len + 1); - VOC_STK_ARRAY(ctx, char, outbuf, len*2); - VOC_STK_ARRAY(ctx, char *, cmd, len*2); + /* + * Allocate space for the original string, and space for the token + * pointers and the tokenized string buffer. We could potentially + * have one token per character in the original string, and we could + * potentially need one extra null terminator for each character in + * the original string; allocate accordingly. + */ + VOC_STK_ARRAY(ctx, char, inbuf, len + 1); + VOC_STK_ARRAY(ctx, char, outbuf, len*2); + VOC_STK_ARRAY(ctx, char *, cmd, len*2); - /* copy the string into our buffer, and null-terminate it */ - memcpy(inbuf, p, len); - inbuf[len] = '\0'; + /* copy the string into our buffer, and null-terminate it */ + memcpy(inbuf, p, len); + inbuf[len] = '\0'; - /* tokenize the string */ - cnt = voctok(ctx, inbuf, outbuf, cmd, TRUE, FALSE, FALSE); + /* tokenize the string */ + cnt = voctok(ctx, inbuf, outbuf, cmd, TRUE, FALSE, FALSE); - /* check the result */ - if (cnt < 0) - { - /* negative count - it's an error, so return nil */ - runpnil(rcx); - } - else - { - /* push the return list */ - voc_push_toklist(ctx, cmd, cnt); - } + /* check the result */ + if (cnt < 0) + { + /* negative count - it's an error, so return nil */ + runpnil(rcx); + } + else + { + /* push the return list */ + voc_push_toklist(ctx, cmd, cnt); + } - /* leave our stack frame */ - voc_leave(ctx, save_sp); + /* leave our stack frame */ + voc_leave(ctx, save_sp); } /* ------------------------------------------------------------------------ */ @@ -3256,72 +3256,72 @@ void voc_parse_tok(voccxdef *ctx) */ void voc_parse_types(voccxdef *ctx) { - runcxdef *rcx = ctx->voccxrun; - uchar *wrdp; - uint wrdsiz; - uchar *typp; - uchar *lstp; - uint lstsiz; - int wrdcnt; + runcxdef *rcx = ctx->voccxrun; + uchar *wrdp; + uint wrdsiz; + uchar *typp; + uchar *lstp; + uint lstsiz; + int wrdcnt; - /* get the list of words from the stack */ - wrdp = runpoplst(rcx); + /* get the list of words from the stack */ + wrdp = runpoplst(rcx); - /* read and skip the size prefix */ - wrdsiz = osrp2(wrdp) - 2; - wrdp += 2; + /* read and skip the size prefix */ + wrdsiz = osrp2(wrdp) - 2; + wrdp += 2; - /* scan the list and count the number of string entries */ - for (wrdcnt = 0, lstp = wrdp, lstsiz = wrdsiz ; lstsiz != 0 ; - lstadv(&lstp, &lstsiz)) - { - /* if this is a string, count it */ - if (*lstp == DAT_SSTRING) - ++wrdcnt; - } + /* scan the list and count the number of string entries */ + for (wrdcnt = 0, lstp = wrdp, lstsiz = wrdsiz ; lstsiz != 0 ; + lstadv(&lstp, &lstsiz)) + { + /* if this is a string, count it */ + if (*lstp == DAT_SSTRING) + ++wrdcnt; + } - /* allocate the return list - one number entry per word */ - typp = voc_push_list(ctx, wrdcnt, 4); + /* allocate the return list - one number entry per word */ + typp = voc_push_list(ctx, wrdcnt, 4); - /* look up each word and set the corresponding element in the type list */ - for (lstp = wrdp, lstsiz = wrdsiz ; lstsiz != 0 ; lstadv(&lstp, &lstsiz)) - { - /* if this is a string, look it up in the dictionary */ - if (*lstp == DAT_SSTRING) - { - char buf[256]; - int curtyp; - uint len; + /* look up each word and set the corresponding element in the type list */ + for (lstp = wrdp, lstsiz = wrdsiz ; lstsiz != 0 ; lstadv(&lstp, &lstsiz)) + { + /* if this is a string, look it up in the dictionary */ + if (*lstp == DAT_SSTRING) + { + char buf[256]; + int curtyp; + uint len; - /* make sure it fits in our buffer */ - len = osrp2(lstp+1) - 2; - if (len < sizeof(buf)) - { - /* extract the word into our buffer */ - memcpy(buf, lstp+3, len); + /* make sure it fits in our buffer */ + len = osrp2(lstp+1) - 2; + if (len < sizeof(buf)) + { + /* extract the word into our buffer */ + memcpy(buf, lstp+3, len); - /* null-terminate it */ - buf[len] = '\0'; + /* null-terminate it */ + buf[len] = '\0'; - /* get the type */ - curtyp = voc_lookup_type(ctx, buf, len, TRUE); + /* get the type */ + curtyp = voc_lookup_type(ctx, buf, len, TRUE); - /* if they didn't find a type at all, set it to UNKNOWN */ - if (curtyp == 0) - curtyp = VOCT_UNKNOWN; - } - else - { - /* the string is too big - just mark it as unknown */ - curtyp = VOCT_UNKNOWN; - } + /* if they didn't find a type at all, set it to UNKNOWN */ + if (curtyp == 0) + curtyp = VOCT_UNKNOWN; + } + else + { + /* the string is too big - just mark it as unknown */ + curtyp = VOCT_UNKNOWN; + } - /* add this type to the return list */ - *typp++ = DAT_NUMBER; - oswp4s(typp, curtyp); - typp += 4; - } - } + /* add this type to the return list */ + *typp++ = DAT_NUMBER; + oswp4s(typp, curtyp); + typp += 4; + } + } } @@ -3336,309 +3336,309 @@ void voc_parse_types(voccxdef *ctx) */ void voc_parse_np(voccxdef *ctx) { - runcxdef *rcx = ctx->voccxrun; - vocoldef *objlist; - uchar *save_sp; - uchar *wordp; - uint wordsiz; - uchar *typp; - uint typsiz; - int cnt; - char **wordarr; - int wordcnt; - char *wordchararr; - uint wordcharsiz; - int *typarr; - int complain; - int chkact; - int multi; - int no_match; - int next; - int cur; - uchar *lstp; - uint lstsiz; - char *p; - int i; - int old_unknown, old_lastunk; + runcxdef *rcx = ctx->voccxrun; + vocoldef *objlist; + uchar *save_sp; + uchar *wordp; + uint wordsiz; + uchar *typp; + uint typsiz; + int cnt; + char **wordarr; + int wordcnt; + char *wordchararr; + uint wordcharsiz; + int *typarr; + int complain; + int chkact; + int multi; + int no_match; + int next; + int cur; + uchar *lstp; + uint lstsiz; + char *p; + int i; + int old_unknown, old_lastunk; - /* allocate stack arrays */ - voc_enter(ctx, &save_sp); - VOC_MAX_ARRAY(ctx, vocoldef, objlist); + /* allocate stack arrays */ + voc_enter(ctx, &save_sp); + VOC_MAX_ARRAY(ctx, vocoldef, objlist); - /* - * Save the original context unknown values, since we don't want to - * affect the context information in this game-initiated call, then - * clear the unknown word count for the duration of the call. - */ - old_unknown = ctx->voccxunknown; - old_lastunk = ctx->voccxlastunk; - ctx->voccxunknown = ctx->voccxlastunk = 0; + /* + * Save the original context unknown values, since we don't want to + * affect the context information in this game-initiated call, then + * clear the unknown word count for the duration of the call. + */ + old_unknown = ctx->voccxunknown; + old_lastunk = ctx->voccxlastunk; + ctx->voccxunknown = ctx->voccxlastunk = 0; - /* get the list of words, and read its length prefix */ - wordp = runpoplst(rcx); - wordsiz = osrp2(wordp) - 2; - wordp += 2; + /* get the list of words, and read its length prefix */ + wordp = runpoplst(rcx); + wordsiz = osrp2(wordp) - 2; + wordp += 2; - /* get the list of types, and read its length prefix */ - typp = runpoplst(rcx); - typsiz = osrp2(typp) - 2; - typp += 2; + /* get the list of types, and read its length prefix */ + typp = runpoplst(rcx); + typsiz = osrp2(typp) - 2; + typp += 2; - /* get the starting index (adjusting for zero-based indexing) */ - cur = runpopnum(rcx) - 1; - next = cur; + /* get the starting index (adjusting for zero-based indexing) */ + cur = runpopnum(rcx) - 1; + next = cur; - /* get the flag arguments */ - complain = runpoplog(rcx); - multi = runpoplog(rcx); - chkact = runpoplog(rcx); + /* get the flag arguments */ + complain = runpoplog(rcx); + multi = runpoplog(rcx); + chkact = runpoplog(rcx); - /* count the words in the word list */ - for (wordcnt = 0, lstp = wordp, wordcharsiz = 0, lstsiz = wordsiz ; - lstsiz != 0 ; lstadv(&lstp, &lstsiz)) - { - /* count the word */ - ++wordcnt; + /* count the words in the word list */ + for (wordcnt = 0, lstp = wordp, wordcharsiz = 0, lstsiz = wordsiz ; + lstsiz != 0 ; lstadv(&lstp, &lstsiz)) + { + /* count the word */ + ++wordcnt; - /* - * count the space needed for the word - count the bytes of the - * string plus a null terminator - */ - if (*lstp == DAT_SSTRING) - wordcharsiz += osrp2(lstp+1) + 1; - } + /* + * count the space needed for the word - count the bytes of the + * string plus a null terminator + */ + if (*lstp == DAT_SSTRING) + wordcharsiz += osrp2(lstp+1) + 1; + } - /* allocate space for the word arrays */ - VOC_STK_ARRAY(ctx, char, wordchararr, wordcharsiz); - VOC_STK_ARRAY(ctx, char *, wordarr, wordcnt+1); - VOC_STK_ARRAY(ctx, int, typarr, wordcnt+1); + /* allocate space for the word arrays */ + VOC_STK_ARRAY(ctx, char, wordchararr, wordcharsiz); + VOC_STK_ARRAY(ctx, char *, wordarr, wordcnt+1); + VOC_STK_ARRAY(ctx, int, typarr, wordcnt+1); - /* build the word array */ - for (i = 0, p = wordchararr, lstp = wordp, lstsiz = wordsiz ; - lstsiz != 0 ; lstadv(&lstp, &lstsiz)) - { - /* add the word to the word array */ - if (*lstp == DAT_SSTRING) - { - uint len; - - /* add this entry to the word array */ - wordarr[i] = p; + /* build the word array */ + for (i = 0, p = wordchararr, lstp = wordp, lstsiz = wordsiz ; + lstsiz != 0 ; lstadv(&lstp, &lstsiz)) + { + /* add the word to the word array */ + if (*lstp == DAT_SSTRING) + { + uint len; + + /* add this entry to the word array */ + wordarr[i] = p; - /* copy the word to the character array and null-terminate it */ - len = osrp2(lstp + 1) - 2; - memcpy(p, lstp + 3, len); - p[len] = '\0'; + /* copy the word to the character array and null-terminate it */ + len = osrp2(lstp + 1) - 2; + memcpy(p, lstp + 3, len); + p[len] = '\0'; - /* move the write pointer past this entry */ - p += len + 1; + /* move the write pointer past this entry */ + p += len + 1; - /* bump the index */ - ++i; - } - } + /* bump the index */ + ++i; + } + } - /* store an empty last entry */ - wordarr[i] = 0; + /* store an empty last entry */ + wordarr[i] = 0; - /* build the type array */ - for (i = 0, lstp = typp, lstsiz = typsiz ; - lstsiz != 0 && i < wordcnt ; lstadv(&lstp, &lstsiz)) - { - /* add this entry to the type array */ - if (*lstp == DAT_NUMBER) - { - /* set the entry */ - typarr[i] = (int)osrp4(lstp + 1); + /* build the type array */ + for (i = 0, lstp = typp, lstsiz = typsiz ; + lstsiz != 0 && i < wordcnt ; lstadv(&lstp, &lstsiz)) + { + /* add this entry to the type array */ + if (*lstp == DAT_NUMBER) + { + /* set the entry */ + typarr[i] = (int)osrp4(lstp + 1); - /* bump the index */ - ++i; - } - } + /* bump the index */ + ++i; + } + } - /* parse the noun phrase */ - cnt = vocgobj(ctx, wordarr, typarr, cur, &next, complain, objlist, - multi, chkact, &no_match); + /* parse the noun phrase */ + cnt = vocgobj(ctx, wordarr, typarr, cur, &next, complain, objlist, + multi, chkact, &no_match); - /* restore context unknown values */ - ctx->voccxunknown = old_unknown; - ctx->voccxlastunk = old_lastunk; + /* restore context unknown values */ + ctx->voccxunknown = old_unknown; + ctx->voccxlastunk = old_lastunk; - /* check the return value */ - if (cnt < 0) - { - /* syntax error; return nil to indicate an error */ - runpnil(rcx); - } - else if (cnt == 0) - { - /* - * No objects found. Return a list consisting only of the next - * index. If the next index is equal to the starting index, - * this will tell the caller that no noun phrase is - * syntactically present; otherwise, it will tell the caller - * that a noun phrase is present but there are no matching - * objects. - * - * Note that we must increment the returned element index to - * conform with the 1-based index values that the game function - * uses. - */ - ++next; - voc_push_numlist(ctx, (uint *)&next, 1); - } - else - { - /* - * We found one or more objects. Return a list whose first - * element is the index of the next word to be parsed, and whose - * remaining elements are sublists. Each sublist contains a - * match for one noun phrase; for each AND adding another noun - * phrase, there's another sublist. Each sublist contains the - * index of the first word of its noun phrase, the index of the - * last word of its noun phrase, and then the objects. For each - * object, there is a pair of entries: the object itself, and - * the flags for the object. - * - * First, figure out how much space we need by scanning the - * return list. - */ - for (lstsiz = 0, i = 0 ; i < cnt ; ) - { - int j; + /* check the return value */ + if (cnt < 0) + { + /* syntax error; return nil to indicate an error */ + runpnil(rcx); + } + else if (cnt == 0) + { + /* + * No objects found. Return a list consisting only of the next + * index. If the next index is equal to the starting index, + * this will tell the caller that no noun phrase is + * syntactically present; otherwise, it will tell the caller + * that a noun phrase is present but there are no matching + * objects. + * + * Note that we must increment the returned element index to + * conform with the 1-based index values that the game function + * uses. + */ + ++next; + voc_push_numlist(ctx, (uint *)&next, 1); + } + else + { + /* + * We found one or more objects. Return a list whose first + * element is the index of the next word to be parsed, and whose + * remaining elements are sublists. Each sublist contains a + * match for one noun phrase; for each AND adding another noun + * phrase, there's another sublist. Each sublist contains the + * index of the first word of its noun phrase, the index of the + * last word of its noun phrase, and then the objects. For each + * object, there is a pair of entries: the object itself, and + * the flags for the object. + * + * First, figure out how much space we need by scanning the + * return list. + */ + for (lstsiz = 0, i = 0 ; i < cnt ; ) + { + int j; - /* - * count the entries in this sublist by looking for the next - * entry whose starting word is different - */ - for (j = i ; - j < cnt && objlist[j].vocolfst == objlist[i].vocolfst ; - ++j) - { - /* - * for this entry, we need space for the object (1 + 2 - * for an object, or just 1 for nil) and flags (1 + 4) - */ - if (objlist[j].vocolobj == MCMONINV) - lstsiz += 1; - else - lstsiz += 3; - lstsiz += 5; - } + /* + * count the entries in this sublist by looking for the next + * entry whose starting word is different + */ + for (j = i ; + j < cnt && objlist[j].vocolfst == objlist[i].vocolfst ; + ++j) + { + /* + * for this entry, we need space for the object (1 + 2 + * for an object, or just 1 for nil) and flags (1 + 4) + */ + if (objlist[j].vocolobj == MCMONINV) + lstsiz += 1; + else + lstsiz += 3; + lstsiz += 5; + } - /* - * For this sublist, we need space for the first index (type - * prefix + number = 1 + 4 = 5) and the last index (5). - * We've already counted space for the objects in the list. - * Finally, we need space for the list type and length - * prefixes (1 + 2) for the sublist itself. - */ - lstsiz += (5 + 5) + 3; + /* + * For this sublist, we need space for the first index (type + * prefix + number = 1 + 4 = 5) and the last index (5). + * We've already counted space for the objects in the list. + * Finally, we need space for the list type and length + * prefixes (1 + 2) for the sublist itself. + */ + lstsiz += (5 + 5) + 3; - /* skip to the next element */ - i = j; - } + /* skip to the next element */ + i = j; + } - /* - * finally, we need space for the first element of the list, - * which is the index of the next word to be parsed (1+4) - */ - lstsiz += 5; + /* + * finally, we need space for the first element of the list, + * which is the index of the next word to be parsed (1+4) + */ + lstsiz += 5; - /* allocate space for the list */ - lstp = voc_push_list_siz(ctx, lstsiz); + /* allocate space for the list */ + lstp = voc_push_list_siz(ctx, lstsiz); - /* - * store the first element - the index of the next word to parse - * (adjusting to 1-based indexing) - */ - *lstp++ = DAT_NUMBER; - oswp4s(lstp, next + 1); - lstp += 4; + /* + * store the first element - the index of the next word to parse + * (adjusting to 1-based indexing) + */ + *lstp++ = DAT_NUMBER; + oswp4s(lstp, next + 1); + lstp += 4; - /* build the list */ - for (i = 0 ; i < cnt ; ) - { - uchar *sublstp; - int j; - int firstidx = 0; + /* build the list */ + for (i = 0 ; i < cnt ; ) + { + uchar *sublstp; + int j; + int firstidx = 0; int lastidx = 0; - /* store the list type prefix */ - *lstp++ = DAT_LIST; + /* store the list type prefix */ + *lstp++ = DAT_LIST; - /* - * remember where the length prefix is, then skip it - we'll - * come back and fill it in when we're done with the sublist - */ - sublstp = lstp; - lstp += 2; + /* + * remember where the length prefix is, then skip it - we'll + * come back and fill it in when we're done with the sublist + */ + sublstp = lstp; + lstp += 2; - /* search the array to find the indices of the boundary words */ - for (j = 0 ; j < wordcnt ; ++j) - { - /* if this is the first word, remember the index */ - if (wordarr[j] == objlist[i].vocolfst) - firstidx = j; + /* search the array to find the indices of the boundary words */ + for (j = 0 ; j < wordcnt ; ++j) + { + /* if this is the first word, remember the index */ + if (wordarr[j] == objlist[i].vocolfst) + firstidx = j; - /* if this is the last word, remember the index */ - if (wordarr[j] == objlist[i].vocollst) - { - /* remember the index */ - lastidx = j; + /* if this is the last word, remember the index */ + if (wordarr[j] == objlist[i].vocollst) + { + /* remember the index */ + lastidx = j; - /* - * we can stop looking now, since the words are - * always in order (so the first index will never be - * after the last index) - */ - break; - } - } + /* + * we can stop looking now, since the words are + * always in order (so the first index will never be + * after the last index) + */ + break; + } + } - /* add the first and last index, adjusting to 1-based indexing */ - *lstp++ = DAT_NUMBER; - oswp4s(lstp, firstidx + 1); - lstp += 4; - *lstp++ = DAT_NUMBER; - oswp4s(lstp, lastidx + 1); - lstp += 4; + /* add the first and last index, adjusting to 1-based indexing */ + *lstp++ = DAT_NUMBER; + oswp4s(lstp, firstidx + 1); + lstp += 4; + *lstp++ = DAT_NUMBER; + oswp4s(lstp, lastidx + 1); + lstp += 4; - /* add the objects */ - for (j = i ; - j < cnt && objlist[j].vocolfst == objlist[i].vocolfst ; - ++j) - { - /* add this object */ - if (objlist[j].vocolobj == MCMONINV) - { - /* just store a nil */ - *lstp++ = DAT_NIL; - } - else - { - /* store the object */ - *lstp++ = DAT_OBJECT; - oswp2(lstp, objlist[j].vocolobj); - lstp += 2; - } + /* add the objects */ + for (j = i ; + j < cnt && objlist[j].vocolfst == objlist[i].vocolfst ; + ++j) + { + /* add this object */ + if (objlist[j].vocolobj == MCMONINV) + { + /* just store a nil */ + *lstp++ = DAT_NIL; + } + else + { + /* store the object */ + *lstp++ = DAT_OBJECT; + oswp2(lstp, objlist[j].vocolobj); + lstp += 2; + } - /* add the flags */ - *lstp++ = DAT_NUMBER; - oswp4s(lstp, objlist[i].vocolflg); - lstp += 4; - } + /* add the flags */ + *lstp++ = DAT_NUMBER; + oswp4s(lstp, objlist[i].vocolflg); + lstp += 4; + } - /* fix up the sublist's length prefix */ - oswp2(sublstp, lstp - sublstp); + /* fix up the sublist's length prefix */ + oswp2(sublstp, lstp - sublstp); - /* move on to the next sublist */ - i = j; - } - } + /* move on to the next sublist */ + i = j; + } + } - /* exit the stack frame */ - voc_leave(ctx, save_sp); + /* exit the stack frame */ + voc_leave(ctx, save_sp); } @@ -3649,197 +3649,197 @@ void voc_parse_np(voccxdef *ctx) */ void voc_parse_dict_lookup(voccxdef *ctx) { - uchar *save_sp; - runcxdef *rcx = ctx->voccxrun; - uchar *wrdp; - uint wrdsiz; - uchar *typp; - uint typsiz; - objnum *list1; - objnum *list2; - int cnt1; - int cnt2; + uchar *save_sp; + runcxdef *rcx = ctx->voccxrun; + uchar *wrdp; + uint wrdsiz; + uchar *typp; + uint typsiz; + objnum *list1; + objnum *list2; + int cnt1; + int cnt2; - /* enter our stack frame and allocate stack arrays */ - voc_enter(ctx, &save_sp); - VOC_MAX_ARRAY(ctx, objnum, list1); - VOC_MAX_ARRAY(ctx, objnum, list2); - - /* get the word list, and read and skip its size prefix */ - wrdp = runpoplst(rcx); - wrdsiz = osrp2(wrdp) - 2; - wrdp += 2; + /* enter our stack frame and allocate stack arrays */ + voc_enter(ctx, &save_sp); + VOC_MAX_ARRAY(ctx, objnum, list1); + VOC_MAX_ARRAY(ctx, objnum, list2); + + /* get the word list, and read and skip its size prefix */ + wrdp = runpoplst(rcx); + wrdsiz = osrp2(wrdp) - 2; + wrdp += 2; - /* get the type list, and read and skip its size prefix */ - typp = runpoplst(rcx); - typsiz = osrp2(typp) - 2; - typp += 2; + /* get the type list, and read and skip its size prefix */ + typp = runpoplst(rcx); + typsiz = osrp2(typp) - 2; + typp += 2; - /* nothing in the main list yet */ - cnt1 = 0; + /* nothing in the main list yet */ + cnt1 = 0; - /* go through the word list */ - while (wrdsiz > 0) - { - int curtyp; - int type_prop; - char *curword; - uint curwordlen; - char *curword2; - uint curwordlen2; - vocwdef *v; - char *p; - uint len; - vocseadef search_ctx; - - /* if this entry is a string, consider it */ - if (*wrdp == DAT_SSTRING) - { - /* get the current word's text string */ - curword = (char *)(wrdp + 3); - curwordlen = osrp2(wrdp+1) - 2; + /* go through the word list */ + while (wrdsiz > 0) + { + int curtyp; + int type_prop; + char *curword; + uint curwordlen; + char *curword2; + uint curwordlen2; + vocwdef *v; + char *p; + uint len; + vocseadef search_ctx; + + /* if this entry is a string, consider it */ + if (*wrdp == DAT_SSTRING) + { + /* get the current word's text string */ + curword = (char *)(wrdp + 3); + curwordlen = osrp2(wrdp+1) - 2; - /* check for an embedded space */ - for (p = curword, len = curwordlen ; len != 0 && !t_isspace(*p) ; - ++p, --len) ; - if (len != 0) - { - /* get the second word */ - curword2 = p + 1; - curwordlen2 = len - 1; + /* check for an embedded space */ + for (p = curword, len = curwordlen ; len != 0 && !t_isspace(*p) ; + ++p, --len) ; + if (len != 0) + { + /* get the second word */ + curword2 = p + 1; + curwordlen2 = len - 1; - /* truncate the first word accordingly */ - curwordlen -= len; - } - else - { - /* no embedded space -> no second word */ - curword2 = 0; - curwordlen2 = 0; - } + /* truncate the first word accordingly */ + curwordlen -= len; + } + else + { + /* no embedded space -> no second word */ + curword2 = 0; + curwordlen2 = 0; + } - /* presume we won't find a valid type property */ - type_prop = PRP_INVALID; + /* presume we won't find a valid type property */ + type_prop = PRP_INVALID; - /* - * get this type entry, if there's another entry in the - * list, and it's of the appropriate type - */ - if (typsiz > 0 && *typp == DAT_NUMBER) - { - /* - * Figure out what type property we'll be using. We'll - * consider only one meaning for each word, and we'll - * arbitrarily pick one if the type code has more than - * one type, because we expect the caller to provide - * exactly one type per word. - */ - int i; - struct typemap_t - { - int flag; - int prop; - }; - static struct typemap_t typemap[] = - { - { VOCT_ARTICLE, PRP_ARTICLE }, - { VOCT_ADJ, PRP_ADJ }, - { VOCT_NOUN, PRP_NOUN }, - { VOCT_PREP, PRP_PREP }, - { VOCT_VERB, PRP_VERB }, - { VOCT_PLURAL, PRP_PLURAL } - }; - struct typemap_t *mapp; + /* + * get this type entry, if there's another entry in the + * list, and it's of the appropriate type + */ + if (typsiz > 0 && *typp == DAT_NUMBER) + { + /* + * Figure out what type property we'll be using. We'll + * consider only one meaning for each word, and we'll + * arbitrarily pick one if the type code has more than + * one type, because we expect the caller to provide + * exactly one type per word. + */ + int i; + struct typemap_t + { + int flag; + int prop; + }; + static struct typemap_t typemap[] = + { + { VOCT_ARTICLE, PRP_ARTICLE }, + { VOCT_ADJ, PRP_ADJ }, + { VOCT_NOUN, PRP_NOUN }, + { VOCT_PREP, PRP_PREP }, + { VOCT_VERB, PRP_VERB }, + { VOCT_PLURAL, PRP_PLURAL } + }; + struct typemap_t *mapp; - /* get the type */ - curtyp = (int)osrp4(typp+1); + /* get the type */ + curtyp = (int)osrp4(typp+1); - /* search for a type */ - for (mapp = typemap, i = sizeof(typemap)/sizeof(typemap[0]) ; - i != 0 ; ++mapp, --i) - { - /* if this flag is set, use this type property */ - if ((curtyp & mapp->flag) != 0) - { - /* use this one */ - type_prop = mapp->prop; - break; - } - } - } + /* search for a type */ + for (mapp = typemap, i = sizeof(typemap)/sizeof(typemap[0]) ; + i != 0 ; ++mapp, --i) + { + /* if this flag is set, use this type property */ + if ((curtyp & mapp->flag) != 0) + { + /* use this one */ + type_prop = mapp->prop; + break; + } + } + } - /* nothing in the new list yet */ - cnt2 = 0; + /* nothing in the new list yet */ + cnt2 = 0; - /* scan for matching words */ - for (v = vocffw(ctx, curword, curwordlen, curword2, curwordlen2, - type_prop, &search_ctx) ; - v != 0 ; - v = vocfnw(ctx, &search_ctx)) - { - int i; - - /* make sure we have room in our list */ - if (cnt2 >= VOCMAXAMBIG - 1) - break; + /* scan for matching words */ + for (v = vocffw(ctx, curword, curwordlen, curword2, curwordlen2, + type_prop, &search_ctx) ; + v != 0 ; + v = vocfnw(ctx, &search_ctx)) + { + int i; + + /* make sure we have room in our list */ + if (cnt2 >= VOCMAXAMBIG - 1) + break; - /* make sure that this entry isn't already in our list */ - for (i = 0 ; i < cnt2 ; ++i) - { - /* if this entry matches, stop looking */ - if (list2[i] == v->vocwobj) - break; - } + /* make sure that this entry isn't already in our list */ + for (i = 0 ; i < cnt2 ; ++i) + { + /* if this entry matches, stop looking */ + if (list2[i] == v->vocwobj) + break; + } - /* if it's not already in the list, add it now */ - if (i == cnt2) - { - /* add it to our list */ - list2[cnt2++] = v->vocwobj; - } - } + /* if it's not already in the list, add it now */ + if (i == cnt2) + { + /* add it to our list */ + list2[cnt2++] = v->vocwobj; + } + } - /* terminate the list */ - list2[cnt2] = MCMONINV; + /* terminate the list */ + list2[cnt2] = MCMONINV; - /* - * if there's nothing in the first list, simply copy this - * into the first list; otherwise, intersect the two lists - */ - if (cnt1 == 0) - { - /* this is the first list -> copy it into the main list */ - memcpy(list1, list2, (cnt2+1)*sizeof(list2[0])); - cnt1 = cnt2; - } - else - { - /* intersect the two lists */ - cnt1 = vocisect(list1, list2); - } + /* + * if there's nothing in the first list, simply copy this + * into the first list; otherwise, intersect the two lists + */ + if (cnt1 == 0) + { + /* this is the first list -> copy it into the main list */ + memcpy(list1, list2, (cnt2+1)*sizeof(list2[0])); + cnt1 = cnt2; + } + else + { + /* intersect the two lists */ + cnt1 = vocisect(list1, list2); + } - /* - * if there's nothing in the result list now, there's no - * need to look any further, because further intersection - * will yield nothing - */ - if (cnt1 == 0) - break; - } - - /* advance the word list */ - lstadv(&wrdp, &wrdsiz); + /* + * if there's nothing in the result list now, there's no + * need to look any further, because further intersection + * will yield nothing + */ + if (cnt1 == 0) + break; + } + + /* advance the word list */ + lstadv(&wrdp, &wrdsiz); - /* if there's anything left in the type list, advance it as well */ - if (typsiz > 0) - lstadv(&typp, &typsiz); - } + /* if there's anything left in the type list, advance it as well */ + if (typsiz > 0) + lstadv(&typp, &typsiz); + } - /* push the result list */ - voc_push_objlist(ctx, list1, cnt1); + /* push the result list */ + voc_push_objlist(ctx, list1, cnt1); - /* exit our stack frame */ - voc_leave(ctx, save_sp); + /* exit our stack frame */ + voc_leave(ctx, save_sp); } /* ------------------------------------------------------------------------ */ @@ -3850,565 +3850,565 @@ void voc_parse_dict_lookup(voccxdef *ctx) */ void voc_parse_disambig(voccxdef *ctx) { - voccxdef ctx_copy; - uchar *save_sp; - runcxdef *rcx = ctx->voccxrun; - vocoldef *inlist; - vocoldef *outlist; - int objcnt; - char **cmd; - char *cmdbuf; - char *oopsbuf; - objnum actor; - objnum verb; - objnum prep; - objnum otherobj; - prpnum defprop; - prpnum accprop; - prpnum verprop; - uchar *tokp; - uint toksiz; - uchar *objp; - uint objsiz; - uchar *lstp; - uint lstsiz; - int tokcnt; - char *p; - int i; - int silent; - int err; - int unknown_count; + voccxdef ctx_copy; + uchar *save_sp; + runcxdef *rcx = ctx->voccxrun; + vocoldef *inlist; + vocoldef *outlist; + int objcnt; + char **cmd; + char *cmdbuf; + char *oopsbuf; + objnum actor; + objnum verb; + objnum prep; + objnum otherobj; + prpnum defprop; + prpnum accprop; + prpnum verprop; + uchar *tokp; + uint toksiz; + uchar *objp; + uint objsiz; + uchar *lstp; + uint lstsiz; + int tokcnt; + char *p; + int i; + int silent; + int err; + int unknown_count; - /* allocate our stack arrays */ - voc_enter(ctx, &save_sp); - VOC_MAX_ARRAY(ctx, vocoldef, outlist); - VOC_STK_ARRAY(ctx, char, cmdbuf, VOCBUFSIZ); - VOC_STK_ARRAY(ctx, char, oopsbuf, VOCBUFSIZ); + /* allocate our stack arrays */ + voc_enter(ctx, &save_sp); + VOC_MAX_ARRAY(ctx, vocoldef, outlist); + VOC_STK_ARRAY(ctx, char, cmdbuf, VOCBUFSIZ); + VOC_STK_ARRAY(ctx, char, oopsbuf, VOCBUFSIZ); - /* get the actor, verb, prep, and otherobj arguments */ - actor = runpopobj(rcx); - verb = runpopobj(rcx); - prep = runpopobjnil(rcx); - otherobj = runpopobjnil(rcx); + /* get the actor, verb, prep, and otherobj arguments */ + actor = runpopobj(rcx); + verb = runpopobj(rcx); + prep = runpopobjnil(rcx); + otherobj = runpopobjnil(rcx); - /* - * get the usage parameter, and use it to select the appropriate - * defprop and accprop - */ - switch(runpopnum(rcx)) - { - case VOC_PRO_RESOLVE_DOBJ: - default: - defprop = PRP_DODEFAULT; - accprop = PRP_VALIDDO; - break; + /* + * get the usage parameter, and use it to select the appropriate + * defprop and accprop + */ + switch(runpopnum(rcx)) + { + case VOC_PRO_RESOLVE_DOBJ: + default: + defprop = PRP_DODEFAULT; + accprop = PRP_VALIDDO; + break; - case VOC_PRO_RESOLVE_IOBJ: - defprop = PRP_IODEFAULT; - accprop = PRP_VALIDIO; - break; + case VOC_PRO_RESOLVE_IOBJ: + defprop = PRP_IODEFAULT; + accprop = PRP_VALIDIO; + break; - case VOC_PRO_RESOLVE_ACTOR: - defprop = PRP_DODEFAULT; - accprop = PRP_VALIDACTOR; - break; - } - - /* get the verprop argument */ - verprop = runpopprp(rcx); + case VOC_PRO_RESOLVE_ACTOR: + defprop = PRP_DODEFAULT; + accprop = PRP_VALIDACTOR; + break; + } + + /* get the verprop argument */ + verprop = runpopprp(rcx); - /* pop the token list, and read and skip the length prefix */ - tokp = runpoplst(rcx); - toksiz = osrp2(tokp) - 2; - tokp += 2; + /* pop the token list, and read and skip the length prefix */ + tokp = runpoplst(rcx); + toksiz = osrp2(tokp) - 2; + tokp += 2; - /* pop the object list, and read and skip the length prefix */ - objp = runpoplst(rcx); - objsiz = osrp2(objp) - 2; - objp += 2; + /* pop the object list, and read and skip the length prefix */ + objp = runpoplst(rcx); + objsiz = osrp2(objp) - 2; + objp += 2; - /* pop the "silent" flag */ - silent = runpoplog(rcx); + /* pop the "silent" flag */ + silent = runpoplog(rcx); - /* count the tokens */ - for (lstp = tokp, lstsiz = toksiz, tokcnt = 0 ; - lstsiz != 0 ; lstadv(&lstp, &lstsiz)) - { - /* if this is a string, count it */ - if (*lstp == DAT_SSTRING) - ++tokcnt; - } + /* count the tokens */ + for (lstp = tokp, lstsiz = toksiz, tokcnt = 0 ; + lstsiz != 0 ; lstadv(&lstp, &lstsiz)) + { + /* if this is a string, count it */ + if (*lstp == DAT_SSTRING) + ++tokcnt; + } - /* allocate stack space for the command pointers and buffer */ - VOC_STK_ARRAY(ctx, char *, cmd, tokcnt + 1); + /* allocate stack space for the command pointers and buffer */ + VOC_STK_ARRAY(ctx, char *, cmd, tokcnt + 1); - /* extract the tokens into our pointer buffer */ - for (lstp = tokp, lstsiz = toksiz, i = 0, p = cmdbuf ; - lstsiz != 0 ; lstadv(&lstp, &lstsiz)) - { - /* if this is a string, count and size it */ - if (*lstp == DAT_SSTRING) - { - uint len; - - /* store a pointer to the word in the command buffer */ - cmd[i++] = p; + /* extract the tokens into our pointer buffer */ + for (lstp = tokp, lstsiz = toksiz, i = 0, p = cmdbuf ; + lstsiz != 0 ; lstadv(&lstp, &lstsiz)) + { + /* if this is a string, count and size it */ + if (*lstp == DAT_SSTRING) + { + uint len; + + /* store a pointer to the word in the command buffer */ + cmd[i++] = p; - /* copy the token into the command buffer and null-terminate it */ - len = osrp2(lstp + 1) - 2; - memcpy(p, lstp + 3, len); - p[len] = '\0'; + /* copy the token into the command buffer and null-terminate it */ + len = osrp2(lstp + 1) - 2; + memcpy(p, lstp + 3, len); + p[len] = '\0'; - /* move the buffer pointer past this word */ - p += len + 1; - } - } + /* move the buffer pointer past this word */ + p += len + 1; + } + } - /* store a null at the end of the command pointer list */ - cmd[i] = 0; + /* store a null at the end of the command pointer list */ + cmd[i] = 0; - /* - * The object list is provided in the same format as the list - * returned by voc_parse_np(), but the leading index number is - * optional. We don't need the leading index for anything, so if - * it's there, simply skip it so that we can start with the first - * sublist. - */ - if (objsiz > 0 && *objp == DAT_NUMBER) - lstadv(&objp, &objsiz); + /* + * The object list is provided in the same format as the list + * returned by voc_parse_np(), but the leading index number is + * optional. We don't need the leading index for anything, so if + * it's there, simply skip it so that we can start with the first + * sublist. + */ + if (objsiz > 0 && *objp == DAT_NUMBER) + lstadv(&objp, &objsiz); - /* - * Count the objects in the object list, so that we can figure out - * how much we need to allocate for the input object list. - */ - for (lstp = objp, lstsiz = objsiz, objcnt = 0 ; lstsiz != 0 ; - lstadv(&lstp, &lstsiz)) - { - /* if this is a sublist, parse it */ - if (*lstp == DAT_LIST) - { - uchar *subp; - uint subsiz; + /* + * Count the objects in the object list, so that we can figure out + * how much we need to allocate for the input object list. + */ + for (lstp = objp, lstsiz = objsiz, objcnt = 0 ; lstsiz != 0 ; + lstadv(&lstp, &lstsiz)) + { + /* if this is a sublist, parse it */ + if (*lstp == DAT_LIST) + { + uchar *subp; + uint subsiz; - /* get the sublist pointer, and read and skip the size prefix */ - subp = lstp + 1; - subsiz = osrp2(subp) - 2; - subp += 2; + /* get the sublist pointer, and read and skip the size prefix */ + subp = lstp + 1; + subsiz = osrp2(subp) - 2; + subp += 2; - /* scan the sublist */ - while (subsiz > 0) - { - /* if this is an object, count it */ - if (*subp == DAT_OBJECT || *subp == DAT_NIL) - ++objcnt; + /* scan the sublist */ + while (subsiz > 0) + { + /* if this is an object, count it */ + if (*subp == DAT_OBJECT || *subp == DAT_NIL) + ++objcnt; - /* skip this element */ - lstadv(&subp, &subsiz); - } - } - } + /* skip this element */ + lstadv(&subp, &subsiz); + } + } + } - /* allocate space for the input list */ - VOC_STK_ARRAY(ctx, vocoldef, inlist, objcnt + 1); + /* allocate space for the input list */ + VOC_STK_ARRAY(ctx, vocoldef, inlist, objcnt + 1); - /* we don't have any unknown words yet */ - unknown_count = 0; + /* we don't have any unknown words yet */ + unknown_count = 0; - /* parse the list, filling in the input array */ - for (lstp = objp, lstsiz = objsiz, i = 0 ; lstsiz != 0 ; - lstadv(&lstp, &lstsiz)) - { - /* if this is a sublist, parse it */ - if (*lstp == DAT_LIST) - { - uchar *subp; - uint subsiz; - int firstwrd, lastwrd; + /* parse the list, filling in the input array */ + for (lstp = objp, lstsiz = objsiz, i = 0 ; lstsiz != 0 ; + lstadv(&lstp, &lstsiz)) + { + /* if this is a sublist, parse it */ + if (*lstp == DAT_LIST) + { + uchar *subp; + uint subsiz; + int firstwrd, lastwrd; - /* get the sublist pointer, and read and skip the size prefix */ - subp = lstp + 1; - subsiz = osrp2(subp) - 2; - subp += 2; + /* get the sublist pointer, and read and skip the size prefix */ + subp = lstp + 1; + subsiz = osrp2(subp) - 2; + subp += 2; - /* in case we don't find token indices, clear them */ - firstwrd = 0; - lastwrd = 0; + /* in case we don't find token indices, clear them */ + firstwrd = 0; + lastwrd = 0; - /* - * the first two elements of the list are the token indices - * of the first and last words of this object's noun phrase - */ - if (subsiz > 0 && *subp == DAT_NUMBER) - { - /* read the first index, adjusting to zero-based indexing */ - firstwrd = (int)osrp4(subp+1) - 1; + /* + * the first two elements of the list are the token indices + * of the first and last words of this object's noun phrase + */ + if (subsiz > 0 && *subp == DAT_NUMBER) + { + /* read the first index, adjusting to zero-based indexing */ + firstwrd = (int)osrp4(subp+1) - 1; - /* make sure it's in range */ - if (firstwrd < 0) - firstwrd = 0; - else if (firstwrd > tokcnt) - firstwrd = tokcnt; + /* make sure it's in range */ + if (firstwrd < 0) + firstwrd = 0; + else if (firstwrd > tokcnt) + firstwrd = tokcnt; - /* skip it */ - lstadv(&subp, &subsiz); - } - if (subsiz > 0 && *subp == DAT_NUMBER) - { - /* read the last index, adjusting to zero-based indexing */ - lastwrd = (int)osrp4(subp+1) - 1; + /* skip it */ + lstadv(&subp, &subsiz); + } + if (subsiz > 0 && *subp == DAT_NUMBER) + { + /* read the last index, adjusting to zero-based indexing */ + lastwrd = (int)osrp4(subp+1) - 1; - /* make sure it's in range */ - if (lastwrd < firstwrd) - lastwrd = firstwrd; - else if (lastwrd > tokcnt) - lastwrd = tokcnt; + /* make sure it's in range */ + if (lastwrd < firstwrd) + lastwrd = firstwrd; + else if (lastwrd > tokcnt) + lastwrd = tokcnt; - /* skip it */ - lstadv(&subp, &subsiz); - } + /* skip it */ + lstadv(&subp, &subsiz); + } - /* scan the sublist */ - while (subsiz > 0) - { - /* if this is an object, store it */ - if (*subp == DAT_OBJECT || *subp == DAT_NIL) - { - /* store the object */ - if (*subp == DAT_OBJECT) - inlist[i].vocolobj = osrp2(subp+1); - else - inlist[i].vocolobj = MCMONINV; + /* scan the sublist */ + while (subsiz > 0) + { + /* if this is an object, store it */ + if (*subp == DAT_OBJECT || *subp == DAT_NIL) + { + /* store the object */ + if (*subp == DAT_OBJECT) + inlist[i].vocolobj = osrp2(subp+1); + else + inlist[i].vocolobj = MCMONINV; - /* set the first and last word pointers */ - inlist[i].vocolfst = cmd[firstwrd]; - inlist[i].vocollst = cmd[lastwrd]; + /* set the first and last word pointers */ + inlist[i].vocolfst = cmd[firstwrd]; + inlist[i].vocollst = cmd[lastwrd]; - /* skip the object */ - lstadv(&subp, &subsiz); + /* skip the object */ + lstadv(&subp, &subsiz); - /* check for flags */ - if (subsiz > 0 && *subp == DAT_NUMBER) - { - /* get the flags value */ - inlist[i].vocolflg = (int)osrp4(subp+1); + /* check for flags */ + if (subsiz > 0 && *subp == DAT_NUMBER) + { + /* get the flags value */ + inlist[i].vocolflg = (int)osrp4(subp+1); - /* skip the number in the list */ - lstadv(&subp, &subsiz); - } - else - { - /* clear the flags */ - inlist[i].vocolflg = 0; - } + /* skip the number in the list */ + lstadv(&subp, &subsiz); + } + else + { + /* clear the flags */ + inlist[i].vocolflg = 0; + } - /* if an unknown word was involved, note it */ - if ((inlist[i].vocolflg & VOCS_UNKNOWN) != 0) - ++unknown_count; + /* if an unknown word was involved, note it */ + if ((inlist[i].vocolflg & VOCS_UNKNOWN) != 0) + ++unknown_count; - /* consume the element */ - ++i; - } - else - { - /* skip this element */ - lstadv(&subp, &subsiz); - } - } - } - } + /* consume the element */ + ++i; + } + else + { + /* skip this element */ + lstadv(&subp, &subsiz); + } + } + } + } - /* terminate the list */ - inlist[i].vocolobj = MCMONINV; - inlist[i].vocolflg = 0; + /* terminate the list */ + inlist[i].vocolobj = MCMONINV; + inlist[i].vocolflg = 0; - /* - * make a copy of our context, so the disambiguation can't make any - * global changes - */ - memcpy(&ctx_copy, ctx, sizeof(ctx_copy)); + /* + * make a copy of our context, so the disambiguation can't make any + * global changes + */ + memcpy(&ctx_copy, ctx, sizeof(ctx_copy)); - /* - * Count the unknown words and set the count in the context. This - * will allow us to determine after we call the resolver whether the - * resolution process cleared up the unknown words (via - * parseUnknownDobj/Iobj). - */ - ctx_copy.voccxunknown = ctx_copy.voccxlastunk = unknown_count; + /* + * Count the unknown words and set the count in the context. This + * will allow us to determine after we call the resolver whether the + * resolution process cleared up the unknown words (via + * parseUnknownDobj/Iobj). + */ + ctx_copy.voccxunknown = ctx_copy.voccxlastunk = unknown_count; - /* disambiguate the noun list */ - err = vocdisambig(&ctx_copy, outlist, inlist, - defprop, accprop, verprop, cmd, - otherobj, actor, verb, prep, cmdbuf, silent); + /* disambiguate the noun list */ + err = vocdisambig(&ctx_copy, outlist, inlist, + defprop, accprop, verprop, cmd, + otherobj, actor, verb, prep, cmdbuf, silent); - /* - * If the error was VOCERR(2) - unknown word - check the input list - * to see if it contained any unknown words. If it does, and we're - * not in "silent" mode, flag the error and then give the user a - * chance to use "oops" to correct the problem. If we're in silent - * mode, don't display an error and don't allow interactive - * correction via "oops." - * - * It is possible that the unknown word is not in the input list, - * but in the user's response to an interactive disambiguation - * query. This is why we must check to see if the unknown word is - * in the original input list or not. - */ - if (err == VOCERR(2) && ctx_copy.voccxunknown != 0 && !silent) - { - char *unk; + /* + * If the error was VOCERR(2) - unknown word - check the input list + * to see if it contained any unknown words. If it does, and we're + * not in "silent" mode, flag the error and then give the user a + * chance to use "oops" to correct the problem. If we're in silent + * mode, don't display an error and don't allow interactive + * correction via "oops." + * + * It is possible that the unknown word is not in the input list, + * but in the user's response to an interactive disambiguation + * query. This is why we must check to see if the unknown word is + * in the original input list or not. + */ + if (err == VOCERR(2) && ctx_copy.voccxunknown != 0 && !silent) + { + char *unk; int unk_idx = 0; - char *rpl_text; + char *rpl_text; - /* - * forget we have unknown words, since we're going to handle - * them now - */ - ctx_copy.voccxunknown = 0; + /* + * forget we have unknown words, since we're going to handle + * them now + */ + ctx_copy.voccxunknown = 0; - /* - * find the unknown word - look up each word until we find one - * that's not in the dictionary - */ - for (i = 0, unk = 0 ; cmd[i] != 0 ; ++i) - { - int t; - - /* - * get this word's type - if the word has no type, it's an - * unknown word - */ - t = voc_lookup_type(ctx, cmd[i], strlen(cmd[i]), TRUE); - if (t == 0) - { - /* this is it - note it and stop searching */ - unk_idx = i; - unk = cmd[i]; - break; - } - } + /* + * find the unknown word - look up each word until we find one + * that's not in the dictionary + */ + for (i = 0, unk = 0 ; cmd[i] != 0 ; ++i) + { + int t; + + /* + * get this word's type - if the word has no type, it's an + * unknown word + */ + t = voc_lookup_type(ctx, cmd[i], strlen(cmd[i]), TRUE); + if (t == 0) + { + /* this is it - note it and stop searching */ + unk_idx = i; + unk = cmd[i]; + break; + } + } - /* - * if we didn't find any unknown words, assume the first word - * was unknown - */ - if (unk == 0) - { - unk_idx = 0; - unk = cmd[0]; - } + /* + * if we didn't find any unknown words, assume the first word + * was unknown + */ + if (unk == 0) + { + unk_idx = 0; + unk = cmd[0]; + } - /* display an error, and read a new command */ - rpl_text = voc_read_oops(&ctx_copy, oopsbuf, VOCBUFSIZ, unk); + /* display an error, and read a new command */ + rpl_text = voc_read_oops(&ctx_copy, oopsbuf, VOCBUFSIZ, unk); - /* - * if they didn't respond with "oops," treat the response as a - * brand new command to replace the current command - */ - if (rpl_text == 0) - { - /* - * it's a replacement command - set the redo flag to - * indicate that we should process the replacement command - */ - ctx_copy.voccxredo = TRUE; + /* + * if they didn't respond with "oops," treat the response as a + * brand new command to replace the current command + */ + if (rpl_text == 0) + { + /* + * it's a replacement command - set the redo flag to + * indicate that we should process the replacement command + */ + ctx_copy.voccxredo = TRUE; - /* copy the response into the command buffer */ - strcpy(cmdbuf, oopsbuf); - } - else - { - /* indicate the correction via the result code */ - err = VOCERR(45); + /* copy the response into the command buffer */ + strcpy(cmdbuf, oopsbuf); + } + else + { + /* indicate the correction via the result code */ + err = VOCERR(45); - /* - * Build the new command string. The new command string - * consists of all of the tokens up to the unknown token, - * then the replacement text, then all of the remaining - * tokens. - */ - for (p = cmdbuf, i = 0 ; cmd[i] != 0 ; ++i) - { - size_t needed; - - /* figure the size needs for this token */ - if (i == unk_idx) - { - /* we need to insert the replacement text */ - needed = strlen(rpl_text); - } - else - { - /* we need to insert this token string */ - needed = strlen(cmd[i]); - } - - /* - * if more tokens follow, we need a space after the - * replacement text to separate it from what follows - */ - if (cmd[i+1] != 0 && needed != 0) - needed += 1; + /* + * Build the new command string. The new command string + * consists of all of the tokens up to the unknown token, + * then the replacement text, then all of the remaining + * tokens. + */ + for (p = cmdbuf, i = 0 ; cmd[i] != 0 ; ++i) + { + size_t needed; + + /* figure the size needs for this token */ + if (i == unk_idx) + { + /* we need to insert the replacement text */ + needed = strlen(rpl_text); + } + else + { + /* we need to insert this token string */ + needed = strlen(cmd[i]); + } + + /* + * if more tokens follow, we need a space after the + * replacement text to separate it from what follows + */ + if (cmd[i+1] != 0 && needed != 0) + needed += 1; - /* leave room for null termination */ - needed += 1; + /* leave room for null termination */ + needed += 1; - /* if we don't have room for this token, stop now */ - if (needed > (size_t)(VOCBUFSIZ - (p - cmdbuf))) - break; + /* if we don't have room for this token, stop now */ + if (needed > (size_t)(VOCBUFSIZ - (p - cmdbuf))) + break; - /* - * if we've reached the unknown token, insert the - * replacement text; otherwise, insert this token - */ - if (i == unk_idx) - { - /* insert the replacement text */ - strcpy(p, rpl_text); - } - else if (*cmd[i] == '"') - { - char *p1; - char qu; - - /* - * Scan the quoted string for embedded double quotes - * - if it has any, use single quotes as the - * delimiter; otherwise, use double quotes as the - * delimiter. Note that we ignore the first and - * last characters in the string, since these are - * always the delimiting double quotes in the - * original token text. - */ - for (qu = '"', p1 = cmd[i] + 1 ; - *p1 != '\0' && *(p1 + 1) != '\0' ; ++p1) - { - /* check for an embedded double quote */ - if (*p1 == '"') - { - /* switch to single quotes as delimiters */ - qu = '\''; + /* + * if we've reached the unknown token, insert the + * replacement text; otherwise, insert this token + */ + if (i == unk_idx) + { + /* insert the replacement text */ + strcpy(p, rpl_text); + } + else if (*cmd[i] == '"') + { + char *p1; + char qu; + + /* + * Scan the quoted string for embedded double quotes + * - if it has any, use single quotes as the + * delimiter; otherwise, use double quotes as the + * delimiter. Note that we ignore the first and + * last characters in the string, since these are + * always the delimiting double quotes in the + * original token text. + */ + for (qu = '"', p1 = cmd[i] + 1 ; + *p1 != '\0' && *(p1 + 1) != '\0' ; ++p1) + { + /* check for an embedded double quote */ + if (*p1 == '"') + { + /* switch to single quotes as delimiters */ + qu = '\''; - /* no need to look any further */ - break; - } - } + /* no need to look any further */ + break; + } + } - /* add the open quote */ - *p++ = qu; + /* add the open quote */ + *p++ = qu; - /* - * add the text, leaving out the first and last - * characters (which are the original quotes) - */ - if (strlen(cmd[i]) > 2) - { - memcpy(p, cmd[i] + 1, strlen(cmd[i]) - 2); - p += strlen(cmd[i]) - 2; - } + /* + * add the text, leaving out the first and last + * characters (which are the original quotes) + */ + if (strlen(cmd[i]) > 2) + { + memcpy(p, cmd[i] + 1, strlen(cmd[i]) - 2); + p += strlen(cmd[i]) - 2; + } - /* add the closing quote */ - *p++ = qu; + /* add the closing quote */ + *p++ = qu; - /* null-terminate here so we don't skip any further */ - *p = '\0'; - } - else - { - /* copy this word */ - strcpy(p, cmd[i]); - } + /* null-terminate here so we don't skip any further */ + *p = '\0'; + } + else + { + /* copy this word */ + strcpy(p, cmd[i]); + } - /* move past this token */ - p += strlen(p); + /* move past this token */ + p += strlen(p); - /* add a space if another token follows */ - if (cmd[i+1] != 0) - *p++ = ' '; - } + /* add a space if another token follows */ + if (cmd[i+1] != 0) + *p++ = ' '; + } - /* null-terminate the replacement text */ - *p = '\0'; - } - } + /* null-terminate the replacement text */ + *p = '\0'; + } + } - /* - * Count the objects. An object list is returned only on success or - * VOCERR(44), which indicates that the list is still ambiguous. - */ - if (err == 0 || err == VOCERR(44)) - { - /* count the objects in the list */ - for (i = 0 ; outlist[i].vocolobj != MCMONINV ; ++i) ; - objcnt = i; - } - else - { - /* there's nothing in the list */ - objcnt = 0; - } + /* + * Count the objects. An object list is returned only on success or + * VOCERR(44), which indicates that the list is still ambiguous. + */ + if (err == 0 || err == VOCERR(44)) + { + /* count the objects in the list */ + for (i = 0 ; outlist[i].vocolobj != MCMONINV ; ++i) ; + objcnt = i; + } + else + { + /* there's nothing in the list */ + objcnt = 0; + } - /* figure out how much space we need for the objects */ - lstsiz = (1+2) * objcnt; - - /* add space for the first element, which contains the status code */ - lstsiz += (1 + 4); + /* figure out how much space we need for the objects */ + lstsiz = (1+2) * objcnt; + + /* add space for the first element, which contains the status code */ + lstsiz += (1 + 4); - /* if there's a new command string, we'll store it, so make room */ - if (ctx_copy.voccxredo || err == VOCERR(45)) - { - /* - * add space for the type prefix (1), length prefix (2), and the - * string bytes (with no null terminator, of course) - */ - lstsiz += (1 + 2 + strlen(cmdbuf)); + /* if there's a new command string, we'll store it, so make room */ + if (ctx_copy.voccxredo || err == VOCERR(45)) + { + /* + * add space for the type prefix (1), length prefix (2), and the + * string bytes (with no null terminator, of course) + */ + lstsiz += (1 + 2 + strlen(cmdbuf)); - /* - * if we're retrying due to the redo flag, always return the - * RETRY error code, regardless of what caused us to retry the - * command - */ - if (ctx_copy.voccxredo) - err = VOCERR(43); - } + /* + * if we're retrying due to the redo flag, always return the + * RETRY error code, regardless of what caused us to retry the + * command + */ + if (ctx_copy.voccxredo) + err = VOCERR(43); + } - /* push a list with space for the objects */ - lstp = voc_push_list_siz(ctx, lstsiz); + /* push a list with space for the objects */ + lstp = voc_push_list_siz(ctx, lstsiz); - /* store the status code in the first element */ - *lstp++ = DAT_NUMBER; - oswp4s(lstp, err); - lstp += 4; + /* store the status code in the first element */ + *lstp++ = DAT_NUMBER; + oswp4s(lstp, err); + lstp += 4; - /* store the remainder of the list */ - if (err == 0 || err == VOCERR(44)) - { - /* fill in the list with the objects */ - for (i = 0 ; i < objcnt ; ++i) - { - /* set this element */ - *lstp++ = DAT_OBJECT; - oswp2(lstp, outlist[i].vocolobj); - lstp += 2; - } - } - else if (ctx_copy.voccxredo || err == VOCERR(45)) - { - uint len; - - /* there's a new command - return it as the second element */ - *lstp++ = DAT_SSTRING; + /* store the remainder of the list */ + if (err == 0 || err == VOCERR(44)) + { + /* fill in the list with the objects */ + for (i = 0 ; i < objcnt ; ++i) + { + /* set this element */ + *lstp++ = DAT_OBJECT; + oswp2(lstp, outlist[i].vocolobj); + lstp += 2; + } + } + else if (ctx_copy.voccxredo || err == VOCERR(45)) + { + uint len; + + /* there's a new command - return it as the second element */ + *lstp++ = DAT_SSTRING; - /* store the length */ - len = strlen(cmdbuf); - oswp2(lstp, len + 2); - lstp += 2; + /* store the length */ + len = strlen(cmdbuf); + oswp2(lstp, len + 2); + lstp += 2; - /* store the string */ - memcpy(lstp, cmdbuf, len); - } + /* store the string */ + memcpy(lstp, cmdbuf, len); + } - /* leave the stack frame */ - voc_leave(ctx, save_sp); + /* leave the stack frame */ + voc_leave(ctx, save_sp); } @@ -4419,30 +4419,30 @@ void voc_parse_disambig(voccxdef *ctx) */ void voc_parse_replace_cmd(voccxdef *ctx) { - runcxdef *rcx = ctx->voccxrun; - uchar *p; - uint len; + runcxdef *rcx = ctx->voccxrun; + uchar *p; + uint len; - /* get the string */ - p = runpopstr(rcx); + /* get the string */ + p = runpopstr(rcx); - /* read and skip the length prefix */ - len = osrp2(p) - 2; - p += 2; + /* read and skip the length prefix */ + len = osrp2(p) - 2; + p += 2; - /* make sure it fits in the redo buffer - truncate it if necessary */ - if (len + 1 > VOCBUFSIZ) - len = VOCBUFSIZ - 1; + /* make sure it fits in the redo buffer - truncate it if necessary */ + if (len + 1 > VOCBUFSIZ) + len = VOCBUFSIZ - 1; - /* copy the string and null-terminate it */ - memcpy(ctx->voccxredobuf, p, len); - ctx->voccxredobuf[len] = '\0'; + /* copy the string and null-terminate it */ + memcpy(ctx->voccxredobuf, p, len); + ctx->voccxredobuf[len] = '\0'; - /* set the "redo" flag so that we execute what's in the buffer */ - ctx->voccxredo = TRUE; + /* set the "redo" flag so that we execute what's in the buffer */ + ctx->voccxredo = TRUE; - /* abort the current command so that we start anew with the replacement */ - errsig(ctx->voccxerr, ERR_RUNABRT); + /* abort the current command so that we start anew with the replacement */ + errsig(ctx->voccxerr, ERR_RUNABRT); } @@ -4457,103 +4457,103 @@ void voc_parse_replace_cmd(voccxdef *ctx) * value is nonzero, then that object is the actor. */ static objnum vocgetactor(voccxdef *ctx, char *cmd[], int typelist[], - int cur, int *next, char *cmdbuf) + int cur, int *next, char *cmdbuf) { - int l; - vocoldef *nounlist; - vocoldef *actlist; - int cnt; - uchar *save_sp; - prpnum valprop, verprop; + int l; + vocoldef *nounlist; + vocoldef *actlist; + int cnt; + uchar *save_sp; + prpnum valprop, verprop; - voc_enter(ctx, &save_sp); - VOC_MAX_ARRAY(ctx, vocoldef, nounlist); - VOC_MAX_ARRAY(ctx, vocoldef, actlist); - - *next = cur; /* assume no error will occur */ - cnt = vocchknoun(ctx, cmd, typelist, cur, next, nounlist, TRUE); - if (cnt > 0 && *next != -1 && cmd[*next] && vocspec(cmd[*next], VOCW_AND)) - { - int have_unknown; + voc_enter(ctx, &save_sp); + VOC_MAX_ARRAY(ctx, vocoldef, nounlist); + VOC_MAX_ARRAY(ctx, vocoldef, actlist); + + *next = cur; /* assume no error will occur */ + cnt = vocchknoun(ctx, cmd, typelist, cur, next, nounlist, TRUE); + if (cnt > 0 && *next != -1 && cmd[*next] && vocspec(cmd[*next], VOCW_AND)) + { + int have_unknown; - /* make a note as to whether the list contains an unknown word */ - have_unknown = ((nounlist[0].vocolflg & VOCS_UNKNOWN) != 0); - - /* - * If validActor is defined for any of the actors, use it; - * otherwise, for compatibility with past versions, use the - * takeVerb disambiguation mechanism. If we have a pronoun, we - * can't decide yet how to do this, so presume that we'll use - * the new mechanism and switch later if necessary. - * - * If we have don't have a valid object (which will be the case - * for a pronoun), we can't decide until we get into the - * disambiguation process, so presume we'll use validActor for - * now. - */ - verprop = PRP_VERACTOR; - if (nounlist[0].vocolobj == MCMONINV - || objgetap(ctx->voccxmem, nounlist[0].vocolobj, PRP_VALIDACTOR, - (objnum *)0, FALSE)) - valprop = PRP_VALIDACTOR; - else - valprop = PRP_VALIDDO; - - /* disambiguate it using the selected properties */ - if (vocdisambig(ctx, actlist, nounlist, PRP_DODEFAULT, valprop, - verprop, cmd, MCMONINV, ctx->voccxme, - ctx->voccxvtk, MCMONINV, cmdbuf, FALSE)) - { - /* - * if we have an unknown word in the list, assume for the - * moment that this isn't an actor phrase after all, but a - * verb - */ - if (have_unknown) - { - /* indicate that we didn't find a noun phrase syntactically */ - *next = cur; - } + /* make a note as to whether the list contains an unknown word */ + have_unknown = ((nounlist[0].vocolflg & VOCS_UNKNOWN) != 0); + + /* + * If validActor is defined for any of the actors, use it; + * otherwise, for compatibility with past versions, use the + * takeVerb disambiguation mechanism. If we have a pronoun, we + * can't decide yet how to do this, so presume that we'll use + * the new mechanism and switch later if necessary. + * + * If we have don't have a valid object (which will be the case + * for a pronoun), we can't decide until we get into the + * disambiguation process, so presume we'll use validActor for + * now. + */ + verprop = PRP_VERACTOR; + if (nounlist[0].vocolobj == MCMONINV + || objgetap(ctx->voccxmem, nounlist[0].vocolobj, PRP_VALIDACTOR, + (objnum *)0, FALSE)) + valprop = PRP_VALIDACTOR; + else + valprop = PRP_VALIDDO; + + /* disambiguate it using the selected properties */ + if (vocdisambig(ctx, actlist, nounlist, PRP_DODEFAULT, valprop, + verprop, cmd, MCMONINV, ctx->voccxme, + ctx->voccxvtk, MCMONINV, cmdbuf, FALSE)) + { + /* + * if we have an unknown word in the list, assume for the + * moment that this isn't an actor phrase after all, but a + * verb + */ + if (have_unknown) + { + /* indicate that we didn't find a noun phrase syntactically */ + *next = cur; + } - /* return no actor */ - VOC_RETVAL(ctx, save_sp, MCMONINV); - } + /* return no actor */ + VOC_RETVAL(ctx, save_sp, MCMONINV); + } - if ((l = voclistlen(actlist)) > 1) - { - vocerr(ctx, VOCERR(12), - "You can only speak to one person at a time."); - *next = cur + 1; /* error flag - return invalid but next!=cur */ - VOC_RETVAL(ctx, save_sp, MCMONINV); - } - else if (l == 0) - return(MCMONINV); + if ((l = voclistlen(actlist)) > 1) + { + vocerr(ctx, VOCERR(12), + "You can only speak to one person at a time."); + *next = cur + 1; /* error flag - return invalid but next!=cur */ + VOC_RETVAL(ctx, save_sp, MCMONINV); + } + else if (l == 0) + return(MCMONINV); - if (cmd[*next] && vocspec(cmd[*next], VOCW_AND)) - { - ++(*next); - VOC_RETVAL(ctx, save_sp, actlist[0].vocolobj); - } - } - if (cnt < 0) - { - /* error - make *next != cur */ - *next = cur + 1; - } - else - *next = cur; /* no error condition, but nothing found */ + if (cmd[*next] && vocspec(cmd[*next], VOCW_AND)) + { + ++(*next); + VOC_RETVAL(ctx, save_sp, actlist[0].vocolobj); + } + } + if (cnt < 0) + { + /* error - make *next != cur */ + *next = cur + 1; + } + else + *next = cur; /* no error condition, but nothing found */ - VOC_RETVAL(ctx, save_sp, MCMONINV); /* so return invalid and *next == cur */ + VOC_RETVAL(ctx, save_sp, MCMONINV); /* so return invalid and *next == cur */ } /* figure out how many objects are in an object list */ int voclistlen(vocoldef *lst) { - int i; - - for (i = 0 ; lst->vocolobj != MCMONINV || lst->vocolflg != 0 ; - ++lst, ++i) ; - return(i); + int i; + + for (i = 0 ; lst->vocolobj != MCMONINV || lst->vocolflg != 0 ; + ++lst, ++i) ; + return(i); } /* @@ -4570,77 +4570,77 @@ int voclistlen(vocoldef *lst) * obj.validActor() for the object itself (not the verb). */ int vocchkaccess(voccxdef *ctx, objnum obj, prpnum verprop, - int seqno, objnum cmdActor, objnum cmdVerb) + int seqno, objnum cmdActor, objnum cmdVerb) { - /* - * special case: the special "string" and "number" objects are - * always accessible - */ - if (obj == ctx->voccxstr || obj == ctx->voccxnum) - return TRUE; + /* + * special case: the special "string" and "number" objects are + * always accessible + */ + if (obj == ctx->voccxstr || obj == ctx->voccxnum) + return TRUE; - /* - * If the access method is validActor, make sure the object in fact - * has a validActor method defined; if it doesn't, we must be - * running a game from before validActor's invention, so use the old - * ValidXo mechanism instead. - */ - if (verprop == PRP_VALIDACTOR) - { - /* checking an actor - check to see if ValidActor is defined */ - if (objgetap(ctx->voccxmem, obj, PRP_VALIDACTOR, (objnum *)0, FALSE)) - { - /* ValidActor is present - call ValidActor in the object itself */ - runppr(ctx->voccxrun, obj, verprop, 0); + /* + * If the access method is validActor, make sure the object in fact + * has a validActor method defined; if it doesn't, we must be + * running a game from before validActor's invention, so use the old + * ValidXo mechanism instead. + */ + if (verprop == PRP_VALIDACTOR) + { + /* checking an actor - check to see if ValidActor is defined */ + if (objgetap(ctx->voccxmem, obj, PRP_VALIDACTOR, (objnum *)0, FALSE)) + { + /* ValidActor is present - call ValidActor in the object itself */ + runppr(ctx->voccxrun, obj, verprop, 0); - /* return the result */ - return runpoplog(ctx->voccxrun); - } - else - { - /* there's no ValidActor - call ValidXo in the "take" verb */ - cmdVerb = ctx->voccxvtk; - verprop = PRP_VALIDDO; - } - } + /* return the result */ + return runpoplog(ctx->voccxrun); + } + else + { + /* there's no ValidActor - call ValidXo in the "take" verb */ + cmdVerb = ctx->voccxvtk; + verprop = PRP_VALIDDO; + } + } - /* call ValidXo in the verb */ - runpnum(ctx->voccxrun, (long)(seqno + 1)); - runpobj(ctx->voccxrun, obj); - runpobj(ctx->voccxrun, - (objnum)(cmdActor == MCMONINV ? ctx->voccxme : cmdActor)); - runppr(ctx->voccxrun, cmdVerb, verprop, 3); + /* call ValidXo in the verb */ + runpnum(ctx->voccxrun, (long)(seqno + 1)); + runpobj(ctx->voccxrun, obj); + runpobj(ctx->voccxrun, + (objnum)(cmdActor == MCMONINV ? ctx->voccxme : cmdActor)); + runppr(ctx->voccxrun, cmdVerb, verprop, 3); - /* return the result */ - return runpoplog(ctx->voccxrun); + /* return the result */ + return runpoplog(ctx->voccxrun); } /* ask game if object is visible to the actor */ int vocchkvis(voccxdef *ctx, objnum obj, objnum cmdActor) { - runpobj(ctx->voccxrun, - (objnum)(cmdActor == MCMONINV ? ctx->voccxme : cmdActor)); - runppr(ctx->voccxrun, obj, (prpnum)PRP_ISVIS, 1); - return(runpoplog(ctx->voccxrun)); + runpobj(ctx->voccxrun, + (objnum)(cmdActor == MCMONINV ? ctx->voccxme : cmdActor)); + runppr(ctx->voccxrun, obj, (prpnum)PRP_ISVIS, 1); + return(runpoplog(ctx->voccxrun)); } /* set {numObj | strObj}.value, as appropriate */ void vocsetobj(voccxdef *ctx, objnum obj, dattyp typ, const void *val, - vocoldef *inobj, vocoldef *outobj) + vocoldef *inobj, vocoldef *outobj) { - *outobj = *inobj; - outobj->vocolobj = obj; - objsetp(ctx->voccxmem, obj, PRP_VALUE, typ, val, ctx->voccxundo); + *outobj = *inobj; + outobj->vocolobj = obj; + objsetp(ctx->voccxmem, obj, PRP_VALUE, typ, val, ctx->voccxundo); } /* set up a vocoldef */ static void vocout(vocoldef *outobj, objnum obj, int flg, - const char *fst, const char *lst) + const char *fst, const char *lst) { - outobj->vocolobj = obj; - outobj->vocolflg = flg; - outobj->vocolfst = fst; - outobj->vocollst = lst; + outobj->vocolobj = obj; + outobj->vocolflg = flg; + outobj->vocolfst = fst; + outobj->vocollst = lst; } /* @@ -4650,52 +4650,52 @@ static void vocout(vocoldef *outobj, objnum obj, int flg, * there is no cantReach in the verb, of each object in the list. */ void vocnoreach(voccxdef *ctx, objnum *list1, int cnt, - objnum actor, objnum verb, objnum prep, prpnum defprop, - int show_multi_prefix, - int multi_flags, int multi_base_index, int multi_total_count) + objnum actor, objnum verb, objnum prep, prpnum defprop, + int show_multi_prefix, + int multi_flags, int multi_base_index, int multi_total_count) { - /* see if the verb has a cantReach method - use it if so */ - if (objgetap(ctx->voccxmem, verb, PRP_NOREACH, (objnum *)0, FALSE)) - { - /* push arguments: (actor, dolist, iolist, prep) */ - runpobj(ctx->voccxrun, prep); - if (defprop == PRP_DODEFAULT) - { - runpnil(ctx->voccxrun); - voc_push_objlist(ctx, list1, cnt); - } - else - { - voc_push_objlist(ctx, list1, cnt); - runpnil(ctx->voccxrun); - } - runpobj(ctx->voccxrun, actor); + /* see if the verb has a cantReach method - use it if so */ + if (objgetap(ctx->voccxmem, verb, PRP_NOREACH, (objnum *)0, FALSE)) + { + /* push arguments: (actor, dolist, iolist, prep) */ + runpobj(ctx->voccxrun, prep); + if (defprop == PRP_DODEFAULT) + { + runpnil(ctx->voccxrun); + voc_push_objlist(ctx, list1, cnt); + } + else + { + voc_push_objlist(ctx, list1, cnt); + runpnil(ctx->voccxrun); + } + runpobj(ctx->voccxrun, actor); - /* invoke the method in the verb */ - runppr(ctx->voccxrun, verb, PRP_NOREACH, 4); - } - else - { - int i; + /* invoke the method in the verb */ + runppr(ctx->voccxrun, verb, PRP_NOREACH, 4); + } + else + { + int i; - /* use the old way - call obj.cantReach() for each object */ - for (i = 0 ; i < cnt ; ++i) - { - /* - * display this object's name if there's more than one, so - * that the player can tell to which object this message - * applies - */ - voc_multi_prefix(ctx, list1[i], show_multi_prefix, multi_flags, - multi_base_index + i, multi_total_count); + /* use the old way - call obj.cantReach() for each object */ + for (i = 0 ; i < cnt ; ++i) + { + /* + * display this object's name if there's more than one, so + * that the player can tell to which object this message + * applies + */ + voc_multi_prefix(ctx, list1[i], show_multi_prefix, multi_flags, + multi_base_index + i, multi_total_count); - /* call cantReach on the object */ - runpobj(ctx->voccxrun, - (objnum)(actor == MCMONINV ? ctx->voccxme : actor)); - runppr(ctx->voccxrun, list1[i], (prpnum)PRP_NOREACH, 1); - tioflush(ctx->voccxtio); - } - } + /* call cantReach on the object */ + runpobj(ctx->voccxrun, + (objnum)(actor == MCMONINV ? ctx->voccxme : actor)); + runppr(ctx->voccxrun, list1[i], (prpnum)PRP_NOREACH, 1); + tioflush(ctx->voccxtio); + } + } } /* @@ -4703,96 +4703,96 @@ void vocnoreach(voccxdef *ctx, objnum *list1, int cnt, * the first string if multiple strings are defined for the entry. */ static void voc_get_spec_str(voccxdef *ctx, char vocw_id, - char *buf, size_t buflen, - const char *default_name) + char *buf, size_t buflen, + const char *default_name) { - int found; + int found; - /* presume we won't find it */ - found = FALSE; + /* presume we won't find it */ + found = FALSE; - /* if there's a special word list, search it for this entry */ - if (ctx->voccxspp != 0) - { - char *p; - char *endp; - size_t len; + /* if there's a special word list, search it for this entry */ + if (ctx->voccxspp != 0) + { + char *p; + char *endp; + size_t len; - /* find appropriate user-defined word in specialWords list */ - for (p = ctx->voccxspp, endp = p + ctx->voccxspl ; p < endp ; ) - { - /* if this one matches, get its first word */ - if (*p++ == vocw_id) - { - /* note that we found it */ - found = TRUE; + /* find appropriate user-defined word in specialWords list */ + for (p = ctx->voccxspp, endp = p + ctx->voccxspl ; p < endp ; ) + { + /* if this one matches, get its first word */ + if (*p++ == vocw_id) + { + /* note that we found it */ + found = TRUE; - /* - * get the length, and limit it to the buffer size, - * leaving room for null termination - */ - len = *p++; - if (len + 1 > buflen) - len = buflen - 1; + /* + * get the length, and limit it to the buffer size, + * leaving room for null termination + */ + len = *p++; + if (len + 1 > buflen) + len = buflen - 1; - /* copy it and null-terminate the string */ - memcpy(buf, p, len); - buf[len] = '\0'; + /* copy it and null-terminate the string */ + memcpy(buf, p, len); + buf[len] = '\0'; - /* we found it - no need to look any further */ - break; - } + /* we found it - no need to look any further */ + break; + } - /* - * move on to the next one - skip the length prefix plus the - * length - */ - p += *p + 1; - } - } + /* + * move on to the next one - skip the length prefix plus the + * length + */ + p += *p + 1; + } + } - /* if we didn't find it, use the default */ - if (!found) - { - strncpy(buf, default_name, (size_t)buflen); - buf[buflen - 1] = '\0'; - } + /* if we didn't find it, use the default */ + if (!found) + { + strncpy(buf, default_name, (size_t)buflen); + buf[buflen - 1] = '\0'; + } } /* set it/him/her */ static int vocsetit(voccxdef *ctx, objnum obj, int accprop, - objnum actor, objnum verb, objnum prep, - vocoldef *outobj, const char *default_name, char vocw_id, - prpnum defprop, int silent) + objnum actor, objnum verb, objnum prep, + vocoldef *outobj, const char *default_name, char vocw_id, + prpnum defprop, int silent) { - if (obj == MCMONINV || !vocchkaccess(ctx, obj, (prpnum)accprop, - 0, actor, verb)) - { - char nambuf[40]; + if (obj == MCMONINV || !vocchkaccess(ctx, obj, (prpnum)accprop, + 0, actor, verb)) + { + char nambuf[40]; - /* get the display name for this specialWords entry */ - voc_get_spec_str(ctx, vocw_id, nambuf, sizeof(nambuf), default_name); - - /* show the error if appropriate */ - if (!silent) - { - /* use 'noreach' if possible, otherwise use a default message */ - if (obj == MCMONINV) - vocerr(ctx, VOCERR(13), - "I don't know what you're referring to with '%s'.", - nambuf); - else - vocnoreach(ctx, &obj, 1, actor, verb, prep, - defprop, FALSE, 0, 0, 1); - } + /* get the display name for this specialWords entry */ + voc_get_spec_str(ctx, vocw_id, nambuf, sizeof(nambuf), default_name); + + /* show the error if appropriate */ + if (!silent) + { + /* use 'noreach' if possible, otherwise use a default message */ + if (obj == MCMONINV) + vocerr(ctx, VOCERR(13), + "I don't know what you're referring to with '%s'.", + nambuf); + else + vocnoreach(ctx, &obj, 1, actor, verb, prep, + defprop, FALSE, 0, 0, 1); + } - /* indicate that the antecedent is inaccessible */ - return VOCERR(13); - } + /* indicate that the antecedent is inaccessible */ + return VOCERR(13); + } - /* set the object */ - vocout(outobj, obj, 0, default_name, default_name); - return 0; + /* set the object */ + vocout(outobj, obj, 0, default_name, default_name); + return 0; } /* @@ -4802,47 +4802,47 @@ static int vocsetit(voccxdef *ctx, objnum obj, int accprop, * can return nil, in which case we'll reject the command. */ static objnum voc_new_num_obj(voccxdef *ctx, objnum objn, - objnum actor, objnum verb, - long num, int plural) + objnum actor, objnum verb, + long num, int plural) { - /* push the number - if we need a plural object, use nil instead */ - if (plural) - runpnil(ctx->voccxrun); - else - runpnum(ctx->voccxrun, num); + /* push the number - if we need a plural object, use nil instead */ + if (plural) + runpnil(ctx->voccxrun); + else + runpnum(ctx->voccxrun, num); - /* push the other arguments and call the method */ - runpobj(ctx->voccxrun, verb); - runpobj(ctx->voccxrun, actor); - runppr(ctx->voccxrun, objn, PRP_NEWNUMOBJ, 3); + /* push the other arguments and call the method */ + runpobj(ctx->voccxrun, verb); + runpobj(ctx->voccxrun, actor); + runppr(ctx->voccxrun, objn, PRP_NEWNUMOBJ, 3); - /* if it was rejected, return an invalid object, else return the object */ - if (runtostyp(ctx->voccxrun) == DAT_NIL) - { - rundisc(ctx->voccxrun); - return MCMONINV; - } - else - return runpopobj(ctx->voccxrun); + /* if it was rejected, return an invalid object, else return the object */ + if (runtostyp(ctx->voccxrun) == DAT_NIL) + { + rundisc(ctx->voccxrun); + return MCMONINV; + } + else + return runpopobj(ctx->voccxrun); } /* check if an object defines the special adjective '#' */ static int has_gen_num_adj(voccxdef *ctx, objnum objn) { - vocwdef *v; - vocseadef search_ctx; + vocwdef *v; + vocseadef search_ctx; - /* scan the list of objects defined '#' as an adjective */ - for (v = vocffw(ctx, "#", 1, (char *)0, 0, PRP_ADJ, &search_ctx) ; - v ; v = vocfnw(ctx, &search_ctx)) - { - /* if this is the object, return positive indication */ - if (v->vocwobj == objn) - return TRUE; - } + /* scan the list of objects defined '#' as an adjective */ + for (v = vocffw(ctx, "#", 1, (char *)0, 0, PRP_ADJ, &search_ctx) ; + v ; v = vocfnw(ctx, &search_ctx)) + { + /* if this is the object, return positive indication */ + if (v->vocwobj == objn) + return TRUE; + } - /* didn't find it */ - return FALSE; + /* didn't find it */ + return FALSE; } @@ -4852,176 +4852,176 @@ static int has_gen_num_adj(voccxdef *ctx, objnum objn) * game-controlled disambiguation. */ static int voc_disambig_hook(voccxdef *ctx, objnum verb, objnum actor, - objnum prep, objnum otherobj, - prpnum accprop, prpnum verprop, - objnum *objlist, uint *flags, int *objcount, - const char *firstwrd, const char *lastwrd, - int num_wanted, int is_ambig, char *resp, - int silent) + objnum prep, objnum otherobj, + prpnum accprop, prpnum verprop, + objnum *objlist, uint *flags, int *objcount, + const char *firstwrd, const char *lastwrd, + int num_wanted, int is_ambig, char *resp, + int silent) { - runcxdef *rcx = ctx->voccxrun; - prpnum call_prop; - runsdef val; - uchar *lstp; - uint lstsiz; - int ret; - int i; - - /* check for actor disambiguation */ - if (verprop == PRP_VERACTOR) - { - /* do nothing on actor disambiguation */ - return VOC_DISAMBIG_CONT; - } + runcxdef *rcx = ctx->voccxrun; + prpnum call_prop; + runsdef val; + uchar *lstp; + uint lstsiz; + int ret; + int i; + + /* check for actor disambiguation */ + if (verprop == PRP_VERACTOR) + { + /* do nothing on actor disambiguation */ + return VOC_DISAMBIG_CONT; + } - /* figure out whether this is a dobj method or an iobj method */ - call_prop = (accprop == PRP_VALIDDO ? PRP_DISAMBIGDO : PRP_DISAMBIGIO); + /* figure out whether this is a dobj method or an iobj method */ + call_prop = (accprop == PRP_VALIDDO ? PRP_DISAMBIGDO : PRP_DISAMBIGIO); - /* if the method isn't defined, we can skip this entirely */ - if (objgetap(ctx->voccxmem, verb, call_prop, (objnum *)0, FALSE) == 0) - return VOC_DISAMBIG_CONT; + /* if the method isn't defined, we can skip this entirely */ + if (objgetap(ctx->voccxmem, verb, call_prop, (objnum *)0, FALSE) == 0) + return VOC_DISAMBIG_CONT; - /* push the "silent" flag */ - val.runstyp = (silent ? DAT_TRUE : DAT_NIL); - runpush(rcx, val.runstyp, &val); + /* push the "silent" flag */ + val.runstyp = (silent ? DAT_TRUE : DAT_NIL); + runpush(rcx, val.runstyp, &val); - /* push the "is_ambiguous" flag */ - val.runstyp = (is_ambig ? DAT_TRUE : DAT_NIL); - runpush(rcx, val.runstyp, &val); + /* push the "is_ambiguous" flag */ + val.runstyp = (is_ambig ? DAT_TRUE : DAT_NIL); + runpush(rcx, val.runstyp, &val); - /* push the "numWanted" count */ - runpnum(rcx, num_wanted); + /* push the "numWanted" count */ + runpnum(rcx, num_wanted); - /* push the flag list */ - voc_push_numlist(ctx, flags, *objcount); + /* push the flag list */ + voc_push_numlist(ctx, flags, *objcount); - /* push the object list */ - voc_push_objlist(ctx, objlist, *objcount); + /* push the object list */ + voc_push_objlist(ctx, objlist, *objcount); - /* push the word list */ - voc_push_strlist(ctx, firstwrd, lastwrd); + /* push the word list */ + voc_push_strlist(ctx, firstwrd, lastwrd); - /* push the verification property */ - val.runstyp = DAT_PROPNUM; - val.runsv.runsvprp = verprop; - runpush(rcx, DAT_PROPNUM, &val); + /* push the verification property */ + val.runstyp = DAT_PROPNUM; + val.runsv.runsvprp = verprop; + runpush(rcx, DAT_PROPNUM, &val); - /* push the other object */ - runpobj(rcx, otherobj); + /* push the other object */ + runpobj(rcx, otherobj); - /* push the preposition and the actor objects */ - runpobj(rcx, prep); - runpobj(rcx, actor); + /* push the preposition and the actor objects */ + runpobj(rcx, prep); + runpobj(rcx, actor); - /* call the method */ - runppr(rcx, verb, call_prop, 10); + /* call the method */ + runppr(rcx, verb, call_prop, 10); - /* check the return value */ - switch(runtostyp(rcx)) - { - case DAT_LIST: - /* get the list */ - lstp = runpoplst(rcx); + /* check the return value */ + switch(runtostyp(rcx)) + { + case DAT_LIST: + /* get the list */ + lstp = runpoplst(rcx); - /* read the list size prefix */ - lstsiz = osrp2(lstp) - 2; - lstp += 2; + /* read the list size prefix */ + lstsiz = osrp2(lstp) - 2; + lstp += 2; - /* check for the status code */ - if (lstsiz > 0 && *lstp == DAT_NUMBER) - { - /* get the status code */ - ret = osrp4s(lstp+1); + /* check for the status code */ + if (lstsiz > 0 && *lstp == DAT_NUMBER) + { + /* get the status code */ + ret = osrp4s(lstp+1); - /* skip the element */ - lstadv(&lstp, &lstsiz); - } - else - { - /* there's no status code - assume CONTINUE */ - ret = VOC_DISAMBIG_CONT; - } + /* skip the element */ + lstadv(&lstp, &lstsiz); + } + else + { + /* there's no status code - assume CONTINUE */ + ret = VOC_DISAMBIG_CONT; + } - /* check for a PARSE_RESP return */ - if (ret == VOC_DISAMBIG_PARSE_RESP) - { - /* the second element is the string */ - if (*lstp == DAT_SSTRING) - { - uint len; - - /* get the length, and limit it to our buffer size */ - len = osrp2(lstp+1) - 2; - if (len > VOCBUFSIZ - 1) - len = VOCBUFSIZ - 1; + /* check for a PARSE_RESP return */ + if (ret == VOC_DISAMBIG_PARSE_RESP) + { + /* the second element is the string */ + if (*lstp == DAT_SSTRING) + { + uint len; + + /* get the length, and limit it to our buffer size */ + len = osrp2(lstp+1) - 2; + if (len > VOCBUFSIZ - 1) + len = VOCBUFSIZ - 1; - /* copy the string into the caller's buffer */ - memcpy(resp, lstp+3, len); - resp[len] = '\0'; - } - else - { - /* there's no string - ignore it */ - ret = VOC_DISAMBIG_CONT; - } - } - else - { - /* store the object list in the caller's list */ - for (i = 0 ; lstsiz > 0 && i < VOCMAXAMBIG-1 ; ++i) - { - /* get this object */ - if (*lstp == DAT_OBJECT) - objlist[i] = osrp2(lstp+1); - else - objlist[i] = MCMONINV; - - /* skip the list entry */ - lstadv(&lstp, &lstsiz); - - /* check for flags */ - if (lstsiz > 0 && *lstp == DAT_NUMBER) - { - /* store the flags */ - flags[i] = (int)osrp4(lstp+1); - - /* skip the flags elements */ - lstadv(&lstp, &lstsiz); - } - else - { - /* no flags - use zero by default */ - flags[i] = 0; - } - } + /* copy the string into the caller's buffer */ + memcpy(resp, lstp+3, len); + resp[len] = '\0'; + } + else + { + /* there's no string - ignore it */ + ret = VOC_DISAMBIG_CONT; + } + } + else + { + /* store the object list in the caller's list */ + for (i = 0 ; lstsiz > 0 && i < VOCMAXAMBIG-1 ; ++i) + { + /* get this object */ + if (*lstp == DAT_OBJECT) + objlist[i] = osrp2(lstp+1); + else + objlist[i] = MCMONINV; + + /* skip the list entry */ + lstadv(&lstp, &lstsiz); + + /* check for flags */ + if (lstsiz > 0 && *lstp == DAT_NUMBER) + { + /* store the flags */ + flags[i] = (int)osrp4(lstp+1); + + /* skip the flags elements */ + lstadv(&lstp, &lstsiz); + } + else + { + /* no flags - use zero by default */ + flags[i] = 0; + } + } - /* store a terminator at the end of the list */ - objlist[i] = MCMONINV; - flags[i] = 0; - - /* store the output count for the caller */ - *objcount = i; - } + /* store a terminator at the end of the list */ + objlist[i] = MCMONINV; + flags[i] = 0; + + /* store the output count for the caller */ + *objcount = i; + } - /* return the result */ - return ret; + /* return the result */ + return ret; - case DAT_NUMBER: - /* get the status code */ - ret = runpopnum(rcx); + case DAT_NUMBER: + /* get the status code */ + ret = runpopnum(rcx); - /* ignore raw PARSE_RESP codes, since they need to return a string */ - if (ret == VOC_DISAMBIG_PARSE_RESP) - ret = VOC_DISAMBIG_CONT; + /* ignore raw PARSE_RESP codes, since they need to return a string */ + if (ret == VOC_DISAMBIG_PARSE_RESP) + ret = VOC_DISAMBIG_CONT; - /* return the status */ - return ret; + /* return the status */ + return ret; - default: - /* treat anything else as CONTINUE */ - rundisc(rcx); - return VOC_DISAMBIG_CONT; - } + default: + /* treat anything else as CONTINUE */ + rundisc(rcx); + return VOC_DISAMBIG_CONT; + } } @@ -5036,66 +5036,66 @@ static int voc_disambig_hook(voccxdef *ctx, objnum verb, objnum actor, * when matches of mixed quality are present. */ static int voc_remove_objs_with_flag(voccxdef *ctx, - objnum *list, uint *flags, int cnt, - int flag_to_remove) + objnum *list, uint *flags, int cnt, + int flag_to_remove) { - int i; - int flag_cnt; - int special_cnt; + int i; + int flag_cnt; + int special_cnt; - /* first, count the number of objects with the flag */ - for (i = 0, flag_cnt = special_cnt = 0 ; i < cnt ; ++i) - { - /* if this object exhibits the flag, count it */ - if ((flags[i] & flag_to_remove) != 0) - ++flag_cnt; + /* first, count the number of objects with the flag */ + for (i = 0, flag_cnt = special_cnt = 0 ; i < cnt ; ++i) + { + /* if this object exhibits the flag, count it */ + if ((flags[i] & flag_to_remove) != 0) + ++flag_cnt; - /* if it's numObj or strObj, count it separately */ - if (list[i] == ctx->voccxnum || list[i] == ctx->voccxstr) - ++special_cnt; - } + /* if it's numObj or strObj, count it separately */ + if (list[i] == ctx->voccxnum || list[i] == ctx->voccxstr) + ++special_cnt; + } - /* - * If all of the objects didn't have the flag, omit the ones that - * did, so that we reduce the ambiguity to those without the flag. - * Don't include the special objects (numObj and strObj) in the - * count, since they will never have any of these flags set. - */ - if (flag_cnt != 0 && flag_cnt < cnt - special_cnt) - { - int dst; + /* + * If all of the objects didn't have the flag, omit the ones that + * did, so that we reduce the ambiguity to those without the flag. + * Don't include the special objects (numObj and strObj) in the + * count, since they will never have any of these flags set. + */ + if (flag_cnt != 0 && flag_cnt < cnt - special_cnt) + { + int dst; - /* - * Remove the flagged objects. Note that we can make this - * adjustment to the arrays in place, because they can only - * shrink - there's no need to make an extra temporary copy. - */ - for (i = 0, dst = 0 ; i < cnt ; ++i) - { - /* - * If this one doesn't have the flag, keep it. Always keep - * the special objects (numObj and strObj). - */ - if ((flags[i] & flag_to_remove) == 0 - || list[i] == ctx->voccxnum - || list[i] == ctx->voccxstr) - { - /* copy this one to the output location */ - list[dst] = list[i]; - flags[dst] = flags[i]; + /* + * Remove the flagged objects. Note that we can make this + * adjustment to the arrays in place, because they can only + * shrink - there's no need to make an extra temporary copy. + */ + for (i = 0, dst = 0 ; i < cnt ; ++i) + { + /* + * If this one doesn't have the flag, keep it. Always keep + * the special objects (numObj and strObj). + */ + if ((flags[i] & flag_to_remove) == 0 + || list[i] == ctx->voccxnum + || list[i] == ctx->voccxstr) + { + /* copy this one to the output location */ + list[dst] = list[i]; + flags[dst] = flags[i]; - /* count the new element of the output */ - ++dst; - } - } + /* count the new element of the output */ + ++dst; + } + } - /* set the updated count */ - cnt = dst; - list[cnt] = MCMONINV; - } + /* set the updated count */ + cnt = dst; + list[cnt] = MCMONINV; + } - /* return the new count */ - return cnt; + /* return the new count */ + return cnt; } /* @@ -5114,16 +5114,16 @@ static int voc_remove_objs_with_flag(voccxdef *ctx, * Returns the number of elements in the result list. */ static int voc_prune_matches(voccxdef *ctx, - objnum *list, uint *flags, int cnt) + objnum *list, uint *flags, int cnt) { - /* remove matches that end with an adjective */ - cnt = voc_remove_objs_with_flag(ctx, list, flags, cnt, VOCS_ENDADJ); + /* remove matches that end with an adjective */ + cnt = voc_remove_objs_with_flag(ctx, list, flags, cnt, VOCS_ENDADJ); - /* remove matches that use truncated words */ - cnt = voc_remove_objs_with_flag(ctx, list, flags, cnt, VOCS_TRUNC); + /* remove matches that use truncated words */ + cnt = voc_remove_objs_with_flag(ctx, list, flags, cnt, VOCS_TRUNC); - /* return the new list size */ - return cnt; + /* return the new list size */ + return cnt; } /* ------------------------------------------------------------------------ */ @@ -5135,98 +5135,98 @@ static int voc_prune_matches(voccxdef *ctx, * we'll keep only one item from each set of indistinguishable items. */ static int voc_count_diff(voccxdef *ctx, objnum *list, uint *flags, int *cnt, - int keep_all) + int keep_all) { - int i; - int diff_cnt; - - /* - * Presume all items will be distinguishable from one another. As - * we scan the list for indistinguishable items, we'll decrement - * this count each time we find an item that can't be distinguished - * from another item. - */ - diff_cnt = *cnt; + int i; + int diff_cnt; + + /* + * Presume all items will be distinguishable from one another. As + * we scan the list for indistinguishable items, we'll decrement + * this count each time we find an item that can't be distinguished + * from another item. + */ + diff_cnt = *cnt; - /* - * Look for indistinguishable items. - * - * An object is distinguishable if it doesn't have the special - * property marking it as one of a group of equivalent objects - * (PRP_ISEQUIV), or if it has the property but there is no object - * following it in the list which has the same immediate superclass. - * - * Note that we want to keep the duplicates if we're looking for - * plurals, because the player is explicitly referring to all - * matching objects. - */ - for (i = 0 ; i < *cnt ; ++i) - { - /* - * check to see if this object might have indistinguishable - * duplicates - it must be marked with isEquiv for this to be - * possible - */ - runppr(ctx->voccxrun, list[i], PRP_ISEQUIV, 0); - if (runpoplog(ctx->voccxrun)) - { - int j; - int dst; - objnum sc; - - /* get the superclass, if possible */ - sc = objget1sc(ctx->voccxmem, list[i]); - if (sc == MCMONINV) - continue; - - /* - * run through the remainder of the list, and remove any - * duplicates of this item - */ - for (j = i + 1, dst = i + 1 ; j < *cnt ; ++j) - { - /* - * see if it matches our object - if not, keep it in the - * list by copying it to our destination position - */ - if (objget1sc(ctx->voccxmem, list[j]) != sc) - { - /* it's distinguishable - keep it */ - list[dst] = list[j]; - flags[dst++] = flags[j]; - } - else - { - /* - * This item is indistinguishable from the list[i]. - * First, reduce the count of different items. - */ - --diff_cnt; - - /* - * Keep this object only if we're keeping all - * redundant indistinguishable items. - */ - if (keep_all) - { - /* keep all items -> keep this item */ - list[dst] = list[j]; - flags[dst++] = flags[j]; - } - } - } - - /* adjust the count to reflect the updated list */ - *cnt = dst; + /* + * Look for indistinguishable items. + * + * An object is distinguishable if it doesn't have the special + * property marking it as one of a group of equivalent objects + * (PRP_ISEQUIV), or if it has the property but there is no object + * following it in the list which has the same immediate superclass. + * + * Note that we want to keep the duplicates if we're looking for + * plurals, because the player is explicitly referring to all + * matching objects. + */ + for (i = 0 ; i < *cnt ; ++i) + { + /* + * check to see if this object might have indistinguishable + * duplicates - it must be marked with isEquiv for this to be + * possible + */ + runppr(ctx->voccxrun, list[i], PRP_ISEQUIV, 0); + if (runpoplog(ctx->voccxrun)) + { + int j; + int dst; + objnum sc; + + /* get the superclass, if possible */ + sc = objget1sc(ctx->voccxmem, list[i]); + if (sc == MCMONINV) + continue; + + /* + * run through the remainder of the list, and remove any + * duplicates of this item + */ + for (j = i + 1, dst = i + 1 ; j < *cnt ; ++j) + { + /* + * see if it matches our object - if not, keep it in the + * list by copying it to our destination position + */ + if (objget1sc(ctx->voccxmem, list[j]) != sc) + { + /* it's distinguishable - keep it */ + list[dst] = list[j]; + flags[dst++] = flags[j]; + } + else + { + /* + * This item is indistinguishable from the list[i]. + * First, reduce the count of different items. + */ + --diff_cnt; + + /* + * Keep this object only if we're keeping all + * redundant indistinguishable items. + */ + if (keep_all) + { + /* keep all items -> keep this item */ + list[dst] = list[j]; + flags[dst++] = flags[j]; + } + } + } + + /* adjust the count to reflect the updated list */ + *cnt = dst; - /* add a terminator */ - list[dst] = MCMONINV; - flags[dst] = 0; - } - } + /* add a terminator */ + list[dst] = MCMONINV; + flags[dst] = 0; + } + } - /* return the number of distinguishable items */ - return diff_cnt; + /* return the number of distinguishable items */ + return diff_cnt; } /* ------------------------------------------------------------------------ */ @@ -5244,2859 +5244,2859 @@ static int voc_count_diff(voccxdef *ctx, objnum *list, uint *flags, int *cnt, * and io.verIo. */ int vocdisambig(voccxdef *ctx, vocoldef *outlist, vocoldef *inlist, - prpnum defprop, prpnum accprop, prpnum verprop, - char *cmd[], objnum otherobj, objnum cmdActor, - objnum cmdVerb, objnum cmdPrep, char *cmdbuf, - int silent) + prpnum defprop, prpnum accprop, prpnum verprop, + char *cmd[], objnum otherobj, objnum cmdActor, + objnum cmdVerb, objnum cmdPrep, char *cmdbuf, + int silent) { - int inpos; - int outpos; - int listlen = voclistlen(inlist); - int noreach = FALSE; - prpnum listprop; - uchar *save_sp; - int old_unknown, old_lastunk; - int err; - int still_ambig; + int inpos; + int outpos; + int listlen = voclistlen(inlist); + int noreach = FALSE; + prpnum listprop; + uchar *save_sp; + int old_unknown, old_lastunk; + int err; + int still_ambig; static char one_name[] = "ones"; - voc_enter(ctx, &save_sp); - - ERRBEGIN(ctx->voccxerr) - - /* presume we will not leave any ambiguity in the result */ - still_ambig = FALSE; - - /* loop through all of the objects in the input list */ - for (inpos = outpos = 0 ; inpos < listlen ; ++inpos) - { - /* - * reset the stack to our entrypoint value, since our stack - * variables are all temporary for a single iteration - */ - voc_leave(ctx, save_sp); - voc_enter(ctx, &save_sp); - - if (inlist[inpos].vocolflg == VOCS_STR) - { - vocsetobj(ctx, ctx->voccxstr, DAT_SSTRING, - inlist[inpos].vocolfst + 1, - &inlist[inpos], &outlist[outpos]); - ++outpos; - } - else if (inlist[inpos].vocolflg == VOCS_NUM) - { - long v1; - char vbuf[4]; - - v1 = atol(inlist[inpos].vocolfst); - oswp4s(vbuf, v1); - vocsetobj(ctx, ctx->voccxnum, DAT_NUMBER, vbuf, - &inlist[inpos], &outlist[outpos]); - ++outpos; - } - else if (inlist[inpos].vocolflg == VOCS_IT || - (inlist[inpos].vocolflg == VOCS_THEM && ctx->voccxthc == 0)) - { - err = vocsetit(ctx, ctx->voccxit, accprop, cmdActor, - cmdVerb, cmdPrep, &outlist[outpos], - inlist[inpos].vocolflg == VOCS_IT ? "it" : "them", - (char)(inlist[inpos].vocolflg == VOCS_IT - ? VOCW_IT : VOCW_THEM), defprop, silent); - if (err != 0) - goto done; - ++outpos; - } - else if (inlist[inpos].vocolflg == VOCS_HIM) - { - err = vocsetit(ctx, ctx->voccxhim, accprop, cmdActor, cmdVerb, - cmdPrep, &outlist[outpos], "him", VOCW_HIM, - defprop, silent); - if (err != 0) - goto done; - ++outpos; - } - else if (inlist[inpos].vocolflg == VOCS_HER) - { - err = vocsetit(ctx, ctx->voccxher, accprop, cmdActor, cmdVerb, - cmdPrep, &outlist[outpos], "her", VOCW_HER, - defprop, silent); - if (err != 0) - goto done; - ++outpos; - } - else if (inlist[inpos].vocolflg == VOCS_THEM) - { - int i; - int thempos = outpos; - static char them_name[] = "them"; - - for (i = 0 ; i < ctx->voccxthc ; ++i) - { - if (outpos >= VOCMAXAMBIG) - { - if (!silent) - vocerr(ctx, VOCERR(11), - "You're referring to too many objects."); - err = VOCERR(11); - goto done; - } - - /* add object only if it's still accessible */ - if (vocchkaccess(ctx, ctx->voccxthm[i], accprop, 0, - cmdActor, cmdVerb)) - { - /* it's still accessible - add it to the list */ - vocout(&outlist[outpos++], ctx->voccxthm[i], VOCS_THEM, - them_name, them_name); - } - else - { - /* it's not accessible - complain about it */ - vocnoreach(ctx, &ctx->voccxthm[i], 1, - cmdActor, cmdVerb, cmdPrep, - defprop, TRUE, VOCS_THEM, i, ctx->voccxthc); - tioflush(ctx->voccxtio); - } - } - - /* make sure we found at least one acceptable object */ - if (outpos == thempos) - { - if (!silent) - vocerr(ctx, VOCERR(14), - "I don't know what you're referring to."); - err = VOCERR(14); - goto done; - } - } - else if (inlist[inpos].vocolflg == VOCS_ALL) - { - uchar *l; - int exccnt = 0; - int allpos = outpos; - int k; - uint len; - static char all_name[] = "all"; - vocoldef *exclist; - vocoldef *exclist2; - - VOC_MAX_ARRAY(ctx, vocoldef, exclist); - VOC_MAX_ARRAY(ctx, vocoldef, exclist2); - - if (defprop != PRP_IODEFAULT) - runpobj(ctx->voccxrun, otherobj); - runpobj(ctx->voccxrun, cmdPrep); - runpobj(ctx->voccxrun, cmdActor); - runppr(ctx->voccxrun, cmdVerb, defprop, - defprop == PRP_DODEFAULT ? 3 : 2); - - if (runtostyp(ctx->voccxrun) == DAT_LIST) - { - l = runpoplst(ctx->voccxrun); - len = osrp2(l) - 2; - l += 2; - - while (len) - { - /* add list element to output if it's an object */ - if (*l == DAT_OBJECT) - vocout(&outlist[outpos++], (objnum)osrp2(l+1), 0, - all_name, all_name); - - /* move on to next list element */ - lstadv(&l, &len); - } - - vocout(&outlist[outpos], MCMONINV, 0, (char *)0, (char *)0); - } - else - rundisc(ctx->voccxrun); /* discard non-list value */ - - /* if we didn't get anything, complain about it and quit */ - if (outpos <= allpos) - { - if (!silent) - vocerr(ctx, VOCERR(15), - "I don't see what you're referring to."); - err = VOCERR(15); - goto done; - } - - /* remove any items in "except" list */ - while (inlist[inpos + 1].vocolflg & VOCS_EXCEPT) - { - OSCPYSTRUCT(exclist[exccnt], inlist[++inpos]); - exclist[exccnt++].vocolflg &= ~VOCS_EXCEPT; - } - exclist[exccnt].vocolobj = MCMONINV; - exclist[exccnt].vocolflg = 0; - - /* disambiguate "except" list */ - if (exccnt) - { - err = vocdisambig(ctx, exclist2, exclist, defprop, accprop, - verprop, cmd, otherobj, cmdActor, - cmdVerb, cmdPrep, cmdbuf, silent); - if (err != 0) - goto done; - - exccnt = voclistlen(exclist2); - for (k = 0 ; k < exccnt ; ++k) - { - int i; - for (i = allpos ; i < outpos ; ++i) - { - if (outlist[i].vocolobj == exclist2[k].vocolobj) - { - int j; - for (j = i ; j < outpos ; ++j) - outlist[j].vocolobj = outlist[j+1].vocolobj; - --i; - --outpos; - if (outpos <= allpos) - { - if (!silent) - vocerr(ctx, VOCERR(15), - "I don't see what you're referring to."); - err = VOCERR(15); - goto done; - } - } - } - } - } - } - else /* we have a (possibly ambiguous) noun */ - { - int lpos = inpos; - int i = 0; - int cnt; - const char *p; - int cnt2, cnt3; - int trying_again; - int user_count = 0; - objnum *cantreach_list; - int unknown_count; - int use_all_objs; - objnum *list1; - uint *flags1; - objnum *list2; - uint *flags2; - objnum *list3; - uint *flags3; - char *usrobj; - uchar *lstbuf; - char *newobj; - char *disnewbuf; - char *disbuffer; - char **diswordlist; - int *distypelist; - vocoldef *disnounlist; - int dst; - - VOC_MAX_ARRAY(ctx, objnum, list1); - VOC_MAX_ARRAY(ctx, objnum, list2); - VOC_MAX_ARRAY(ctx, objnum, list3); - VOC_MAX_ARRAY(ctx, uint, flags1); - VOC_MAX_ARRAY(ctx, uint, flags2); - VOC_MAX_ARRAY(ctx, uint, flags3); - VOC_MAX_ARRAY(ctx, vocoldef, disnounlist); - VOC_STK_ARRAY(ctx, char, disnewbuf, VOCBUFSIZ); - VOC_STK_ARRAY(ctx, char, disbuffer, 2*VOCBUFSIZ); - VOC_STK_ARRAY(ctx, char *, diswordlist, VOCBUFSIZ); - VOC_STK_ARRAY(ctx, int, distypelist, VOCBUFSIZ); - VOC_STK_ARRAY(ctx, char, usrobj, VOCBUFSIZ); - VOC_STK_ARRAY(ctx, char, newobj, VOCBUFSIZ); - VOC_STK_ARRAY(ctx, uchar, lstbuf, 2 + VOCMAXAMBIG*3); - - /* presume we won't resolve any unknown words */ - unknown_count = 0; - - /* - * Presume that we won't use all the objects that match - * these words, since we normally want to try to find a - * single, unambiguous match for a given singular noun - * phrase. Under certain circumstances, we'll want to keep - * all of the words that match the noun phrase, in which - * case we'll set this flag accordingly. - */ - use_all_objs = FALSE; - - /* - * go through the objects matching the current noun phrase - * and add them into our list - */ - while (inlist[lpos].vocolfst == inlist[inpos].vocolfst - && lpos < listlen) - { - /* add this object to the list of nouns */ - list1[i] = inlist[lpos].vocolobj; - - /* - * note whether this object matched a plural, whether it - * matched adjective-at-end usage, and whether it - * matched a truncated dictionary word - */ - flags1[i] = inlist[lpos].vocolflg - & (VOCS_PLURAL | VOCS_ANY | VOCS_COUNT - | VOCS_ENDADJ | VOCS_TRUNC); - - /* if this is a valid object, count it */ - if (list1[i] != MCMONINV) - ++i; - - /* if there's a user count, note it */ - if ((inlist[lpos].vocolflg & VOCS_COUNT) != 0) - user_count = atoi(inlist[lpos].vocolfst); - - /* if an unknown word was involved, note it */ - if ((inlist[lpos].vocolflg & VOCS_UNKNOWN) != 0) - ++unknown_count; - - /* move on to the next entry */ - ++lpos; - } - - /* terminate the list */ - list1[i] = MCMONINV; - cnt = i; - - /* - * If this noun phrase contained an unknown word, check to - * see if the verb defines the parseUnknownXobj() method. - * If so, call the method and check the result. - */ - if (unknown_count > 0) - { - prpnum prp; - - /* - * figure out which method to call - use - * parseUnknownDobj if we're disambiguating the direct - * object, parseUnknownIobj for the indirect object - */ - prp = (defprop == PRP_DODEFAULT - ? PRP_PARSEUNKNOWNDOBJ : PRP_PARSEUNKNOWNIOBJ); - - /* check if the verb defines this method */ - if (objgetap(ctx->voccxmem, cmdVerb, prp, (objnum *)0, FALSE)) - { - uchar *lstp; - uint lstlen; - - /* trace the event for debugging */ - if (ctx->voccxflg & VOCCXFDBG) - tioputs(ctx->voccxtio, - "... unknown word: calling " - "parseUnknownXobj\\n"); - - /* push the list of words in the noun phrase */ - voc_push_strlist(ctx, inlist[inpos].vocolfst, - inlist[inpos].vocollst); - - /* push the other arguments */ - runpobj(ctx->voccxrun, otherobj); - runpobj(ctx->voccxrun, cmdPrep); - runpobj(ctx->voccxrun, cmdActor); - - /* call the method */ - runppr(ctx->voccxrun, cmdVerb, prp, 4); - - /* see what they returned */ - switch(runtostyp(ctx->voccxrun)) - { - case DAT_OBJECT: - /* - * use the object they returned as the match for - * the noun phrase - */ - list1[cnt++] = runpopobj(ctx->voccxrun); - - /* terminate the new list */ - list1[cnt] = MCMONINV; - break; - - case DAT_LIST: - /* - * use the list of objects they returned as the - * match for the noun phrase - */ - lstp = runpoplst(ctx->voccxrun); - - /* get the length of the list */ - lstlen = osrp2(lstp) - 2; - lstp += 2; - - /* run through the list's elements */ - while (lstlen != 0) - { - /* if this is an object, add it */ - if (*lstp == DAT_OBJECT - && i < VOCMAXAMBIG) - list1[cnt++] = osrp2(lstp+1); - - /* move on to the next element */ - lstadv(&lstp, &lstlen); - } - - /* - * Note that we want to use all of these objects - * without disambiguation, since the game code - * has explicitly said that this is the list - * that matches the given noun phrase. - */ - use_all_objs = TRUE; - - /* terminate the new list */ - list1[cnt] = MCMONINV; - break; - - case DAT_TRUE: - /* - * A 'true' return value indicates that the - * parseUnknownXobj routine has fully handled - * the command. They don't want anything more - * to be done with these words. Simply remove - * the unknown words and continue with any other - * words in the list. - */ - rundisc(ctx->voccxrun); - - /* we're done with this input phrase */ - continue; - - default: - /* - * For anything else, use the default mechanism. - * Simply return an error; since the "unknown - * word" flag is set, we'll reparse the - * sentence, this time rejecting unknown words - * from the outset. - * - * Return error 2, since that's the generic "I - * don't know the word..." error code. - */ - rundisc(ctx->voccxrun); - err = VOCERR(2); - goto done; - } - - /* - * If we made it this far, it means that they've - * resolved the object for us, so we can consider - * the previously unknown words to be known now. - */ - ctx->voccxunknown -= unknown_count; - } - else - { - /* trace the event for debugging */ - if (ctx->voccxflg & VOCCXFDBG) - tioputs(ctx->voccxtio, - "... unknown word: no parseUnknownXobj - " - "restarting parsing\\n"); - - /* - * The verb doesn't define this method, so we should - * use the traditional method; simply return - * failure, and we'll reparse the sentence to reject - * the unknown word in the usual fashion. Return - * error 2, since that's the generic "I don't know - * the word..." error code. - */ - err = VOCERR(2); - goto done; - } - } - - /* - * Use a new method to cut down on the time it will take to - * iterate through the verprop's on all of those words. - * We'll call the verb's validXoList method - it should - * return a list containing all of the valid objects for the - * verb (it's sort of a Fourier transform of validDo). - * We'll intersect that list with the list we're about to - * disambiguate, which should provide a list of objects that - * are already qualified, in that validDo should return true - * for every one of them. - * - * The calling sequence is: - * verb.validXoList(actor, prep, otherobj) - * - * For reverse compatibility, if the return value is nil, - * we use the old algorithm and consider all objects - * that match the vocabulary. The return value must be - * a list to be considered. - * - * If disambiguating the actor, skip this phase, since - * we don't have a verb yet. - */ - if (accprop != PRP_VALIDACTOR && cnt != 0) - { - if (defprop == PRP_DODEFAULT) - listprop = PRP_VALDOLIST; - else - listprop = PRP_VALIOLIST; - - /* push the arguments: the actor, prep, and other object */ - runpobj(ctx->voccxrun, otherobj); - runpobj(ctx->voccxrun, cmdPrep); - runpobj(ctx->voccxrun, cmdActor); - runppr(ctx->voccxrun, cmdVerb, listprop, 3); - if (runtostyp(ctx->voccxrun) == DAT_LIST) - { - uchar *l; - uint len; - int kept_numobj; - - /* presume we won't keep numObj */ - kept_numobj = FALSE; - - /* read the list length prefix, and skip it */ - l = runpoplst(ctx->voccxrun); - len = osrp2(l) - 2; - l += 2; - - /* - * For each element of the return value, see if - * it's in list1. If so, copy the object into - * list2, unless it's already in list2. - */ - for (cnt2 = 0 ; len != 0 ; ) - { - if (*l == DAT_OBJECT) - { - objnum o = osrp2(l+1); - - for (i = 0 ; i < cnt ; ++i) - { - if (list1[i] == o) - { - int j; - - /* check to see if o is already in list2 */ - for (j = 0 ; j < cnt2 ; ++j) - if (list2[j] == o) break; - - /* if o is not in list2 yet, add it */ - if (j == cnt2) - { - /* add it */ - list2[cnt2] = o; - flags2[cnt2] = flags1[i]; - ++cnt2; - - /* - * if it's numObj, note that - * we've already included it in - * the output list, so that we - * don't add it again later - */ - if (o == ctx->voccxnum) - kept_numobj = TRUE; - } - break; - } - } - } - - /* move on to next element */ - lstadv(&l, &len); - } - - /* - * If the original list included numObj, keep it in - * the accessible list for now - we consider numObj - * to be always accessible. The noun phrase matcher - * will include numObj whenever the player enters a - * single number as a noun phrase, even when the - * number matches an object. Note that we can skip - * this special step if we already kept numObj in - * the valid list. - */ - if (!kept_numobj) - { - /* search the original list for numObj */ - for (i = 0 ; i < cnt ; ++i) - { - /* if this original entry is numObj, keep it */ - if (list1[i] == ctx->voccxnum) - { - /* keep it in the accessible list */ - list2[cnt2++] = ctx->voccxnum; - - /* no need to look any further */ - break; - } - } - } - - /* copy list2 into list1 */ - memcpy(list1, list2, (size_t)(cnt2 * sizeof(list1[0]))); - memcpy(flags1, flags2, (size_t)cnt2 * sizeof(flags1[0])); - cnt = cnt2; - list1[cnt] = MCMONINV; - } - else - rundisc(ctx->voccxrun); - } - - /* - * Determine accessibility and visibility. First, limit - * list1 to those objects that are visible OR accessible, - * and limit list3 to those objects that are visible. - */ - for (cnt = cnt3 = i = 0 ; list1[i] != MCMONINV ; ++i) - { - int is_vis; - int is_acc; - - /* determine if the object is visible */ - is_vis = vocchkvis(ctx, list1[i], cmdActor); - - /* determine if it's accessible */ - is_acc = vocchkaccess(ctx, list1[i], accprop, i, - cmdActor, cmdVerb); - - /* keep items that are visible OR accessible in list1 */ - if (is_acc || is_vis) - { - list1[cnt] = list1[i]; - flags1[cnt] = flags1[i]; - ++cnt; - } - - /* - * put items that are visible (regardless of whether or - * not they're accessible) in list3 - */ - if (is_vis) - { - list3[cnt3] = list1[i]; - flags3[cnt3] = flags1[i]; - ++cnt3; - } - } - - /* - * If some of our accessible objects matched with an - * adjective at the end of the noun phrase, and others - * didn't (i.e., the others matched with a noun or plural at - * the end of the noun phrase), eliminate the ones that - * matched with an adjective at the end. Ending a noun - * phrase with an adjective is really a kind of short-hand; - * if we have matches for both the full name version (with a - * noun at the end) and a short-hand version, we want to - * discard the short-hand version so that we don't treat it - * as ambiguous with the long-name version. Likewise, if we - * have some exact matches and some truncations, keep only - * the exact matches. - */ - cnt = voc_prune_matches(ctx, list1, flags1, cnt); - cnt3 = voc_prune_matches(ctx, list3, flags3, cnt3); - - /* - * Now, reduce list1 to objects that are accessible. The - * reason for this multi-step process is to ensure that we - * prune the list with respect to every object in scope - * (visible or accessible for the verb), so that we get the - * most sensible pruning behavior. This is more sensible - * than pruning by accessibility only, because sometimes we - * may have objects that are visible but are not accessible; - * as far as the player is concerned, the visible objects - * are part of the current location, so the player should be - * able to refer to them regardless of whether they're - * accessible. - */ - for (dst = 0, i = 0 ; i < cnt ; ++i) - { - /* check this object for accessibility */ - if (vocchkaccess(ctx, list1[i], accprop, i, - cmdActor, cmdVerb)) - { - /* keep it in the final list */ - list1[dst] = list1[i]; - flags1[dst] = flags1[i]; - - /* count the new list entry */ - ++dst; - } - } - - /* terminate list1 */ - cnt = dst; - list1[dst] = MCMONINV; - - /* - * Go through the list of accessible objects, and perform - * the sensible-object (verXoVerb) check on each. Copy each - * sensible object to list2. - */ - for (i = 0, cnt2 = 0 ; i < cnt ; ++i) - { - /* run it by the appropriate sensible-object check */ - if (accprop == PRP_VALIDACTOR) - { - /* run it through preferredActor */ - runppr(ctx->voccxrun, list1[i], PRP_PREFACTOR, 0); - if (runpoplog(ctx->voccxrun)) - { - list2[cnt2] = list1[i]; - flags2[cnt2] = flags1[i]; - ++cnt2; - } - } - else - { - /* run it through verXoVerb */ - tiohide(ctx->voccxtio); - if (otherobj != MCMONINV) - runpobj(ctx->voccxrun, otherobj); - runpobj(ctx->voccxrun, cmdActor); - runppr(ctx->voccxrun, list1[i], verprop, - (otherobj != MCMONINV ? 2 : 1)); - - /* - * If that didn't result in a message, this object - * passed the tougher test of ver?oX, so include it - * in list2. - */ - if (!tioshow(ctx->voccxtio)) - { - list2[cnt2] = list1[i]; - flags2[cnt2] = flags1[i]; - ++cnt2; - } - } - } - - /* - * Construct a string consisting of the words the user typed - * to reference this object, in case we need to complain. - */ - usrobj[0] = '\0'; - if (inlist[inpos].vocolfst != 0 && inlist[inpos].vocollst != 0) - { - for (p = inlist[inpos].vocolfst ; p <= inlist[inpos].vocollst - ; p += strlen(p) + 1) - { - /* add a space if we have a prior word */ - if (usrobj[0] != '\0') - { - /* quote the space if the last word ended with '.' */ - if (p[strlen(p)-1] == '.') - strcat(usrobj, "\\"); - - /* add the space */ - strcat(usrobj, " "); - } - - /* add the current word, or "of" if it's "of" */ - if (voc_check_special(ctx, p, VOCW_OF)) - vocaddof(ctx, usrobj); - else - strcat(usrobj, p); - } - } - - /* - * If there's nothing in the YES list, and we have just a - * single number as our word, act as though they are talking - * about the number itself, rather than one of the objects - * that happened to use the number -- none of those objects - * make any sense, it seems, so fall back on the number. - * - * Note that we may also have only numObj in the YES list, - * because the noun phrase parser normally adds numObj when - * the player types a noun phrase consisting only of a - * number. Do the same thing in this case -- just return - * the number object. - */ - if ((cnt2 == 0 - || (cnt2 == 1 && list2[0] == ctx->voccxnum)) - && inlist[inpos].vocolfst != 0 - && inlist[inpos].vocolfst == inlist[inpos].vocollst - && vocisdigit(*inlist[inpos].vocolfst)) - { - long v1; - char vbuf[4]; - - v1 = atol(inlist[inpos].vocolfst); - oswp4s(vbuf, v1); - vocsetobj(ctx, ctx->voccxnum, DAT_NUMBER, vbuf, - &inlist[inpos], &outlist[outpos]); - outlist[outpos].vocolflg = VOCS_NUM; - ++outpos; - - /* skip all objects that matched the number */ - for ( ; inlist[inpos+1].vocolobj != MCMONINV - && inlist[inpos+1].vocolfst == inlist[inpos].vocolfst - ; ++inpos) ; - continue; - } - - /* - * Check if we found anything in either the YES (list2) or - * MAYBE (list1) lists. If there's nothing in either list, - * complain and return. - */ - if (cnt2 == 0 && cnt == 0) - { - /* - * We have nothing sensible, and nothing even - * accessible. If there's anything merely visible, - * complain about those items. - */ - if (cnt3 != 0) - { - /* there are visible items - complain about them */ - cnt = cnt3; - cantreach_list = list3; - noreach = TRUE; - - /* give the cantReach message, even for multiple objects */ - goto noreach1; - } - else - { - /* - * explain that there's nothing visible or - * accessible matching the noun phrase, and abort - * the command with an error - */ - if (!silent) - vocerr(ctx, VOCERR(9), - "I don't see any %s here.", usrobj); - err = VOCERR(9); - goto done; - } - } - - /* - * If anything passed the stronger test (objects passing are - * in list2), use this as our proposed resolution for the - * noun phrase. If nothing passed the stronger test (i.e., - * list2 is empty), simply keep the list of accessible - * objects in list1. - */ - if (cnt2 != 0) - { - /* - * we have items passing the stronger test -- copy the - * stronger list (list2) to list1 - */ - cnt = cnt2; - memcpy(list1, list2, (size_t)(cnt2 * sizeof(list1[0]))); - memcpy(flags1, flags2, (size_t)(cnt2 * sizeof(flags1[0]))); - } - - /* - * Check for redundant objects in the list. If the same - * object appears multiple times in the list, remove the - * extra occurrences. Sometimes, a game can inadvertantly - * define the same vocabulary word several times for the - * same object, because of the parser's leniency with - * matching leading substrings of 6 characters or longer. - * To avoid unnecessary "which x do you mean..." errors, - * simply discard any duplicates in the list. - */ - for (dst = 0, i = 0 ; i < cnt ; ++i) - { - int dup; - int j; - - /* presume we won't find a duplicate of this object */ - dup = FALSE; - - /* - * look for duplicates of this object in the remainder - * of the list - */ - for (j = i + 1 ; j < cnt ; ++j) - { - /* check for a duplicate */ - if (list1[i] == list1[j]) - { - /* note that this object has a duplicate */ - dup = TRUE; - - /* we don't need to look any further */ - break; - } - } - - /* - * if this object has no duplicate, retain it in the - * output list - */ - if (!dup) - { - /* copy the element to the output */ - list1[dst] = list1[i]; - flags1[dst] = flags1[i]; - - /* count the output */ - ++dst; - } - } - - /* update the count to the new list's size */ - cnt = dst; - list1[cnt] = MCMONINV; - - /* - * If we have more than one object in the list, and numObj - * is still in the list, remove numObj - we don't want to - * consider numObj to be considered ambiguous with another - * object when the other object passes access and validation - * tests. - */ - if (cnt > 1) - { - /* scan the list for numObj */ - for (i = 0, dst = 0 ; i < cnt ; ++i) - { - /* if this isn't numObj, keep this element */ - if (list1[i] != ctx->voccxnum) - list1[dst++] = list1[i]; - } - - /* update the final count */ - cnt = dst; - list1[cnt] = MCMONINV; - } - - /* - * Check for a generic numeric adjective ('#' in the - * adjective list for the object) in each object. If we - * find it, we need to make sure there's a number in the - * name of the object. - */ - for (i = 0 ; i < cnt ; ++i) - { - if (has_gen_num_adj(ctx, list1[i])) - { - /* - * If they specified a count, create the specified - * number of objects. Otherwise, if the object is - * plural, they mean to use all of the objects, so a - * numeric adjective isn't required -- set the - * numeric adjective property in the object to nil - * to so indicate. Otherwise, look for the number, - * and set the numeric adjective property - * accordingly. - */ - if ((flags1[i] & (VOCS_ANY | VOCS_COUNT)) != 0) - { - int n = (user_count ? user_count : 1); - int j; - objnum objn = list1[i]; - - /* - * They specified a count, so we want to create - * n-1 copies of the numbered object. Make room - * for the n-1 new copies of this object by - * shifting any elements that follow up n-1 - * slots. - */ - if (i + 1 != cnt && n > 1) - { - memmove(&list1[i + n - 1], &list1[i], - (cnt - i) * sizeof(list1[i])); - memmove(&flags1[i + n - 1], &flags1[i], - (cnt - i) * sizeof(flags1[i])); - } - - /* create n copies of this object */ - for (j = 0 ; j < n ; ++j) - { - long l; - - /* - * Generate a number for the new object, - * asking the object to tell us what value - * to use for an "any". - */ - runpnum(ctx->voccxrun, (long)(j + 1)); - runppr(ctx->voccxrun, objn, PRP_ANYVALUE, 1); - l = runpopnum(ctx->voccxrun); - - /* try creating the new object */ - list1[i+j] = - voc_new_num_obj(ctx, objn, - cmdActor, cmdVerb, - l, FALSE); - if (list1[i+j] == MCMONINV) - { - err = VOCERR(40); - goto done; - } - } - } - else if ((flags1[i] & VOCS_PLURAL) != 0) - { - /* - * get the plural object by asking for the - * numbered object with a nil number parameter - */ - list1[i] = - voc_new_num_obj(ctx, list1[i], cmdActor, cmdVerb, - (long)0, TRUE); - if (list1[i] == MCMONINV) - { - err = VOCERR(40); - goto done; - } - } - else - { - //char *p; - int found; - - /* - * No plural, no "any" - we just want to create - * one numbered object, using the number that - * the player must have specified. Make sure - * the player did, in fact, specify a number. - */ - for (found = FALSE, p = inlist[inpos].vocolfst ; - p != 0 && p <= inlist[inpos].vocollst ; - p += strlen(p) + 1) - { - /* did we find it? */ - if (vocisdigit(*p)) - { - long l; - - /* get the number */ - l = atol(p); - - /* create the object with this number */ - list1[i] = voc_new_num_obj(ctx, list1[i], - cmdActor, cmdVerb, - l, FALSE); - if (list1[i] == MCMONINV) - { - err = VOCERR(40); - goto done; - } - - /* the command looks to be valid */ - found = TRUE; - break; - } - } - - /* if we didn't find it, stop now */ - if (!found) - { - if (!silent) - vocerr(ctx, VOCERR(160), - "You'll have to be more specific about which %s you mean.", - usrobj); - err = VOCERR(160); - goto done; - } - } - } - } - - /* - * We still have an ambiguous word - ask the user which of - * the possible objects they meant to use - */ - trying_again = FALSE; - for (;;) - { - int wrdcnt; - int next; - uchar *pu; - int cleared_noun; - int diff_cnt; - int stat; - int num_wanted; - int is_ambig; - int all_plural; - - /* - * check for usage - determine if we have singular - * definite, singular indefinite, counted, or plural - * usage - */ - if ((flags1[0] & (VOCS_PLURAL | VOCS_ANY | VOCS_COUNT)) != 0) - { - //int i; - - /* - * loop through the objects to AND together the - * flags from all of the objects; we only care about - * the plural flags (PLURAL, ANY, and COUNT), so - * start out with only those, then AND off any that - * aren't in all of the objects - */ - for (all_plural = VOCS_PLURAL | VOCS_ANY | VOCS_COUNT, - i = 0 ; i < cnt ; ++i) - { - /* AND out this object's flags */ - all_plural &= flags1[i]; - - /* - * if we've ANDed down to zero, there's no need - * to look any further - */ - if (!all_plural) - break; - } - } - else - { - /* - * it looks like we want just a single object - - * clear the various plural flags - */ - all_plural = 0; - } - - /* - * Count the distinguishable items. - * - * If we're looking for a single object, don't keep - * duplicate indistinguishable items (i.e., keep only - * one item from each set of mutually indistinguishable - * items), since we could equally well use any single - * one of those items. If we're looking for multiple - * objects, keep all of the items, since the user is - * referring to all of them. - */ - diff_cnt = voc_count_diff(ctx, list1, flags1, &cnt, - all_plural != 0 || use_all_objs); - - /* - * Determine how many objects we'd like to find. If we - * have a count specified, we'd like to find the given - * number of objects. If we have "ANY" specified, we - * just want to pick one object arbitrarily. If we have - * all plurals, we can keep all of the objects. If the - * 'use_all_objs' flag is true, it means that we can use - * everything in the list. - */ - if (use_all_objs) - { - /* we want to use all of the objects */ - num_wanted = cnt; - is_ambig = FALSE; - } - else if ((all_plural & VOCS_COUNT) != 0) - { - /* - * we have a count - we want exactly the given - * number of objects, but we can pick an arbitrary - * subset, so it's not ambiguous even if we have too - * many at the moment - */ - num_wanted = user_count; - is_ambig = FALSE; - } - else if ((all_plural & VOCS_ANY) != 0) - { - /* - * they specified "any", so we want exactly one, but - * we can pick one arbitrarily, so there's no - * ambiguity - */ - num_wanted = 1; - is_ambig = FALSE; - } - else if (all_plural != 0) - { - /* - * we have a simple plural, so we can use all of the - * provided objects without ambiguity - */ - num_wanted = cnt; - is_ambig = FALSE; - } - else - { - /* - * it's a singular, definite usage, so we want - * exactly one item; if we have more than one in our - * list, it's ambiguous - */ - num_wanted = 1; - is_ambig = (cnt != 1); - } - - /* call the disambiguation hook */ - stat = voc_disambig_hook(ctx, cmdVerb, cmdActor, cmdPrep, - otherobj, accprop, verprop, - list1, flags1, &cnt, - inlist[inpos].vocolfst, - inlist[inpos].vocollst, - num_wanted, is_ambig, disnewbuf, - silent); - - /* check the status */ - if (stat == VOC_DISAMBIG_DONE) - { - /* that's it - copy the result */ - for (i = 0 ; i < cnt ; ++i) - vocout(&outlist[outpos++], list1[i], flags1[i], - inlist[inpos].vocolfst, - inlist[inpos].vocollst); - - /* we're done */ - break; - } - else if (stat == VOC_DISAMBIG_CONT) - { - /* - * Continue with the new list (which is the same as - * the old list, if it wasn't actually updated by - * the hook routine) - proceed with remaining - * processing, but using the new list. - * - * Because the list has been updated, we must once - * again count the number of distinguishable items, - * since that may have changed. - */ - diff_cnt = voc_count_diff(ctx, list1, flags1, &cnt, TRUE); - } - else if (stat == VOC_DISAMBIG_PARSE_RESP - || stat == VOC_DISAMBIG_PROMPTED) - { - /* - * The status indicates one of the following: - * - * - the hook prompted for more information and read - * a response from the player, but decided not to - * parse it; we will continue with the current list, - * and parse the player's response as provided by - * the hook. - * - * - the hook prompted for more information, but - * left the reading to us. We'll proceed with the - * current list and read a response as normal, but - * without displaying another prompt. - * - * In any case, just continue processing; we'll take - * appropriate action on the prompting and reading - * when we reach those steps. - */ - } - else - { - /* anything else is an error */ - err = VOCERR(41); - goto done; - } - - /* - * If we found only one word, or a plural/ANY, we are - * finished. If we found a count, use that count if - * possible. - */ - if (cnt == 1 || all_plural || use_all_objs) - { - int flags; - - /* keep only one of the objects if ANY was used */ - if ((all_plural & VOCS_COUNT) != 0) - { - if (user_count > cnt) - { - if (!silent) - vocerr(ctx, VOCERR(30), - "I only see %d of those.", cnt); - err = VOCERR(30); - goto done; - } - cnt = user_count; - flags = VOCS_ALL; - } - else if ((all_plural & VOCS_ANY) != 0) - { - cnt = 1; - flags = VOCS_ALL; - } - else - flags = 0; - - /* put the list */ - for (i = 0 ; i < cnt ; ++i) - vocout(&outlist[outpos++], list1[i], flags, - inlist[inpos].vocolfst, - inlist[inpos].vocollst); - - /* we're done */ - break; - } - - /* make sure output capturing is off */ - tiocapture(ctx->voccxtio, (mcmcxdef *)0, FALSE); - tioclrcapture(ctx->voccxtio); - - /* - * if we're in "silent" mode, we can't ask the player - * for help, so return an error - */ - if (silent) - { - /* - * We can't disambiguate the list. Fill in the - * return list with what's left, which is still - * ambiguous, and note that we need to return an - * error code indicating that the list remains - * ambiguous. - */ - for (i = 0 ; i < cnt && outpos < VOCMAXAMBIG ; ++i) - vocout(&outlist[outpos++], list1[i], 0, - inlist[inpos].vocolfst, - inlist[inpos].vocollst); - - /* note that we have ambiguity remaining */ - still_ambig = TRUE; - - /* we're done with this sublist */ - break; - } - - /* - * We need to prompt for more information interactively. - * Figure out how we're going to display the prompt. - * - * - If the disambigXobj hook status (stat) indicates - * that the hook already displayed a prompt of its own, - * we don't need to add anything here. - * - * - Otherwise, if there's a parseDisambig function - * defined in the game, call it to display the prompt. - * - * - Otherwise, display our default prompt. - */ - if (stat == VOC_DISAMBIG_PARSE_RESP - || stat == VOC_DISAMBIG_PROMPTED) - { - /* - * the disambigXobj hook already asked for a - * response, so don't display any prompt of our own - */ - } - else if (ctx->voccxpdis != MCMONINV) - { - uint l; - - /* - * There's a parseDisambig function defined in the - * game - call it to display the prompt, passing the - * list of possible objects and the player's - * original noun phrase text as parameters. - */ - for (i = 0, pu = lstbuf+2 ; i < cnt ; ++i, pu += 2) - { - *pu++ = DAT_OBJECT; - oswp2(pu, list1[i]); - } - l = pu - lstbuf; - oswp2(lstbuf, l); - runpbuf(ctx->voccxrun, DAT_LIST, lstbuf); - runpstr(ctx->voccxrun, usrobj, (int)strlen(usrobj), 1); - runfn(ctx->voccxrun, ctx->voccxpdis, 2); - } - else - { - /* display "again" message, if necessary */ - if (trying_again) - vocerr_info(ctx, VOCERR(100), "Let's try it again: "); - - /* ask the user about it */ - vocerr_info(ctx, VOCERR(101), - "Which %s do you mean, ", usrobj); - for (i = 0 ; i < cnt ; ) - { - int eqcnt; - int j; - objnum sc; - - /* - * See if we have multiple instances of an - * identical object. All such instances should - * be grouped together (this was done above), so - * we can just count the number of consecutive - * equivalent objects. - */ - eqcnt = 1; - runppr(ctx->voccxrun, list1[i], PRP_ISEQUIV, 0); - if (runpoplog(ctx->voccxrun)) - { - /* get the superclass, if possible */ - sc = objget1sc(ctx->voccxmem, list1[i]); - if (sc != MCMONINV) - { - /* count equivalent objects that follow */ - for (j = i + 1 ; j < cnt ; ++j) - { - if (objget1sc(ctx->voccxmem, list1[j]) - == sc) - ++eqcnt; - else - break; - } - } - } - - /* - * Display this object's name. If we have only - * one such object, display its thedesc, - * otherwise display its adesc. - */ - runppr(ctx->voccxrun, list1[i], - (prpnum)(eqcnt == 1 ? - PRP_THEDESC : PRP_ADESC), 0); - - /* display the separator as appropriate */ - if (i + 1 < diff_cnt) - vocerr_info(ctx, VOCERR(102), ", "); - if (i + 2 == diff_cnt) - vocerr_info(ctx, VOCERR(103), "or "); - - /* skip all equivalent items */ - i += eqcnt; - } - vocerr_info(ctx, VOCERR(104), "?"); - } - - /* - * Read the response. If the disambigXobj hook already - * read the response, we don't need to read anything - * more. - */ - if (stat != VOC_DISAMBIG_PARSE_RESP - && vocread(ctx, cmdActor, cmdVerb, disnewbuf, - (int)VOCBUFSIZ, 2) == VOCREAD_REDO) - { - /* they want to treat the input as a new command */ - strcpy(cmdbuf, disnewbuf); - ctx->voccxunknown = 0; - ctx->voccxredo = TRUE; - err = VOCERR(43); - goto done; - } - - /* - * parse the response - */ - - /* tokenize the list */ - wrdcnt = voctok(ctx, disnewbuf, disbuffer, diswordlist, - TRUE, TRUE, TRUE); - if (wrdcnt == 0) - { - /* empty response - run pardon() function and abort */ - runfn(ctx->voccxrun, ctx->voccxprd, 0); - err = VOCERR(42); - goto done; - } - if (wrdcnt < 0) - { - /* return the generic punctuation error */ - err = VOCERR(1); - goto done; - } - - /* - * Before we tokenize the sentence, remember the current - * unknown word count, then momentarily set the count to - * zero. This will cause the tokenizer to absorb any - * unknown words; if there are any unknown words, the - * tokenizer will parse them and set the unknown count. - * If we find any unknown words in the input, we'll - * simply treat the input as an entirely new command. - */ - old_unknown = ctx->voccxunknown; - old_lastunk = ctx->voccxlastunk; - ctx->voccxunknown = 0; - - /* clear our internal type list */ - memset(distypelist, 0, VOCBUFSIZ * sizeof(distypelist[0])); - - /* tokenize the sentence */ - diswordlist[wrdcnt] = 0; - if (vocgtyp(ctx, diswordlist, distypelist, cmdbuf) - || ctx->voccxunknown != 0) - { - /* - * there's an unknown word or other problem - retry - * the input as an entirely new command - */ - strcpy(cmdbuf, disnewbuf); - ctx->voccxunknown = 0; - ctx->voccxredo = TRUE; - err = VOCERR(2); - goto done; - } - - /* restore the original unknown word count */ - ctx->voccxunknown = old_unknown; - ctx->voccxlastunk = old_lastunk; - - /* - * Find the last word that can be an adj and/or a noun. - * If it can be either (i.e., both bits are set), clear - * the noun bit and make it just an adjective. This is - * because we're asking for an adjective for clarification, - * and we most likely want it to be an adjective in this - * context; if the noun bit is set, too, the object lister - * will think it must be a noun, being the last word. - */ - for (i = 0 ; i < wrdcnt ; ++i) - { - if (!(distypelist[i] & - (VOCT_ADJ | VOCT_NOUN | VOCT_ARTICLE))) - break; - } - - if (i && (distypelist[i-1] & VOCT_ADJ) - && (distypelist[i-1] & VOCT_NOUN)) - { - /* - * Note that we're clearing the noun flag. If - * we're unsuccessful in finding the object with the - * noun flag cleared, we'll put the noun flag back - * in and give it another try (by adding VOCT_NOUN - * back into distypelist[cleared_noun], and coming - * back to the label below). - */ - cleared_noun = i-1; - distypelist[i-1] &= ~VOCT_NOUN; - } - else - cleared_noun = -1; - - try_current_flags: - /* start with the first word */ - if (vocspec(diswordlist[0], VOCW_ALL) - || vocspec(diswordlist[0], VOCW_BOTH)) - { - char *nam; - static char all_name[] = "all"; - static char both_name[] = "both"; - - if (vocspec(diswordlist[0], VOCW_ALL)) - nam = all_name; - else - nam = both_name; - - for (i = 0 ; i < cnt ; ++i) - vocout(&outlist[outpos++], list1[i], 0, nam, nam); - if (noreach) - { - cantreach_list = list1; - goto noreach1; - } - break; - } - else if (vocspec(diswordlist[0], VOCW_ANY)) - { - /* choose the first object arbitrarily */ + voc_enter(ctx, &save_sp); + + ERRBEGIN(ctx->voccxerr) + + /* presume we will not leave any ambiguity in the result */ + still_ambig = FALSE; + + /* loop through all of the objects in the input list */ + for (inpos = outpos = 0 ; inpos < listlen ; ++inpos) + { + /* + * reset the stack to our entrypoint value, since our stack + * variables are all temporary for a single iteration + */ + voc_leave(ctx, save_sp); + voc_enter(ctx, &save_sp); + + if (inlist[inpos].vocolflg == VOCS_STR) + { + vocsetobj(ctx, ctx->voccxstr, DAT_SSTRING, + inlist[inpos].vocolfst + 1, + &inlist[inpos], &outlist[outpos]); + ++outpos; + } + else if (inlist[inpos].vocolflg == VOCS_NUM) + { + long v1; + char vbuf[4]; + + v1 = atol(inlist[inpos].vocolfst); + oswp4s(vbuf, v1); + vocsetobj(ctx, ctx->voccxnum, DAT_NUMBER, vbuf, + &inlist[inpos], &outlist[outpos]); + ++outpos; + } + else if (inlist[inpos].vocolflg == VOCS_IT || + (inlist[inpos].vocolflg == VOCS_THEM && ctx->voccxthc == 0)) + { + err = vocsetit(ctx, ctx->voccxit, accprop, cmdActor, + cmdVerb, cmdPrep, &outlist[outpos], + inlist[inpos].vocolflg == VOCS_IT ? "it" : "them", + (char)(inlist[inpos].vocolflg == VOCS_IT + ? VOCW_IT : VOCW_THEM), defprop, silent); + if (err != 0) + goto done; + ++outpos; + } + else if (inlist[inpos].vocolflg == VOCS_HIM) + { + err = vocsetit(ctx, ctx->voccxhim, accprop, cmdActor, cmdVerb, + cmdPrep, &outlist[outpos], "him", VOCW_HIM, + defprop, silent); + if (err != 0) + goto done; + ++outpos; + } + else if (inlist[inpos].vocolflg == VOCS_HER) + { + err = vocsetit(ctx, ctx->voccxher, accprop, cmdActor, cmdVerb, + cmdPrep, &outlist[outpos], "her", VOCW_HER, + defprop, silent); + if (err != 0) + goto done; + ++outpos; + } + else if (inlist[inpos].vocolflg == VOCS_THEM) + { + int i; + int thempos = outpos; + static char them_name[] = "them"; + + for (i = 0 ; i < ctx->voccxthc ; ++i) + { + if (outpos >= VOCMAXAMBIG) + { + if (!silent) + vocerr(ctx, VOCERR(11), + "You're referring to too many objects."); + err = VOCERR(11); + goto done; + } + + /* add object only if it's still accessible */ + if (vocchkaccess(ctx, ctx->voccxthm[i], accprop, 0, + cmdActor, cmdVerb)) + { + /* it's still accessible - add it to the list */ + vocout(&outlist[outpos++], ctx->voccxthm[i], VOCS_THEM, + them_name, them_name); + } + else + { + /* it's not accessible - complain about it */ + vocnoreach(ctx, &ctx->voccxthm[i], 1, + cmdActor, cmdVerb, cmdPrep, + defprop, TRUE, VOCS_THEM, i, ctx->voccxthc); + tioflush(ctx->voccxtio); + } + } + + /* make sure we found at least one acceptable object */ + if (outpos == thempos) + { + if (!silent) + vocerr(ctx, VOCERR(14), + "I don't know what you're referring to."); + err = VOCERR(14); + goto done; + } + } + else if (inlist[inpos].vocolflg == VOCS_ALL) + { + uchar *l; + int exccnt = 0; + int allpos = outpos; + int k; + uint len; + static char all_name[] = "all"; + vocoldef *exclist; + vocoldef *exclist2; + + VOC_MAX_ARRAY(ctx, vocoldef, exclist); + VOC_MAX_ARRAY(ctx, vocoldef, exclist2); + + if (defprop != PRP_IODEFAULT) + runpobj(ctx->voccxrun, otherobj); + runpobj(ctx->voccxrun, cmdPrep); + runpobj(ctx->voccxrun, cmdActor); + runppr(ctx->voccxrun, cmdVerb, defprop, + defprop == PRP_DODEFAULT ? 3 : 2); + + if (runtostyp(ctx->voccxrun) == DAT_LIST) + { + l = runpoplst(ctx->voccxrun); + len = osrp2(l) - 2; + l += 2; + + while (len) + { + /* add list element to output if it's an object */ + if (*l == DAT_OBJECT) + vocout(&outlist[outpos++], (objnum)osrp2(l+1), 0, + all_name, all_name); + + /* move on to next list element */ + lstadv(&l, &len); + } + + vocout(&outlist[outpos], MCMONINV, 0, (char *)0, (char *)0); + } + else + rundisc(ctx->voccxrun); /* discard non-list value */ + + /* if we didn't get anything, complain about it and quit */ + if (outpos <= allpos) + { + if (!silent) + vocerr(ctx, VOCERR(15), + "I don't see what you're referring to."); + err = VOCERR(15); + goto done; + } + + /* remove any items in "except" list */ + while (inlist[inpos + 1].vocolflg & VOCS_EXCEPT) + { + OSCPYSTRUCT(exclist[exccnt], inlist[++inpos]); + exclist[exccnt++].vocolflg &= ~VOCS_EXCEPT; + } + exclist[exccnt].vocolobj = MCMONINV; + exclist[exccnt].vocolflg = 0; + + /* disambiguate "except" list */ + if (exccnt) + { + err = vocdisambig(ctx, exclist2, exclist, defprop, accprop, + verprop, cmd, otherobj, cmdActor, + cmdVerb, cmdPrep, cmdbuf, silent); + if (err != 0) + goto done; + + exccnt = voclistlen(exclist2); + for (k = 0 ; k < exccnt ; ++k) + { + int i; + for (i = allpos ; i < outpos ; ++i) + { + if (outlist[i].vocolobj == exclist2[k].vocolobj) + { + int j; + for (j = i ; j < outpos ; ++j) + outlist[j].vocolobj = outlist[j+1].vocolobj; + --i; + --outpos; + if (outpos <= allpos) + { + if (!silent) + vocerr(ctx, VOCERR(15), + "I don't see what you're referring to."); + err = VOCERR(15); + goto done; + } + } + } + } + } + } + else /* we have a (possibly ambiguous) noun */ + { + int lpos = inpos; + int i = 0; + int cnt; + const char *p; + int cnt2, cnt3; + int trying_again; + int user_count = 0; + objnum *cantreach_list; + int unknown_count; + int use_all_objs; + objnum *list1; + uint *flags1; + objnum *list2; + uint *flags2; + objnum *list3; + uint *flags3; + char *usrobj; + uchar *lstbuf; + char *newobj; + char *disnewbuf; + char *disbuffer; + char **diswordlist; + int *distypelist; + vocoldef *disnounlist; + int dst; + + VOC_MAX_ARRAY(ctx, objnum, list1); + VOC_MAX_ARRAY(ctx, objnum, list2); + VOC_MAX_ARRAY(ctx, objnum, list3); + VOC_MAX_ARRAY(ctx, uint, flags1); + VOC_MAX_ARRAY(ctx, uint, flags2); + VOC_MAX_ARRAY(ctx, uint, flags3); + VOC_MAX_ARRAY(ctx, vocoldef, disnounlist); + VOC_STK_ARRAY(ctx, char, disnewbuf, VOCBUFSIZ); + VOC_STK_ARRAY(ctx, char, disbuffer, 2*VOCBUFSIZ); + VOC_STK_ARRAY(ctx, char *, diswordlist, VOCBUFSIZ); + VOC_STK_ARRAY(ctx, int, distypelist, VOCBUFSIZ); + VOC_STK_ARRAY(ctx, char, usrobj, VOCBUFSIZ); + VOC_STK_ARRAY(ctx, char, newobj, VOCBUFSIZ); + VOC_STK_ARRAY(ctx, uchar, lstbuf, 2 + VOCMAXAMBIG*3); + + /* presume we won't resolve any unknown words */ + unknown_count = 0; + + /* + * Presume that we won't use all the objects that match + * these words, since we normally want to try to find a + * single, unambiguous match for a given singular noun + * phrase. Under certain circumstances, we'll want to keep + * all of the words that match the noun phrase, in which + * case we'll set this flag accordingly. + */ + use_all_objs = FALSE; + + /* + * go through the objects matching the current noun phrase + * and add them into our list + */ + while (inlist[lpos].vocolfst == inlist[inpos].vocolfst + && lpos < listlen) + { + /* add this object to the list of nouns */ + list1[i] = inlist[lpos].vocolobj; + + /* + * note whether this object matched a plural, whether it + * matched adjective-at-end usage, and whether it + * matched a truncated dictionary word + */ + flags1[i] = inlist[lpos].vocolflg + & (VOCS_PLURAL | VOCS_ANY | VOCS_COUNT + | VOCS_ENDADJ | VOCS_TRUNC); + + /* if this is a valid object, count it */ + if (list1[i] != MCMONINV) + ++i; + + /* if there's a user count, note it */ + if ((inlist[lpos].vocolflg & VOCS_COUNT) != 0) + user_count = atoi(inlist[lpos].vocolfst); + + /* if an unknown word was involved, note it */ + if ((inlist[lpos].vocolflg & VOCS_UNKNOWN) != 0) + ++unknown_count; + + /* move on to the next entry */ + ++lpos; + } + + /* terminate the list */ + list1[i] = MCMONINV; + cnt = i; + + /* + * If this noun phrase contained an unknown word, check to + * see if the verb defines the parseUnknownXobj() method. + * If so, call the method and check the result. + */ + if (unknown_count > 0) + { + prpnum prp; + + /* + * figure out which method to call - use + * parseUnknownDobj if we're disambiguating the direct + * object, parseUnknownIobj for the indirect object + */ + prp = (defprop == PRP_DODEFAULT + ? PRP_PARSEUNKNOWNDOBJ : PRP_PARSEUNKNOWNIOBJ); + + /* check if the verb defines this method */ + if (objgetap(ctx->voccxmem, cmdVerb, prp, (objnum *)0, FALSE)) + { + uchar *lstp; + uint lstlen; + + /* trace the event for debugging */ + if (ctx->voccxflg & VOCCXFDBG) + tioputs(ctx->voccxtio, + "... unknown word: calling " + "parseUnknownXobj\\n"); + + /* push the list of words in the noun phrase */ + voc_push_strlist(ctx, inlist[inpos].vocolfst, + inlist[inpos].vocollst); + + /* push the other arguments */ + runpobj(ctx->voccxrun, otherobj); + runpobj(ctx->voccxrun, cmdPrep); + runpobj(ctx->voccxrun, cmdActor); + + /* call the method */ + runppr(ctx->voccxrun, cmdVerb, prp, 4); + + /* see what they returned */ + switch(runtostyp(ctx->voccxrun)) + { + case DAT_OBJECT: + /* + * use the object they returned as the match for + * the noun phrase + */ + list1[cnt++] = runpopobj(ctx->voccxrun); + + /* terminate the new list */ + list1[cnt] = MCMONINV; + break; + + case DAT_LIST: + /* + * use the list of objects they returned as the + * match for the noun phrase + */ + lstp = runpoplst(ctx->voccxrun); + + /* get the length of the list */ + lstlen = osrp2(lstp) - 2; + lstp += 2; + + /* run through the list's elements */ + while (lstlen != 0) + { + /* if this is an object, add it */ + if (*lstp == DAT_OBJECT + && i < VOCMAXAMBIG) + list1[cnt++] = osrp2(lstp+1); + + /* move on to the next element */ + lstadv(&lstp, &lstlen); + } + + /* + * Note that we want to use all of these objects + * without disambiguation, since the game code + * has explicitly said that this is the list + * that matches the given noun phrase. + */ + use_all_objs = TRUE; + + /* terminate the new list */ + list1[cnt] = MCMONINV; + break; + + case DAT_TRUE: + /* + * A 'true' return value indicates that the + * parseUnknownXobj routine has fully handled + * the command. They don't want anything more + * to be done with these words. Simply remove + * the unknown words and continue with any other + * words in the list. + */ + rundisc(ctx->voccxrun); + + /* we're done with this input phrase */ + continue; + + default: + /* + * For anything else, use the default mechanism. + * Simply return an error; since the "unknown + * word" flag is set, we'll reparse the + * sentence, this time rejecting unknown words + * from the outset. + * + * Return error 2, since that's the generic "I + * don't know the word..." error code. + */ + rundisc(ctx->voccxrun); + err = VOCERR(2); + goto done; + } + + /* + * If we made it this far, it means that they've + * resolved the object for us, so we can consider + * the previously unknown words to be known now. + */ + ctx->voccxunknown -= unknown_count; + } + else + { + /* trace the event for debugging */ + if (ctx->voccxflg & VOCCXFDBG) + tioputs(ctx->voccxtio, + "... unknown word: no parseUnknownXobj - " + "restarting parsing\\n"); + + /* + * The verb doesn't define this method, so we should + * use the traditional method; simply return + * failure, and we'll reparse the sentence to reject + * the unknown word in the usual fashion. Return + * error 2, since that's the generic "I don't know + * the word..." error code. + */ + err = VOCERR(2); + goto done; + } + } + + /* + * Use a new method to cut down on the time it will take to + * iterate through the verprop's on all of those words. + * We'll call the verb's validXoList method - it should + * return a list containing all of the valid objects for the + * verb (it's sort of a Fourier transform of validDo). + * We'll intersect that list with the list we're about to + * disambiguate, which should provide a list of objects that + * are already qualified, in that validDo should return true + * for every one of them. + * + * The calling sequence is: + * verb.validXoList(actor, prep, otherobj) + * + * For reverse compatibility, if the return value is nil, + * we use the old algorithm and consider all objects + * that match the vocabulary. The return value must be + * a list to be considered. + * + * If disambiguating the actor, skip this phase, since + * we don't have a verb yet. + */ + if (accprop != PRP_VALIDACTOR && cnt != 0) + { + if (defprop == PRP_DODEFAULT) + listprop = PRP_VALDOLIST; + else + listprop = PRP_VALIOLIST; + + /* push the arguments: the actor, prep, and other object */ + runpobj(ctx->voccxrun, otherobj); + runpobj(ctx->voccxrun, cmdPrep); + runpobj(ctx->voccxrun, cmdActor); + runppr(ctx->voccxrun, cmdVerb, listprop, 3); + if (runtostyp(ctx->voccxrun) == DAT_LIST) + { + uchar *l; + uint len; + int kept_numobj; + + /* presume we won't keep numObj */ + kept_numobj = FALSE; + + /* read the list length prefix, and skip it */ + l = runpoplst(ctx->voccxrun); + len = osrp2(l) - 2; + l += 2; + + /* + * For each element of the return value, see if + * it's in list1. If so, copy the object into + * list2, unless it's already in list2. + */ + for (cnt2 = 0 ; len != 0 ; ) + { + if (*l == DAT_OBJECT) + { + objnum o = osrp2(l+1); + + for (i = 0 ; i < cnt ; ++i) + { + if (list1[i] == o) + { + int j; + + /* check to see if o is already in list2 */ + for (j = 0 ; j < cnt2 ; ++j) + if (list2[j] == o) break; + + /* if o is not in list2 yet, add it */ + if (j == cnt2) + { + /* add it */ + list2[cnt2] = o; + flags2[cnt2] = flags1[i]; + ++cnt2; + + /* + * if it's numObj, note that + * we've already included it in + * the output list, so that we + * don't add it again later + */ + if (o == ctx->voccxnum) + kept_numobj = TRUE; + } + break; + } + } + } + + /* move on to next element */ + lstadv(&l, &len); + } + + /* + * If the original list included numObj, keep it in + * the accessible list for now - we consider numObj + * to be always accessible. The noun phrase matcher + * will include numObj whenever the player enters a + * single number as a noun phrase, even when the + * number matches an object. Note that we can skip + * this special step if we already kept numObj in + * the valid list. + */ + if (!kept_numobj) + { + /* search the original list for numObj */ + for (i = 0 ; i < cnt ; ++i) + { + /* if this original entry is numObj, keep it */ + if (list1[i] == ctx->voccxnum) + { + /* keep it in the accessible list */ + list2[cnt2++] = ctx->voccxnum; + + /* no need to look any further */ + break; + } + } + } + + /* copy list2 into list1 */ + memcpy(list1, list2, (size_t)(cnt2 * sizeof(list1[0]))); + memcpy(flags1, flags2, (size_t)cnt2 * sizeof(flags1[0])); + cnt = cnt2; + list1[cnt] = MCMONINV; + } + else + rundisc(ctx->voccxrun); + } + + /* + * Determine accessibility and visibility. First, limit + * list1 to those objects that are visible OR accessible, + * and limit list3 to those objects that are visible. + */ + for (cnt = cnt3 = i = 0 ; list1[i] != MCMONINV ; ++i) + { + int is_vis; + int is_acc; + + /* determine if the object is visible */ + is_vis = vocchkvis(ctx, list1[i], cmdActor); + + /* determine if it's accessible */ + is_acc = vocchkaccess(ctx, list1[i], accprop, i, + cmdActor, cmdVerb); + + /* keep items that are visible OR accessible in list1 */ + if (is_acc || is_vis) + { + list1[cnt] = list1[i]; + flags1[cnt] = flags1[i]; + ++cnt; + } + + /* + * put items that are visible (regardless of whether or + * not they're accessible) in list3 + */ + if (is_vis) + { + list3[cnt3] = list1[i]; + flags3[cnt3] = flags1[i]; + ++cnt3; + } + } + + /* + * If some of our accessible objects matched with an + * adjective at the end of the noun phrase, and others + * didn't (i.e., the others matched with a noun or plural at + * the end of the noun phrase), eliminate the ones that + * matched with an adjective at the end. Ending a noun + * phrase with an adjective is really a kind of short-hand; + * if we have matches for both the full name version (with a + * noun at the end) and a short-hand version, we want to + * discard the short-hand version so that we don't treat it + * as ambiguous with the long-name version. Likewise, if we + * have some exact matches and some truncations, keep only + * the exact matches. + */ + cnt = voc_prune_matches(ctx, list1, flags1, cnt); + cnt3 = voc_prune_matches(ctx, list3, flags3, cnt3); + + /* + * Now, reduce list1 to objects that are accessible. The + * reason for this multi-step process is to ensure that we + * prune the list with respect to every object in scope + * (visible or accessible for the verb), so that we get the + * most sensible pruning behavior. This is more sensible + * than pruning by accessibility only, because sometimes we + * may have objects that are visible but are not accessible; + * as far as the player is concerned, the visible objects + * are part of the current location, so the player should be + * able to refer to them regardless of whether they're + * accessible. + */ + for (dst = 0, i = 0 ; i < cnt ; ++i) + { + /* check this object for accessibility */ + if (vocchkaccess(ctx, list1[i], accprop, i, + cmdActor, cmdVerb)) + { + /* keep it in the final list */ + list1[dst] = list1[i]; + flags1[dst] = flags1[i]; + + /* count the new list entry */ + ++dst; + } + } + + /* terminate list1 */ + cnt = dst; + list1[dst] = MCMONINV; + + /* + * Go through the list of accessible objects, and perform + * the sensible-object (verXoVerb) check on each. Copy each + * sensible object to list2. + */ + for (i = 0, cnt2 = 0 ; i < cnt ; ++i) + { + /* run it by the appropriate sensible-object check */ + if (accprop == PRP_VALIDACTOR) + { + /* run it through preferredActor */ + runppr(ctx->voccxrun, list1[i], PRP_PREFACTOR, 0); + if (runpoplog(ctx->voccxrun)) + { + list2[cnt2] = list1[i]; + flags2[cnt2] = flags1[i]; + ++cnt2; + } + } + else + { + /* run it through verXoVerb */ + tiohide(ctx->voccxtio); + if (otherobj != MCMONINV) + runpobj(ctx->voccxrun, otherobj); + runpobj(ctx->voccxrun, cmdActor); + runppr(ctx->voccxrun, list1[i], verprop, + (otherobj != MCMONINV ? 2 : 1)); + + /* + * If that didn't result in a message, this object + * passed the tougher test of ver?oX, so include it + * in list2. + */ + if (!tioshow(ctx->voccxtio)) + { + list2[cnt2] = list1[i]; + flags2[cnt2] = flags1[i]; + ++cnt2; + } + } + } + + /* + * Construct a string consisting of the words the user typed + * to reference this object, in case we need to complain. + */ + usrobj[0] = '\0'; + if (inlist[inpos].vocolfst != 0 && inlist[inpos].vocollst != 0) + { + for (p = inlist[inpos].vocolfst ; p <= inlist[inpos].vocollst + ; p += strlen(p) + 1) + { + /* add a space if we have a prior word */ + if (usrobj[0] != '\0') + { + /* quote the space if the last word ended with '.' */ + if (p[strlen(p)-1] == '.') + strcat(usrobj, "\\"); + + /* add the space */ + strcat(usrobj, " "); + } + + /* add the current word, or "of" if it's "of" */ + if (voc_check_special(ctx, p, VOCW_OF)) + vocaddof(ctx, usrobj); + else + strcat(usrobj, p); + } + } + + /* + * If there's nothing in the YES list, and we have just a + * single number as our word, act as though they are talking + * about the number itself, rather than one of the objects + * that happened to use the number -- none of those objects + * make any sense, it seems, so fall back on the number. + * + * Note that we may also have only numObj in the YES list, + * because the noun phrase parser normally adds numObj when + * the player types a noun phrase consisting only of a + * number. Do the same thing in this case -- just return + * the number object. + */ + if ((cnt2 == 0 + || (cnt2 == 1 && list2[0] == ctx->voccxnum)) + && inlist[inpos].vocolfst != 0 + && inlist[inpos].vocolfst == inlist[inpos].vocollst + && vocisdigit(*inlist[inpos].vocolfst)) + { + long v1; + char vbuf[4]; + + v1 = atol(inlist[inpos].vocolfst); + oswp4s(vbuf, v1); + vocsetobj(ctx, ctx->voccxnum, DAT_NUMBER, vbuf, + &inlist[inpos], &outlist[outpos]); + outlist[outpos].vocolflg = VOCS_NUM; + ++outpos; + + /* skip all objects that matched the number */ + for ( ; inlist[inpos+1].vocolobj != MCMONINV + && inlist[inpos+1].vocolfst == inlist[inpos].vocolfst + ; ++inpos) ; + continue; + } + + /* + * Check if we found anything in either the YES (list2) or + * MAYBE (list1) lists. If there's nothing in either list, + * complain and return. + */ + if (cnt2 == 0 && cnt == 0) + { + /* + * We have nothing sensible, and nothing even + * accessible. If there's anything merely visible, + * complain about those items. + */ + if (cnt3 != 0) + { + /* there are visible items - complain about them */ + cnt = cnt3; + cantreach_list = list3; + noreach = TRUE; + + /* give the cantReach message, even for multiple objects */ + goto noreach1; + } + else + { + /* + * explain that there's nothing visible or + * accessible matching the noun phrase, and abort + * the command with an error + */ + if (!silent) + vocerr(ctx, VOCERR(9), + "I don't see any %s here.", usrobj); + err = VOCERR(9); + goto done; + } + } + + /* + * If anything passed the stronger test (objects passing are + * in list2), use this as our proposed resolution for the + * noun phrase. If nothing passed the stronger test (i.e., + * list2 is empty), simply keep the list of accessible + * objects in list1. + */ + if (cnt2 != 0) + { + /* + * we have items passing the stronger test -- copy the + * stronger list (list2) to list1 + */ + cnt = cnt2; + memcpy(list1, list2, (size_t)(cnt2 * sizeof(list1[0]))); + memcpy(flags1, flags2, (size_t)(cnt2 * sizeof(flags1[0]))); + } + + /* + * Check for redundant objects in the list. If the same + * object appears multiple times in the list, remove the + * extra occurrences. Sometimes, a game can inadvertantly + * define the same vocabulary word several times for the + * same object, because of the parser's leniency with + * matching leading substrings of 6 characters or longer. + * To avoid unnecessary "which x do you mean..." errors, + * simply discard any duplicates in the list. + */ + for (dst = 0, i = 0 ; i < cnt ; ++i) + { + int dup; + int j; + + /* presume we won't find a duplicate of this object */ + dup = FALSE; + + /* + * look for duplicates of this object in the remainder + * of the list + */ + for (j = i + 1 ; j < cnt ; ++j) + { + /* check for a duplicate */ + if (list1[i] == list1[j]) + { + /* note that this object has a duplicate */ + dup = TRUE; + + /* we don't need to look any further */ + break; + } + } + + /* + * if this object has no duplicate, retain it in the + * output list + */ + if (!dup) + { + /* copy the element to the output */ + list1[dst] = list1[i]; + flags1[dst] = flags1[i]; + + /* count the output */ + ++dst; + } + } + + /* update the count to the new list's size */ + cnt = dst; + list1[cnt] = MCMONINV; + + /* + * If we have more than one object in the list, and numObj + * is still in the list, remove numObj - we don't want to + * consider numObj to be considered ambiguous with another + * object when the other object passes access and validation + * tests. + */ + if (cnt > 1) + { + /* scan the list for numObj */ + for (i = 0, dst = 0 ; i < cnt ; ++i) + { + /* if this isn't numObj, keep this element */ + if (list1[i] != ctx->voccxnum) + list1[dst++] = list1[i]; + } + + /* update the final count */ + cnt = dst; + list1[cnt] = MCMONINV; + } + + /* + * Check for a generic numeric adjective ('#' in the + * adjective list for the object) in each object. If we + * find it, we need to make sure there's a number in the + * name of the object. + */ + for (i = 0 ; i < cnt ; ++i) + { + if (has_gen_num_adj(ctx, list1[i])) + { + /* + * If they specified a count, create the specified + * number of objects. Otherwise, if the object is + * plural, they mean to use all of the objects, so a + * numeric adjective isn't required -- set the + * numeric adjective property in the object to nil + * to so indicate. Otherwise, look for the number, + * and set the numeric adjective property + * accordingly. + */ + if ((flags1[i] & (VOCS_ANY | VOCS_COUNT)) != 0) + { + int n = (user_count ? user_count : 1); + int j; + objnum objn = list1[i]; + + /* + * They specified a count, so we want to create + * n-1 copies of the numbered object. Make room + * for the n-1 new copies of this object by + * shifting any elements that follow up n-1 + * slots. + */ + if (i + 1 != cnt && n > 1) + { + memmove(&list1[i + n - 1], &list1[i], + (cnt - i) * sizeof(list1[i])); + memmove(&flags1[i + n - 1], &flags1[i], + (cnt - i) * sizeof(flags1[i])); + } + + /* create n copies of this object */ + for (j = 0 ; j < n ; ++j) + { + long l; + + /* + * Generate a number for the new object, + * asking the object to tell us what value + * to use for an "any". + */ + runpnum(ctx->voccxrun, (long)(j + 1)); + runppr(ctx->voccxrun, objn, PRP_ANYVALUE, 1); + l = runpopnum(ctx->voccxrun); + + /* try creating the new object */ + list1[i+j] = + voc_new_num_obj(ctx, objn, + cmdActor, cmdVerb, + l, FALSE); + if (list1[i+j] == MCMONINV) + { + err = VOCERR(40); + goto done; + } + } + } + else if ((flags1[i] & VOCS_PLURAL) != 0) + { + /* + * get the plural object by asking for the + * numbered object with a nil number parameter + */ + list1[i] = + voc_new_num_obj(ctx, list1[i], cmdActor, cmdVerb, + (long)0, TRUE); + if (list1[i] == MCMONINV) + { + err = VOCERR(40); + goto done; + } + } + else + { + //char *p; + int found; + + /* + * No plural, no "any" - we just want to create + * one numbered object, using the number that + * the player must have specified. Make sure + * the player did, in fact, specify a number. + */ + for (found = FALSE, p = inlist[inpos].vocolfst ; + p != 0 && p <= inlist[inpos].vocollst ; + p += strlen(p) + 1) + { + /* did we find it? */ + if (vocisdigit(*p)) + { + long l; + + /* get the number */ + l = atol(p); + + /* create the object with this number */ + list1[i] = voc_new_num_obj(ctx, list1[i], + cmdActor, cmdVerb, + l, FALSE); + if (list1[i] == MCMONINV) + { + err = VOCERR(40); + goto done; + } + + /* the command looks to be valid */ + found = TRUE; + break; + } + } + + /* if we didn't find it, stop now */ + if (!found) + { + if (!silent) + vocerr(ctx, VOCERR(160), + "You'll have to be more specific about which %s you mean.", + usrobj); + err = VOCERR(160); + goto done; + } + } + } + } + + /* + * We still have an ambiguous word - ask the user which of + * the possible objects they meant to use + */ + trying_again = FALSE; + for (;;) + { + int wrdcnt; + int next; + uchar *pu; + int cleared_noun; + int diff_cnt; + int stat; + int num_wanted; + int is_ambig; + int all_plural; + + /* + * check for usage - determine if we have singular + * definite, singular indefinite, counted, or plural + * usage + */ + if ((flags1[0] & (VOCS_PLURAL | VOCS_ANY | VOCS_COUNT)) != 0) + { + //int i; + + /* + * loop through the objects to AND together the + * flags from all of the objects; we only care about + * the plural flags (PLURAL, ANY, and COUNT), so + * start out with only those, then AND off any that + * aren't in all of the objects + */ + for (all_plural = VOCS_PLURAL | VOCS_ANY | VOCS_COUNT, + i = 0 ; i < cnt ; ++i) + { + /* AND out this object's flags */ + all_plural &= flags1[i]; + + /* + * if we've ANDed down to zero, there's no need + * to look any further + */ + if (!all_plural) + break; + } + } + else + { + /* + * it looks like we want just a single object - + * clear the various plural flags + */ + all_plural = 0; + } + + /* + * Count the distinguishable items. + * + * If we're looking for a single object, don't keep + * duplicate indistinguishable items (i.e., keep only + * one item from each set of mutually indistinguishable + * items), since we could equally well use any single + * one of those items. If we're looking for multiple + * objects, keep all of the items, since the user is + * referring to all of them. + */ + diff_cnt = voc_count_diff(ctx, list1, flags1, &cnt, + all_plural != 0 || use_all_objs); + + /* + * Determine how many objects we'd like to find. If we + * have a count specified, we'd like to find the given + * number of objects. If we have "ANY" specified, we + * just want to pick one object arbitrarily. If we have + * all plurals, we can keep all of the objects. If the + * 'use_all_objs' flag is true, it means that we can use + * everything in the list. + */ + if (use_all_objs) + { + /* we want to use all of the objects */ + num_wanted = cnt; + is_ambig = FALSE; + } + else if ((all_plural & VOCS_COUNT) != 0) + { + /* + * we have a count - we want exactly the given + * number of objects, but we can pick an arbitrary + * subset, so it's not ambiguous even if we have too + * many at the moment + */ + num_wanted = user_count; + is_ambig = FALSE; + } + else if ((all_plural & VOCS_ANY) != 0) + { + /* + * they specified "any", so we want exactly one, but + * we can pick one arbitrarily, so there's no + * ambiguity + */ + num_wanted = 1; + is_ambig = FALSE; + } + else if (all_plural != 0) + { + /* + * we have a simple plural, so we can use all of the + * provided objects without ambiguity + */ + num_wanted = cnt; + is_ambig = FALSE; + } + else + { + /* + * it's a singular, definite usage, so we want + * exactly one item; if we have more than one in our + * list, it's ambiguous + */ + num_wanted = 1; + is_ambig = (cnt != 1); + } + + /* call the disambiguation hook */ + stat = voc_disambig_hook(ctx, cmdVerb, cmdActor, cmdPrep, + otherobj, accprop, verprop, + list1, flags1, &cnt, + inlist[inpos].vocolfst, + inlist[inpos].vocollst, + num_wanted, is_ambig, disnewbuf, + silent); + + /* check the status */ + if (stat == VOC_DISAMBIG_DONE) + { + /* that's it - copy the result */ + for (i = 0 ; i < cnt ; ++i) + vocout(&outlist[outpos++], list1[i], flags1[i], + inlist[inpos].vocolfst, + inlist[inpos].vocollst); + + /* we're done */ + break; + } + else if (stat == VOC_DISAMBIG_CONT) + { + /* + * Continue with the new list (which is the same as + * the old list, if it wasn't actually updated by + * the hook routine) - proceed with remaining + * processing, but using the new list. + * + * Because the list has been updated, we must once + * again count the number of distinguishable items, + * since that may have changed. + */ + diff_cnt = voc_count_diff(ctx, list1, flags1, &cnt, TRUE); + } + else if (stat == VOC_DISAMBIG_PARSE_RESP + || stat == VOC_DISAMBIG_PROMPTED) + { + /* + * The status indicates one of the following: + * + * - the hook prompted for more information and read + * a response from the player, but decided not to + * parse it; we will continue with the current list, + * and parse the player's response as provided by + * the hook. + * + * - the hook prompted for more information, but + * left the reading to us. We'll proceed with the + * current list and read a response as normal, but + * without displaying another prompt. + * + * In any case, just continue processing; we'll take + * appropriate action on the prompting and reading + * when we reach those steps. + */ + } + else + { + /* anything else is an error */ + err = VOCERR(41); + goto done; + } + + /* + * If we found only one word, or a plural/ANY, we are + * finished. If we found a count, use that count if + * possible. + */ + if (cnt == 1 || all_plural || use_all_objs) + { + int flags; + + /* keep only one of the objects if ANY was used */ + if ((all_plural & VOCS_COUNT) != 0) + { + if (user_count > cnt) + { + if (!silent) + vocerr(ctx, VOCERR(30), + "I only see %d of those.", cnt); + err = VOCERR(30); + goto done; + } + cnt = user_count; + flags = VOCS_ALL; + } + else if ((all_plural & VOCS_ANY) != 0) + { + cnt = 1; + flags = VOCS_ALL; + } + else + flags = 0; + + /* put the list */ + for (i = 0 ; i < cnt ; ++i) + vocout(&outlist[outpos++], list1[i], flags, + inlist[inpos].vocolfst, + inlist[inpos].vocollst); + + /* we're done */ + break; + } + + /* make sure output capturing is off */ + tiocapture(ctx->voccxtio, (mcmcxdef *)0, FALSE); + tioclrcapture(ctx->voccxtio); + + /* + * if we're in "silent" mode, we can't ask the player + * for help, so return an error + */ + if (silent) + { + /* + * We can't disambiguate the list. Fill in the + * return list with what's left, which is still + * ambiguous, and note that we need to return an + * error code indicating that the list remains + * ambiguous. + */ + for (i = 0 ; i < cnt && outpos < VOCMAXAMBIG ; ++i) + vocout(&outlist[outpos++], list1[i], 0, + inlist[inpos].vocolfst, + inlist[inpos].vocollst); + + /* note that we have ambiguity remaining */ + still_ambig = TRUE; + + /* we're done with this sublist */ + break; + } + + /* + * We need to prompt for more information interactively. + * Figure out how we're going to display the prompt. + * + * - If the disambigXobj hook status (stat) indicates + * that the hook already displayed a prompt of its own, + * we don't need to add anything here. + * + * - Otherwise, if there's a parseDisambig function + * defined in the game, call it to display the prompt. + * + * - Otherwise, display our default prompt. + */ + if (stat == VOC_DISAMBIG_PARSE_RESP + || stat == VOC_DISAMBIG_PROMPTED) + { + /* + * the disambigXobj hook already asked for a + * response, so don't display any prompt of our own + */ + } + else if (ctx->voccxpdis != MCMONINV) + { + uint l; + + /* + * There's a parseDisambig function defined in the + * game - call it to display the prompt, passing the + * list of possible objects and the player's + * original noun phrase text as parameters. + */ + for (i = 0, pu = lstbuf+2 ; i < cnt ; ++i, pu += 2) + { + *pu++ = DAT_OBJECT; + oswp2(pu, list1[i]); + } + l = pu - lstbuf; + oswp2(lstbuf, l); + runpbuf(ctx->voccxrun, DAT_LIST, lstbuf); + runpstr(ctx->voccxrun, usrobj, (int)strlen(usrobj), 1); + runfn(ctx->voccxrun, ctx->voccxpdis, 2); + } + else + { + /* display "again" message, if necessary */ + if (trying_again) + vocerr_info(ctx, VOCERR(100), "Let's try it again: "); + + /* ask the user about it */ + vocerr_info(ctx, VOCERR(101), + "Which %s do you mean, ", usrobj); + for (i = 0 ; i < cnt ; ) + { + int eqcnt; + int j; + objnum sc; + + /* + * See if we have multiple instances of an + * identical object. All such instances should + * be grouped together (this was done above), so + * we can just count the number of consecutive + * equivalent objects. + */ + eqcnt = 1; + runppr(ctx->voccxrun, list1[i], PRP_ISEQUIV, 0); + if (runpoplog(ctx->voccxrun)) + { + /* get the superclass, if possible */ + sc = objget1sc(ctx->voccxmem, list1[i]); + if (sc != MCMONINV) + { + /* count equivalent objects that follow */ + for (j = i + 1 ; j < cnt ; ++j) + { + if (objget1sc(ctx->voccxmem, list1[j]) + == sc) + ++eqcnt; + else + break; + } + } + } + + /* + * Display this object's name. If we have only + * one such object, display its thedesc, + * otherwise display its adesc. + */ + runppr(ctx->voccxrun, list1[i], + (prpnum)(eqcnt == 1 ? + PRP_THEDESC : PRP_ADESC), 0); + + /* display the separator as appropriate */ + if (i + 1 < diff_cnt) + vocerr_info(ctx, VOCERR(102), ", "); + if (i + 2 == diff_cnt) + vocerr_info(ctx, VOCERR(103), "or "); + + /* skip all equivalent items */ + i += eqcnt; + } + vocerr_info(ctx, VOCERR(104), "?"); + } + + /* + * Read the response. If the disambigXobj hook already + * read the response, we don't need to read anything + * more. + */ + if (stat != VOC_DISAMBIG_PARSE_RESP + && vocread(ctx, cmdActor, cmdVerb, disnewbuf, + (int)VOCBUFSIZ, 2) == VOCREAD_REDO) + { + /* they want to treat the input as a new command */ + strcpy(cmdbuf, disnewbuf); + ctx->voccxunknown = 0; + ctx->voccxredo = TRUE; + err = VOCERR(43); + goto done; + } + + /* + * parse the response + */ + + /* tokenize the list */ + wrdcnt = voctok(ctx, disnewbuf, disbuffer, diswordlist, + TRUE, TRUE, TRUE); + if (wrdcnt == 0) + { + /* empty response - run pardon() function and abort */ + runfn(ctx->voccxrun, ctx->voccxprd, 0); + err = VOCERR(42); + goto done; + } + if (wrdcnt < 0) + { + /* return the generic punctuation error */ + err = VOCERR(1); + goto done; + } + + /* + * Before we tokenize the sentence, remember the current + * unknown word count, then momentarily set the count to + * zero. This will cause the tokenizer to absorb any + * unknown words; if there are any unknown words, the + * tokenizer will parse them and set the unknown count. + * If we find any unknown words in the input, we'll + * simply treat the input as an entirely new command. + */ + old_unknown = ctx->voccxunknown; + old_lastunk = ctx->voccxlastunk; + ctx->voccxunknown = 0; + + /* clear our internal type list */ + memset(distypelist, 0, VOCBUFSIZ * sizeof(distypelist[0])); + + /* tokenize the sentence */ + diswordlist[wrdcnt] = 0; + if (vocgtyp(ctx, diswordlist, distypelist, cmdbuf) + || ctx->voccxunknown != 0) + { + /* + * there's an unknown word or other problem - retry + * the input as an entirely new command + */ + strcpy(cmdbuf, disnewbuf); + ctx->voccxunknown = 0; + ctx->voccxredo = TRUE; + err = VOCERR(2); + goto done; + } + + /* restore the original unknown word count */ + ctx->voccxunknown = old_unknown; + ctx->voccxlastunk = old_lastunk; + + /* + * Find the last word that can be an adj and/or a noun. + * If it can be either (i.e., both bits are set), clear + * the noun bit and make it just an adjective. This is + * because we're asking for an adjective for clarification, + * and we most likely want it to be an adjective in this + * context; if the noun bit is set, too, the object lister + * will think it must be a noun, being the last word. + */ + for (i = 0 ; i < wrdcnt ; ++i) + { + if (!(distypelist[i] & + (VOCT_ADJ | VOCT_NOUN | VOCT_ARTICLE))) + break; + } + + if (i && (distypelist[i-1] & VOCT_ADJ) + && (distypelist[i-1] & VOCT_NOUN)) + { + /* + * Note that we're clearing the noun flag. If + * we're unsuccessful in finding the object with the + * noun flag cleared, we'll put the noun flag back + * in and give it another try (by adding VOCT_NOUN + * back into distypelist[cleared_noun], and coming + * back to the label below). + */ + cleared_noun = i-1; + distypelist[i-1] &= ~VOCT_NOUN; + } + else + cleared_noun = -1; + + try_current_flags: + /* start with the first word */ + if (vocspec(diswordlist[0], VOCW_ALL) + || vocspec(diswordlist[0], VOCW_BOTH)) + { + char *nam; + static char all_name[] = "all"; + static char both_name[] = "both"; + + if (vocspec(diswordlist[0], VOCW_ALL)) + nam = all_name; + else + nam = both_name; + + for (i = 0 ; i < cnt ; ++i) + vocout(&outlist[outpos++], list1[i], 0, nam, nam); + if (noreach) + { + cantreach_list = list1; + goto noreach1; + } + break; + } + else if (vocspec(diswordlist[0], VOCW_ANY)) + { + /* choose the first object arbitrarily */ vocout(&outlist[outpos++], list1[i], VOCS_ALL, "any", "any"); - break; - } - else - { - /* check for a word matching the phrase */ - cnt2 = vocchknoun(ctx, diswordlist, distypelist, - 0, &next, disnounlist, FALSE); - if (cnt2 > 0) - { - /* - * if that didn't consume the entire phrase, or - * at least up to "one" or "ones" or a period, - * disallow it, since they must be entering - * something more complicated - */ - if (diswordlist[next] != 0 - && !vocspec(diswordlist[next], VOCW_ONE) - && !vocspec(diswordlist[next], VOCW_ONES) - && !vocspec(diswordlist[next], VOCW_THEN)) - { - cnt2 = 0; - } - } - else if (cnt2 < 0) - { - /* - * There was a syntax error in the phrase. - * vocchknoun() will have displayed a message in - * this case, so we're done parsing this command. - */ - err = VOCERR(45); - goto done; - } + break; + } + else + { + /* check for a word matching the phrase */ + cnt2 = vocchknoun(ctx, diswordlist, distypelist, + 0, &next, disnounlist, FALSE); + if (cnt2 > 0) + { + /* + * if that didn't consume the entire phrase, or + * at least up to "one" or "ones" or a period, + * disallow it, since they must be entering + * something more complicated + */ + if (diswordlist[next] != 0 + && !vocspec(diswordlist[next], VOCW_ONE) + && !vocspec(diswordlist[next], VOCW_ONES) + && !vocspec(diswordlist[next], VOCW_THEN)) + { + cnt2 = 0; + } + } + else if (cnt2 < 0) + { + /* + * There was a syntax error in the phrase. + * vocchknoun() will have displayed a message in + * this case, so we're done parsing this command. + */ + err = VOCERR(45); + goto done; + } - /* proceed only if we got a valid phrase */ - if (cnt2 > 0) - { - //int cnt3; - int newcnt; + /* proceed only if we got a valid phrase */ + if (cnt2 > 0) + { + //int cnt3; + int newcnt; - /* build the list of matches for the new phrase */ - for (i = 0, newcnt = 0 ; i < cnt2 ; ++i) - { - int j; - int found; + /* build the list of matches for the new phrase */ + for (i = 0, newcnt = 0 ; i < cnt2 ; ++i) + { + int j; + int found; - /* - * make sure this object isn't already in - * our list - we want each object only once - */ - for (j = 0, found = FALSE ; j < newcnt ; ++j) - { - /* if this is in the list, note it */ - if (list2[j] == disnounlist[i].vocolobj) - { - found = TRUE; - break; - } - } + /* + * make sure this object isn't already in + * our list - we want each object only once + */ + for (j = 0, found = FALSE ; j < newcnt ; ++j) + { + /* if this is in the list, note it */ + if (list2[j] == disnounlist[i].vocolobj) + { + found = TRUE; + break; + } + } - /* - * add it to our list only if it wasn't - * already there - */ - if (!found) - { - /* copy the object ID */ - list2[newcnt] = disnounlist[i].vocolobj; + /* + * add it to our list only if it wasn't + * already there + */ + if (!found) + { + /* copy the object ID */ + list2[newcnt] = disnounlist[i].vocolobj; - /* copy the flags that we care about */ - flags2[newcnt] = disnounlist[i].vocolflg - & (VOCS_PLURAL | VOCS_ANY - | VOCS_COUNT); + /* copy the flags that we care about */ + flags2[newcnt] = disnounlist[i].vocolflg + & (VOCS_PLURAL | VOCS_ANY + | VOCS_COUNT); - /* count the entry */ - ++newcnt; - } - } + /* count the entry */ + ++newcnt; + } + } - /* terminate the list */ - list2[newcnt] = MCMONINV; + /* terminate the list */ + list2[newcnt] = MCMONINV; - /* intersect the new list with the old list */ - newcnt = vocisect(list2, list1); + /* intersect the new list with the old list */ + newcnt = vocisect(list2, list1); - /* count the noun phrases in the new list */ - for (i = cnt3 = 0 ; i < cnt2 ; ++i) - { - /* we have one more noun phrase */ - ++cnt3; + /* count the noun phrases in the new list */ + for (i = cnt3 = 0 ; i < cnt2 ; ++i) + { + /* we have one more noun phrase */ + ++cnt3; - /* if we have a noun phrase, skip matching objs */ - if (disnounlist[i].vocolfst != 0) - { - int j; + /* if we have a noun phrase, skip matching objs */ + if (disnounlist[i].vocolfst != 0) + { + int j; - /* skip objects matching this noun phrase */ - for (j = i + 1 ; disnounlist[i].vocolfst == - disnounlist[j].vocolfst ; ++j) ; - i = j - 1; - } - } - - /* - * If the count of items in the intersection of - * the original list and the typed-in list is no - * bigger than the number of items specified in - * the typed-in list, we've successfully - * disambiguated the object, because the user's - * new list matches only one object for each set - * of words the user typed. - */ - if (newcnt - && (newcnt <= cnt3 - || (diswordlist[next] - && vocspec(diswordlist[next], - VOCW_ONES)))) - { - for (i = 0 ; i < cnt ; ++i) - vocout(&outlist[outpos++], list2[i], 0, - one_name, one_name); - - if (noreach) - { - cnt = newcnt; - cantreach_list = list2; - noreach1: - if (accprop == PRP_VALIDACTOR) - { - /* for actors, show a special message */ - vocerr(ctx, VOCERR(31), - "You can't talk to that."); - } - else - { - /* use the normal no-reach message */ - vocnoreach(ctx, cantreach_list, cnt, - cmdActor, cmdVerb, cmdPrep, - defprop, cnt > 1, 0, 0, cnt); - } - err = VOCERR(31); - goto done; - } - break; - } - else if (newcnt == 0) - { - /* - * If we cleared the noun, maybe we actually - * need to treat the word as a noun, so add - * the noun flag back in and give it another - * go. If we didn't clear the noun, there's - * nothing left to try, so explain that we - * don't see any such object and give up. - */ - if (cleared_noun != -1) - { - distypelist[cleared_noun] |= VOCT_NOUN; - cleared_noun = -1; - goto try_current_flags; - } + /* skip objects matching this noun phrase */ + for (j = i + 1 ; disnounlist[i].vocolfst == + disnounlist[j].vocolfst ; ++j) ; + i = j - 1; + } + } + + /* + * If the count of items in the intersection of + * the original list and the typed-in list is no + * bigger than the number of items specified in + * the typed-in list, we've successfully + * disambiguated the object, because the user's + * new list matches only one object for each set + * of words the user typed. + */ + if (newcnt + && (newcnt <= cnt3 + || (diswordlist[next] + && vocspec(diswordlist[next], + VOCW_ONES)))) + { + for (i = 0 ; i < cnt ; ++i) + vocout(&outlist[outpos++], list2[i], 0, + one_name, one_name); + + if (noreach) + { + cnt = newcnt; + cantreach_list = list2; + noreach1: + if (accprop == PRP_VALIDACTOR) + { + /* for actors, show a special message */ + vocerr(ctx, VOCERR(31), + "You can't talk to that."); + } + else + { + /* use the normal no-reach message */ + vocnoreach(ctx, cantreach_list, cnt, + cmdActor, cmdVerb, cmdPrep, + defprop, cnt > 1, 0, 0, cnt); + } + err = VOCERR(31); + goto done; + } + break; + } + else if (newcnt == 0) + { + /* + * If we cleared the noun, maybe we actually + * need to treat the word as a noun, so add + * the noun flag back in and give it another + * go. If we didn't clear the noun, there's + * nothing left to try, so explain that we + * don't see any such object and give up. + */ + if (cleared_noun != -1) + { + distypelist[cleared_noun] |= VOCT_NOUN; + cleared_noun = -1; + goto try_current_flags; + } - /* find the first object with a noun phrase */ - for (i = 0 ; i < cnt2 ; ++i) - { - /* if we have a noun phrase, stop scanning */ - if (disnounlist[i].vocolfst != 0) - break; - } + /* find the first object with a noun phrase */ + for (i = 0 ; i < cnt2 ; ++i) + { + /* if we have a noun phrase, stop scanning */ + if (disnounlist[i].vocolfst != 0) + break; + } - /* - * if we found a noun phrase, build a string - * out of the words used; otherwise, just - * use "such" - */ - if (i != cnt2) { - const char *last; + /* + * if we found a noun phrase, build a string + * out of the words used; otherwise, just + * use "such" + */ + if (i != cnt2) { + const char *last; - /* clear the word buffer */ - newobj[0] = '\0'; - - /* build a string out of the words */ - p = disnounlist[i].vocolfst; - last = disnounlist[i].vocollst; - for ( ; p <= last ; p += strlen(p) + 1) - { - /* - * If this is a special word, we - * probably can't construct a - * sensible sentence - special words - * are special parts of speech that - * will look weird if inserted into - * our constructed noun phrase. In - * these cases, turn the entire - * thing into "I don't see any - * *such* object" rather than trying - * to make do with pronouns or other - * special words. - */ - if (vocisspec(p)) - { - /* - * replace the entire adjective - * phrase with "such" - */ - strcpy(newobj, "such"); + /* clear the word buffer */ + newobj[0] = '\0'; + + /* build a string out of the words */ + p = disnounlist[i].vocolfst; + last = disnounlist[i].vocollst; + for ( ; p <= last ; p += strlen(p) + 1) + { + /* + * If this is a special word, we + * probably can't construct a + * sensible sentence - special words + * are special parts of speech that + * will look weird if inserted into + * our constructed noun phrase. In + * these cases, turn the entire + * thing into "I don't see any + * *such* object" rather than trying + * to make do with pronouns or other + * special words. + */ + if (vocisspec(p)) + { + /* + * replace the entire adjective + * phrase with "such" + */ + strcpy(newobj, "such"); - /* - * stop here - don't add any - * more, since "such" is the - * whole thing - */ - break; - } - - /* add a space if we have a prior word */ - if (newobj[0] != '\0') - strcat(newobj, " "); + /* + * stop here - don't add any + * more, since "such" is the + * whole thing + */ + break; + } + + /* add a space if we have a prior word */ + if (newobj[0] != '\0') + strcat(newobj, " "); - /* add this word */ - strcat(newobj, p); - } - } - else - { - /* no noun phrase found */ - strcpy(newobj, "such"); - } + /* add this word */ + strcat(newobj, p); + } + } + else + { + /* no noun phrase found */ + strcpy(newobj, "such"); + } - /* didn't find anything - complain and give up */ - vocerr(ctx, VOCERR(16), - "You don't see any %s %s here.", - newobj, usrobj); - err = VOCERR(16); - goto done; - } - - /* - * If we get here, it means that we have still - * more than one object per noun phrase typed in - * the latest sentence. Limit the list to the - * intersection (by copying list2 to list1), and - * try again. - */ - memcpy(list1, list2, - (size_t)((newcnt + 1) * sizeof(list1[0]))); - cnt = newcnt; - trying_again = TRUE; - } - else - { - /* - * We didn't find a noun phrase, so it's probably a - * new command. However, check first to see if we - * were making a trial run with the noun flag - * cleared: if so, go back and make another pass - * with the noun flag added back in to see if that - * works any better. - */ - if (cleared_noun != -1) - { - distypelist[cleared_noun] |= VOCT_NOUN; - cleared_noun = -1; - goto try_current_flags; - } - - /* retry as an entire new command */ - strcpy(cmdbuf, disnewbuf); - ctx->voccxunknown = 0; - ctx->voccxredo = TRUE; - err = VOCERR(43); - goto done; - } - } - } - inpos = lpos - 1; - } - } + /* didn't find anything - complain and give up */ + vocerr(ctx, VOCERR(16), + "You don't see any %s %s here.", + newobj, usrobj); + err = VOCERR(16); + goto done; + } + + /* + * If we get here, it means that we have still + * more than one object per noun phrase typed in + * the latest sentence. Limit the list to the + * intersection (by copying list2 to list1), and + * try again. + */ + memcpy(list1, list2, + (size_t)((newcnt + 1) * sizeof(list1[0]))); + cnt = newcnt; + trying_again = TRUE; + } + else + { + /* + * We didn't find a noun phrase, so it's probably a + * new command. However, check first to see if we + * were making a trial run with the noun flag + * cleared: if so, go back and make another pass + * with the noun flag added back in to see if that + * works any better. + */ + if (cleared_noun != -1) + { + distypelist[cleared_noun] |= VOCT_NOUN; + cleared_noun = -1; + goto try_current_flags; + } + + /* retry as an entire new command */ + strcpy(cmdbuf, disnewbuf); + ctx->voccxunknown = 0; + ctx->voccxredo = TRUE; + err = VOCERR(43); + goto done; + } + } + } + inpos = lpos - 1; + } + } - /* terminate the output list */ - vocout(&outlist[outpos], MCMONINV, 0, (char *)0, (char *)0); + /* terminate the output list */ + vocout(&outlist[outpos], MCMONINV, 0, (char *)0, (char *)0); - /* - * If we still have ambiguous objects, so indicate. This can only - * happen when we operate in "silent" mode, because only then can we - * give up without fully resolving a list. - */ - if (still_ambig) - err = VOCERR(44); + /* + * If we still have ambiguous objects, so indicate. This can only + * happen when we operate in "silent" mode, because only then can we + * give up without fully resolving a list. + */ + if (still_ambig) + err = VOCERR(44); - /* no error */ - err = 0; + /* no error */ + err = 0; done: - ERRCLEAN(ctx->voccxerr) - { - /* - * reset the stack before we return, in case the caller handles - * the error without aborting the command - */ - voc_leave(ctx, save_sp); - } - ERRENDCLN(ctx->voccxerr); + ERRCLEAN(ctx->voccxerr) + { + /* + * reset the stack before we return, in case the caller handles + * the error without aborting the command + */ + voc_leave(ctx, save_sp); + } + ERRENDCLN(ctx->voccxerr); - /* return success */ - VOC_RETVAL(ctx, save_sp, err); + /* return success */ + VOC_RETVAL(ctx, save_sp, err); } /* vocready - see if at end of command, execute & return TRUE if so */ static int vocready(voccxdef *ctx, char *cmd[], int *typelist, int cur, - objnum cmdActor, objnum cmdPrep, char *vverb, char *vprep, - vocoldef *dolist, vocoldef *iolist, int *errp, - char *cmdbuf, int first_word, uchar **preparse_list, - int *next_start) + objnum cmdActor, objnum cmdPrep, char *vverb, char *vprep, + vocoldef *dolist, vocoldef *iolist, int *errp, + char *cmdbuf, int first_word, uchar **preparse_list, + int *next_start) { - if (cur != -1 - && (cmd[cur] == (char *)0 - || vocspec(cmd[cur], VOCW_AND) || vocspec(cmd[cur], VOCW_THEN))) - { - if (ctx->voccxflg & VOCCXFDBG) - { - char buf[128]; - - sprintf(buf, ". executing verb: %s %s\\n", - vverb, vprep ? vprep : ""); - tioputs(ctx->vocxtio, buf); - } + if (cur != -1 + && (cmd[cur] == (char *)0 + || vocspec(cmd[cur], VOCW_AND) || vocspec(cmd[cur], VOCW_THEN))) + { + if (ctx->voccxflg & VOCCXFDBG) + { + char buf[128]; + + sprintf(buf, ". executing verb: %s %s\\n", + vverb, vprep ? vprep : ""); + tioputs(ctx->vocxtio, buf); + } - *errp = execmd(ctx, cmdActor, cmdPrep, vverb, vprep, dolist, iolist, - &cmd[first_word], &typelist[first_word],cmdbuf, - cur - first_word, preparse_list, next_start); - return(TRUE); - } - return(FALSE); + *errp = execmd(ctx, cmdActor, cmdPrep, vverb, vprep, dolist, iolist, + &cmd[first_word], &typelist[first_word],cmdbuf, + cur - first_word, preparse_list, next_start); + return(TRUE); + } + return(FALSE); } /* execute a single command */ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf, - objnum *cmdActorp, int first) + objnum *cmdActorp, int first) { - int cur; - int next; - objnum o; - vocwdef *v; - char *vverb; - int vvlen; - char *vprep; - int cnt; - int err; - vocoldef *dolist; - vocoldef *iolist; - int *typelist; - objnum cmdActor = *cmdActorp; - objnum cmdPrep; - int swapObj; /* TRUE -> swap dobj and iobj */ - int again; - int first_word; + int cur; + int next; + objnum o; + vocwdef *v; + char *vverb; + int vvlen; + char *vprep; + int cnt; + int err; + vocoldef *dolist; + vocoldef *iolist; + int *typelist; + objnum cmdActor = *cmdActorp; + objnum cmdPrep; + int swapObj; /* TRUE -> swap dobj and iobj */ + int again; + int first_word; uchar *preparse_list = nullptr; - int next_start; - struct - { - int active; - int cur; - char **cmd; - char *cmdbuf; - } preparseCmd_stat; - char **newcmd; - char *origcmdbuf; - char *newcmdbuf; - uchar *save_sp; - int no_match; - int retval; + int next_start; + struct + { + int active; + int cur; + char **cmd; + char *cmdbuf; + } preparseCmd_stat; + char **newcmd; + char *origcmdbuf; + char *newcmdbuf; + uchar *save_sp; + int no_match; + int retval; - voc_enter(ctx, &save_sp); - VOC_MAX_ARRAY(ctx, vocoldef, dolist); - VOC_MAX_ARRAY(ctx, vocoldef, iolist); - VOC_STK_ARRAY(ctx, int, typelist, VOCBUFSIZ); - VOC_STK_ARRAY(ctx, char *, newcmd, VOCBUFSIZ); - VOC_STK_ARRAY(ctx, char, newcmdbuf, VOCBUFSIZ); + voc_enter(ctx, &save_sp); + VOC_MAX_ARRAY(ctx, vocoldef, dolist); + VOC_MAX_ARRAY(ctx, vocoldef, iolist); + VOC_STK_ARRAY(ctx, int, typelist, VOCBUFSIZ); + VOC_STK_ARRAY(ctx, char *, newcmd, VOCBUFSIZ); + VOC_STK_ARRAY(ctx, char, newcmdbuf, VOCBUFSIZ); preparseCmd_stat.active = 0; preparseCmd_stat.cur = 0; preparseCmd_stat.cmd = nullptr; preparseCmd_stat.cmdbuf = nullptr; - /* save the original command buf in case we need to redo the command */ - origcmdbuf = cmdbuf; + /* save the original command buf in case we need to redo the command */ + origcmdbuf = cmdbuf; - /* clear out the type list */ - memset(typelist, 0, VOCBUFSIZ*sizeof(typelist[0])); + /* clear out the type list */ + memset(typelist, 0, VOCBUFSIZ*sizeof(typelist[0])); - /* get the types of the words in the command */ - if (vocgtyp(ctx, cmd, typelist, cmdbuf)) - { - retval = 1; - goto done; - } + /* get the types of the words in the command */ + if (vocgtyp(ctx, cmd, typelist, cmdbuf)) + { + retval = 1; + goto done; + } - /* start off at the first word */ - cur = next = first_word = 0; + /* start off at the first word */ + cur = next = first_word = 0; - /* - * Presume we will be in control of the next word - when execmd() or - * another routine we call decides where the command ends, it will - * fill in a new value here. When this value is non-zero, it will - * tell us where the next sentence start is relative to the previous - * sentence start. - */ - next_start = 0; + /* + * Presume we will be in control of the next word - when execmd() or + * another routine we call decides where the command ends, it will + * fill in a new value here. When this value is non-zero, it will + * tell us where the next sentence start is relative to the previous + * sentence start. + */ + next_start = 0; - /* we don't have a preparseCmd result yet */ - preparseCmd_stat.active = FALSE; + /* we don't have a preparseCmd result yet */ + preparseCmd_stat.active = FALSE; - /* keep going until we run out of work to do */ - for (again = FALSE, err = 0 ; ; again = TRUE) - { - /* - * if preparseCmd sent us back a list, parse that list as a new - * command - */ - if (err == ERR_PREPRSCMDREDO) - { - uchar *src; - size_t len; - size_t curlen; - char *dst; - //int cnt; + /* keep going until we run out of work to do */ + for (again = FALSE, err = 0 ; ; again = TRUE) + { + /* + * if preparseCmd sent us back a list, parse that list as a new + * command + */ + if (err == ERR_PREPRSCMDREDO) + { + uchar *src; + size_t len; + size_t curlen; + char *dst; + //int cnt; - /* don't allow a preparseCmd to loop */ - if (preparseCmd_stat.active) - { - vocerr(ctx, VOCERR(34), - "Internal game error: preparseCmd loop"); - retval = 1; - goto done; - } - - /* save our status prior to processing the preparseCmd list */ - preparseCmd_stat.active = TRUE; - preparseCmd_stat.cur = cur; - preparseCmd_stat.cmd = cmd; - preparseCmd_stat.cmdbuf = cmdbuf; + /* don't allow a preparseCmd to loop */ + if (preparseCmd_stat.active) + { + vocerr(ctx, VOCERR(34), + "Internal game error: preparseCmd loop"); + retval = 1; + goto done; + } + + /* save our status prior to processing the preparseCmd list */ + preparseCmd_stat.active = TRUE; + preparseCmd_stat.cur = cur; + preparseCmd_stat.cmd = cmd; + preparseCmd_stat.cmdbuf = cmdbuf; - /* set up with the new command */ - cmd = newcmd; - cmdbuf = newcmdbuf; - cur = 0; + /* set up with the new command */ + cmd = newcmd; + cmdbuf = newcmdbuf; + cur = 0; - /* break up the list into the new command buffer */ - src = preparse_list; - len = osrp2(src) - 2; - for (src += 2, dst = cmdbuf, cnt = 0 ; len ; ) - { - /* make sure the next element is a string */ - if (*src != DAT_SSTRING) - { - vocerr(ctx, VOCERR(32), - "Internal game error: preparseCmd returned an invalid list"); - retval = 1; - goto done; - } + /* break up the list into the new command buffer */ + src = preparse_list; + len = osrp2(src) - 2; + for (src += 2, dst = cmdbuf, cnt = 0 ; len ; ) + { + /* make sure the next element is a string */ + if (*src != DAT_SSTRING) + { + vocerr(ctx, VOCERR(32), + "Internal game error: preparseCmd returned an invalid list"); + retval = 1; + goto done; + } - /* get the string */ - ++src; - curlen = osrp2(src) - 2; - src += 2; + /* get the string */ + ++src; + curlen = osrp2(src) - 2; + src += 2; - /* make sure it will fit in the buffer */ - if (dst + curlen + 1 >= cmdbuf + VOCBUFSIZ) - { - vocerr(ctx, VOCERR(33), - "Internal game error: preparseCmd command too long"); - retval = 1; - goto done; - } + /* make sure it will fit in the buffer */ + if (dst + curlen + 1 >= cmdbuf + VOCBUFSIZ) + { + vocerr(ctx, VOCERR(33), + "Internal game error: preparseCmd command too long"); + retval = 1; + goto done; + } - /* store the word */ - cmd[cnt++] = dst; - memcpy(dst, src, curlen); - dst[curlen] = '\0'; + /* store the word */ + cmd[cnt++] = dst; + memcpy(dst, src, curlen); + dst[curlen] = '\0'; - /* move on to the next word */ - len -= 3 + curlen; - src += curlen; - dst += curlen + 1; - } + /* move on to the next word */ + len -= 3 + curlen; + src += curlen; + dst += curlen + 1; + } - /* enter a null last word */ - cmd[cnt] = 0; + /* enter a null last word */ + cmd[cnt] = 0; - /* generate the type list for the new list */ - if (vocgtyp(ctx, cmd, typelist, cmdbuf)) - { - /* return an error */ - retval = 1; - goto done; - } + /* generate the type list for the new list */ + if (vocgtyp(ctx, cmd, typelist, cmdbuf)) + { + /* return an error */ + retval = 1; + goto done; + } - /* - * this is not a new command - it's just further processing - * of the current command - */ - again = FALSE; + /* + * this is not a new command - it's just further processing + * of the current command + */ + again = FALSE; - /* clear the error */ - err = 0; - } + /* clear the error */ + err = 0; + } - /* initialize locals */ - cmdPrep = MCMONINV; /* assume no preposition */ - swapObj = FALSE; /* assume no object swapping */ - dolist[0].vocolobj = iolist[0].vocolobj = MCMONINV; - dolist[0].vocolflg = iolist[0].vocolflg = 0; + /* initialize locals */ + cmdPrep = MCMONINV; /* assume no preposition */ + swapObj = FALSE; /* assume no object swapping */ + dolist[0].vocolobj = iolist[0].vocolobj = MCMONINV; + dolist[0].vocolflg = iolist[0].vocolflg = 0; - /* check error return from vocready (which returns from execmd) */ - if (err) - { - /* return the error */ - retval = err; - goto done; - } + /* check error return from vocready (which returns from execmd) */ + if (err) + { + /* return the error */ + retval = err; + goto done; + } - skip_leading_stuff: - /* - * If someone updated the sentence start point, jump there. The - * sentence start is relative to the previous sentence start. - */ - if (next_start != 0) - cur = first_word + next_start; + skip_leading_stuff: + /* + * If someone updated the sentence start point, jump there. The + * sentence start is relative to the previous sentence start. + */ + if (next_start != 0) + cur = first_word + next_start; - /* clear next_start, so we can tell if someone updates it */ - next_start = 0; - - /* skip any leading THEN's and AND's */ - while (cmd[cur] && (vocspec(cmd[cur], VOCW_THEN) - || vocspec(cmd[cur], VOCW_AND))) - ++cur; + /* clear next_start, so we can tell if someone updates it */ + next_start = 0; + + /* skip any leading THEN's and AND's */ + while (cmd[cur] && (vocspec(cmd[cur], VOCW_THEN) + || vocspec(cmd[cur], VOCW_AND))) + ++cur; - /* see if there's anything left to parse */ - if (cmd[cur] == 0) - { - /* - * if we've been off doing preparseCmd work, return to the - * original command list - */ - if (preparseCmd_stat.active) - { - /* restore the original status */ - cur = preparseCmd_stat.cur; - cmd = preparseCmd_stat.cmd; - cmdbuf = preparseCmd_stat.cmdbuf; - preparseCmd_stat.active = FALSE; - - /* get the type list for the original list again */ - if (vocgtyp(ctx, cmd, typelist, cmdbuf)) - { - /* return the error */ - retval = 1; - goto done; - } + /* see if there's anything left to parse */ + if (cmd[cur] == 0) + { + /* + * if we've been off doing preparseCmd work, return to the + * original command list + */ + if (preparseCmd_stat.active) + { + /* restore the original status */ + cur = preparseCmd_stat.cur; + cmd = preparseCmd_stat.cmd; + cmdbuf = preparseCmd_stat.cmdbuf; + preparseCmd_stat.active = FALSE; + + /* get the type list for the original list again */ + if (vocgtyp(ctx, cmd, typelist, cmdbuf)) + { + /* return the error */ + retval = 1; + goto done; + } - /* try again */ - goto skip_leading_stuff; - } - else - { - /* nothing to pop - we must be done */ - retval = 0; - goto done; - } - } + /* try again */ + goto skip_leading_stuff; + } + else + { + /* nothing to pop - we must be done */ + retval = 0; + goto done; + } + } - /* - * display a blank line if this is not the first command on this - * command line, so that we visually separate the results of the - * new command from the results of the previous command - */ - if (again) - outformat("\\b"); /* tioblank(ctx->voccxtio); */ + /* + * display a blank line if this is not the first command on this + * command line, so that we visually separate the results of the + * new command from the results of the previous command + */ + if (again) + outformat("\\b"); /* tioblank(ctx->voccxtio); */ - { - /* look for an explicit actor in the command */ - if ((o = vocgetactor(ctx, cmd, typelist, cur, &next, cmdbuf)) - != MCMONINV) - { - /* skip the actor noun phrase in the input */ - cur = next; + { + /* look for an explicit actor in the command */ + if ((o = vocgetactor(ctx, cmd, typelist, cur, &next, cmdbuf)) + != MCMONINV) + { + /* skip the actor noun phrase in the input */ + cur = next; - /* remember the actor internally */ - cmdActor = *cmdActorp = o; + /* remember the actor internally */ + cmdActor = *cmdActorp = o; - /* set the actor in the context */ - ctx->voccxactor = o; - } + /* set the actor in the context */ + ctx->voccxactor = o; + } - /* if the actor parsing failed, return an error */ - if (cur != next) - { - /* error getting actor */ - retval = 1; - goto done; - } - } + /* if the actor parsing failed, return an error */ + if (cur != next) + { + /* error getting actor */ + retval = 1; + goto done; + } + } - /* remember where the sentence starts */ - first_word = cur; + /* remember where the sentence starts */ + first_word = cur; - /* make sure we have a verb */ - if ((cmd[cur] == (char *)0) || !(typelist[cur] & VOCT_VERB)) - { - /* unknown verb - handle it with parseUnknownVerb if possible */ - if (!try_unknown_verb(ctx, cmdActor, &cmd[cur], &typelist[cur], - 0, &next_start, TRUE, VOCERR(17), - "There's no verb in that sentence!")) - { - /* error - abort the command */ - retval = 1; - goto done; - } - else - { - /* go back for more */ - continue; - } - } - vverb = cmd[cur++]; /* this is the verb */ - vvlen = strlen(vverb); /* remember length of verb */ - vprep = 0; /* assume no verb-preposition */ + /* make sure we have a verb */ + if ((cmd[cur] == (char *)0) || !(typelist[cur] & VOCT_VERB)) + { + /* unknown verb - handle it with parseUnknownVerb if possible */ + if (!try_unknown_verb(ctx, cmdActor, &cmd[cur], &typelist[cur], + 0, &next_start, TRUE, VOCERR(17), + "There's no verb in that sentence!")) + { + /* error - abort the command */ + retval = 1; + goto done; + } + else + { + /* go back for more */ + continue; + } + } + vverb = cmd[cur++]; /* this is the verb */ + vvlen = strlen(vverb); /* remember length of verb */ + vprep = 0; /* assume no verb-preposition */ - /* execute if the command is just a verb */ - if (vocready(ctx, cmd, typelist, cur, cmdActor, cmdPrep, - vverb, vprep, dolist, iolist, &err, cmdbuf, - first_word, &preparse_list, &next_start)) - continue; + /* execute if the command is just a verb */ + if (vocready(ctx, cmd, typelist, cur, cmdActor, cmdPrep, + vverb, vprep, dolist, iolist, &err, cmdbuf, + first_word, &preparse_list, &next_start)) + continue; - /* - * If the next word is a preposition, and it makes sense to be - * aggregated with this verb, use it as such. - */ - if (typelist[cur] & VOCT_PREP) - { - if (vocffw(ctx, vverb, vvlen, cmd[cur], (int)strlen(cmd[cur]), - PRP_VERB, (vocseadef *)0)) - { - vprep = cmd[cur++]; - if (vocready(ctx, cmd, typelist, cur, cmdActor, cmdPrep, - vverb, vprep, dolist, iolist, &err, cmdbuf, - first_word, &preparse_list, &next_start)) - continue; - } - else - { - /* - * If we have a preposition which can NOT be aggregated - * with the verb, take command of this form: "verb prep - * iobj dobj". Note that we do *not* do this if the - * word is also a noun, or it's an adjective and a noun - * (possibly separated by one or more adjectives) - * follows. - */ - if ((v = vocffw(ctx, cmd[cur], (int)strlen(cmd[cur]), - (char *)0, 0, PRP_PREP, (vocseadef *)0)) != 0) - { - int swap_ok; + /* + * If the next word is a preposition, and it makes sense to be + * aggregated with this verb, use it as such. + */ + if (typelist[cur] & VOCT_PREP) + { + if (vocffw(ctx, vverb, vvlen, cmd[cur], (int)strlen(cmd[cur]), + PRP_VERB, (vocseadef *)0)) + { + vprep = cmd[cur++]; + if (vocready(ctx, cmd, typelist, cur, cmdActor, cmdPrep, + vverb, vprep, dolist, iolist, &err, cmdbuf, + first_word, &preparse_list, &next_start)) + continue; + } + else + { + /* + * If we have a preposition which can NOT be aggregated + * with the verb, take command of this form: "verb prep + * iobj dobj". Note that we do *not* do this if the + * word is also a noun, or it's an adjective and a noun + * (possibly separated by one or more adjectives) + * follows. + */ + if ((v = vocffw(ctx, cmd[cur], (int)strlen(cmd[cur]), + (char *)0, 0, PRP_PREP, (vocseadef *)0)) != 0) + { + int swap_ok; - /* if it can be an adjective, check further */ - if (typelist[cur] & VOCT_NOUN) - { - /* don't allow the swap */ - swap_ok = FALSE; - } - else if (typelist[cur] & VOCT_ADJ) - { - int i; + /* if it can be an adjective, check further */ + if (typelist[cur] & VOCT_NOUN) + { + /* don't allow the swap */ + swap_ok = FALSE; + } + else if (typelist[cur] & VOCT_ADJ) + { + int i; - /* look for a noun, possibly preceded by adj's */ - for (i = cur + 1 ; - cmd[i] && (typelist[i] & VOCT_ADJ) - && !(typelist[i] & VOCT_NOUN) ; ++i) ; - swap_ok = (!cmd[i] || !(typelist[i] & VOCT_NOUN)); - } - else - { - /* we can definitely allow this swap */ - swap_ok = TRUE; - } + /* look for a noun, possibly preceded by adj's */ + for (i = cur + 1 ; + cmd[i] && (typelist[i] & VOCT_ADJ) + && !(typelist[i] & VOCT_NOUN) ; ++i) ; + swap_ok = (!cmd[i] || !(typelist[i] & VOCT_NOUN)); + } + else + { + /* we can definitely allow this swap */ + swap_ok = TRUE; + } - if (swap_ok) - { - cmdPrep = v->vocwobj; - swapObj = TRUE; - ++cur; - } - } - } - } + if (swap_ok) + { + cmdPrep = v->vocwobj; + swapObj = TRUE; + ++cur; + } + } + } + } - retry_swap: - /* get the direct object if there is one */ - if ((cnt = vocchknoun2(ctx, cmd, typelist, cur, &next, dolist, - FALSE, &no_match)) > 0) - { - /* we found a noun phrase matching one or more objects */ - cur = next; - } - else if (no_match) - { - /* - * we found a valid noun phrase, but we didn't find any - * objects that matched the words -- get the noun again, - * this time showing the error - */ - vocgetnoun(ctx, cmd, typelist, cur, &next, dolist); + retry_swap: + /* get the direct object if there is one */ + if ((cnt = vocchknoun2(ctx, cmd, typelist, cur, &next, dolist, + FALSE, &no_match)) > 0) + { + /* we found a noun phrase matching one or more objects */ + cur = next; + } + else if (no_match) + { + /* + * we found a valid noun phrase, but we didn't find any + * objects that matched the words -- get the noun again, + * this time showing the error + */ + vocgetnoun(ctx, cmd, typelist, cur, &next, dolist); - /* return the error */ - retval = 1; - goto done; - } - else if (cnt < 0) - { - /* invalid syntax - return failure */ - retval = 1; - goto done; - } - else - { - /* - * If we thought we were going to get a two-object - * sentence, and we got a zero-object sentence, and it looks - * like the word we took as a preposition is also an - * adjective or noun, go back and treat it as such. - */ - if (swapObj && - ((typelist[cur-1] & VOCT_NOUN) - || (typelist[cur-1] & VOCT_ADJ))) - { - --cur; - swapObj = FALSE; - cmdPrep = MCMONINV; - goto retry_swap; - } + /* return the error */ + retval = 1; + goto done; + } + else if (cnt < 0) + { + /* invalid syntax - return failure */ + retval = 1; + goto done; + } + else + { + /* + * If we thought we were going to get a two-object + * sentence, and we got a zero-object sentence, and it looks + * like the word we took as a preposition is also an + * adjective or noun, go back and treat it as such. + */ + if (swapObj && + ((typelist[cur-1] & VOCT_NOUN) + || (typelist[cur-1] & VOCT_ADJ))) + { + --cur; + swapObj = FALSE; + cmdPrep = MCMONINV; + goto retry_swap; + } - bad_sentence: - /* find the last word */ - while (cmd[cur]) ++cur; - - /* try running the sentence through preparseCmd */ - err = try_preparse_cmd(ctx, &cmd[first_word], cur - first_word, - &preparse_list); - switch(err) - { - case 0: - /* preparseCmd didn't do anything - the sentence fails */ - if (!try_unknown_verb(ctx, cmdActor, &cmd[first_word], - &typelist[first_word], 0, &next_start, - TRUE, VOCERR(18), - "I don't understand that sentence.")) - { - /* error - abort the command */ - retval = 1; - goto done; - } - else - { - /* success - go back for more */ - continue; - } + bad_sentence: + /* find the last word */ + while (cmd[cur]) ++cur; + + /* try running the sentence through preparseCmd */ + err = try_preparse_cmd(ctx, &cmd[first_word], cur - first_word, + &preparse_list); + switch(err) + { + case 0: + /* preparseCmd didn't do anything - the sentence fails */ + if (!try_unknown_verb(ctx, cmdActor, &cmd[first_word], + &typelist[first_word], 0, &next_start, + TRUE, VOCERR(18), + "I don't understand that sentence.")) + { + /* error - abort the command */ + retval = 1; + goto done; + } + else + { + /* success - go back for more */ + continue; + } - case ERR_PREPRSCMDCAN: - /* they cancelled - we're done with the sentence */ - retval = 0; - goto done; + case ERR_PREPRSCMDCAN: + /* they cancelled - we're done with the sentence */ + retval = 0; + goto done; - case ERR_PREPRSCMDREDO: - /* reparse with the new sentence */ - continue; - } - } + case ERR_PREPRSCMDREDO: + /* reparse with the new sentence */ + continue; + } + } - /* see if we want to execute the command now */ - if (vocready(ctx, cmd, typelist, cur, cmdActor, cmdPrep, - vverb, vprep, - swapObj ? iolist : dolist, - swapObj ? dolist : iolist, - &err, cmdbuf, first_word, &preparse_list, - &next_start)) - continue; - - /* - * Check for an indirect object, which may or may not be preceded - * by a preposition. (Note that the lack of a preposition implies - * that the object we already found is the indirect object, and the - * next object is the direct object. It also implies a preposition - * of "to.") - */ - if (cmdPrep == MCMONINV && (typelist[cur] & VOCT_PREP)) - { - char *p1 = cmd[cur++]; + /* see if we want to execute the command now */ + if (vocready(ctx, cmd, typelist, cur, cmdActor, cmdPrep, + vverb, vprep, + swapObj ? iolist : dolist, + swapObj ? dolist : iolist, + &err, cmdbuf, first_word, &preparse_list, + &next_start)) + continue; + + /* + * Check for an indirect object, which may or may not be preceded + * by a preposition. (Note that the lack of a preposition implies + * that the object we already found is the indirect object, and the + * next object is the direct object. It also implies a preposition + * of "to.") + */ + if (cmdPrep == MCMONINV && (typelist[cur] & VOCT_PREP)) + { + char *p1 = cmd[cur++]; - /* if this is the end of the sentence, add the prep to the verb */ - if (cmd[cur] == (char *)0 - || vocspec(cmd[cur], VOCW_AND) - || vocspec(cmd[cur], VOCW_THEN)) - { - if (vocffw(ctx, vverb, vvlen, p1, (int)strlen(p1), PRP_VERB, - (vocseadef *)0) - && !vprep) - vprep = p1; - else - { - /* call parseUnknownVerb */ - if (!try_unknown_verb(ctx, cmdActor, &cmd[first_word], - &typelist[first_word], 0, - &next_start, TRUE, VOCERR(19), - "There are words after your command I couldn't use.")) - { - /* error - abandon the command */ - retval = 1; - goto done; - } - else - { - /* go back for more */ - continue; - } - } - - if ((err = execmd(ctx, cmdActor, cmdPrep, vverb, vprep, - dolist, iolist, - &cmd[first_word], &typelist[first_word], - cmdbuf, cur - first_word, - &preparse_list, &next_start)) != 0) - { - retval = 1; - goto done; - } - continue; - } + /* if this is the end of the sentence, add the prep to the verb */ + if (cmd[cur] == (char *)0 + || vocspec(cmd[cur], VOCW_AND) + || vocspec(cmd[cur], VOCW_THEN)) + { + if (vocffw(ctx, vverb, vvlen, p1, (int)strlen(p1), PRP_VERB, + (vocseadef *)0) + && !vprep) + vprep = p1; + else + { + /* call parseUnknownVerb */ + if (!try_unknown_verb(ctx, cmdActor, &cmd[first_word], + &typelist[first_word], 0, + &next_start, TRUE, VOCERR(19), + "There are words after your command I couldn't use.")) + { + /* error - abandon the command */ + retval = 1; + goto done; + } + else + { + /* go back for more */ + continue; + } + } + + if ((err = execmd(ctx, cmdActor, cmdPrep, vverb, vprep, + dolist, iolist, + &cmd[first_word], &typelist[first_word], + cmdbuf, cur - first_word, + &preparse_list, &next_start)) != 0) + { + retval = 1; + goto done; + } + continue; + } - /* - * If we have no verb preposition already, and we have - * another prep-capable word following this prep-capable - * word, and this preposition aggregates with the verb, take - * it as a sentence of the form "pry box open with crowbar" - * (where the current word is "with"). We also must have at - * least one more word after that, since there will have to - * be an indirect object. - */ - if (cmd[cur] && (typelist[cur] & VOCT_PREP) && cmd[cur+1] - && vprep == 0 - && vocffw(ctx, vverb, vvlen, p1, (int)strlen(p1), PRP_VERB, - (vocseadef *)0)) - { - /* - * check to make sure that the next word, which we're - * about to take for a prep (the "with" in "pry box open - * with crowbar") is actually not part of an object name - * - if it is, use it as the object name rather than as - * the prep - */ - if (vocgobj(ctx, cmd, typelist, cur, &next, - FALSE, iolist, FALSE, FALSE, 0) <= 0) - { - /* aggregate the first preposition into the verb */ - vprep = p1; + /* + * If we have no verb preposition already, and we have + * another prep-capable word following this prep-capable + * word, and this preposition aggregates with the verb, take + * it as a sentence of the form "pry box open with crowbar" + * (where the current word is "with"). We also must have at + * least one more word after that, since there will have to + * be an indirect object. + */ + if (cmd[cur] && (typelist[cur] & VOCT_PREP) && cmd[cur+1] + && vprep == 0 + && vocffw(ctx, vverb, vvlen, p1, (int)strlen(p1), PRP_VERB, + (vocseadef *)0)) + { + /* + * check to make sure that the next word, which we're + * about to take for a prep (the "with" in "pry box open + * with crowbar") is actually not part of an object name + * - if it is, use it as the object name rather than as + * the prep + */ + if (vocgobj(ctx, cmd, typelist, cur, &next, + FALSE, iolist, FALSE, FALSE, 0) <= 0) + { + /* aggregate the first preposition into the verb */ + vprep = p1; - /* use the current word as the object-introducing prep */ - p1 = cmd[cur++]; - } - } + /* use the current word as the object-introducing prep */ + p1 = cmd[cur++]; + } + } - /* try for an indirect object */ - cnt = vocgobj(ctx, cmd, typelist, cur, &next, TRUE, iolist, - TRUE, FALSE, &no_match); - if (cnt > 0) - { - cur = next; - v = vocffw(ctx, p1, (int)strlen(p1), (char *)0, 0, PRP_PREP, - (vocseadef *)0); - if (v == (vocwdef *)0) - { - /* let parseUnknownVerb handle it */ - if (!try_unknown_verb(ctx, cmdActor, &cmd[first_word], - &typelist[first_word], 0, - &next_start, TRUE, VOCERR(20), - "I don't know how to use the word \"%s\" like that.", p1)) - { - /* error - abort the command */ - retval = 1; - goto done; - } - else - { - /* go on to the next command */ - continue; - } - } - cmdPrep = v->vocwobj; + /* try for an indirect object */ + cnt = vocgobj(ctx, cmd, typelist, cur, &next, TRUE, iolist, + TRUE, FALSE, &no_match); + if (cnt > 0) + { + cur = next; + v = vocffw(ctx, p1, (int)strlen(p1), (char *)0, 0, PRP_PREP, + (vocseadef *)0); + if (v == (vocwdef *)0) + { + /* let parseUnknownVerb handle it */ + if (!try_unknown_verb(ctx, cmdActor, &cmd[first_word], + &typelist[first_word], 0, + &next_start, TRUE, VOCERR(20), + "I don't know how to use the word \"%s\" like that.", p1)) + { + /* error - abort the command */ + retval = 1; + goto done; + } + else + { + /* go on to the next command */ + continue; + } + } + cmdPrep = v->vocwobj; - if (vocready(ctx, cmd, typelist, cur, cmdActor, cmdPrep, - vverb, vprep, dolist, iolist, &err, cmdbuf, - first_word, &preparse_list, &next_start)) - continue; - else if ((typelist[cur] & VOCT_PREP) && - vocffw(ctx, vverb, vvlen, cmd[cur], - (int)strlen(cmd[cur]), PRP_VERB, - (vocseadef *)0) && !vprep) - { - vprep = cmd[cur++]; - if (vocready(ctx, cmd, typelist, cur, cmdActor, - cmdPrep, vverb, vprep, dolist, iolist, - &err, cmdbuf, first_word, &preparse_list, - &next_start)) - continue; - else - { - /* let parseUnknownVerb handle it */ - if (!try_unknown_verb(ctx, cmdActor, &cmd[first_word], - &typelist[first_word], 0, - &next_start, TRUE, VOCERR(19), - "There are words after your command I couldn't use.")) - { - /* error - abandon the command */ - retval = 1; - goto done; - } - else - { - /* go on to the next command */ - continue; - } - } - } - else - { - /* - * If the latter object phrase is flagged with the - * "trimmed preposition" flag, meaning that we could - * have used the preposition in the noun phrase but - * assumed instead it was part of the verb, reverse - * this assumption now: add the preposition back to the - * noun phrase and explain that there's no such thing - * present. - * - * Otherwise, we simply have an unknown verb phrasing, - * so let parseUnknownVerb handle it. - */ - vocoldef *np1 = - (dolist[0].vocolflg & VOCS_TRIMPREP) != 0 - ? &dolist[0] - : (iolist[0].vocolflg & VOCS_TRIMPREP) != 0 - ? &iolist[0] - : 0; - if (np1 != 0) - { - char namebuf[VOCBUFSIZ]; - - /* show the name, adding the prep back in */ - voc_make_obj_name_from_list( - ctx, namebuf, cmd, np1->vocolfst, np1->vocolhlst); - vocerr(ctx, VOCERR(9), "I don't see any %s here.", - namebuf); + if (vocready(ctx, cmd, typelist, cur, cmdActor, cmdPrep, + vverb, vprep, dolist, iolist, &err, cmdbuf, + first_word, &preparse_list, &next_start)) + continue; + else if ((typelist[cur] & VOCT_PREP) && + vocffw(ctx, vverb, vvlen, cmd[cur], + (int)strlen(cmd[cur]), PRP_VERB, + (vocseadef *)0) && !vprep) + { + vprep = cmd[cur++]; + if (vocready(ctx, cmd, typelist, cur, cmdActor, + cmdPrep, vverb, vprep, dolist, iolist, + &err, cmdbuf, first_word, &preparse_list, + &next_start)) + continue; + else + { + /* let parseUnknownVerb handle it */ + if (!try_unknown_verb(ctx, cmdActor, &cmd[first_word], + &typelist[first_word], 0, + &next_start, TRUE, VOCERR(19), + "There are words after your command I couldn't use.")) + { + /* error - abandon the command */ + retval = 1; + goto done; + } + else + { + /* go on to the next command */ + continue; + } + } + } + else + { + /* + * If the latter object phrase is flagged with the + * "trimmed preposition" flag, meaning that we could + * have used the preposition in the noun phrase but + * assumed instead it was part of the verb, reverse + * this assumption now: add the preposition back to the + * noun phrase and explain that there's no such thing + * present. + * + * Otherwise, we simply have an unknown verb phrasing, + * so let parseUnknownVerb handle it. + */ + vocoldef *np1 = + (dolist[0].vocolflg & VOCS_TRIMPREP) != 0 + ? &dolist[0] + : (iolist[0].vocolflg & VOCS_TRIMPREP) != 0 + ? &iolist[0] + : 0; + if (np1 != 0) + { + char namebuf[VOCBUFSIZ]; + + /* show the name, adding the prep back in */ + voc_make_obj_name_from_list( + ctx, namebuf, cmd, np1->vocolfst, np1->vocolhlst); + vocerr(ctx, VOCERR(9), "I don't see any %s here.", + namebuf); - /* error - abort */ - retval = 1; - goto done; - } - else if (!try_unknown_verb( - ctx, cmdActor, - &cmd[first_word], &typelist[first_word], - 0, &next_start, TRUE, VOCERR(19), - "There are words after your command that I couldn't use.")) - { - /* error - abort */ - retval = 1; - goto done; - } - else - { - /* continue with the next command */ - continue; - } - } - } - else if (cnt < 0) - { - /* - * the noun phrase syntax was invalid - we've already - * displayed an error about it, so simply return failure - */ - retval = 1; - goto done; - } - else if (no_match) - { - /* - * we found a valid noun phrase, but we didn't find any - * matching objects - we've already generated an error, - * so simply return failure - */ - retval = 1; - goto done; - } - else - { - goto bad_sentence; - } - } - else if ((cnt = vocchknoun(ctx, cmd, typelist, cur, - &next, iolist, FALSE)) > 0) - { - /* look for prep at end of command */ - cur = next; - if (cmd[cur]) - { - if ((typelist[cur] & VOCT_PREP) && - vocffw(ctx, vverb, vvlen, cmd[cur], - (int)strlen(cmd[cur]), PRP_VERB, - (vocseadef *)0) && !vprep) - { - vprep = cmd[cur++]; - } - } + /* error - abort */ + retval = 1; + goto done; + } + else if (!try_unknown_verb( + ctx, cmdActor, + &cmd[first_word], &typelist[first_word], + 0, &next_start, TRUE, VOCERR(19), + "There are words after your command that I couldn't use.")) + { + /* error - abort */ + retval = 1; + goto done; + } + else + { + /* continue with the next command */ + continue; + } + } + } + else if (cnt < 0) + { + /* + * the noun phrase syntax was invalid - we've already + * displayed an error about it, so simply return failure + */ + retval = 1; + goto done; + } + else if (no_match) + { + /* + * we found a valid noun phrase, but we didn't find any + * matching objects - we've already generated an error, + * so simply return failure + */ + retval = 1; + goto done; + } + else + { + goto bad_sentence; + } + } + else if ((cnt = vocchknoun(ctx, cmd, typelist, cur, + &next, iolist, FALSE)) > 0) + { + /* look for prep at end of command */ + cur = next; + if (cmd[cur]) + { + if ((typelist[cur] & VOCT_PREP) && + vocffw(ctx, vverb, vvlen, cmd[cur], + (int)strlen(cmd[cur]), PRP_VERB, + (vocseadef *)0) && !vprep) + { + vprep = cmd[cur++]; + } + } - /* the command should definitely be done now */ - if (cmd[cur] != 0) - { - /* let parseUnknownVerb handle it */ - if (!try_unknown_verb(ctx, cmdActor, &cmd[first_word], - &typelist[first_word], 0, - &next_start, TRUE, VOCERR(21), - "There appear to be extra words after your command.")) - { - /* error - stop the command */ - retval = 1; - goto done; - } - else - { - /* go on to the next command */ - continue; - } - } - - /* - * If we don't have a preposition yet, we need to find the - * verb's default. If the verb object has a nilPrep - * property defined, use that prep object; otherwise, look - * up the word "to" and use that. - */ - if (cmdPrep == MCMONINV && - (v = vocffw(ctx, vverb, vvlen, - vprep, (vprep ? (int)strlen(vprep) : 0), - PRP_VERB, (vocseadef *)0)) != 0) - { - runppr(ctx->voccxrun, v->vocwobj, PRP_NILPREP, 0); - if (runtostyp(ctx->voccxrun) == DAT_OBJECT) - cmdPrep = runpopobj(ctx->voccxrun); - else - rundisc(ctx->voccxrun); - } + /* the command should definitely be done now */ + if (cmd[cur] != 0) + { + /* let parseUnknownVerb handle it */ + if (!try_unknown_verb(ctx, cmdActor, &cmd[first_word], + &typelist[first_word], 0, + &next_start, TRUE, VOCERR(21), + "There appear to be extra words after your command.")) + { + /* error - stop the command */ + retval = 1; + goto done; + } + else + { + /* go on to the next command */ + continue; + } + } + + /* + * If we don't have a preposition yet, we need to find the + * verb's default. If the verb object has a nilPrep + * property defined, use that prep object; otherwise, look + * up the word "to" and use that. + */ + if (cmdPrep == MCMONINV && + (v = vocffw(ctx, vverb, vvlen, + vprep, (vprep ? (int)strlen(vprep) : 0), + PRP_VERB, (vocseadef *)0)) != 0) + { + runppr(ctx->voccxrun, v->vocwobj, PRP_NILPREP, 0); + if (runtostyp(ctx->voccxrun) == DAT_OBJECT) + cmdPrep = runpopobj(ctx->voccxrun); + else + rundisc(ctx->voccxrun); + } - /* if we didn't find anything with nilPrep, find "to" */ - if (cmdPrep == MCMONINV) - { - v = vocffw(ctx, "to", 2, (char *)0, 0, PRP_PREP, - (vocseadef *)0); - if (v) cmdPrep = v->vocwobj; - } + /* if we didn't find anything with nilPrep, find "to" */ + if (cmdPrep == MCMONINV) + { + v = vocffw(ctx, "to", 2, (char *)0, 0, PRP_PREP, + (vocseadef *)0); + if (v) cmdPrep = v->vocwobj; + } - /* execute the command */ - err = execmd(ctx, cmdActor, cmdPrep, vverb, vprep, - iolist, dolist, - &cmd[first_word], &typelist[first_word], cmdbuf, - cur - first_word, &preparse_list, &next_start); - continue; - } - else if (cnt < 0) - { - retval = 1; - goto done; - } - else - { - goto bad_sentence; - } - } + /* execute the command */ + err = execmd(ctx, cmdActor, cmdPrep, vverb, vprep, + iolist, dolist, + &cmd[first_word], &typelist[first_word], cmdbuf, + cur - first_word, &preparse_list, &next_start); + continue; + } + else if (cnt < 0) + { + retval = 1; + goto done; + } + else + { + goto bad_sentence; + } + } done: - /* copy back the command if we need to redo */ - if (ctx->voccxredo && cmdbuf != origcmdbuf) - strcpy(origcmdbuf, cmdbuf); - - /* return the status */ - VOC_RETVAL(ctx, save_sp, retval); + /* copy back the command if we need to redo */ + if (ctx->voccxredo && cmdbuf != origcmdbuf) + strcpy(origcmdbuf, cmdbuf); + + /* return the status */ + VOC_RETVAL(ctx, save_sp, retval); } /* execute a player command */ int voccmd(voccxdef *ctx, char *cmd, uint cmdlen) { - int wrdcnt; + int wrdcnt; int cur = 0; - int next; - char *buffer; - char **wordlist; - objnum cmdActor; - int first; + int next; + char *buffer; + char **wordlist; + objnum cmdActor; + int first; - /* - * Make sure the stack is set up, resetting the stack on entry. Note - * that this makes this routine non-reentrant - recursively calling - * this routine will wipe out the enclosing caller's stack. - */ - voc_stk_ini(ctx, (uint)VOC_STACK_SIZE); + /* + * Make sure the stack is set up, resetting the stack on entry. Note + * that this makes this routine non-reentrant - recursively calling + * this routine will wipe out the enclosing caller's stack. + */ + voc_stk_ini(ctx, (uint)VOC_STACK_SIZE); - /* allocate our stack arrays */ - VOC_STK_ARRAY(ctx, char, buffer, 2*VOCBUFSIZ); - VOC_STK_ARRAY(ctx, char *, wordlist, VOCBUFSIZ); - - /* until further notice, the actor for formatStrings is Me */ - tiosetactor(ctx->voccxtio, ctx->voccxme); + /* allocate our stack arrays */ + VOC_STK_ARRAY(ctx, char, buffer, 2*VOCBUFSIZ); + VOC_STK_ARRAY(ctx, char *, wordlist, VOCBUFSIZ); + + /* until further notice, the actor for formatStrings is Me */ + tiosetactor(ctx->voccxtio, ctx->voccxme); - /* clear the 'ignore' flag */ - ctx->voccxflg &= ~VOCCXFCLEAR; + /* clear the 'ignore' flag */ + ctx->voccxflg &= ~VOCCXFCLEAR; - /* send to game function 'preparse' */ - if (ctx->voccxpre != MCMONINV) - { - int typ; - uchar *s; - size_t len; - int err; + /* send to game function 'preparse' */ + if (ctx->voccxpre != MCMONINV) + { + int typ; + uchar *s; + size_t len; + int err; - /* push the argument string */ - runpstr(ctx->voccxrun, cmd, (int)strlen(cmd), 0); + /* push the argument string */ + runpstr(ctx->voccxrun, cmd, (int)strlen(cmd), 0); - /* presume no error will occur */ - err = 0; + /* presume no error will occur */ + err = 0; - /* catch errors that occur during preparse() */ - ERRBEGIN(ctx->voccxerr) - { - /* call preparse() */ - runfn(ctx->voccxrun, ctx->voccxpre, 1); - } - ERRCATCH(ctx->voccxerr, err) - { - /* see what we have */ - switch(err) - { - case ERR_RUNEXIT: - case ERR_RUNEXITOBJ: - case ERR_RUNABRT: - /* - * if we encountered abort, exit, or exitobj, treat it - * the same as a nil result code - simply cancel the - * entire current command - */ - break; + /* catch errors that occur during preparse() */ + ERRBEGIN(ctx->voccxerr) + { + /* call preparse() */ + runfn(ctx->voccxrun, ctx->voccxpre, 1); + } + ERRCATCH(ctx->voccxerr, err) + { + /* see what we have */ + switch(err) + { + case ERR_RUNEXIT: + case ERR_RUNEXITOBJ: + case ERR_RUNABRT: + /* + * if we encountered abort, exit, or exitobj, treat it + * the same as a nil result code - simply cancel the + * entire current command + */ + break; - default: - /* re-throw any other error */ - errrse(ctx->voccxerr); - } - } - ERREND(ctx->voccxerr); + default: + /* re-throw any other error */ + errrse(ctx->voccxerr); + } + } + ERREND(ctx->voccxerr); - /* if an error occurred, abort the command */ - if (err != 0) - return 0; + /* if an error occurred, abort the command */ + if (err != 0) + return 0; - /* check the return value's type */ - typ = runtostyp(ctx->voccxrun); - if (typ == DAT_SSTRING) - { - /* - * It's a string - replace the command with the new string. - * Pop the new string and scan its length prefix. - */ - s = runpopstr(ctx->voccxrun); - len = osrp2(s) - 2; - s += 2; + /* check the return value's type */ + typ = runtostyp(ctx->voccxrun); + if (typ == DAT_SSTRING) + { + /* + * It's a string - replace the command with the new string. + * Pop the new string and scan its length prefix. + */ + s = runpopstr(ctx->voccxrun); + len = osrp2(s) - 2; + s += 2; - /* - * limit the size of the command to our buffer length, - * leaving space for null termination - */ - if (len > cmdlen - 1) - len = cmdlen - 1; + /* + * limit the size of the command to our buffer length, + * leaving space for null termination + */ + if (len > cmdlen - 1) + len = cmdlen - 1; - /* copy the new command string into our command buffer */ - memcpy(cmd, s, len); + /* copy the new command string into our command buffer */ + memcpy(cmd, s, len); - /* null-terminate the command buffer */ - cmd[len] = '\0'; - } - else - { - /* the value isn't important for any other type */ - rundisc(ctx->voccxrun); + /* null-terminate the command buffer */ + cmd[len] = '\0'; + } + else + { + /* the value isn't important for any other type */ + rundisc(ctx->voccxrun); - /* if they returned nil, we're done processing the command */ - if (typ == DAT_NIL) - return 0; - } - } + /* if they returned nil, we're done processing the command */ + if (typ == DAT_NIL) + return 0; + } + } - /* break up into individual words */ - if ((wrdcnt = voctok(ctx, cmd, buffer, wordlist, TRUE, FALSE, TRUE)) > 0) - { - /* skip any leading "and" and "then" separators */ - for (cur = 0 ; cur < wrdcnt ; ++cur) - { - /* if this isn't "and" or "then", we're done scanning */ - if (!vocspec(wordlist[cur], VOCW_THEN) - && !vocspec(wordlist[cur], VOCW_AND)) - break; - } - } + /* break up into individual words */ + if ((wrdcnt = voctok(ctx, cmd, buffer, wordlist, TRUE, FALSE, TRUE)) > 0) + { + /* skip any leading "and" and "then" separators */ + for (cur = 0 ; cur < wrdcnt ; ++cur) + { + /* if this isn't "and" or "then", we're done scanning */ + if (!vocspec(wordlist[cur], VOCW_THEN) + && !vocspec(wordlist[cur], VOCW_AND)) + break; + } + } - /* - * if we found no words, or we found only useless leading "and" and - * "then" separators, run the "pardon" function to tell the player - * that we didn't find any command on the line - */ - if (wrdcnt == 0 || (wrdcnt > 0 && cur >= wrdcnt)) - { - runfn(ctx->voccxrun, ctx->voccxprd, 0); - return 0; - } + /* + * if we found no words, or we found only useless leading "and" and + * "then" separators, run the "pardon" function to tell the player + * that we didn't find any command on the line + */ + if (wrdcnt == 0 || (wrdcnt > 0 && cur >= wrdcnt)) + { + runfn(ctx->voccxrun, ctx->voccxprd, 0); + return 0; + } - /* - * if we got an error tokenizing the word list, return - we've - * already displayed an error message, so there's nothing more for - * us to do here - */ - if (wrdcnt < 0) - return 0; + /* + * if we got an error tokenizing the word list, return - we've + * already displayed an error message, so there's nothing more for + * us to do here + */ + if (wrdcnt < 0) + return 0; - /* process the commands on the line */ - for (first = TRUE, cmdActor = ctx->voccxactor = MCMONINV ; cur < wrdcnt ; - ++cur, first = FALSE) - { - /* presume we won't find an unknown word */ - ctx->voccxunknown = 0; + /* process the commands on the line */ + for (first = TRUE, cmdActor = ctx->voccxactor = MCMONINV ; cur < wrdcnt ; + ++cur, first = FALSE) + { + /* presume we won't find an unknown word */ + ctx->voccxunknown = 0; - /* find the THEN that ends the command, if there is one */ - for (next = cur ; cur < wrdcnt && !vocspec(wordlist[cur], VOCW_THEN) - ; ++cur) ; - wordlist[cur] = (char *)0; + /* find the THEN that ends the command, if there is one */ + for (next = cur ; cur < wrdcnt && !vocspec(wordlist[cur], VOCW_THEN) + ; ++cur) ; + wordlist[cur] = (char *)0; - /* process until we run out of work to do */ - for (;;) - { - /* try processing the command */ - if (voc1cmd(ctx, &wordlist[next], cmd, &cmdActor, first)) - { - /* - * If the unknown word flag is set, try the command - * again from the beginning. This flag means that we - * tried using parseUnknownDobj/Iobj to resolve the - * unknown word, but that failed and we need to try - * again with the normal "oops" processing. - */ - if (ctx->voccxunknown > 0) - continue; - - /* return an error */ - return 1; - } + /* process until we run out of work to do */ + for (;;) + { + /* try processing the command */ + if (voc1cmd(ctx, &wordlist[next], cmd, &cmdActor, first)) + { + /* + * If the unknown word flag is set, try the command + * again from the beginning. This flag means that we + * tried using parseUnknownDobj/Iobj to resolve the + * unknown word, but that failed and we need to try + * again with the normal "oops" processing. + */ + if (ctx->voccxunknown > 0) + continue; + + /* return an error */ + return 1; + } - /* success - we're done with the command */ - break; - } + /* success - we're done with the command */ + break; + } - /* if the rest of the command is to be ignored, we're done */ - if (ctx->voccxflg & VOCCXFCLEAR) - return 0; + /* if the rest of the command is to be ignored, we're done */ + if (ctx->voccxflg & VOCCXFCLEAR) + return 0; - /* scan past any separating AND's and THEN's */ - while (cur + 1 < wrdcnt - && (vocspec(wordlist[cur+1], VOCW_THEN) - || vocspec(wordlist[cur+1], VOCW_AND))) - ++cur; + /* scan past any separating AND's and THEN's */ + while (cur + 1 < wrdcnt + && (vocspec(wordlist[cur+1], VOCW_THEN) + || vocspec(wordlist[cur+1], VOCW_AND))) + ++cur; - /* - * if another command follows, add a blank line to separate the - * results from the previous command and those from the next - * command - */ - if (cur + 1 < wrdcnt) - outformat("\\b"); - } + /* + * if another command follows, add a blank line to separate the + * results from the previous command and those from the next + * command + */ + if (cur + 1 < wrdcnt) + outformat("\\b"); + } - /* done */ - return 0; + /* done */ + return 0; } @@ -8107,53 +8107,53 @@ int voccmd(voccxdef *ctx, char *cmd, uint cmdlen) /* allocate/reset the stack */ void voc_stk_ini(voccxdef *ctx, uint siz) { - /* allocate it if it's not already allocated */ - if (ctx->voc_stk_ptr == 0) - { - ctx->voc_stk_ptr = mchalo(ctx->voccxerr, siz, "voc_stk_ini"); - ctx->voc_stk_end = ctx->voc_stk_ptr + siz; - } - - /* reset the stack */ - ctx->voc_stk_cur = ctx->voc_stk_ptr; + /* allocate it if it's not already allocated */ + if (ctx->voc_stk_ptr == 0) + { + ctx->voc_stk_ptr = mchalo(ctx->voccxerr, siz, "voc_stk_ini"); + ctx->voc_stk_end = ctx->voc_stk_ptr + siz; + } + + /* reset the stack */ + ctx->voc_stk_cur = ctx->voc_stk_ptr; } /* allocate space from the off-stack stack */ void *voc_stk_alo(voccxdef *ctx, uint siz) { - void *ret; - - /* round size up to allocation units */ - siz = osrndsz(siz); + void *ret; + + /* round size up to allocation units */ + siz = osrndsz(siz); - /* if there's not space, signal an error */ - if (ctx->voc_stk_cur + siz > ctx->voc_stk_end) - errsig(ctx->voccxerr, ERR_VOCSTK); + /* if there's not space, signal an error */ + if (ctx->voc_stk_cur + siz > ctx->voc_stk_end) + errsig(ctx->voccxerr, ERR_VOCSTK); - /* save the return pointer */ - ret = ctx->voc_stk_cur; + /* save the return pointer */ + ret = ctx->voc_stk_cur; - /* consume the space */ - ctx->voc_stk_cur += siz; + /* consume the space */ + ctx->voc_stk_cur += siz; /*#define SHOW_HI*/ #ifdef SHOW_HI { - static uint maxsiz; - if (ctx->voc_stk_cur - ctx->voc_stk_ptr > maxsiz) - { - char buf[20]; - - maxsiz = ctx->voc_stk_cur - ctx->voc_stk_ptr; - sprintf(buf, "%u\n", maxsiz); - os_printz(buf); - } + static uint maxsiz; + if (ctx->voc_stk_cur - ctx->voc_stk_ptr > maxsiz) + { + char buf[20]; + + maxsiz = ctx->voc_stk_cur - ctx->voc_stk_ptr; + sprintf(buf, "%u\n", maxsiz); + os_printz(buf); + } } #endif - /* return the space */ - return ret; + /* return the space */ + return ret; } } // End of namespace TADS2 diff --git a/engines/glk/window_graphics.cpp b/engines/glk/window_graphics.cpp index bf5514c321f..38cde398c5e 100644 --- a/engines/glk/window_graphics.cpp +++ b/engines/glk/window_graphics.cpp @@ -97,7 +97,7 @@ void GraphicsWindow::redraw() { } bool GraphicsWindow::drawPicture(const Common::String &image, int xpos, int ypos, bool scale, - uint imagewidth, uint imageheight) { + uint imagewidth, uint imageheight) { Picture *pic = g_vm->_pictures->load(image); uint hyperlink = _attr.hyper; diff --git a/engines/gob/anifile.cpp b/engines/gob/anifile.cpp index 8d4afdf94a1..8657f1a3cbc 100644 --- a/engines/gob/anifile.cpp +++ b/engines/gob/anifile.cpp @@ -34,7 +34,7 @@ namespace Gob { ANIFile::ANIFile(GobEngine *vm, const Common::String &fileName, - uint16 width, uint8 bpp) : _vm(vm), + uint16 width, uint8 bpp) : _vm(vm), _width(width), _bpp(bpp), _hasPadding(false) { bool bigEndian = false; @@ -113,7 +113,7 @@ void ANIFile::load(Common::SeekableSubReadStreamEndian &ani, const Common::Strin } void ANIFile::loadAnimation(Animation &animation, FrameArray &frames, - Common::SeekableSubReadStreamEndian &ani) { + Common::SeekableSubReadStreamEndian &ani) { // Animation properties @@ -258,7 +258,7 @@ const ANIFile::Animation &ANIFile::getAnimationInfo(uint16 animation) const { } bool ANIFile::getCoordinates(uint16 layer, uint16 part, - uint16 &left, uint16 &top, uint16 &right, uint16 &bottom) const { + uint16 &left, uint16 &top, uint16 &right, uint16 &bottom) const { if (layer >= _layers.size()) return false; @@ -281,7 +281,7 @@ void ANIFile::draw(Surface &dest, uint16 animation, uint16 frame, int16 x, int16 } void ANIFile::drawLayer(Surface &dest, uint16 layer, uint16 part, - int16 x, int16 y, int32 transp) const { + int16 x, int16 y, int32 transp) const { if (layer >= _layers.size()) return; diff --git a/engines/gob/aniobject.cpp b/engines/gob/aniobject.cpp index 905997f160b..4678ac19bc7 100644 --- a/engines/gob/aniobject.cpp +++ b/engines/gob/aniobject.cpp @@ -189,7 +189,7 @@ bool ANIObject::isIn(const ANIObject &obj) const { } bool ANIObject::draw(Surface &dest, int16 &left, int16 &top, - int16 &right, int16 &bottom) { + int16 &right, int16 &bottom) { if (!_visible) return false; @@ -203,7 +203,7 @@ bool ANIObject::draw(Surface &dest, int16 &left, int16 &top, } bool ANIObject::drawCMP(Surface &dest, int16 &left, int16 &top, - int16 &right, int16 &bottom) { + int16 &right, int16 &bottom) { if (!hasBuffer()) { uint16 width, height; @@ -227,7 +227,7 @@ bool ANIObject::drawCMP(Surface &dest, int16 &left, int16 &top, } bool ANIObject::drawANI(Surface &dest, int16 &left, int16 &top, - int16 &right, int16 &bottom) { + int16 &right, int16 &bottom) { if (!hasBuffer()) { uint16 width, height; @@ -257,7 +257,7 @@ bool ANIObject::drawANI(Surface &dest, int16 &left, int16 &top, } bool ANIObject::clear(Surface &dest, int16 &left, int16 &top, - int16 &right, int16 &bottom) { + int16 &right, int16 &bottom) { return restoreScreen(dest, left, top, right, bottom); } diff --git a/engines/gob/cmpfile.cpp b/engines/gob/cmpfile.cpp index 67b378475de..293091dcd37 100644 --- a/engines/gob/cmpfile.cpp +++ b/engines/gob/cmpfile.cpp @@ -35,7 +35,7 @@ namespace Gob { CMPFile::CMPFile(GobEngine *vm, const Common::String &baseName, - uint16 width, uint16 height, uint8 bpp) : + uint16 width, uint16 height, uint8 bpp) : _vm(vm), _width(width), _height(height), _bpp(bpp), _maxWidth(0), _maxHeight(0), _surface(0), _coordinates(0) { @@ -55,7 +55,7 @@ CMPFile::CMPFile(GobEngine *vm, const Common::String &baseName, } CMPFile::CMPFile(GobEngine *vm, const Common::String &cmpFile, const Common::String &rxyFile, - uint16 width, uint16 height, uint8 bpp) : + uint16 width, uint16 height, uint8 bpp) : _vm(vm), _width(width), _height(height), _bpp(bpp), _maxWidth(0), _maxHeight(0), _surface(0), _coordinates(0) { @@ -69,7 +69,7 @@ CMPFile::CMPFile(GobEngine *vm, const Common::String &cmpFile, const Common::Str } CMPFile::CMPFile(GobEngine *vm, Common::SeekableReadStream &cmp, Common::SeekableReadStream &rxy, - uint16 width, uint16 height, uint8 bpp) : + uint16 width, uint16 height, uint8 bpp) : _vm(vm), _width(width), _height(height), _bpp(bpp), _maxWidth(0), _maxHeight(0), _surface(0), _coordinates(0) { @@ -80,7 +80,7 @@ CMPFile::CMPFile(GobEngine *vm, Common::SeekableReadStream &cmp, Common::Seekabl } CMPFile::CMPFile(GobEngine *vm, Common::SeekableReadStream &cmp, - uint16 width, uint16 height, uint8 bpp) : + uint16 width, uint16 height, uint8 bpp) : _vm(vm), _width(width), _height(height), _bpp(bpp), _maxWidth(0), _maxHeight(0), _surface(0), _coordinates(0) { @@ -229,7 +229,7 @@ void CMPFile::draw(Surface &dest, uint16 sprite, uint16 x, uint16 y, int32 trans } void CMPFile::draw(Surface &dest, uint16 left, uint16 top, uint16 right, uint16 bottom, - uint16 x, uint16 y, int32 transp) const { + uint16 x, uint16 y, int32 transp) const { if (!_surface) return; diff --git a/engines/gob/decfile.cpp b/engines/gob/decfile.cpp index 3ea3773ec6c..3952c93b37f 100644 --- a/engines/gob/decfile.cpp +++ b/engines/gob/decfile.cpp @@ -35,7 +35,7 @@ namespace Gob { DECFile::DECFile(GobEngine *vm, const Common::String &fileName, - uint16 width, uint16 height, uint8 bpp) : _vm(vm), + uint16 width, uint16 height, uint8 bpp) : _vm(vm), _width(width), _height(height), _bpp(bpp), _hasPadding(false), _backdrop(0) { bool bigEndian = false; @@ -171,7 +171,7 @@ void DECFile::drawBackdrop(Surface &dest) const { } void DECFile::drawLayer(Surface &dest, uint16 layer, uint16 part, - uint16 x, uint16 y, int32 transp) const { + uint16 x, uint16 y, int32 transp) const { if (layer >= _layers.size()) return; diff --git a/engines/gob/metaengine.cpp b/engines/gob/metaengine.cpp index e257b1b7ec7..1d99d2b92ed 100644 --- a/engines/gob/metaengine.cpp +++ b/engines/gob/metaengine.cpp @@ -33,7 +33,7 @@ public: return "gob"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; }; diff --git a/engines/gob/minigames/geisha/evilfish.cpp b/engines/gob/minigames/geisha/evilfish.cpp index 7b3a4c9787d..04bcdb2aecc 100644 --- a/engines/gob/minigames/geisha/evilfish.cpp +++ b/engines/gob/minigames/geisha/evilfish.cpp @@ -27,8 +27,8 @@ namespace Gob { namespace Geisha { EvilFish::EvilFish(const ANIFile &ani, uint16 screenWidth, - uint16 animSwimLeft, uint16 animSwimRight, - uint16 animTurnLeft, uint16 animTurnRight, uint16 animDie) : + uint16 animSwimLeft, uint16 animSwimRight, + uint16 animTurnLeft, uint16 animTurnRight, uint16 animDie) : ANIObject(ani), _screenWidth(screenWidth), _animSwimLeft(animSwimLeft), _animSwimRight(animSwimRight), _animTurnLeft(animTurnLeft), _animTurnRight(animTurnRight), _animDie(animDie), @@ -150,7 +150,7 @@ void EvilFish::advance() { } void EvilFish::mutate(uint16 animSwimLeft, uint16 animSwimRight, - uint16 animTurnLeft, uint16 animTurnRight, uint16 animDie) { + uint16 animTurnLeft, uint16 animTurnRight, uint16 animDie) { _animSwimLeft = animSwimLeft; _animSwimRight = animSwimRight; diff --git a/engines/gob/minigames/geisha/meter.cpp b/engines/gob/minigames/geisha/meter.cpp index 29a5a20e9a2..b7a3bc6cd36 100644 --- a/engines/gob/minigames/geisha/meter.cpp +++ b/engines/gob/minigames/geisha/meter.cpp @@ -31,7 +31,7 @@ namespace Gob { namespace Geisha { Meter::Meter(int16 x, int16 y, int16 width, int16 height, uint8 frontColor, - uint8 backColor, int32 maxValue, Direction direction) : + uint8 backColor, int32 maxValue, Direction direction) : _x(x), _y(y), _width(width), _height(height), _frontColor(frontColor), _backColor(backColor), _value(0), _maxValue(maxValue), _direction(direction), _needUpdate(true), _surface(0) { diff --git a/engines/gob/minigames/geisha/mouth.cpp b/engines/gob/minigames/geisha/mouth.cpp index 2a1fea13a56..c263a81c74b 100644 --- a/engines/gob/minigames/geisha/mouth.cpp +++ b/engines/gob/minigames/geisha/mouth.cpp @@ -29,7 +29,7 @@ namespace Gob { namespace Geisha { Mouth::Mouth(const ANIFile &ani, const CMPFile &cmp, - uint16 mouthAnim, uint16 mouthSprite, uint16 floorSprite) : ANIObject(ani) { + uint16 mouthAnim, uint16 mouthSprite, uint16 floorSprite) : ANIObject(ani) { _sprite = new ANIObject(cmp); _sprite->setAnimation(mouthSprite); diff --git a/engines/gob/pregob/gctfile.cpp b/engines/gob/pregob/gctfile.cpp index ca842707d60..75a7799aa34 100644 --- a/engines/gob/pregob/gctfile.cpp +++ b/engines/gob/pregob/gctfile.cpp @@ -262,7 +262,7 @@ bool GCTFile::finished() const { } bool GCTFile::draw(Surface &dest, uint16 item, const Font &font, uint8 color, - int16 &left, int16 &top, int16 &right, int16 &bottom) { + int16 &left, int16 &top, int16 &right, int16 &bottom) { if ((item >= _items.size()) || !_hasArea) return false; diff --git a/engines/gob/pregob/onceupon/onceupon.cpp b/engines/gob/pregob/onceupon/onceupon.cpp index ab9b1427998..d53dea83bd9 100644 --- a/engines/gob/pregob/onceupon/onceupon.cpp +++ b/engines/gob/pregob/onceupon/onceupon.cpp @@ -284,7 +284,7 @@ void OnceUpon::setGameCursor() { } void OnceUpon::drawLineByLine(const Surface &src, int16 left, int16 top, int16 right, int16 bottom, - int16 x, int16 y) const { + int16 x, int16 y) const { // A special way of drawing something: // Draw every other line "downwards", wait a bit after each line @@ -488,7 +488,7 @@ bool OnceUpon::doCopyProtection(const uint8 colors[7], const uint8 shapes[7 * 20 } int8 OnceUpon::cpSetup(const uint8 colors[7], const uint8 shapes[7 * 20], const uint8 obfuscate[4], - const Surface sprites[2]) { + const Surface sprites[2]) { fadeOut(); hideCursor(); @@ -708,7 +708,7 @@ void OnceUpon::showByeBye() { } void OnceUpon::doStartMenu(const MenuButton *animalsButton, uint animalCount, - const MenuButton *animalButtons, const char * const *animalNames) { + const MenuButton *animalButtons, const char * const *animalNames) { clearScreen(); // Wait until we clicked on of the difficulty buttons and are ready to start playing diff --git a/engines/gob/pregob/onceupon/parents.cpp b/engines/gob/pregob/onceupon/parents.cpp index ab08b941819..4858e2750ac 100644 --- a/engines/gob/pregob/onceupon/parents.cpp +++ b/engines/gob/pregob/onceupon/parents.cpp @@ -56,8 +56,8 @@ const uint16 Parents::kLoop[kLoopCount][3] = { Parents::Parents(GobEngine *vm, const Common::String &seq, const Common::String &gct, - const Common::String &childName, uint8 house, const Font &font, - const byte *normalPalette, const byte *brightPalette, uint paletteSize) : + const Common::String &childName, uint8 house, const Font &font, + const byte *normalPalette, const byte *brightPalette, uint paletteSize) : SEQFile(vm, seq), _gct(0), _house(house), _font(&font), _paletteSize(paletteSize), _normalPalette(normalPalette), _brightPalette(brightPalette) { diff --git a/engines/gob/pregob/pregob.cpp b/engines/gob/pregob/pregob.cpp index 118bbbde834..78afa857685 100644 --- a/engines/gob/pregob/pregob.cpp +++ b/engines/gob/pregob/pregob.cpp @@ -116,7 +116,7 @@ void PreGob::setCursor(Surface &sprite, int16 hotspotX, int16 hotspotY) { } void PreGob::setCursor(Surface &sprite, int16 left, int16 top, int16 right, int16 bottom, - int16 hotspotX, int16 hotspotY) { + int16 hotspotX, int16 hotspotY) { const int width = right - left + 1; const int height = bottom - top + 1; diff --git a/engines/gob/pregob/txtfile.cpp b/engines/gob/pregob/txtfile.cpp index 861a34855b5..4d6c0254f16 100644 --- a/engines/gob/pregob/txtfile.cpp +++ b/engines/gob/pregob/txtfile.cpp @@ -63,7 +63,7 @@ void TXTFile::load(Common::SeekableReadStream &txt, Format format) { } bool TXTFile::draw(Surface &surface, int16 &left, int16 &top, int16 &right, int16 &bottom, - const Font * const *fonts, uint fontCount, int color) { + const Font * const *fonts, uint fontCount, int color) { trashBuffer(); @@ -84,7 +84,7 @@ bool TXTFile::draw(Surface &surface, int16 &left, int16 &top, int16 &right, int1 } bool TXTFile::draw(uint line, Surface &surface, int16 &left, int16 &top, int16 &right, int16 &bottom, - const Font * const *fonts, uint fontCount, int color) { + const Font * const *fonts, uint fontCount, int color) { trashBuffer(); @@ -118,7 +118,7 @@ bool TXTFile::clear(Surface &surface, int16 &left, int16 &top, int16 &right, int } bool TXTFile::getArea(int16 &left, int16 &top, int16 &right, int16 &bottom, - const Font * const *fonts, uint fontCount) const { + const Font * const *fonts, uint fontCount) const { bool hasLine = false; @@ -144,7 +144,7 @@ bool TXTFile::getArea(int16 &left, int16 &top, int16 &right, int16 &bottom, } bool TXTFile::getArea(uint line, int16 &left, int16 &top, int16 &right, int16 &bottom, - const Font * const *fonts, uint fontCount) const { + const Font * const *fonts, uint fontCount) const { if ((line >= _lines.size()) || (_lines[line].font >= fontCount)) diff --git a/engines/gob/video.cpp b/engines/gob/video.cpp index 6480fe89f07..0a7f8cb91ce 100644 --- a/engines/gob/video.cpp +++ b/engines/gob/video.cpp @@ -139,7 +139,7 @@ void Font::drawLetter(Surface &surf, uint8 c, uint16 x, uint16 y, } void Font::drawString(const Common::String &str, int16 x, int16 y, int16 color1, int16 color2, - bool transp, Surface &dest) const { + bool transp, Surface &dest) const { const char *s = str.c_str(); diff --git a/engines/griffon/metaengine.cpp b/engines/griffon/metaengine.cpp index b7f00eec14b..200ad45b555 100644 --- a/engines/griffon/metaengine.cpp +++ b/engines/griffon/metaengine.cpp @@ -33,11 +33,11 @@ class GriffonMetaEngine: public AdvancedMetaEngine { public: - const char *getName() const override { + const char *getName() const override { return "griffon"; } - int getMaximumSaveSlot() const override { + int getMaximumSaveSlot() const override { return ConfMan.getInt("autosave_period") ? 4 : 3; } diff --git a/engines/grim/emi/lua_v2.cpp b/engines/grim/emi/lua_v2.cpp index 26997ac46ab..5841642363d 100644 --- a/engines/grim/emi/lua_v2.cpp +++ b/engines/grim/emi/lua_v2.cpp @@ -691,7 +691,7 @@ void Lua_V2::SetLayerSortOrder() { // Stub function for builtin functions not yet implemented /*static void stubWarning(const char *funcName) { - warning("Stub function: %s", funcName); + warning("Stub function: %s", funcName); }*/ static void stubError(const char *funcName) { diff --git a/engines/grim/gfx_base.cpp b/engines/grim/gfx_base.cpp index 804bbf79e7e..6becf7798cc 100644 --- a/engines/grim/gfx_base.cpp +++ b/engines/grim/gfx_base.cpp @@ -176,41 +176,41 @@ void GfxBase::createSpecialtyTexture(uint id, const uint8 *data, int width, int } Bitmap *GfxBase::createScreenshotBitmap(const Graphics::PixelBuffer src, int w, int h, bool flipOrientation) { - Graphics::PixelBuffer buffer = Graphics::PixelBuffer::createBuffer<565>(w * h, DisposeAfterUse::YES); + Graphics::PixelBuffer buffer = Graphics::PixelBuffer::createBuffer<565>(w * h, DisposeAfterUse::YES); - int i1 = (_screenWidth * w - 1) / _screenWidth + 1; - int j1 = (_screenHeight * h - 1) / _screenHeight + 1; + int i1 = (_screenWidth * w - 1) / _screenWidth + 1; + int j1 = (_screenHeight * h - 1) / _screenHeight + 1; - for (int j = 0; j < j1; j++) { - for (int i = 0; i < i1; i++) { - int x0 = i * _screenWidth / w; - int x1 = ((i + 1) * _screenWidth - 1) / w + 1; - int y0 = j * _screenHeight / h; - int y1 = ((j + 1) * _screenHeight - 1) / h + 1; - uint16 sr = 0, sg = 0, sb = 0; - for (int y = y0; y < y1; y++) { - for (int x = x0; x < x1; x++) { - uint8 r, g, b; - src.getRGBAt(y * _screenWidth + x, r, g, b); - sr += r; - sg += g; - sb += b; - } - } - sr /= (x1 - x0) * (y1 - y0); - sg /= (x1 - x0) * (y1 - y0); - sb /= (x1 - x0) * (y1 - y0); - if (g_grim->getGameType() == GType_MONKEY4) { - buffer.setPixelAt( (flipOrientation ? j : (h - j - 1) ) * w + i, sr, sg, sb); - } else { - uint32 color = (sr + sg + sb) / 3; - buffer.setPixelAt( (flipOrientation ? j : (h - j - 1) ) * w + i, color, color, color); - } - } - } + for (int j = 0; j < j1; j++) { + for (int i = 0; i < i1; i++) { + int x0 = i * _screenWidth / w; + int x1 = ((i + 1) * _screenWidth - 1) / w + 1; + int y0 = j * _screenHeight / h; + int y1 = ((j + 1) * _screenHeight - 1) / h + 1; + uint16 sr = 0, sg = 0, sb = 0; + for (int y = y0; y < y1; y++) { + for (int x = x0; x < x1; x++) { + uint8 r, g, b; + src.getRGBAt(y * _screenWidth + x, r, g, b); + sr += r; + sg += g; + sb += b; + } + } + sr /= (x1 - x0) * (y1 - y0); + sg /= (x1 - x0) * (y1 - y0); + sb /= (x1 - x0) * (y1 - y0); + if (g_grim->getGameType() == GType_MONKEY4) { + buffer.setPixelAt( (flipOrientation ? j : (h - j - 1) ) * w + i, sr, sg, sb); + } else { + uint32 color = (sr + sg + sb) / 3; + buffer.setPixelAt( (flipOrientation ? j : (h - j - 1) ) * w + i, color, color, color); + } + } + } - Bitmap *screenshot = new Bitmap(buffer, w, h, "screenshot"); - return screenshot; + Bitmap *screenshot = new Bitmap(buffer, w, h, "screenshot"); + return screenshot; } void GfxBase::makeScreenTextures() { diff --git a/engines/grim/lua/lapi.cpp b/engines/grim/lua/lapi.cpp index 977a9d3f56e..67d6eed7fdd 100644 --- a/engines/grim/lua/lapi.cpp +++ b/engines/grim/lua/lapi.cpp @@ -417,7 +417,7 @@ int32 lua_setlocal(lua_Function func, int32 local_number) { void lua_funcinfo(lua_Object func, const char **filename, int32 *linedefined) { if (!lua_isfunction(func)) lua_error("API - `funcinfo' called with a non-function value"); - else { + else { TObject *f = luaA_protovalue(Address(func)); if (normalized_type(f) == LUA_T_PROTO) { *filename = tfvalue(f)->fileName->str; diff --git a/engines/grim/md5check.cpp b/engines/grim/md5check.cpp index 51facd2f1a5..ab5d8f0842f 100644 --- a/engines/grim/md5check.cpp +++ b/engines/grim/md5check.cpp @@ -330,10 +330,10 @@ const char *emiPS2_local[] = { }; /* const char *emiPS2_music1[] = { - "a44753d9aaed016e6c7b398b55c97d3d", // english + "a44753d9aaed016e6c7b398b55c97d3d", // english }; const char *emiPS2_music2[] = { - "204cb3d451e4bf71ae5432ab33ca3a49", // english + "204cb3d451e4bf71ae5432ab33ca3a49", // english }; */ const char *emiPS2_sfx[] = { diff --git a/engines/grim/movie/codecs/blocky8.cpp b/engines/grim/movie/codecs/blocky8.cpp index 52a3aee7f0b..d5a05dc567a 100644 --- a/engines/grim/movie/codecs/blocky8.cpp +++ b/engines/grim/movie/codecs/blocky8.cpp @@ -346,19 +346,19 @@ extern "C" { } extern "C" void ARM_Blocky8_decode2( byte *dst, - const byte *src, - int width, - int height, - const byte *param_ptr, - int16 *_table, - byte *_tableBig, - int32 offset1, - int32 offset2, - byte *_tableSmall); + const byte *src, + int width, + int height, + const byte *param_ptr, + int16 *_table, + byte *_tableBig, + int32 offset1, + int32 offset2, + byte *_tableSmall); #define decode2(SRC,DST,WIDTH,HEIGHT,PARAM) \ ARM_Blocky8_decode2(SRC,DST,WIDTH,HEIGHT,PARAM,_table,_tableBig, \ - _offset1,_offset2,_tableSmall) + _offset1,_offset2,_tableSmall) #else void Blocky8::level3(byte *d_dst) { diff --git a/engines/grim/remastered/lua_remastered.cpp b/engines/grim/remastered/lua_remastered.cpp index 60126024561..04f11af7bd0 100644 --- a/engines/grim/remastered/lua_remastered.cpp +++ b/engines/grim/remastered/lua_remastered.cpp @@ -580,7 +580,7 @@ void Lua_Remastered::ReadRegistryIntValue() { // Stub function for builtin functions not yet implemented static void stubWarning(const char *funcName) { - warning("Stub function: %s", funcName); + warning("Stub function: %s", funcName); } /* static void stubError(const char *funcName) { diff --git a/engines/grim/textobject.h b/engines/grim/textobject.h index 590fd57e053..6b2d31a2db3 100644 --- a/engines/grim/textobject.h +++ b/engines/grim/textobject.h @@ -83,7 +83,7 @@ class TextObjectDefaults : public TextObjectCommon { }; class TextObject : public PoolObject, - public TextObjectCommon { + public TextObjectCommon { public: TextObject(); ~TextObject(); diff --git a/engines/groovie/metaengine.cpp b/engines/groovie/metaengine.cpp index 25b483867f1..7f7837b30fb 100644 --- a/engines/groovie/metaengine.cpp +++ b/engines/groovie/metaengine.cpp @@ -33,7 +33,7 @@ namespace Groovie { class GroovieMetaEngine : public AdvancedMetaEngine { public: - const char *getName() const override { + const char *getName() const override { return "groovie"; } diff --git a/engines/hadesch/ambient.h b/engines/hadesch/ambient.h index 5135d79aedd..05d2f50e394 100644 --- a/engines/hadesch/ambient.h +++ b/engines/hadesch/ambient.h @@ -67,7 +67,7 @@ public: void unpause(); void hide(); void unpauseAndFirstFrame(); - void selectFirstFrame(); + void selectFirstFrame(); void playFinished(bool reschedule); bool isReady(); private: diff --git a/engines/hadesch/rooms/ferry.cpp b/engines/hadesch/rooms/ferry.cpp index bea4043ef03..e2ffc8583cb 100644 --- a/engines/hadesch/rooms/ferry.cpp +++ b/engines/hadesch/rooms/ferry.cpp @@ -273,7 +273,7 @@ static const struct { { "V9220tB0", {"V9220nB0", _s("He must not sit next to or across from pierced beings") } }, { "V9220tC0", {"V9220nC0", _s("He must not sit next to or across from monsters") } }, // 80 { "V9220tD0", {"V9220nD0", _s("He must not sit next to or across from animals") } }, - { "V9245tA0", {"V9300nE0", _s("Ha-ha-ha") } } + { "V9245tA0", {"V9300nE0", _s("Ha-ha-ha") } } }; static const struct { diff --git a/engines/hadesch/rooms/medisle.cpp b/engines/hadesch/rooms/medisle.cpp index cfdaa9368a7..a424a8d4ccc 100644 --- a/engines/hadesch/rooms/medisle.cpp +++ b/engines/hadesch/rooms/medisle.cpp @@ -124,7 +124,7 @@ struct StatuePiece { return Common::Point(hotspotx, hotspoty); } }; - + static const StatuePiece statuePieces[] = { {"LowerLeg1", "m1010or0", "m1010or2", 519, 282, 2009, 461, 395, 26, 28, -1, -1 }, {"LowerLeg2", "m1010or1", "m1010or3", 571, 276, 2008, 339, 358, 15, 30, -1, -1 }, @@ -336,7 +336,7 @@ public: return; } } - + if (name == "FatesLair") { if (showAllFates()) return; @@ -1172,7 +1172,7 @@ private: void statueDClick(int pieceNum) { _statueDrag = pieceNum; - + renderStatue(); } diff --git a/engines/hadesch/rooms/riverstyx.cpp b/engines/hadesch/rooms/riverstyx.cpp index 6c6806d346d..30d7b8cf584 100644 --- a/engines/hadesch/rooms/riverstyx.cpp +++ b/engines/hadesch/rooms/riverstyx.cpp @@ -350,7 +350,7 @@ public: if (quest == kRescuePhilQuest) { _alchemist = StyxShade("alchemist", 750, 5000, 10000, "alchemist"); - if (!persistent->_styxAlchemistSaidIntro) + if (!persistent->_styxAlchemistSaidIntro) _alchemist.addSound("alchemist intro"); if (persistent->_hintsAreEnabled) { if ((persistent->isInInventory(kCoin) || persistent->_styxCharonUsedCoin) @@ -361,7 +361,7 @@ public: _alchemist.addSound("alchemist hint 1"); } } - if (persistent->_styxAlchemistSaidIntro) + if (persistent->_styxAlchemistSaidIntro) _alchemist.addSound("alchemist intro"); _alchemist.addSound("alchemist click"); _alchemist.start(); diff --git a/engines/hadesch/rooms/seriphos.cpp b/engines/hadesch/rooms/seriphos.cpp index 5e45328b48b..1c4590bec8a 100644 --- a/engines/hadesch/rooms/seriphos.cpp +++ b/engines/hadesch/rooms/seriphos.cpp @@ -71,7 +71,7 @@ static const TranscribedSound seClickTranscript[] = { enum { kAnimationCompleted = 26007, - // 26008 is the end of statue animation that we handle as functor instead + // 26008 is the end of statue animation that we handle as functor instead kStrawTaken = 26020, kStrawTakenCleanup = 26021, diff --git a/engines/hadesch/video.cpp b/engines/hadesch/video.cpp index ed303fd03b1..5918904422c 100644 --- a/engines/hadesch/video.cpp +++ b/engines/hadesch/video.cpp @@ -165,7 +165,7 @@ void VideoRoom::setPannable(bool val) { } void VideoRoom::setHotzoneEnabled(const Common::String &name, bool enabled) { - _hotZones.setHotzoneEnabled(name, enabled); + _hotZones.setHotzoneEnabled(name, enabled); } void VideoRoom::enableHotzone(const Common::String &name) { diff --git a/engines/hadesch/video.h b/engines/hadesch/video.h index 1337f31a011..a1e41eb43dc 100644 --- a/engines/hadesch/video.h +++ b/engines/hadesch/video.h @@ -55,7 +55,7 @@ static const int kDefaultSpeed = 100; class Renderable { public: - Renderable(Common::Array images); + Renderable(Common::Array images); const PodImage &getFrame(int time); void startAnimation(int startms, int msperframe, bool loop, int first, int last); @@ -211,7 +211,7 @@ public: PlayAnimParams params, EventHandlerWrapper callbackEvent = EventHandlerWrapper(), Common::Point offset = Common::Point(0, 0)); - void playAnimWithMusic(const LayerId &animName, + void playAnimWithMusic(const LayerId &animName, const Common::String &soundName, int zValue, PlayAnimParams params, diff --git a/engines/hopkins/files.h b/engines/hopkins/files.h index 0c117ccc107..94db09b290f 100644 --- a/engines/hopkins/files.h +++ b/engines/hopkins/files.h @@ -34,7 +34,7 @@ class HopkinsEngine; // RES_ANI = 4 has been removed because it's not used enum CatMode { RES_INI = 1, RES_REP = 2, RES_LIN = 3, RES_PER = 5, - RES_PIC = 6, RES_SAN = 7, RES_SLI = 8, RES_VOI = 9 }; + RES_PIC = 6, RES_SAN = 7, RES_SLI = 8, RES_VOI = 9 }; class FileManager { public: diff --git a/engines/hopkins/metaengine.cpp b/engines/hopkins/metaengine.cpp index b48748acdd2..d8b228bc081 100644 --- a/engines/hopkins/metaengine.cpp +++ b/engines/hopkins/metaengine.cpp @@ -64,7 +64,7 @@ public: return "hopkins"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; SaveStateList listSaves(const char *target) const override; diff --git a/engines/icb/actor_fx_pc.cpp b/engines/icb/actor_fx_pc.cpp index 3106f669147..79a3c76f0e6 100644 --- a/engines/icb/actor_fx_pc.cpp +++ b/engines/icb/actor_fx_pc.cpp @@ -57,7 +57,7 @@ int32 minX, maxX, minY, maxY, minZ, maxZ; // draw the special effects int32 DrawActorSpecialEffectsPC(int32 mflash, SVECTOR *mfpos, int32 mfh, int32 mfw, int32 bullet, SVECTOR *bulletPos, int32 bulletCol, Breath *breath, MATRIXPC *local2screen, int32 brightness, - SVECTOR *minBBox, SVECTOR *maxBBox) { + SVECTOR *minBBox, SVECTOR *maxBBox) { // Put the correct rot and trans matrix in place // transform model from world space to screen space gte_SetRotMatrix_pc(local2screen); @@ -246,13 +246,13 @@ void DrawBreathingPC(Breath *breath) { // 8 points on cubic shape, length by 2*radius (width) by 2*radius (height)... const short bulletOffsets[BULLET_POINTS][3] = {{-BULLET_RADIUS, BULLET_RADIUS, 0}, - {BULLET_RADIUS, BULLET_RADIUS, 0}, - {BULLET_RADIUS, -BULLET_RADIUS, 0}, - {-BULLET_RADIUS, -BULLET_RADIUS, 0}, - {-BULLET_RADIUS, BULLET_RADIUS, BULLET_LENGTH}, - {BULLET_RADIUS, BULLET_RADIUS, BULLET_LENGTH}, - {BULLET_RADIUS, -BULLET_RADIUS, BULLET_LENGTH}, - {-BULLET_RADIUS, -BULLET_RADIUS, BULLET_LENGTH}}; + {BULLET_RADIUS, BULLET_RADIUS, 0}, + {BULLET_RADIUS, -BULLET_RADIUS, 0}, + {-BULLET_RADIUS, -BULLET_RADIUS, 0}, + {-BULLET_RADIUS, BULLET_RADIUS, BULLET_LENGTH}, + {BULLET_RADIUS, BULLET_RADIUS, BULLET_LENGTH}, + {BULLET_RADIUS, -BULLET_RADIUS, BULLET_LENGTH}, + {-BULLET_RADIUS, -BULLET_RADIUS, BULLET_LENGTH}}; // 6 sides for cube.... const int32 bulletQuads[BULLET_QUADS][4] = {{1, 0, 2, 3}, {0, 1, 4, 5}, {1, 2, 5, 6}, {2, 3, 6, 7}, {3, 0, 7, 4}, {4, 5, 7, 6}}; diff --git a/engines/icb/actor_pc.cpp b/engines/icb/actor_pc.cpp index 73124e782a9..abfd9297f7c 100644 --- a/engines/icb/actor_pc.cpp +++ b/engines/icb/actor_pc.cpp @@ -74,9 +74,9 @@ void DrawModel4PC(rap_API *mrap, int32 poseBone, MATRIXPC *lw, MATRIXPC *local2s // using soft-skinning specific data void DrawActor4PC(psxActor *actor, psxCamera *camera, Bone_Frame *frame, rap_API *mesh, rap_API *pose, rap_API *smesh, PSXrgb *ambient, PSXLampList *lamplist, - PSXShadeList *shadelist, int32 nShadows, SVECTORPC *p_n, int32 *p_d, uint32 debug, int32 uvframe, BoneDeformation **boneDeforms, int32 *brightness, - MATRIXPC *local2screen // filled in - ) { + PSXShadeList *shadelist, int32 nShadows, SVECTORPC *p_n, int32 *p_d, uint32 debug, int32 uvframe, BoneDeformation **boneDeforms, int32 *brightness, + MATRIXPC *local2screen // filled in + ) { // The position actor->pos is the world position // lw is the local to world matrix diff --git a/engines/icb/actor_pc.h b/engines/icb/actor_pc.h index b5036d3cdea..9ac6c388e60 100644 --- a/engines/icb/actor_pc.h +++ b/engines/icb/actor_pc.h @@ -46,14 +46,14 @@ void ConvertToScreenCoords(SVECTORPC *local, SVECTORPC *screen, int32 nVertices) void ConvertToScreenCoords(SVECTOR *local, SVECTOR *screen, int32 nVertices); void DrawActor4PC(psxActor *actor, psxCamera *camera, Bone_Frame *frame, rap_API *mesh, rap_API *pose, rap_API *smesh, PSXrgb *ambient, PSXLampList *lamplist, - PSXShadeList *shadelist, int32 nShadows, SVECTORPC *p_n, int32 *p_d, uint32 debug, int32 uvframe, BoneDeformation **boneDeforms, int32 *brightness, - MATRIXPC *local2screen); + PSXShadeList *shadelist, int32 nShadows, SVECTORPC *p_n, int32 *p_d, uint32 debug, int32 uvframe, BoneDeformation **boneDeforms, int32 *brightness, + MATRIXPC *local2screen); void DrawActorTiePC(psxCamera *camera, SVECTORPC *pos, uint32 size, CVECTOR *colour); // return 1 if something drawn, else return 0 int32 DrawActorSpecialEffectsPC(int32 mflash, SVECTOR *mfpos, int32 mfh, int32 mfw, int32 bullet, SVECTOR *bulletPos, int32 bulletCol, Breath *breath, MATRIXPC *local2screen, int32 brightness, - SVECTOR *minBBox, SVECTOR *maxBBox); + SVECTOR *minBBox, SVECTOR *maxBBox); } // End of namespace ICB diff --git a/engines/icb/actor_view_pc.h b/engines/icb/actor_view_pc.h index 4e0c0fed453..1c14d203ec3 100644 --- a/engines/icb/actor_view_pc.h +++ b/engines/icb/actor_view_pc.h @@ -38,22 +38,22 @@ extern bool8 g_av_userControlled; #define ANIMATION_END 0x01 void InitActorView(const char *name, // Character to draw (ie "cord") - const char *outfit, // Characters outfit (ie "casual_wear") - const char *weapon, // Character pose (ie "unarmed") - const char *anim, // Character anim (ie "walk") - int16 ix, // Initial render x coord - int16 iy, // Initial render y coord - int16 iz); // Initial render z coord + const char *outfit, // Characters outfit (ie "casual_wear") + const char *weapon, // Character pose (ie "unarmed") + const char *anim, // Character anim (ie "walk") + int16 ix, // Initial render x coord + int16 iy, // Initial render y coord + int16 iz); // Initial render z coord int32 ActorViewDraw(); // Call each cycle to draw void ChangeAnimPlaying(const char *pose, // Pose to swap to NULL if keep the same - const char *anim, // Anim to change to - bool8 forwards, // Play anim forwards or backwards - int32 repeats, // Number of times to play this anim before ActorViewDraw() returns ANIMATION_END - int16 ix, // New render x coordinate - int16 iy, // New render y coordinate - int16 iz); // New render z coordinate + const char *anim, // Anim to change to + bool8 forwards, // Play anim forwards or backwards + int32 repeats, // Number of times to play this anim before ActorViewDraw() returns ANIMATION_END + int16 ix, // New render x coordinate + int16 iy, // New render y coordinate + int16 iz); // New render z coordinate } // End of namespace ICB diff --git a/engines/icb/animation_mega_set.cpp b/engines/icb/animation_mega_set.cpp index 11677405477..a8563e92b08 100644 --- a/engines/icb/animation_mega_set.cpp +++ b/engines/icb/animation_mega_set.cpp @@ -47,93 +47,93 @@ namespace ICB { // this is the master animation declaration table. _an_anim_entry master_anim_name_table[__TOTAL_ANIMS] = { - {"walk", __WALK}, - {"walk_to_stand", __WALK_TO_STAND}, - {"walk_to_other_stand_(left_leg)", __WALK_TO_OTHER_STAND_LEFT_LEG}, - {"walk_to_pull_out_weapon", __WALK_TO_PULL_OUT_WEAPON}, + {"walk", __WALK}, + {"walk_to_stand", __WALK_TO_STAND}, + {"walk_to_other_stand_(left_leg)", __WALK_TO_OTHER_STAND_LEFT_LEG}, + {"walk_to_pull_out_weapon", __WALK_TO_PULL_OUT_WEAPON}, - {"stand", __STAND}, - {"stand_to_walk", __STAND_TO_WALK}, - {"stand_to_walk_upstairs_right", __STAND_TO_WALK_UP_STAIRS_RIGHT}, - {"stand_to_walk_downstairs_right", __STAND_TO_WALK_DOWN_STAIRS_RIGHT}, - {"stand_to_run", __STAND_TO_RUN}, - {"stand_to_step_backward", __STAND_TO_STEP_BACKWARD}, - {"stand_crouch_to_stand", __STAND_CROUCHED_TO_STAND}, - {"stand_crouch_to_walk_crouched", __STAND_CROUCHED_TO_WALK_CROUCHED}, + {"stand", __STAND}, + {"stand_to_walk", __STAND_TO_WALK}, + {"stand_to_walk_upstairs_right", __STAND_TO_WALK_UP_STAIRS_RIGHT}, + {"stand_to_walk_downstairs_right", __STAND_TO_WALK_DOWN_STAIRS_RIGHT}, + {"stand_to_run", __STAND_TO_RUN}, + {"stand_to_step_backward", __STAND_TO_STEP_BACKWARD}, + {"stand_crouch_to_stand", __STAND_CROUCHED_TO_STAND}, + {"stand_crouch_to_walk_crouched", __STAND_CROUCHED_TO_WALK_CROUCHED}, - {"run", __RUN}, - {"run_to_stand", __RUN_TO_STAND}, - {"run_to_pull_out_weapon", __RUN_TO_PULL_OUT_WEAPON}, + {"run", __RUN}, + {"run_to_stand", __RUN_TO_STAND}, + {"run_to_pull_out_weapon", __RUN_TO_PULL_OUT_WEAPON}, - {"use_card_on_slot", __USE_CARD_ON_SLOT}, - {"pick_up_object_from_floor", __PICK_UP_OBJECT_FROM_FLOOR}, - {"push_button", __PUSH_BUTTON}, - {"being_shot", __BEING_SHOT}, - {"being_shot_dead", __BEING_SHOT_DEAD}, + {"use_card_on_slot", __USE_CARD_ON_SLOT}, + {"pick_up_object_from_floor", __PICK_UP_OBJECT_FROM_FLOOR}, + {"push_button", __PUSH_BUTTON}, + {"being_shot", __BEING_SHOT}, + {"being_shot_dead", __BEING_SHOT_DEAD}, - {"sidestep_left", __SIDESTEP_LEFT}, - {"step_backward", __STEP_BACKWARD}, - {"step_forward", __STEP_FORWARD}, - {"step_backward_to_stand", __STEP_BACKWARD_TO_STAND}, - {"step_backward_to_other_stand_(left_leg)", __STEP_BACKWARD_TO_OTHER_STAND_LEFT}, + {"sidestep_left", __SIDESTEP_LEFT}, + {"step_backward", __STEP_BACKWARD}, + {"step_forward", __STEP_FORWARD}, + {"step_backward_to_stand", __STEP_BACKWARD_TO_STAND}, + {"step_backward_to_other_stand_(left_leg)", __STEP_BACKWARD_TO_OTHER_STAND_LEFT}, - {"stand_and_aim", __STAND_AND_AIM}, - {"stand_and_shoot", __STAND_AND_SHOOT}, - {"pull_out_weapon", __PULL_OUT_WEAPON}, - {"cord_strike", __STRIKE}, - {"low_strike", __LOW_STRIKE}, - {"hit_from_behind", __HIT_FROM_BEHIND}, + {"stand_and_aim", __STAND_AND_AIM}, + {"stand_and_shoot", __STAND_AND_SHOOT}, + {"pull_out_weapon", __PULL_OUT_WEAPON}, + {"cord_strike", __STRIKE}, + {"low_strike", __LOW_STRIKE}, + {"hit_from_behind", __HIT_FROM_BEHIND}, - {"turn_on_the_spot_cw", __TURN_ON_THE_SPOT_CLOCKWISE}, + {"turn_on_the_spot_cw", __TURN_ON_THE_SPOT_CLOCKWISE}, - {"walk_upstairs_left", __WALK_UPSTAIRS_LEFT}, - {"walk_upstairs_right", __WALK_UPSTAIRS_RIGHT}, - {"walk_downstairs_left", __WALK_DOWNSTAIRS_LEFT}, - {"walk_downstairs_right", __WALK_DOWNSTAIRS_RIGHT}, + {"walk_upstairs_left", __WALK_UPSTAIRS_LEFT}, + {"walk_upstairs_right", __WALK_UPSTAIRS_RIGHT}, + {"walk_downstairs_left", __WALK_DOWNSTAIRS_LEFT}, + {"walk_downstairs_right", __WALK_DOWNSTAIRS_RIGHT}, - {"walk_upstairs_left_to_stood_on_stairs_facing_up", __WALK_UPSTAIRS_LEFT_TO_STOOD_ON_STAIRS_FACING_UP}, - {"walk_upstairs_right_to_stood_on_stairs_facing_up", __WALK_UPSTAIRS_RIGHT_TO_STOOD_ON_STAIRS_FACING_UP}, - {"walk_downstairs_left_to_stood_on_stairs_facing_down", __WALK_DOWNSTAIRS_LEFT_TO_STOOD_ON_STAIRS_FACING_DOWN}, - {"walk_downstairs_right_to_stood_on_stairs_facing_down", __WALK_DOWNSTAIRS_RIGHT_TO_STOOD_ON_STAIRS_FACING_DOWN}, + {"walk_upstairs_left_to_stood_on_stairs_facing_up", __WALK_UPSTAIRS_LEFT_TO_STOOD_ON_STAIRS_FACING_UP}, + {"walk_upstairs_right_to_stood_on_stairs_facing_up", __WALK_UPSTAIRS_RIGHT_TO_STOOD_ON_STAIRS_FACING_UP}, + {"walk_downstairs_left_to_stood_on_stairs_facing_down", __WALK_DOWNSTAIRS_LEFT_TO_STOOD_ON_STAIRS_FACING_DOWN}, + {"walk_downstairs_right_to_stood_on_stairs_facing_down", __WALK_DOWNSTAIRS_RIGHT_TO_STOOD_ON_STAIRS_FACING_DOWN}, - {"walk_upstairs_left_to_walk_downstairs_right", __WALK_UPSTAIRS_LEFT_TO_WALK_DOWNSTAIRS_RIGHT}, - {"walk_upstairs_right_to_walk_downstairs_left", __WALK_UPSTAIRS_RIGHT_TO_WALK_DOWNSTAIRS_LEFT}, - {"walk_downstairs_left_to_walk_upstairs_right", __WALK_DOWNSTAIRS_LEFT_TO_WALK_UPSTAIRS_RIGHT}, - {"walk_downstairs_right_to_walk_upstairs_left", __WALK_DOWNSTAIRS_RIGHT_TO_WALK_UPSTAIRS_LEFT}, + {"walk_upstairs_left_to_walk_downstairs_right", __WALK_UPSTAIRS_LEFT_TO_WALK_DOWNSTAIRS_RIGHT}, + {"walk_upstairs_right_to_walk_downstairs_left", __WALK_UPSTAIRS_RIGHT_TO_WALK_DOWNSTAIRS_LEFT}, + {"walk_downstairs_left_to_walk_upstairs_right", __WALK_DOWNSTAIRS_LEFT_TO_WALK_UPSTAIRS_RIGHT}, + {"walk_downstairs_right_to_walk_upstairs_left", __WALK_DOWNSTAIRS_RIGHT_TO_WALK_UPSTAIRS_LEFT}, - {"run_up_stairs_left", __RUN_UPSTAIRS_LEFT}, - {"run_up_stairs_right", __RUN_UPSTAIRS_RIGHT}, - {"run_down_stairs_left", __RUN_DOWNSTAIRS_LEFT}, - {"run_down_stairs_right", __RUN_DOWNSTAIRS_RIGHT}, + {"run_up_stairs_left", __RUN_UPSTAIRS_LEFT}, + {"run_up_stairs_right", __RUN_UPSTAIRS_RIGHT}, + {"run_down_stairs_left", __RUN_DOWNSTAIRS_LEFT}, + {"run_down_stairs_right", __RUN_DOWNSTAIRS_RIGHT}, - {"climb_up_ladder_left", __CLIMB_UP_LADDER_LEFT}, - {"climb_up_ladder_right", __CLIMB_UP_LADDER_RIGHT}, - {"climb_down_ladder_left", __CLIMB_DOWN_LADDER_LEFT}, - {"climb_down_ladder_right", __CLIMB_DOWN_LADDER_RIGHT}, + {"climb_up_ladder_left", __CLIMB_UP_LADDER_LEFT}, + {"climb_up_ladder_right", __CLIMB_UP_LADDER_RIGHT}, + {"climb_down_ladder_left", __CLIMB_DOWN_LADDER_LEFT}, + {"climb_down_ladder_right", __CLIMB_DOWN_LADDER_RIGHT}, - {"climb_up_ladder_right_to_stand", __CLIMB_UP_LADDER_RIGHT_TO_STAND}, - {"climb_down_ladder_right_to_stand", __CLIMB_DOWN_LADDER_RIGHT_TO_STAND}, + {"climb_up_ladder_right_to_stand", __CLIMB_UP_LADDER_RIGHT_TO_STAND}, + {"climb_down_ladder_right_to_stand", __CLIMB_DOWN_LADDER_RIGHT_TO_STAND}, - {"cord_stand_to_climb_up_ladder", __CORD_STAND_TO_CLIMB_UP_LADDER}, + {"cord_stand_to_climb_up_ladder", __CORD_STAND_TO_CLIMB_UP_LADDER}, - {"stand_to_climb_up_ladder_right", __STAND_TO_CLIMB_UP_LADDER_RIGHT}, - {"stand_to_climb_down_ladder_right", __STAND_TO_CLIMB_DOWN_LADDER_RIGHT}, + {"stand_to_climb_up_ladder_right", __STAND_TO_CLIMB_UP_LADDER_RIGHT}, + {"stand_to_climb_down_ladder_right", __STAND_TO_CLIMB_DOWN_LADDER_RIGHT}, - {"climb_down_ladder_left_to_slide_down_ladder", __CLIMB_DOWN_LADDER_LEFT_TO_SLIDE_DOWN_LADDER}, - {"slide_down_ladder", __SLIDE_DOWN_LADDER}, - {"slide_down_ladder_to_stand", __SLIDE_DOWN_LADDER_TO_STAND}, + {"climb_down_ladder_left_to_slide_down_ladder", __CLIMB_DOWN_LADDER_LEFT_TO_SLIDE_DOWN_LADDER}, + {"slide_down_ladder", __SLIDE_DOWN_LADDER}, + {"slide_down_ladder_to_stand", __SLIDE_DOWN_LADDER_TO_STAND}, - {"load_gun", __LOAD_GUN}, - {"load_gun_2", __LOAD_GUN_2}, - {"load_gun2", __LOAD_GUN_CROUCH_2}, + {"load_gun", __LOAD_GUN}, + {"load_gun_2", __LOAD_GUN_2}, + {"load_gun2", __LOAD_GUN_CROUCH_2}, - {"cowering", __COWER}, - {"cowering_to_stand", __COWER_TO_STAND}, - {"run_hand_through_hair", __HAND_HAIR}, - {"shrug", __SHRUG}, - {"look_at_watch", __LOOK_AT_WATCH}, - {"stretch", __STRETCH}, - {"scratching_backside", __SCRATCH}, + {"cowering", __COWER}, + {"cowering_to_stand", __COWER_TO_STAND}, + {"run_hand_through_hair", __HAND_HAIR}, + {"shrug", __SHRUG}, + {"look_at_watch", __LOOK_AT_WATCH}, + {"stretch", __STRETCH}, + {"scratching_backside", __SCRATCH}, }; // these names must be in same order as __weapon diff --git a/engines/icb/bone.cpp b/engines/icb/bone.cpp index a17bbe445e1..03f6eb30bd3 100644 --- a/engines/icb/bone.cpp +++ b/engines/icb/bone.cpp @@ -436,15 +436,15 @@ mcodeFunctionReturnCodes speak_simple_look(int32 &result, int32 *params) { retur #define LOOK_DOWN (int16)(-LOOK_UP) const short looks[9][3] = { - {0, 0, 0}, // ahead - {0, 0, LOOK_UP}, // up - {LOOK_RIGHT, 0, LOOK_UP}, // up/right - {LOOK_RIGHT, 0, 0}, // right - {LOOK_RIGHT, 0, LOOK_DOWN}, // down/right - {0, 0, LOOK_DOWN}, // down - {LOOK_LEFT, 0, LOOK_DOWN}, // down/left - {LOOK_LEFT, 0, 0}, // left - {LOOK_LEFT, 0, LOOK_UP} // up/left + {0, 0, 0}, // ahead + {0, 0, LOOK_UP}, // up + {LOOK_RIGHT, 0, LOOK_UP}, // up/right + {LOOK_RIGHT, 0, 0}, // right + {LOOK_RIGHT, 0, LOOK_DOWN}, // down/right + {0, 0, LOOK_DOWN}, // down + {LOOK_LEFT, 0, LOOK_DOWN}, // down/left + {LOOK_LEFT, 0, 0}, // left + {LOOK_LEFT, 0, LOOK_UP} // up/left }; // look diff --git a/engines/icb/cluster_manager_pc.cpp b/engines/icb/cluster_manager_pc.cpp index c0bd5021d51..6b6e867a544 100644 --- a/engines/icb/cluster_manager_pc.cpp +++ b/engines/icb/cluster_manager_pc.cpp @@ -58,13 +58,13 @@ MovieManager *g_while_u_wait_SequenceManager; // Colours used by progress display uint32 g_progressColourMap[7] = { - 0x3C3C3C, // OFF 60 60 60 - 0xFEFEFE, // | 254 254 254 - 0xCAD5E4, // | 202 213 228 - 0xA6B8D4, // | 166 184 212 - 0x89A1C7, // | 137 161 199 - 0x587AB0, // V 88 122 176 - 0x2E579C // ON 46 87 156 + 0x3C3C3C, // OFF 60 60 60 + 0xFEFEFE, // | 254 254 254 + 0xCAD5E4, // | 202 213 228 + 0xA6B8D4, // | 166 184 212 + 0x89A1C7, // | 137 161 199 + 0x587AB0, // V 88 122 176 + 0x2E579C // ON 46 87 156 }; // Controls the decay on the progress bit colouring diff --git a/engines/icb/common/pc_props.h b/engines/icb/common/pc_props.h index a79719ae599..622ada92fbe 100644 --- a/engines/icb/common/pc_props.h +++ b/engines/icb/common/pc_props.h @@ -165,7 +165,7 @@ public: }; class pcPropRGB { - private: +private: char name[32]; uint32 stateQty; pcPropRGBState **states; diff --git a/engines/icb/common/px_common.h b/engines/icb/common/px_common.h index c51a2c42e55..de00177e99e 100644 --- a/engines/icb/common/px_common.h +++ b/engines/icb/common/px_common.h @@ -75,9 +75,9 @@ enum _file_type { // add more here! /***IMPORTANT*** - DO NOT DELETE ENTRIES FROM THIS LIST OR SUBSEQUENT RESOURCE TYPES WILL BE RENUMBERED - RENAME ENTRIES NO LONGER IN USE AND REUSE THEM LATER - */ + DO NOT DELETE ENTRIES FROM THIS LIST OR SUBSEQUENT RESOURCE TYPES WILL BE RENUMBERED + RENAME ENTRIES NO LONGER IN USE AND REUSE THEM LATER + */ // The following entries can go in any order, but should not be changed diff --git a/engines/icb/common/px_route_barriers.h b/engines/icb/common/px_route_barriers.h index 57792d9f441..aef344ce883 100644 --- a/engines/icb/common/px_route_barriers.h +++ b/engines/icb/common/px_route_barriers.h @@ -90,8 +90,8 @@ enum _barrier_logic_value { NO_IMPACT = 0, BLOCKS, ALLOWS, MAYBE, SPECIAL }; // This is the truth table that states what kind of ray passes through what // type of barrier. static enum _barrier_logic_value _barrier_logic_table[BARRIER_TYPE_CARDINALITY][RAY_TYPE_CARDINALITY] = { - {BLOCKS, BLOCKS, BLOCKS}, {BLOCKS, ALLOWS, SPECIAL}, {BLOCKS, ALLOWS, BLOCKS}, {BLOCKS, BLOCKS, ALLOWS}, {BLOCKS, ALLOWS, MAYBE}, - {BLOCKS, ALLOWS, ALLOWS}, {BLOCKS, ALLOWS, ALLOWS}, {BLOCKS, ALLOWS, ALLOWS}, {BLOCKS, ALLOWS, ALLOWS}}; + {BLOCKS, BLOCKS, BLOCKS}, {BLOCKS, ALLOWS, SPECIAL}, {BLOCKS, ALLOWS, BLOCKS}, {BLOCKS, BLOCKS, ALLOWS}, {BLOCKS, ALLOWS, MAYBE}, + {BLOCKS, ALLOWS, ALLOWS}, {BLOCKS, ALLOWS, ALLOWS}, {BLOCKS, ALLOWS, ALLOWS}, {BLOCKS, ALLOWS, ALLOWS}}; // simple, this is just for the converters // Some extra figures to speed up barrier collision detection. diff --git a/engines/icb/common/px_scriptengine.cpp b/engines/icb/common/px_scriptengine.cpp index d888668f9d9..9076c549529 100644 --- a/engines/icb/common/px_scriptengine.cpp +++ b/engines/icb/common/px_scriptengine.cpp @@ -118,9 +118,9 @@ extern mcodeFunctionReturnCodes fn_context_chosen_logic(int32 &, int32 *); extern mcodeFunctionReturnCodes fn_start_player_interaction(int32 &, int32 *); scriptInterpreterReturnCodes RunScript(const char *&scriptData, // A pointer to the script data that can be modified - c_game_object *object, // A pointer to the object that owns this object - int32 *engineReturnValue2, - const char *scriptSourceName) { // A value to return to the game engine + c_game_object *object, // A pointer to the object that owns this object + int32 *engineReturnValue2, + const char *scriptSourceName) { // A value to return to the game engine // Run a script ScriptTrace("Run script"); diff --git a/engines/icb/common/px_scriptengine.h b/engines/icb/common/px_scriptengine.h index 321ff7f90bd..297736efa67 100644 --- a/engines/icb/common/px_scriptengine.h +++ b/engines/icb/common/px_scriptengine.h @@ -44,9 +44,9 @@ enum scriptInterpreterReturnCodes { }; scriptInterpreterReturnCodes RunScript(const char *&scriptData, // A pointer to the script data that can be modified - c_game_object *object, // A pointer to the object that owns this object - int32 *engineReturnValue = NULL, - const char *scriptSourceName = NULL); // A value to return to the game engine + c_game_object *object, // A pointer to the object that owns this object + int32 *engineReturnValue = NULL, + const char *scriptSourceName = NULL); // A value to return to the game engine void SetScriptDebugging(bool8 f); // Set script debugging flag diff --git a/engines/icb/common/px_staticlayers.h b/engines/icb/common/px_staticlayers.h index 78adb1133f9..aab571ce6c7 100644 --- a/engines/icb/common/px_staticlayers.h +++ b/engines/icb/common/px_staticlayers.h @@ -42,7 +42,7 @@ namespace ICB { #define TILE_COUNT (TILES_WIDE * TILES_HIGH) class pcStaticLayers { - private: +private: char id[4]; uint32 schema; uint32 mapping; @@ -51,7 +51,7 @@ class pcStaticLayers { uint8 *DataStart() { return (uint8 *)id; } - public: +public: uint16 *GetSemiTileTable(int32 idx) { return semiPtrs[idx] ? (uint16 *)(DataStart() + semiPtrs[idx]) : 0; } uint16 *GetTileTable(int32 idx) { return tilePtrs[idx] ? (uint16 *)(DataStart() + tilePtrs[idx]) : 0; } diff --git a/engines/icb/common/px_walkarea_integer.h b/engines/icb/common/px_walkarea_integer.h index d365aa79d08..ab56e37581e 100644 --- a/engines/icb/common/px_walkarea_integer.h +++ b/engines/icb/common/px_walkarea_integer.h @@ -88,7 +88,7 @@ public: bool8 GetPoint(uint32 area, uint32 number, __point &point) const; bool8 GetCameraName(uint32 number, const char *&name) const; - private: +private: uint32 noAreas; uint32 offsetTable[1]; }; diff --git a/engines/icb/console_pc.cpp b/engines/icb/console_pc.cpp index 90b24f6fe99..24ebe30bd5b 100644 --- a/engines/icb/console_pc.cpp +++ b/engines/icb/console_pc.cpp @@ -37,9 +37,9 @@ namespace ICB { uint8 version_string[HEAD_LEN + 10] = {1, 255, 37, 22, 45, 128, 34, 67}; uint8 unencoded_name[HEAD_LEN + 48] = {9, 11, 73, 18, 120, 209, 211, 237, 'R', 'e', 'v', 'o', 'l', 'u', 't', 'i', - 'o', 'n', ' ', 'S', 'o', 'f', 't', 'w', 'a', 'r', 'e', ' ', 'L', 't', 'd', 0}; + 'o', 'n', ' ', 'S', 'o', 'f', 't', 'w', 'a', 'r', 'e', ' ', 'L', 't', 'd', 0}; uint8 encoded_name[HEAD_LEN + 48] = {24, 52, 90, 122, 223, 165, 33, 199, 179, 209, 225, 157, 222, 238, 219, 209, 143, 224, 133, 190, 232, 209, 162, 177, 198, 228, 202, 146, - 180, 232, 214, 65, 65, 65, 116, 104, 116, 114, 107, 104, 32, 49, 64, 35, 123, 125, 61, 45, 41, 40, 163, 36, 49, 123, 125, 10}; + 180, 232, 214, 65, 65, 65, 116, 104, 116, 114, 107, 104, 32, 49, 64, 35, 123, 125, 61, 45, 41, 40, 163, 36, 49, 123, 125, 10}; } // End of namespace ICB diff --git a/engines/icb/fn_routines.cpp b/engines/icb/fn_routines.cpp index e878ef3da9f..338fe84b636 100644 --- a/engines/icb/fn_routines.cpp +++ b/engines/icb/fn_routines.cpp @@ -446,425 +446,425 @@ mcodeFunctionReturnCodes fn_deactivate_sparkle(int32 &, int32 *); mcodeFunctionReturnCodes fn_missing_routine(int32 &, int32 *); mcodeFunctionReturnCodes (*McodeTable[NO_API_ROUTINES])(int32 &, int32 *) = { - fn_test, - fn_create_mega, - fn_shut_down_object, - fn_prop_animate, - fn_set_voxel_image_path, - fn_set_xyz, - fn_set_to_floor, - fn_init_from_nico_file, - fn_init_from_marker_file, - fn_set_pan, - fn_context_chosen_logic, - fn_tiny_route, - fn_player, - fn_pause, - fn_face_coord, - fn_face_object, - fn_play_generic_anim, - fn_set_player_can_interact, - fn_set_player_cannot_interact, - fn_generic_prop_interact, - fn_custom_prop_interact, - fn_register_for_event, - fn_unregister_for_event, - fn_register_object_for_event, - fn_unregister_object_for_event, - fn_post_event, - fn_post_future_event, - fn_post_repeating_event, - fn_post_named_event_to_object, - fn_register_for_line_of_sight, - fn_unregister_for_line_of_sight, - fn_register_object_for_line_of_sight, - fn_unregister_object_for_line_of_sight, - fn_can_see, - fn_can_object_see, - fn_call_socket, - fn_prop_set_to_last_frame, - fn_prop_set_to_first_frame, - fn_prop_near_a_mega, - socket_force_new_logic, - fn_set_weapon, - fn_set_mega_field_of_view, - fn_apply_bullet, - fn_add_inventory_item, - fn_remove_inventory_item, - fn_is_carrying, - fn_reset_player, - fn_speak, - fn_request_speech, - fn_add_talker, - fn_issue_speech_request, - fn_confirm_requests, - fn_anon_speech_invite, - fn_converse, - speak_object_face_object, - speak_play_generic_anim, - speak_wait_for_everyone, - fn_get_weapon, - fn_rig_test, - fn_is_holding, - fn_drop, - fn_item_held, - fn_set_to_last_frame_generic_anim, - fn_play_common_xa_music, - fn_pass_flag_to_engine, - fn_remora_is_active, - fn_easy_play_generic_anim, - fn_teleport, - fn_play_custom_anim, - fn_get_pan_from_nico, - fn_teleport_to_nico, - fn_are_we_on_this_floor, - fn_is_object_on_our_floor, - fn_is_object_on_screen, - fn_is_object_dead, - fn_set_custom, - fn_message, - fn_clear_all_events, - fn_get_state_flag, - fn_check_event_waiting, - fn_event_check_last_sender, - fn_get_last_event_sender_id, - fn_near, - fn_easy_play_custom_anim, - fn_snap_face_object, - fn_teleport_z, - fn_on_screen, - fn_hold_if_off_screen, - fn_mega_interacts, - fn_restart_object, - fn_object_near_nico, - fn_remora_get_mode, - fn_remora_set_mode, - fn_teleport_y_to_id, - fn_call_socket_id, - fn_route_to_nico, - fn_lift_process_list, - fn_add_object_name_to_list, - fn_add_object_id_to_list, - fn_hold_while_list_near_nico, - fn_set_watch, - fn_get_persons_weapon, - fn_kill_me, - fn_kill_object, - fn_set_to_first_frame_custom_anim, - fn_set_to_last_frame_custom_anim, - fn_shut_down_event_processing, - fn_three_sixty_interact, - fn_route_to_marker, - fn_play_mission_xa_music, - fn_play_common_vag_music, - fn_play_mission_vag_music, - fn_near_list, - fn_get_list_result, - fn_play_common_fx, - fn_play_mission_fx, - fn_add_icon_to_icon_list, - fn_remove_icon_from_icon_list, - fn_remora_is_email_waiting, - fn_destroy_icon_list, - fn_remora_send_email, - fn_remora_menu_return, - fn_remora_picture, - fn_remora_clear_screen, - fn_new_apply_bullet, - fn_new_script, - fn_random, - fn_change_session, - fn_changed_sessions, - fn_remora_set_current_zoom, - fn_is_there_interact_object, - fn_get_interact_object_id, - fn_is_object_interact_object, - speak_chosen, - speak_user_chooser, - speak_add_chooser_icon, - fn_remora_add_icon, - fn_remora_remove_icon, - fn_remora_reset_icon_list, - fn_remora_choose, - fn_simple_chi, - fn_chi, - speak_menu_still_active, - speak_menu_choices_remain, - speak_close_menu, - speak_new_menu, - speak_end_conversation, - speak_end_menu, - speak_add_special_chooser_icon, - fn_floor_and_floor_camera_linked, - fn_is_object_adjacent, - fn_is_object_on_this_floor, - fn_get_objects_lvar_value, - fn_mega_generic_interact, - fn_set_objects_lvar_value, - fn_set_object_sight_range, - fn_set_object_sight_height, - fn_is_registered_for_event, - fn_is_object_registered_for_event, - fn_switch_on_the_really_neat_and_special_script_debugging_facility, - fn_switch_off_the_really_neat_and_special_script_debugging_facility, - fn_sound_heard_this, - fn_can_see_in_dark, - fn_mega_never_in_shadow, - fn_message_var, - fn_remora_new_menu_on_icon, - fn_remora_new_menu, - fn_no_logic, - fn_gosub, - fn_set_custom_simple_animator, - fn_sharp_route, - fn_set_custom_button_operated_door, - fn_test_prop_anim, - fn_lift2_process, - fn_post_named_event_to_object_id, - fn_set_custom_auto_door, - fn_switch_to_manual_camera, - fn_cancel_manual_camera, - fn_carrying_how_many, - fn_preload_custom_mega_anim, - fn_remora_wait_on_icon, - fn_reverse_generic_anim, - fn_register_for_auto_interaction, - fn_sound_set_hearing_sensitivity, - fn_suspend_events, - fn_unsuspend_events, - fn_sound_heard_something, - fn_prime_player_history, - fn_inherit_prop_anim_height, - fn_start_chi_following, - fn_init_mega_from_nico, - fn_record_player_interaction, - fn_mega_use_lift, - fn_snap_to_nico_y, - fn_inherit_prop_anim_height_id, - fn_route_to_custom_prop_interact, - fn_route_to_generic_prop_interact, - fn_fetch_chi_mode, - fn_lib_lift_chord_and_chi, - fn_set_interacting, - fn_clear_interacting, - fn_remora_emp_flash, - fn_remora_check_email_id, - fx_widescreen, - fn_remora_mark_email_read, - fn_remora_set_map_knowledge_level, - fn_remora_fix_motion_scan_xz, - fn_remora_update_player, - fn_remora_script_activate, - fn_remora_script_deactivate, - fn_line_of_sight_suspend, - fn_line_of_sight_unsuspend, - fn_check_for_nico, - fn_sony_door_interact, - fn_apply_anim_y, - fn_remora_default_logic, - fn_line_of_sight_now, - fn_play_sfx, - fn_stop_sfx, - fn_set_to_first_frame_generic_anim, - fn_easy_play_generic_anim_with_pan, - speak_set_custom, - speak_play_custom_anim, - fn_check_for_chi, - fn_wait_for_chi, - fn_send_chi_to_this_object, - fn_set_ids_lvar_value, - fn_teleport_to_nico_y, - fn_is_id_the_player, - fn_set_to_exlusive_coords, - fn_chi_wait_for_player_to_move, - fn_set_evil, - fn_remora_menu_return_on_icon, - fn_remora_mega_says, - fn_changed_via_this_shaft, - fn_get_objects_x, - fn_get_objects_y, - fn_get_objects_z, - fn_set_cad_lock_status, - fn_are_we_on_screen, - fn_reset_icon_list, - fn_get_speech_status, - fn_interact_choose, - fn_is_mega_within_area, - fn_get_cad_state_flag, - fn_end_mission, - fn_remora_set_max_zoom, - fn_remora_set_min_zoom, - fn_route_to_near_mega, - fn_stop_chi_following, - fn_set_pose, - fn_is_crouching, - fn_is_armed, - fn_push_player_status, - fn_pop_player_status, - fn_post_third_party_speech, - fn_fast_face_object, - fn_remora_paragraph_text, - fn_remora_main_heading, - fn_remora_sub_heading, - fn_remora_option_text, - fn_remora_warning_text, - fn_object_rerun_logic_context, - fn_interact_near_mega, - fn_am_i_player, - fn_set_shoot_overide, - fn_set_strike_overide, - fn_start_player_interaction, - fn_start_conveyor, - fn_stop_conveyor, - fn_interact_with_id, - fn_face_nicos_pan, - fn_unregister_for_auto_interaction, - fn_register_chi, - fn_add_y, - fn_play_sfx_xyz, - fn_register_stairway, - fn_reverse_custom_anim, - fn_trace, - fn_set_player_has_weapon, - fn_sound_new_entry, - fn_sound_remove_entry, - fn_sound_simulate, - fn_PLEASE_REUSE_THIS_SLOT_2, - fn_PLEASE_REUSE_THIS_SLOT_3, - fn_set_object_type, - fn_register_ladder, - fn_play_movie, - fn_is_an_object_crouching, - fn_align_with_floor, - fn_play_sfx_offset, - fn_play_sfx_time, - fn_add_medipacks, - fn_use_medipacks, - fn_add_ammo_clips, - fn_use_ammo_clips, - fn_load_players_gun, - fn_flash_health, - fn_set_player_pose, - fn_kill_conversations, - fn_is_player_running, - fn_is_player_walking, - fn_set_anim_speed, - fn_push_coords, - fn_pop_coords, - fn_fast_face_coord, - fn_sound_fast_face, - fn_remora_add_floor_range, - fn_remora_reset_floor_ranges, - fn_send_chi_to_named_object, - fx_brighten_to, - fx_brighten_from, - fx_narrow_screen, - fn_sound_route_to_near, - fn_sound_suspend, - fn_sound_unsuspend, - fn_wandering_custom_prop_interact, - fn_wandering_generic_prop_interact, - fn_set_texture, - fn_set_palette, - fn_restart_gamescript, - fn_quick_restart, - fx_generic_fade, - fx_darken_to, - fx_darken_from, - fx_fade_to, - fx_fade_from, - fx_blend, - fn_speech_colour, - fn_is_current_camera, - fn_is_mega_near_mega, - fn_easy_play_custom_anim_with_pan, - fn_make_remora_beep, - fn_shadows_on, - fn_shadows_off, - fn_set_neck_bone, - fn_set_neck_vector, - speak_set_neck_vector, - fn_simple_look, - speak_simple_look, - fn_panless_teleport_to_nico, - fn_can_mega_see_dead_megas, - fn_breath, - fn_set_dynamic_light, - speak_set_dynamic_light, - fn_sharp_route_to_near_mega, - fn_spectre_route_to_mega, - fn_set_shade_percentage, - fn_can_hear_players_feet, - fn_set_screen_offset, - fn_shake_screen, - fn_is_player_striking, - fn_do_not_disturb, - fn_has_mega_our_height, - fn_chi_heard_gunshot, - fn_prime_custom_anim, - fn_preload_basics, - fn_activate_timer, - fn_stop_timer, - fn_play_sfx_special, - fn_set_default_footstep_sfx, - fn_set_floor_footstep_sfx, - fn_set_footstep_weight, - fn_set_special_footstep, - speak_reverse_custom_anim, - speak_preload_custom_anim, - fn_register_platform_coords, - fn_remora_progress_bar, - fn_play_sfx_offset_time, - fn_activate_stair_or_ladder, - fn_deactivate_stair_or_ladder, - fn_set_half_character_width, - fn_set_interact_look_height, - fn_swordfight, - fn_set_visible, - fn_set_object_visible, - fn_calibrate_chi, - fn_set_to_dead, - fn_sound_link_floors, - fn_set_voice_over_colour, - fn_default_voice_over_colour, - fn_remora_blank_line, - fn_set_camera_hold, - fn_set_mega_wait_for_player, - fn_set_mega_off_camera_hold, - fn_set_mega_slice_hold, - fn_set_mesh, - fn_sync_with_mega, - fn_laser_route, - fn_prop_crouch_interact, - fn_preload_sting, - fn_play_sting, - fn_stop_sting, - fn_set_sleep, - speak_allocate_music, - speak_preload_music, - speak_play_music, - speak_stop_music, - speak_end_music, - fn_set_sfx, - fn_wait_for_button, - fn_set_as_player, - fn_lock_y, - fn_unlock_y, - fn_is_current_location, - fn_flip_pan, - fn_snap_to_ladder_top, - fn_snap_to_ladder_bottom, - fn_set_feet_to_pan, - fn_room_route, - fn_hard_load_generic_anim, - fn_hard_load_custom_anim, - fn_activate_sparkle, - fn_deactivate_sparkle, - fn_missing_routine, - fn_missing_routine, - fn_missing_routine, - fn_missing_routine, - fn_missing_routine, + fn_test, + fn_create_mega, + fn_shut_down_object, + fn_prop_animate, + fn_set_voxel_image_path, + fn_set_xyz, + fn_set_to_floor, + fn_init_from_nico_file, + fn_init_from_marker_file, + fn_set_pan, + fn_context_chosen_logic, + fn_tiny_route, + fn_player, + fn_pause, + fn_face_coord, + fn_face_object, + fn_play_generic_anim, + fn_set_player_can_interact, + fn_set_player_cannot_interact, + fn_generic_prop_interact, + fn_custom_prop_interact, + fn_register_for_event, + fn_unregister_for_event, + fn_register_object_for_event, + fn_unregister_object_for_event, + fn_post_event, + fn_post_future_event, + fn_post_repeating_event, + fn_post_named_event_to_object, + fn_register_for_line_of_sight, + fn_unregister_for_line_of_sight, + fn_register_object_for_line_of_sight, + fn_unregister_object_for_line_of_sight, + fn_can_see, + fn_can_object_see, + fn_call_socket, + fn_prop_set_to_last_frame, + fn_prop_set_to_first_frame, + fn_prop_near_a_mega, + socket_force_new_logic, + fn_set_weapon, + fn_set_mega_field_of_view, + fn_apply_bullet, + fn_add_inventory_item, + fn_remove_inventory_item, + fn_is_carrying, + fn_reset_player, + fn_speak, + fn_request_speech, + fn_add_talker, + fn_issue_speech_request, + fn_confirm_requests, + fn_anon_speech_invite, + fn_converse, + speak_object_face_object, + speak_play_generic_anim, + speak_wait_for_everyone, + fn_get_weapon, + fn_rig_test, + fn_is_holding, + fn_drop, + fn_item_held, + fn_set_to_last_frame_generic_anim, + fn_play_common_xa_music, + fn_pass_flag_to_engine, + fn_remora_is_active, + fn_easy_play_generic_anim, + fn_teleport, + fn_play_custom_anim, + fn_get_pan_from_nico, + fn_teleport_to_nico, + fn_are_we_on_this_floor, + fn_is_object_on_our_floor, + fn_is_object_on_screen, + fn_is_object_dead, + fn_set_custom, + fn_message, + fn_clear_all_events, + fn_get_state_flag, + fn_check_event_waiting, + fn_event_check_last_sender, + fn_get_last_event_sender_id, + fn_near, + fn_easy_play_custom_anim, + fn_snap_face_object, + fn_teleport_z, + fn_on_screen, + fn_hold_if_off_screen, + fn_mega_interacts, + fn_restart_object, + fn_object_near_nico, + fn_remora_get_mode, + fn_remora_set_mode, + fn_teleport_y_to_id, + fn_call_socket_id, + fn_route_to_nico, + fn_lift_process_list, + fn_add_object_name_to_list, + fn_add_object_id_to_list, + fn_hold_while_list_near_nico, + fn_set_watch, + fn_get_persons_weapon, + fn_kill_me, + fn_kill_object, + fn_set_to_first_frame_custom_anim, + fn_set_to_last_frame_custom_anim, + fn_shut_down_event_processing, + fn_three_sixty_interact, + fn_route_to_marker, + fn_play_mission_xa_music, + fn_play_common_vag_music, + fn_play_mission_vag_music, + fn_near_list, + fn_get_list_result, + fn_play_common_fx, + fn_play_mission_fx, + fn_add_icon_to_icon_list, + fn_remove_icon_from_icon_list, + fn_remora_is_email_waiting, + fn_destroy_icon_list, + fn_remora_send_email, + fn_remora_menu_return, + fn_remora_picture, + fn_remora_clear_screen, + fn_new_apply_bullet, + fn_new_script, + fn_random, + fn_change_session, + fn_changed_sessions, + fn_remora_set_current_zoom, + fn_is_there_interact_object, + fn_get_interact_object_id, + fn_is_object_interact_object, + speak_chosen, + speak_user_chooser, + speak_add_chooser_icon, + fn_remora_add_icon, + fn_remora_remove_icon, + fn_remora_reset_icon_list, + fn_remora_choose, + fn_simple_chi, + fn_chi, + speak_menu_still_active, + speak_menu_choices_remain, + speak_close_menu, + speak_new_menu, + speak_end_conversation, + speak_end_menu, + speak_add_special_chooser_icon, + fn_floor_and_floor_camera_linked, + fn_is_object_adjacent, + fn_is_object_on_this_floor, + fn_get_objects_lvar_value, + fn_mega_generic_interact, + fn_set_objects_lvar_value, + fn_set_object_sight_range, + fn_set_object_sight_height, + fn_is_registered_for_event, + fn_is_object_registered_for_event, + fn_switch_on_the_really_neat_and_special_script_debugging_facility, + fn_switch_off_the_really_neat_and_special_script_debugging_facility, + fn_sound_heard_this, + fn_can_see_in_dark, + fn_mega_never_in_shadow, + fn_message_var, + fn_remora_new_menu_on_icon, + fn_remora_new_menu, + fn_no_logic, + fn_gosub, + fn_set_custom_simple_animator, + fn_sharp_route, + fn_set_custom_button_operated_door, + fn_test_prop_anim, + fn_lift2_process, + fn_post_named_event_to_object_id, + fn_set_custom_auto_door, + fn_switch_to_manual_camera, + fn_cancel_manual_camera, + fn_carrying_how_many, + fn_preload_custom_mega_anim, + fn_remora_wait_on_icon, + fn_reverse_generic_anim, + fn_register_for_auto_interaction, + fn_sound_set_hearing_sensitivity, + fn_suspend_events, + fn_unsuspend_events, + fn_sound_heard_something, + fn_prime_player_history, + fn_inherit_prop_anim_height, + fn_start_chi_following, + fn_init_mega_from_nico, + fn_record_player_interaction, + fn_mega_use_lift, + fn_snap_to_nico_y, + fn_inherit_prop_anim_height_id, + fn_route_to_custom_prop_interact, + fn_route_to_generic_prop_interact, + fn_fetch_chi_mode, + fn_lib_lift_chord_and_chi, + fn_set_interacting, + fn_clear_interacting, + fn_remora_emp_flash, + fn_remora_check_email_id, + fx_widescreen, + fn_remora_mark_email_read, + fn_remora_set_map_knowledge_level, + fn_remora_fix_motion_scan_xz, + fn_remora_update_player, + fn_remora_script_activate, + fn_remora_script_deactivate, + fn_line_of_sight_suspend, + fn_line_of_sight_unsuspend, + fn_check_for_nico, + fn_sony_door_interact, + fn_apply_anim_y, + fn_remora_default_logic, + fn_line_of_sight_now, + fn_play_sfx, + fn_stop_sfx, + fn_set_to_first_frame_generic_anim, + fn_easy_play_generic_anim_with_pan, + speak_set_custom, + speak_play_custom_anim, + fn_check_for_chi, + fn_wait_for_chi, + fn_send_chi_to_this_object, + fn_set_ids_lvar_value, + fn_teleport_to_nico_y, + fn_is_id_the_player, + fn_set_to_exlusive_coords, + fn_chi_wait_for_player_to_move, + fn_set_evil, + fn_remora_menu_return_on_icon, + fn_remora_mega_says, + fn_changed_via_this_shaft, + fn_get_objects_x, + fn_get_objects_y, + fn_get_objects_z, + fn_set_cad_lock_status, + fn_are_we_on_screen, + fn_reset_icon_list, + fn_get_speech_status, + fn_interact_choose, + fn_is_mega_within_area, + fn_get_cad_state_flag, + fn_end_mission, + fn_remora_set_max_zoom, + fn_remora_set_min_zoom, + fn_route_to_near_mega, + fn_stop_chi_following, + fn_set_pose, + fn_is_crouching, + fn_is_armed, + fn_push_player_status, + fn_pop_player_status, + fn_post_third_party_speech, + fn_fast_face_object, + fn_remora_paragraph_text, + fn_remora_main_heading, + fn_remora_sub_heading, + fn_remora_option_text, + fn_remora_warning_text, + fn_object_rerun_logic_context, + fn_interact_near_mega, + fn_am_i_player, + fn_set_shoot_overide, + fn_set_strike_overide, + fn_start_player_interaction, + fn_start_conveyor, + fn_stop_conveyor, + fn_interact_with_id, + fn_face_nicos_pan, + fn_unregister_for_auto_interaction, + fn_register_chi, + fn_add_y, + fn_play_sfx_xyz, + fn_register_stairway, + fn_reverse_custom_anim, + fn_trace, + fn_set_player_has_weapon, + fn_sound_new_entry, + fn_sound_remove_entry, + fn_sound_simulate, + fn_PLEASE_REUSE_THIS_SLOT_2, + fn_PLEASE_REUSE_THIS_SLOT_3, + fn_set_object_type, + fn_register_ladder, + fn_play_movie, + fn_is_an_object_crouching, + fn_align_with_floor, + fn_play_sfx_offset, + fn_play_sfx_time, + fn_add_medipacks, + fn_use_medipacks, + fn_add_ammo_clips, + fn_use_ammo_clips, + fn_load_players_gun, + fn_flash_health, + fn_set_player_pose, + fn_kill_conversations, + fn_is_player_running, + fn_is_player_walking, + fn_set_anim_speed, + fn_push_coords, + fn_pop_coords, + fn_fast_face_coord, + fn_sound_fast_face, + fn_remora_add_floor_range, + fn_remora_reset_floor_ranges, + fn_send_chi_to_named_object, + fx_brighten_to, + fx_brighten_from, + fx_narrow_screen, + fn_sound_route_to_near, + fn_sound_suspend, + fn_sound_unsuspend, + fn_wandering_custom_prop_interact, + fn_wandering_generic_prop_interact, + fn_set_texture, + fn_set_palette, + fn_restart_gamescript, + fn_quick_restart, + fx_generic_fade, + fx_darken_to, + fx_darken_from, + fx_fade_to, + fx_fade_from, + fx_blend, + fn_speech_colour, + fn_is_current_camera, + fn_is_mega_near_mega, + fn_easy_play_custom_anim_with_pan, + fn_make_remora_beep, + fn_shadows_on, + fn_shadows_off, + fn_set_neck_bone, + fn_set_neck_vector, + speak_set_neck_vector, + fn_simple_look, + speak_simple_look, + fn_panless_teleport_to_nico, + fn_can_mega_see_dead_megas, + fn_breath, + fn_set_dynamic_light, + speak_set_dynamic_light, + fn_sharp_route_to_near_mega, + fn_spectre_route_to_mega, + fn_set_shade_percentage, + fn_can_hear_players_feet, + fn_set_screen_offset, + fn_shake_screen, + fn_is_player_striking, + fn_do_not_disturb, + fn_has_mega_our_height, + fn_chi_heard_gunshot, + fn_prime_custom_anim, + fn_preload_basics, + fn_activate_timer, + fn_stop_timer, + fn_play_sfx_special, + fn_set_default_footstep_sfx, + fn_set_floor_footstep_sfx, + fn_set_footstep_weight, + fn_set_special_footstep, + speak_reverse_custom_anim, + speak_preload_custom_anim, + fn_register_platform_coords, + fn_remora_progress_bar, + fn_play_sfx_offset_time, + fn_activate_stair_or_ladder, + fn_deactivate_stair_or_ladder, + fn_set_half_character_width, + fn_set_interact_look_height, + fn_swordfight, + fn_set_visible, + fn_set_object_visible, + fn_calibrate_chi, + fn_set_to_dead, + fn_sound_link_floors, + fn_set_voice_over_colour, + fn_default_voice_over_colour, + fn_remora_blank_line, + fn_set_camera_hold, + fn_set_mega_wait_for_player, + fn_set_mega_off_camera_hold, + fn_set_mega_slice_hold, + fn_set_mesh, + fn_sync_with_mega, + fn_laser_route, + fn_prop_crouch_interact, + fn_preload_sting, + fn_play_sting, + fn_stop_sting, + fn_set_sleep, + speak_allocate_music, + speak_preload_music, + speak_play_music, + speak_stop_music, + speak_end_music, + fn_set_sfx, + fn_wait_for_button, + fn_set_as_player, + fn_lock_y, + fn_unlock_y, + fn_is_current_location, + fn_flip_pan, + fn_snap_to_ladder_top, + fn_snap_to_ladder_bottom, + fn_set_feet_to_pan, + fn_room_route, + fn_hard_load_generic_anim, + fn_hard_load_custom_anim, + fn_activate_sparkle, + fn_deactivate_sparkle, + fn_missing_routine, + fn_missing_routine, + fn_missing_routine, + fn_missing_routine, + fn_missing_routine, }; } // End of namespace ICB diff --git a/engines/icb/game_volume.cpp b/engines/icb/game_volume.cpp index 324f565297f..03c1da35cd8 100644 --- a/engines/icb/game_volume.cpp +++ b/engines/icb/game_volume.cpp @@ -77,9 +77,9 @@ void _game_volume::SetUpParameters(_linked_data_file *pyLOSData) { } bool8 _game_volume::GetCubeAndIndices(const px3DRealPoint &oPoint, // IN: The current point in space. - _XYZ_index &oIndex, // OUT: The XYZ array index containing the point. - _bullet_cube &oCube // OUT: Dimensions of the cube represented by the index. - ) const { + _XYZ_index &oIndex, // OUT: The XYZ array index containing the point. + _bullet_cube &oCube // OUT: Dimensions of the cube represented by the index. + ) const { int32 nIndex; int32 nLeastSide; uint32 nSlice; diff --git a/engines/icb/gfx/gfxstub.h b/engines/icb/gfx/gfxstub.h index 086084cdbe3..6ec378dffa7 100644 --- a/engines/icb/gfx/gfxstub.h +++ b/engines/icb/gfx/gfxstub.h @@ -82,7 +82,7 @@ int32 DrawLineG3(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, uin // three connected lines gouraud coloured : 4 points, 4 colours int32 DrawLineG4(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, uint8 r0, uint8 g0, uint8 b0, uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2, uint8 r3, - uint8 g3, uint8 b3, uint8 alpha, uint16 z); + uint8 g3, uint8 b3, uint8 alpha, uint16 z); // Simple flat coloured triangle : 3 points, 1 colour int32 DrawFlatTriangle(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, uint8 r0, uint8 g0, uint8 b0, uint8 alpha, uint16 z); @@ -92,27 +92,27 @@ int32 DrawFlatQuad(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, i // Simple gouraud coloured triangle : 3 points, 3 colours int32 DrawGouraudTriangle(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, uint8 r0, uint8 g0, uint8 b0, uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2, uint8 alpha, - uint16 z); + uint16 z); // Simple gouraud coloured quad : 4 points, 4 colours int32 DrawGouraudQuad(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, uint8 r0, uint8 g0, uint8 b0, uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2, - uint8 r3, uint8 g3, uint8 b3, uint8 alpha, uint16 z); + uint8 r3, uint8 g3, uint8 b3, uint8 alpha, uint16 z); // Simple flat coloured triangle : 3 points, 1 colour, 3 UV's int32 DrawFlatTriangleTextured(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, uint8 r0, uint8 g0, uint8 b0, uint16 u0, uint16 v0, uint16 u1, uint16 v1, uint16 u2, uint16 v2, - uint8 alpha, uint16 z, void *tex); + uint8 alpha, uint16 z, void *tex); // Simple flat coloured quad : 4 points, 1 colour, 4 UV's int32 DrawFlatQuadTextured(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, uint8 r0, uint8 g0, uint8 b0, uint16 u0, uint16 v0, uint16 u1, uint16 v1, uint16 u2, - uint16 v2, uint16 u3, uint16 v3, uint8 alpha, uint16 z, void *tex); + uint16 v2, uint16 u3, uint16 v3, uint8 alpha, uint16 z, void *tex); // Simple gouraud coloured triangle : 3 points, 3 colours int32 DrawGouraudTriangleTextured(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, uint8 r0, uint8 g0, uint8 b0, uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2, - uint16 u0, uint16 v0, uint16 u1, uint16 v1, uint16 u2, uint16 v2, uint8 alpha, uint16 z, void *tex); + uint16 u0, uint16 v0, uint16 u1, uint16 v1, uint16 u2, uint16 v2, uint8 alpha, uint16 z, void *tex); // Simple gouraud coloured quad : 4 points, 4 colours int32 DrawGouraudQuadTextured(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, uint8 r0, uint8 g0, uint8 b0, uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, - uint8 b2, uint8 r3, uint8 g3, uint8 b3, uint16 u0, uint16 v0, uint16 u1, uint16 v1, uint16 u2, uint16 v2, uint16 u3, uint16 v3, uint8 alpha, - uint16 z, void *tex); + uint8 b2, uint8 r3, uint8 g3, uint8 b3, uint16 u0, uint16 v0, uint16 u1, uint16 v1, uint16 u2, uint16 v2, uint16 u3, uint16 v3, uint8 alpha, + uint16 z, void *tex); } // End of namespace ICB diff --git a/engines/icb/gfx/gfxstub_rev.cpp b/engines/icb/gfx/gfxstub_rev.cpp index b02ee2e7117..9e0b0ea7e67 100644 --- a/engines/icb/gfx/gfxstub_rev.cpp +++ b/engines/icb/gfx/gfxstub_rev.cpp @@ -742,7 +742,7 @@ int32 DrawLineG3(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, uin // three connected lines gouraud coloured : 4 points, 4 colours int32 DrawLineG4(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, uint8 r0, uint8 g0, uint8 b0, uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2, uint8 r3, - uint8 g3, uint8 b3, uint8 alpha, uint16 z) { + uint8 g3, uint8 b3, uint8 alpha, uint16 z) { DrawLineG2(x0, y0, x1, y1, r0, g0, b0, r1, g1, b1, alpha, z); DrawLineG2(x1, y1, x2, y2, r1, g1, b1, r2, g2, b2, alpha, z); DrawLineG2(x2, y2, x3, y3, r2, g2, b2, r3, g3, b3, alpha, z); @@ -832,7 +832,7 @@ int32 DrawFlatQuad(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, i // Simple gouraud coloured triangle : 3 points, 3 colours int32 DrawGouraudTriangle(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, uint8 r0, uint8 g0, uint8 b0, uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2, uint8 alpha, - uint16 z) { + uint16 z) { verts[0].x = (RGBWidth / 2 + x0) << 16; verts[0].y = (RGBHeight / 2 + y0) << 16; verts[1].x = (RGBWidth / 2 + x1) << 16; @@ -873,7 +873,7 @@ int32 DrawGouraudTriangle(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int3 // Simple gouraud coloured quad : 4 points, 4 colours int32 DrawGouraudQuad(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, uint8 r0, uint8 g0, uint8 b0, uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2, - uint8 r3, uint8 g3, uint8 b3, uint8 alpha, uint16 z) { + uint8 r3, uint8 g3, uint8 b3, uint8 alpha, uint16 z) { // Input Quad is : // 0----1 // | | @@ -920,7 +920,7 @@ int32 DrawGouraudQuad(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2 // Simple flat coloured triangle : 3 points, 1 colour, 3 UV's // r0, g0, b0 : 128 means colour scale of 1.0 int32 DrawFlatTriangleTextured(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, uint8 r0, uint8 g0, uint8 b0, uint16 u0, uint16 v0, uint16 u1, uint16 v1, uint16 u2, uint16 v2, - uint8 alpha, uint16 z, void *tex) { + uint8 alpha, uint16 z, void *tex) { verts[0].x = (RGBWidth / 2 + x0) << 16; verts[0].y = (RGBHeight / 2 + y0) << 16; verts[1].x = (RGBWidth / 2 + x1) << 16; @@ -980,7 +980,7 @@ int32 DrawFlatTriangleTextured(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, // Simple flat coloured quad : 4 points, 1 colour, 4 UV's // r0, g0, b0 : 128 means colour scale of 1.0 int32 DrawFlatQuadTextured(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, uint8 r0, uint8 g0, uint8 b0, uint16 u0, uint16 v0, uint16 u1, uint16 v1, uint16 u2, - uint16 v2, uint16 u3, uint16 v3, uint8 alpha, uint16 z, void *tex) { + uint16 v2, uint16 u3, uint16 v3, uint8 alpha, uint16 z, void *tex) { // Input Quad is : // 0----1 // | | @@ -1049,7 +1049,7 @@ int32 tempor = 0; // Simple gouraud coloured triangle : 3 points, 3 colours // r0, g0, b0 : 128 means colour scale of 1.0 int32 DrawGouraudTriangleTextured(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, uint8 r0, uint8 g0, uint8 b0, uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2, - uint16 u0, uint16 v0, uint16 u1, uint16 v1, uint16 u2, uint16 v2, uint8 alpha, uint16 z, void *tex) { + uint16 u0, uint16 v0, uint16 u1, uint16 v1, uint16 u2, uint16 v2, uint8 alpha, uint16 z, void *tex) { verts[0].x = (RGBWidth / 2 + x0) << 16; verts[0].y = (RGBHeight / 2 + y0) << 16; verts[1].x = (RGBWidth / 2 + x1) << 16; @@ -1111,8 +1111,8 @@ int32 DrawGouraudTriangleTextured(int32 x0, int32 y0, int32 x1, int32 y1, int32 // Simple gouraud coloured quad : 4 points, 4 colours // r0, g0, b0 : 128 means colour scale of 1.0 int32 DrawGouraudQuadTextured(int32 x0, int32 y0, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, uint8 r0, uint8 g0, uint8 b0, uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, - uint8 b2, uint8 r3, uint8 g3, uint8 b3, uint16 u0, uint16 v0, uint16 u1, uint16 v1, uint16 u2, uint16 v2, uint16 u3, uint16 v3, uint8 alpha, - uint16 z, void *tex) { + uint8 b2, uint8 r3, uint8 g3, uint8 b3, uint16 u0, uint16 v0, uint16 u1, uint16 v1, uint16 u2, uint16 v2, uint16 u3, uint16 v3, uint8 alpha, + uint16 z, void *tex) { // Input Quad is : // 0----1 // | | diff --git a/engines/icb/gfx/psx_pchmd.h b/engines/icb/gfx/psx_pchmd.h index c623bd077e5..9f017e93dcb 100644 --- a/engines/icb/gfx/psx_pchmd.h +++ b/engines/icb/gfx/psx_pchmd.h @@ -55,8 +55,8 @@ const int32 HMD_GTL3_SIZE = 6; const int32 TRIANGLE_SIZE = 2; int32 decodeHMDpolygon(uint32 primType, uint32 pcplatform, uint32 *&pp, uint32 &code0, uint32 &r0, uint32 &g0, uint32 &b0, uint32 &code1, uint32 &r1, uint32 &g1, uint32 &b1, uint32 &code2, uint32 &r2, - uint32 &g2, uint32 &b2, uint32 &u0, uint32 &v0, uint32 &u1, uint32 &v1, uint32 &u2, uint32 &v2, uint32 &cba, uint32 &cx, uint32 &cy, uint32 &tsb, uint32 &tp, uint32 &n0, uint32 &vert0, - uint32 &n1, uint32 &vert1, uint32 &n2, uint32 &vert2, uint32 dump); + uint32 &g2, uint32 &b2, uint32 &u0, uint32 &v0, uint32 &u1, uint32 &v1, uint32 &u2, uint32 &v2, uint32 &cba, uint32 &cx, uint32 &cy, uint32 &tsb, uint32 &tp, uint32 &n0, uint32 &vert0, + uint32 &n1, uint32 &vert1, uint32 &n2, uint32 &vert2, uint32 dump); // Handy structures for decoding polygon information diff --git a/engines/icb/gfx/psx_props.h b/engines/icb/gfx/psx_props.h index 86d2e97ace8..451659e7d75 100644 --- a/engines/icb/gfx/psx_props.h +++ b/engines/icb/gfx/psx_props.h @@ -46,36 +46,36 @@ namespace ICB { uint32 cmOffsets[nCms]; // cmOffsets[nCms]; propcmStruct props[propQty]; { - char* name; - uint32 stateQty; - } + char* name; + uint32 stateQty; + } // This is the actual construction matrix and where the cmOffsets point to cmStruct cm[cmQty]; { - uint32 propQty; // currently always 1 but is likely to change - uint32 propNameOffset; - uint32 width; // how many bits in the CM table - uint32 stateQty; // how many states - uint32 statePtrs[stateQty]; // points to a psxPropLayers struct - { - int16 xs, xe; - int16 ys, ye; - uint16 zs, ze; - uint16 w, h; - uint32 n; - uint32 zoverlayOffset; // relative bytes from state start to zoverlay - uint32 zOffset; // relative bytes from state start to z data; - uint16 palette[256]; - uint8 rgbData[w*h] - uint8 zdata[w*h]; - psxZOverlay layers[n] - { - int16 xs, xe; - int16 ys, ye; - uint16 zs, ze; - uint16 dZScale, dZShift; - } - } + uint32 propQty; // currently always 1 but is likely to change + uint32 propNameOffset; + uint32 width; // how many bits in the CM table + uint32 stateQty; // how many states + uint32 statePtrs[stateQty]; // points to a psxPropLayers struct + { + int16 xs, xe; + int16 ys, ye; + uint16 zs, ze; + uint16 w, h; + uint32 n; + uint32 zoverlayOffset; // relative bytes from state start to zoverlay + uint32 zOffset; // relative bytes from state start to z data; + uint16 palette[256]; + uint8 rgbData[w*h] + uint8 zdata[w*h]; + psxZOverlay layers[n] + { + int16 xs, xe; + int16 ys, ye; + uint16 zs, ze; + uint16 dZScale, dZShift; + } + } } */ @@ -88,35 +88,35 @@ namespace ICB { uint32 cmOffsets[nCms]; // cmOffsets[nCms]; propcmStruct props[propQty]; { - char* name; - uint32 stateQty; - } + char* name; + uint32 stateQty; + } // This is the actual construction matrix and where the cmOffsets point to cmStruct cm[cmQty]; { - uint32 propQty; // currently always 1 but is likely to change - uint32 propNameOffset; - uint32 width; // how many bits in the CM table - uint32 stateQty; // how many states - uint32 statePtrs[stateQty]; // points to a psxPropLayers struct - { - int16 xs, xe; - int16 ys, ye; - uint16 zs, ze; - uint16 w, h; - uint32 n; - uint32 zoverlayOffset; // relative bytes from state start to zoverlay - uint32 zOffset; // relative bytes from state start to z data; - _pxPSXBitmap bitmap; // compress PSX Bitmap format inc. palette - uint8 zdata[w*h]; - psxZOverlay layers[n] - { - int16 xs, xe; - int16 ys, ye; - uint16 zs, ze; - uint16 dZScale, dZShift; - } - } + uint32 propQty; // currently always 1 but is likely to change + uint32 propNameOffset; + uint32 width; // how many bits in the CM table + uint32 stateQty; // how many states + uint32 statePtrs[stateQty]; // points to a psxPropLayers struct + { + int16 xs, xe; + int16 ys, ye; + uint16 zs, ze; + uint16 w, h; + uint32 n; + uint32 zoverlayOffset; // relative bytes from state start to zoverlay + uint32 zOffset; // relative bytes from state start to z data; + _pxPSXBitmap bitmap; // compress PSX Bitmap format inc. palette + uint8 zdata[w*h]; + psxZOverlay layers[n] + { + int16 xs, xe; + int16 ys, ye; + uint16 zs, ze; + uint16 dZScale, dZShift; + } + } } */ @@ -128,24 +128,24 @@ namespace ICB { uint32 propOffsets[propQty]; // propOffsets[propQty]; psxPropInfo propInfo[propQty]; { - char* name; - uint32 stateQty; + char* name; + uint32 stateQty; } psxProp props[propQty]; { - uint32 stateQty; // how many states - uint32 propNameOffset; - uint32 statePtrs[stateQty]; // points to a psxPropState struct - psxPropState propStates[stateQty]; - { - int16 xs, xe; - int16 ys, ye; - uint16 zs, ze; - uint16 w, h; - uint16 nPropRGBsprites; - uint16 nBgRGBsprites; - _pxPSXBitmap propBitmap; // compressed PSX Bitmap inc. palette - } + uint32 stateQty; // how many states + uint32 propNameOffset; + uint32 statePtrs[stateQty]; // points to a psxPropState struct + psxPropState propStates[stateQty]; + { + int16 xs, xe; + int16 ys, ye; + uint16 zs, ze; + uint16 w, h; + uint16 nPropRGBsprites; + uint16 nBgRGBsprites; + _pxPSXBitmap propBitmap; // compressed PSX Bitmap inc. palette + } } */ @@ -157,28 +157,28 @@ namespace ICB { uint32 propOffsets[propQty]; // propOffsets[propQty]; psxPropInfo propInfo[propQty]; { - char* name; - uint32 stateQty; + char* name; + uint32 stateQty; } psxProp props[propQty]; { - uint32 stateQty; // how many states - uint32 propNameOffset; - uint32 statePtrs[stateQty]; // points to a psxPropState struct - psxPropState propStates[stateQty]; - { - int16 xs, xe; - int16 ys, ye; - uint16 zs, ze; - uint16 w, h; - uint16 nPropRGBsprites; - uint16 nBgRGBsprites; - uint32 zMicroOffset; - uint32 propBitmapOffset; - psxZMacroFrag zMacro[nPropRGBsprites]; - psxZMicroFrag zMicro[nMicroFrags]; - _pxPSXBitmap propBitmap; // compressed PSX Bitmap inc. palette - } + uint32 stateQty; // how many states + uint32 propNameOffset; + uint32 statePtrs[stateQty]; // points to a psxPropState struct + psxPropState propStates[stateQty]; + { + int16 xs, xe; + int16 ys, ye; + uint16 zs, ze; + uint16 w, h; + uint16 nPropRGBsprites; + uint16 nBgRGBsprites; + uint32 zMicroOffset; + uint32 propBitmapOffset; + psxZMacroFrag zMacro[nPropRGBsprites]; + psxZMicroFrag zMicro[nMicroFrags]; + _pxPSXBitmap propBitmap; // compressed PSX Bitmap inc. palette + } } */ @@ -190,34 +190,34 @@ namespace ICB { uint32 propOffsets[propQty]; // propOffsets[propQty]; psxPropInfo propInfo[propQty]; { - char* name; - uint32 stateQty; + char* name; + uint32 stateQty; } psxProp props[propQty]; { - uint32 stateQty; // how many states - uint32 propNameOffset; - uint32 statePtrs[stateQty]; // points to a psxPropState struct - psxPropState propStates[stateQty]; - { - int16 xs, xe; - int16 ys, ye; - uint16 zs, ze; - uint16 w, h; + uint32 stateQty; // how many states + uint32 propNameOffset; + uint32 statePtrs[stateQty]; // points to a psxPropState struct + psxPropState propStates[stateQty]; + { + int16 xs, xe; + int16 ys, ye; + uint16 zs, ze; + uint16 w, h; - uint16 nPropZsprites; - uint16 nPropFGZsprites; - uint16 nPropBGZsprites; - uint16 padding; + uint16 nPropZsprites; + uint16 nPropFGZsprites; + uint16 nPropBGZsprites; + uint16 padding; - uint16 nPropRGBsprites; - uint16 nBgRGBsprites; - uint32 zMicroOffset; - uint32 propBitmapOffset; - psxZMacroFrag zMacro[nPropRGBsprites]; - psxZMicroFrag zMicro[nMicroFrags]; - _pxPSXBitmap propBitmap; // compressed PSX Bitmap inc. palette - } + uint16 nPropRGBsprites; + uint16 nBgRGBsprites; + uint32 zMicroOffset; + uint32 propBitmapOffset; + psxZMacroFrag zMacro[nPropRGBsprites]; + psxZMicroFrag zMicro[nMicroFrags]; + _pxPSXBitmap propBitmap; // compressed PSX Bitmap inc. palette + } } */ diff --git a/engines/icb/global_objects.cpp b/engines/icb/global_objects.cpp index a4f5ebde580..6fffb9b4c33 100644 --- a/engines/icb/global_objects.cpp +++ b/engines/icb/global_objects.cpp @@ -146,33 +146,33 @@ const char *g_mission_names[NUMBER_OF_MISSIONS] = { }; const char *g_sessions[MAX_SESSIONS] = {"m01_investigate_mine", "mine", - "m01_investigate_mine", "mineworkings", - "m01_investigate_mine", "office_building", - "m02_security_hq", "basement", - "m02_security_hq", "ground_floor", - "m02_security_hq", "first_floor", - "m03_land_train", "car_1", - "m03_land_train", "car_2", - "m03_land_train", "car_3", - "m03_land_train", "car_4", - "m03_land_train", "car_5", - "m04_raid_on_containment", "level_alphabeta", - "m04_raid_on_containment", "level_kappa", - "m04_raid_on_containment", "level_omega", - "m05_sabotage_refinery", "m5_mine", - "m05_sabotage_refinery", "m5_office_building", - "m05_sabotage_refinery", "refinery", - "m07_mainland_base", "compound", - "m07_mainland_base", "monorail__station", - "m07_mainland_base", "cable_car_building", - "m08_entering_island_base", "cable_car_dock", - "m08_entering_island_base", "manufacturing", - "m08_entering_island_base", "quayside", - "m08_entering_island_base", "reactor", - "m08_entering_island_base", "security", - "m10_submarine", "submarine", - "test_mission", "test_mission", - "test_mission", "test_session_2", - "m_ed", "2_ship"}; + "m01_investigate_mine", "mineworkings", + "m01_investigate_mine", "office_building", + "m02_security_hq", "basement", + "m02_security_hq", "ground_floor", + "m02_security_hq", "first_floor", + "m03_land_train", "car_1", + "m03_land_train", "car_2", + "m03_land_train", "car_3", + "m03_land_train", "car_4", + "m03_land_train", "car_5", + "m04_raid_on_containment", "level_alphabeta", + "m04_raid_on_containment", "level_kappa", + "m04_raid_on_containment", "level_omega", + "m05_sabotage_refinery", "m5_mine", + "m05_sabotage_refinery", "m5_office_building", + "m05_sabotage_refinery", "refinery", + "m07_mainland_base", "compound", + "m07_mainland_base", "monorail__station", + "m07_mainland_base", "cable_car_building", + "m08_entering_island_base", "cable_car_dock", + "m08_entering_island_base", "manufacturing", + "m08_entering_island_base", "quayside", + "m08_entering_island_base", "reactor", + "m08_entering_island_base", "security", + "m10_submarine", "submarine", + "test_mission", "test_mission", + "test_mission", "test_session_2", + "m_ed", "2_ship"}; } // End of namespace ICB diff --git a/engines/icb/graphic_prims.h b/engines/icb/graphic_prims.h index 6fbbf2f045e..d1957ae3f56 100644 --- a/engines/icb/graphic_prims.h +++ b/engines/icb/graphic_prims.h @@ -76,17 +76,17 @@ void Draw_horizontal_line(int32 xx, int32 yy, uint32 len, _rgb *pen, uint8 *ad, void Draw_vertical_line(int32 xx, int32 yy, uint32 len, _rgb *pen, uint8 *ad, uint32 pitch); void Fill_rect(int32 x, int32 y, int32 x2, int32 y2, uint32 pen, int32 z = 0); void General_draw_line_24_32(int16 x0, int16 y0, int16 x1, int16 y1, _rgb *colour, uint8 *myScreenBuffer, uint32 pitch, int32 surface_width = SCREEN_WIDTH, - int32 surface_height = SCREEN_DEPTH); + int32 surface_height = SCREEN_DEPTH); void General_poly_draw_24_32(_point *pVerts, int32 nNumVerts, _rgb sColour, bool8 bFill, uint8 *pSurface, int32 nPitch, int32 nSurfaceWidth, int32 nSurfaceHeight); // This draws a sprite to a surface, using the x, y found in the sprite itself. void SpriteFrameDraw(uint8 *pSurfaceBitmap, uint32 nPitch, uint32 nSurfaceWidth, uint32 nSurfaceHeight, _pxBitmap *pBitmap, uint32 nFrameNumber, uint32 *nTransparencyRef, - uint8 nOpacity); + uint8 nOpacity); // This draws a sprite to a surface, using a supplied x, y, so the sprite can be moved on the surface. void SpriteXYFrameDraw(uint8 *pSurfaceBitmap, uint32 nPitch, uint32 nSurfaceWidth, uint32 nSurfaceHeight, _pxBitmap *pBitmap, int32 nX, int32 nY, uint32 nFrameNumber, - bool8 bCentre, uint32 *nTransparencyRef, uint8 nOpacity); + bool8 bCentre, uint32 *nTransparencyRef, uint8 nOpacity); // These all make LRECTs (needed by Direct-X) from various sources. LRECT ConvertPxBitmapRectToRECT(const _PxBitmapRect &sBitmapRect); diff --git a/engines/icb/graphic_prims_pc.cpp b/engines/icb/graphic_prims_pc.cpp index 629b64dea0f..5aa4cddbebe 100644 --- a/engines/icb/graphic_prims_pc.cpp +++ b/engines/icb/graphic_prims_pc.cpp @@ -36,7 +36,7 @@ typedef struct { int32 nX, nY; } Span; // This function is used only inside this file. static void RawSpriteDraw(uint8 *pSurfaceBitmap, uint32 nPitch, uint32 nSurfaceWidth, uint32 nSurfaceHeight, _pxSprite *pSprite, uint8 *pPalette, int32 nX, int32 nY, - uint32 *nTransparencyRef, uint8 nOpacity); + uint32 *nTransparencyRef, uint8 nOpacity); void Draw_horizontal_line(int32 xx, int32 yy, uint32 len, _rgb *pen, uint8 *ad, uint32 pitch) { // viewport coordinates @@ -843,14 +843,14 @@ void BlendedLine(int32 x0, int32 y0, int32 x1, int32 y1, _rgb c, int32 surface_w } void SpriteFrameDraw(uint8 *pSurfaceBitmap, // IN: Pointer to the surface's drawing area. - uint32 nPitch, // IN: Pitch for the surface. - uint32 nSurfaceWidth, // IN: Width of the surface. - uint32 nSurfaceHeight, // IN: Height of the surface. - _pxBitmap *pBitmap, // IN: Pointer to the bitmap to render. - uint32 nFrameNumber, // IN: Frame to draw. - uint32 *pnTransparencyRef, // IN: Colour to use for transparency. - uint8 nOpacity // IN: Opacity 0-255 to draw sprite into surface. - ) { + uint32 nPitch, // IN: Pitch for the surface. + uint32 nSurfaceWidth, // IN: Width of the surface. + uint32 nSurfaceHeight, // IN: Height of the surface. + _pxBitmap *pBitmap, // IN: Pointer to the bitmap to render. + uint32 nFrameNumber, // IN: Frame to draw. + uint32 *pnTransparencyRef, // IN: Colour to use for transparency. + uint8 nOpacity // IN: Opacity 0-255 to draw sprite into surface. + ) { uint8 *pPalette; _pxSprite *pSprite; @@ -865,17 +865,17 @@ void SpriteFrameDraw(uint8 *pSurfaceBitmap, // IN: Pointer to the surface's } void SpriteXYFrameDraw(uint8 *pSurfaceBitmap, // IN: Pointer to the surface's drawing area. - uint32 nPitch, // IN: Pitch for the surface. - uint32 nSurfaceWidth, // IN: Width of the surface. - uint32 nSurfaceHeight, // IN: Height of the surface. - _pxBitmap *pBitmap, // IN: Pointer to the bitmap to render. - int32 nX, // IN: X-position to draw sprite at (relative to the surface). - int32 nY, // IN: Y-position to draw sprite at (relative to the surface). - uint32 nFrameNumber, // IN: Frame to draw. - bool8 bCenter, // IN: If true, centre the sprite. - uint32 *pnTransparencyRef, // IN: Colour to use for transparency. - uint8 nOpacity // IN: Opacity 0-255 to draw sprite into surface. - ) { + uint32 nPitch, // IN: Pitch for the surface. + uint32 nSurfaceWidth, // IN: Width of the surface. + uint32 nSurfaceHeight, // IN: Height of the surface. + _pxBitmap *pBitmap, // IN: Pointer to the bitmap to render. + int32 nX, // IN: X-position to draw sprite at (relative to the surface). + int32 nY, // IN: Y-position to draw sprite at (relative to the surface). + uint32 nFrameNumber, // IN: Frame to draw. + bool8 bCenter, // IN: If true, centre the sprite. + uint32 *pnTransparencyRef, // IN: Colour to use for transparency. + uint8 nOpacity // IN: Opacity 0-255 to draw sprite into surface. + ) { uint8 *pPalette; _pxSprite *pSprite; @@ -896,16 +896,16 @@ void SpriteXYFrameDraw(uint8 *pSurfaceBitmap, // IN: Pointer to the surface } void RawSpriteDraw(uint8 *pSurfaceBitmap, // IN: Pointer to the surface's drawing area. - uint32 nPitch, // IN: Pitch for the surface. - uint32 nSurfaceWidth, // IN: Width of surface in pixels. - uint32 nSurfaceHeight, // IN: Height of surface in pixels. - _pxSprite *pSprite, // IN: Pointer to one frame of a sprite. - uint8 *pPalette, // IN: Pointer to the palette. - int32 nX, // IN: X-position to draw sprite at (relative to the surface). - int32 nY, // IN: Y-position to draw sprite at (relative to the surface). - uint32 *pnTransparentRef, // IN: Colour to use for transparency. - uint8 nOpacity // IN: If true, pixels are blended into the surface. - ) { + uint32 nPitch, // IN: Pitch for the surface. + uint32 nSurfaceWidth, // IN: Width of surface in pixels. + uint32 nSurfaceHeight, // IN: Height of surface in pixels. + _pxSprite *pSprite, // IN: Pointer to one frame of a sprite. + uint8 *pPalette, // IN: Pointer to the palette. + int32 nX, // IN: X-position to draw sprite at (relative to the surface). + int32 nY, // IN: Y-position to draw sprite at (relative to the surface). + uint32 *pnTransparentRef, // IN: Colour to use for transparency. + uint8 nOpacity // IN: If true, pixels are blended into the surface. + ) { uint32 x, y; uint32 *pSurfaceRowStart32; uint8 *pSurfaceRowStart8; diff --git a/engines/icb/icon_menu.h b/engines/icb/icon_menu.h index 65a2e60aed4..1ff9bd932a4 100644 --- a/engines/icb/icon_menu.h +++ b/engines/icb/icon_menu.h @@ -143,7 +143,7 @@ public: // These are used for PSX smoothing. (Won't do any harm on the PC.) void PreloadIcon(const char *pcIconPath, const char *pcIconName); - private: +private: int32 GetScrollingPosition(const int32 nInputX, uint32 &nIconIndex); enum IconMenuGameState { INACTIVE = 0, ACTIVE }; diff --git a/engines/icb/jpeg.cpp b/engines/icb/jpeg.cpp index 410125fd77b..9963a654e6c 100644 --- a/engines/icb/jpeg.cpp +++ b/engines/icb/jpeg.cpp @@ -50,12 +50,12 @@ namespace ICB { // These values are the inverse of those shown in the // JPEG standard. const uint32 JpegZigZagInputOrderCodes[JpegSampleSize] = {0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, - 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, - 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63}; + 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, + 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63}; const uint32 JpegZigZagOutputOrderCodes[JpegSampleSize] = {0, 1, 5, 6, 14, 15, 27, 28, 2, 4, 7, 13, 16, 26, 29, 42, 3, 8, 12, 17, 25, 30, - 41, 43, 9, 11, 18, 24, 31, 40, 44, 53, 10, 19, 23, 32, 39, 45, 52, 54, 20, 21, 33, 38, - 46, 51, 55, 60, 21, 34, 37, 47, 50, 56, 59, 61, 35, 36, 48, 49, 57, 58, 62, 63}; + 41, 43, 9, 11, 18, 24, 31, 40, 44, 53, 10, 19, 23, 32, 39, 45, 52, 54, 20, 21, 33, 38, + 46, 51, 55, 60, 21, 34, 37, 47, 50, 56, 59, 61, 35, 36, 48, 49, 57, 58, 62, 63}; static const int32 IntegerScale = 6; @@ -547,36 +547,36 @@ int32 JpegHuffmanDecoder::Decode(JpegDecoder &decoder) { // static const double floatscaling[JpegSampleWidth][JpegSampleWidth] = { - { - 0.125, 0.09011997775086849627, 0.09567085809127244544, 0.1063037618459070632, 0.125, 0.159094822571604233, 0.2309698831278216846, 0.4530637231764438333, - }, - { - 0.09011997775086849627, 0.0649728831185362593, 0.0689748448207357645, 0.07664074121909414394, 0.09011997775086849627, 0.1147009749634507608, 0.1665200058287998886, - 0.3266407412190940884, - }, - { - 0.09567085809127244544, 0.0689748448207357645, 0.0732233047033631207, 0.08136137691302557096, 0.09567085809127244544, 0.1217659055464329343, 0.1767766952966368932, - 0.3467599613305368256, - }, - { - 0.1063037618459070632, 0.07664074121909414394, 0.08136137691302557096, 0.09040391826073060355, 0.1063037618459070632, 0.135299025036549253, 0.1964237395967755595, - 0.3852990250365491698, - }, - { - 0.125, 0.09011997775086849627, 0.09567085809127244544, 0.1063037618459070632, 0.125, 0.159094822571604233, 0.2309698831278216846, 0.4530637231764438333, - }, - { - 0.159094822571604233, 0.1147009749634507608, 0.1217659055464329343, 0.135299025036549253, 0.159094822571604233, 0.2024893005527218515, 0.2939689006048396558, - 0.5766407412190940329, - }, - { - 0.2309698831278216846, 0.1665200058287998886, 0.1767766952966368932, 0.1964237395967755595, 0.2309698831278216846, 0.2939689006048396558, 0.4267766952966368654, - 0.8371526015321518744, - }, - { - 0.4530637231764438333, 0.3266407412190940884, 0.3467599613305368256, 0.3852990250365491698, 0.4530637231764438333, 0.5766407412190940329, 0.8371526015321518744, - 1.642133898068010689, - }, + { + 0.125, 0.09011997775086849627, 0.09567085809127244544, 0.1063037618459070632, 0.125, 0.159094822571604233, 0.2309698831278216846, 0.4530637231764438333, + }, + { + 0.09011997775086849627, 0.0649728831185362593, 0.0689748448207357645, 0.07664074121909414394, 0.09011997775086849627, 0.1147009749634507608, 0.1665200058287998886, + 0.3266407412190940884, + }, + { + 0.09567085809127244544, 0.0689748448207357645, 0.0732233047033631207, 0.08136137691302557096, 0.09567085809127244544, 0.1217659055464329343, 0.1767766952966368932, + 0.3467599613305368256, + }, + { + 0.1063037618459070632, 0.07664074121909414394, 0.08136137691302557096, 0.09040391826073060355, 0.1063037618459070632, 0.135299025036549253, 0.1964237395967755595, + 0.3852990250365491698, + }, + { + 0.125, 0.09011997775086849627, 0.09567085809127244544, 0.1063037618459070632, 0.125, 0.159094822571604233, 0.2309698831278216846, 0.4530637231764438333, + }, + { + 0.159094822571604233, 0.1147009749634507608, 0.1217659055464329343, 0.135299025036549253, 0.159094822571604233, 0.2024893005527218515, 0.2939689006048396558, + 0.5766407412190940329, + }, + { + 0.2309698831278216846, 0.1665200058287998886, 0.1767766952966368932, 0.1964237395967755595, 0.2309698831278216846, 0.2939689006048396558, 0.4267766952966368654, + 0.8371526015321518744, + }, + { + 0.4530637231764438333, 0.3266407412190940884, 0.3467599613305368256, 0.3852990250365491698, 0.4530637231764438333, 0.5766407412190940329, 0.8371526015321518744, + 1.642133898068010689, + }, }; // diff --git a/engines/icb/object_structs.h b/engines/icb/object_structs.h index be54af58c20..98f2e7854bc 100644 --- a/engines/icb/object_structs.h +++ b/engines/icb/object_structs.h @@ -97,7 +97,7 @@ public: __weapon temp_weapon; char alternativeImagePath[128]; // this stores the pcp path for animations (for getting the raj files instead of rai files... char alternativeBasePath[128]; // this is same as base path but is pcp (on voxels) - isn't required for polys and can go when we - // ditch + // ditch // setting functions bool8 Init_custom_animation(const char *anim_name); bool8 Find_anim_type(__mega_set_names *anim, const char *name); @@ -202,7 +202,7 @@ enum CameraStateEnum { OFF_CAMERA = 0x0, ON_CAMERA = 0x1 }; #define ON_ON_CAMERA MAKE_VIEW_STATE(ON_CAMERA, ON_CAMERA) class _mega { // mega logic specific - public: +public: _parent_box *cur_parent; // our owner parent box uint32 par_number; // for players abar list update uint32 cur_slice; // for speedups diff --git a/engines/icb/options_manager_pc.cpp b/engines/icb/options_manager_pc.cpp index 938d7446012..558726155e1 100644 --- a/engines/icb/options_manager_pc.cpp +++ b/engines/icb/options_manager_pc.cpp @@ -5789,12 +5789,12 @@ void DoSomeMagicStuff() { // Magic input sequences uint8 magic_unlockmovies[13] = {Common::KEYCODE_t, Common::KEYCODE_e, Common::KEYCODE_s, Common::KEYCODE_t, Common::KEYCODE_b, Common::KEYCODE_r, Common::KEYCODE_e, - Common::KEYCODE_a, Common::KEYCODE_k, Common::KEYCODE_d, Common::KEYCODE_o, Common::KEYCODE_w, Common::KEYCODE_n}; + Common::KEYCODE_a, Common::KEYCODE_k, Common::KEYCODE_d, Common::KEYCODE_o, Common::KEYCODE_w, Common::KEYCODE_n}; uint8 magic_fastmovies[6] = {Common::KEYCODE_s, Common::KEYCODE_p, Common::KEYCODE_e, Common::KEYCODE_e, Common::KEYCODE_d, Common::KEYCODE_y}; uint8 magic_slideshowextras[12] = {Common::KEYCODE_h, Common::KEYCODE_o, Common::KEYCODE_l, Common::KEYCODE_i, Common::KEYCODE_d, Common::KEYCODE_a, - Common::KEYCODE_y, Common::KEYCODE_s, Common::KEYCODE_n, Common::KEYCODE_a, Common::KEYCODE_p, Common::KEYCODE_s}; + Common::KEYCODE_y, Common::KEYCODE_s, Common::KEYCODE_n, Common::KEYCODE_a, Common::KEYCODE_p, Common::KEYCODE_s}; uint8 magic_avcontrol[7] = {Common::KEYCODE_r, Common::KEYCODE_a, Common::KEYCODE_b, Common::KEYCODE_v, Common::KEYCODE_i, Common::KEYCODE_e, Common::KEYCODE_w}; @@ -6317,8 +6317,8 @@ uint32 GetFileSz(const char *path) { } Crediter::Crediter() - : m_creditsFile(NULL), m_numberOfBytes(0), m_endOfCredits(0), m_currentHeight(0), m_cursor(0), m_scrollOffset(0), m_logoSurfaceID(0), m_logoDraw(0), m_logoAttached(0), - m_movieSurfaceID(0), m_movieBackdrop(FALSE8), m_loopingMovie(FALSE8), m_frameStart(0), m_totalMovieFrames(0) { + : m_creditsFile(NULL), m_numberOfBytes(0), m_endOfCredits(0), m_currentHeight(0), m_cursor(0), m_scrollOffset(0), m_logoSurfaceID(0), m_logoDraw(0), m_logoAttached(0), + m_movieSurfaceID(0), m_movieBackdrop(FALSE8), m_loopingMovie(FALSE8), m_frameStart(0), m_totalMovieFrames(0) { memset(m_theData, 0, MAX_BYTESIZE_OF_CREDITS_FILE); m_movieRect.left = m_movieRect.right = m_movieRect.bottom = m_movieRect.top = 0; } diff --git a/engines/icb/remora_pc.cpp b/engines/icb/remora_pc.cpp index f8b15b33032..9aa5e17dad3 100644 --- a/engines/icb/remora_pc.cpp +++ b/engines/icb/remora_pc.cpp @@ -74,86 +74,86 @@ enum ColourIndex { #define REMPAL(c, v) (pnRemoraColour[m_nCurrentPalette][c][v]) const uint8 pnRemoraColour[REMORA_NUM_COLOUR_SCHEMES][REMORA_COLOURS_PER_SCHEME][3] = { - // Pallete 0. - {{0, 180, 241}, // CI_HEADING - {255, 255, 255}, // CI_WARNING - {0, 221, 160}, // CI_OPTION - {0, 140, 200}, // CI_PARAGRAPH - {0, 3, 35}, // CI_BACKGROUND - {30, 60, 120}, // CI_GRID - {0, 3, 35}, // CI_CLIP - {2, 55, 128}, // CI_FLOORS - {50, 80, 255}, // CI_BARRIERS - {0, 20, 180}, // CI_BEAM_LEADING - {0, 0, 0}, // CI_BEAM_TRAILING - {225, 34, 5}, // CI_ROBOT - {160, 10, 0}, // CI_DEAD_ROBOT - {2, 24, 200}, // CI_HUMAN - {1, 10, 140}, // CI_DEAD_HUMAN - {38, 255, 0}, // CI_RECHARGE - {255, 20, 20}, // CI_RECHARGE_ARMED - {255, 255, 255}, // CI_PLAYER - {38, 255, 0}, // CI_DOOR_OPEN - {255, 125, 0}, // CI_DOOR_CLOSED - {255, 255, 255}, // CI_PROGRESS_HEAD - {15, 50, 200}, // CI_PROGRESS_TAIL - {255, 30, 30}, // CI_M08_LOCKED_DOOR - {7, 141, 23}, // CI_M08_UNLOCKED_DOOR - {0, 90, 220}}, // CI_M08_BARRIERS + // Pallete 0. + {{0, 180, 241}, // CI_HEADING + {255, 255, 255}, // CI_WARNING + {0, 221, 160}, // CI_OPTION + {0, 140, 200}, // CI_PARAGRAPH + {0, 3, 35}, // CI_BACKGROUND + {30, 60, 120}, // CI_GRID + {0, 3, 35}, // CI_CLIP + {2, 55, 128}, // CI_FLOORS + {50, 80, 255}, // CI_BARRIERS + {0, 20, 180}, // CI_BEAM_LEADING + {0, 0, 0}, // CI_BEAM_TRAILING + {225, 34, 5}, // CI_ROBOT + {160, 10, 0}, // CI_DEAD_ROBOT + {2, 24, 200}, // CI_HUMAN + {1, 10, 140}, // CI_DEAD_HUMAN + {38, 255, 0}, // CI_RECHARGE + {255, 20, 20}, // CI_RECHARGE_ARMED + {255, 255, 255}, // CI_PLAYER + {38, 255, 0}, // CI_DOOR_OPEN + {255, 125, 0}, // CI_DOOR_CLOSED + {255, 255, 255}, // CI_PROGRESS_HEAD + {15, 50, 200}, // CI_PROGRESS_TAIL + {255, 30, 30}, // CI_M08_LOCKED_DOOR + {7, 141, 23}, // CI_M08_UNLOCKED_DOOR + {0, 90, 220}}, // CI_M08_BARRIERS - // Pallete 1. - {{0, 241, 180}, // CI_HEADING - {255, 255, 255}, // CI_WARNING - {0, 160, 221}, // CI_OPTION - {0, 200, 140}, // CI_PARAGRAPH - {0, 35, 10}, // CI_BACKGROUND - {0, 220, 80}, // CI_GRID - {0, 35, 10}, // CI_CLIP - {0, 75, 15}, // CI_FLOORS - {0, 220, 80}, // CI_BARRIERS - {40, 255, 100}, // CI_BEAM_LEADING - {0, 20, 0}, // CI_BEAM_TRAILING - {255, 34, 5}, // CI_ROBOT - {170, 10, 0}, // CI_DEAD_ROBOT - {5, 225, 34}, // CI_HUMAN - {5, 160, 10}, // CI_DEAD_HUMAN - {238, 156, 0}, // CI_RECHARGE - {255, 20, 20}, // CI_RECHARGE_ARMED - {255, 255, 255}, // CI_PLAYER - {238, 156, 0}, // CI_DOOR_OPEN - {238, 4, 0}, // CI_DOOR_CLOSED - {255, 255, 255}, // CI_PROGRESS_HEAD - {5, 200, 50}, // CI_PROGRESS_TAIL - {255, 30, 30}, // CI_M08_LOCKED_DOOR - {7, 235, 23}, // CI_M08_UNLOCKED_DOOR - {0, 230, 90}}, // CI_M08_BARRIERS + // Pallete 1. + {{0, 241, 180}, // CI_HEADING + {255, 255, 255}, // CI_WARNING + {0, 160, 221}, // CI_OPTION + {0, 200, 140}, // CI_PARAGRAPH + {0, 35, 10}, // CI_BACKGROUND + {0, 220, 80}, // CI_GRID + {0, 35, 10}, // CI_CLIP + {0, 75, 15}, // CI_FLOORS + {0, 220, 80}, // CI_BARRIERS + {40, 255, 100}, // CI_BEAM_LEADING + {0, 20, 0}, // CI_BEAM_TRAILING + {255, 34, 5}, // CI_ROBOT + {170, 10, 0}, // CI_DEAD_ROBOT + {5, 225, 34}, // CI_HUMAN + {5, 160, 10}, // CI_DEAD_HUMAN + {238, 156, 0}, // CI_RECHARGE + {255, 20, 20}, // CI_RECHARGE_ARMED + {255, 255, 255}, // CI_PLAYER + {238, 156, 0}, // CI_DOOR_OPEN + {238, 4, 0}, // CI_DOOR_CLOSED + {255, 255, 255}, // CI_PROGRESS_HEAD + {5, 200, 50}, // CI_PROGRESS_TAIL + {255, 30, 30}, // CI_M08_LOCKED_DOOR + {7, 235, 23}, // CI_M08_UNLOCKED_DOOR + {0, 230, 90}}, // CI_M08_BARRIERS - // Pallete 2. - {{247, 236, 23}, // CI_HEADING - {252, 21, 10}, // CI_WARNING - {235, 165, 33}, // CI_OPTION - {233, 238, 30}, // CI_PARAGRAPH - {85, 45, 0}, // CI_BACKGROUND - {216, 151, 1}, // CI_GRID - {85, 45, 0}, // CI_CLIP - {133, 84, 1}, // CI_FLOORS - {216, 151, 1}, // CI_BARRIERS - {224, 200, 123}, // CI_BEAM_LEADING - {35, 20, 0}, // CI_BEAM_TRAILING - {250, 140, 15}, // CI_ROBOT - {176, 94, 2}, // CI_DEAD_ROBOT - {24, 175, 3}, // CI_HUMAN - {15, 104, 2}, // CI_DEAD_HUMAN - {247, 236, 23}, // CI_RECHARGE - {255, 20, 20}, // CI_RECHARGE_ARMED - {255, 255, 255}, // CI_PLAYER - {197, 47, 20}, // CI_DOOR_OPEN - {235, 47, 20}, // CI_DOOR_CLOSED - {255, 255, 255}, // CI_PROGRESS_HEAD - {216, 137, 8}, // CI_PROGRESS_TAIL - {255, 30, 30}, // CI_M08_LOCKED_DOOR - {247, 236, 23}, // CI_M08_UNLOCKED_DOOR - {247, 236, 23}} // CI_M08_BARRIERS + // Pallete 2. + {{247, 236, 23}, // CI_HEADING + {252, 21, 10}, // CI_WARNING + {235, 165, 33}, // CI_OPTION + {233, 238, 30}, // CI_PARAGRAPH + {85, 45, 0}, // CI_BACKGROUND + {216, 151, 1}, // CI_GRID + {85, 45, 0}, // CI_CLIP + {133, 84, 1}, // CI_FLOORS + {216, 151, 1}, // CI_BARRIERS + {224, 200, 123}, // CI_BEAM_LEADING + {35, 20, 0}, // CI_BEAM_TRAILING + {250, 140, 15}, // CI_ROBOT + {176, 94, 2}, // CI_DEAD_ROBOT + {24, 175, 3}, // CI_HUMAN + {15, 104, 2}, // CI_DEAD_HUMAN + {247, 236, 23}, // CI_RECHARGE + {255, 20, 20}, // CI_RECHARGE_ARMED + {255, 255, 255}, // CI_PLAYER + {197, 47, 20}, // CI_DOOR_OPEN + {235, 47, 20}, // CI_DOOR_CLOSED + {255, 255, 255}, // CI_PROGRESS_HEAD + {216, 137, 8}, // CI_PROGRESS_TAIL + {255, 30, 30}, // CI_M08_LOCKED_DOOR + {247, 236, 23}, // CI_M08_UNLOCKED_DOOR + {247, 236, 23}} // CI_M08_BARRIERS }; // struct Point2DColoured @@ -176,10 +176,10 @@ typedef struct { Span remora_spans[REMORA_MAX_YS]; void DrawGouraudQuad(uint32 nX0, uint32 nY0, uint32 nX1, uint32 nY1, uint32 nX2, uint32 nY2, uint32 nX3, uint32 nY3, uint8 nRed0, uint8 nGreen0, uint8 nBlue0, uint8 nRed1, - uint8 nGreen1, uint8 nBlue1, uint8 nRed2, uint8 nGreen2, uint8 nBlue2, uint8 nRed3, uint8 nGreen3, uint8 nBlue3, int32 nOpacity); + uint8 nGreen1, uint8 nBlue1, uint8 nRed2, uint8 nGreen2, uint8 nBlue2, uint8 nRed3, uint8 nGreen3, uint8 nBlue3, int32 nOpacity); void DrawGouraudTriangle(uint32 x0, uint32 y0, uint32 x1, uint32 y1, uint32 x2, uint32 y2, uint8 r0, uint8 g0, uint8 b0, uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2, - int32 nOpacity); + int32 nOpacity); // These values are used for mapping game-world points to the Remora's screen. float fRotateCos, fRotateSin; // Used to store cosine and sine for rotating, so we don't have to keep working it out. @@ -1711,14 +1711,14 @@ inline void _remora::DrawOctagonSymbol(int32 nX, int32 nY, uint32 nPal, uint32 n } void DrawGouraudQuad(uint32 nX0, uint32 nY0, uint32 nX1, uint32 nY1, uint32 nX2, uint32 nY2, uint32 nX3, uint32 nY3, uint8 nRed0, uint8 nGreen0, uint8 nBlue0, uint8 nRed1, - uint8 nGreen1, uint8 nBlue1, uint8 nRed2, uint8 nGreen2, uint8 nBlue2, uint8 nRed3, uint8 nGreen3, uint8 nBlue3, int32 nOpacity) { + uint8 nGreen1, uint8 nBlue1, uint8 nRed2, uint8 nGreen2, uint8 nBlue2, uint8 nRed3, uint8 nGreen3, uint8 nBlue3, int32 nOpacity) { DrawGouraudTriangle(nX0, nY0, nX1, nY1, nX2, nY2, nRed0, nGreen0, nBlue0, nRed1, nGreen1, nBlue1, nRed2, nGreen2, nBlue2, nOpacity); DrawGouraudTriangle(nX1, nY1, nX2, nY2, nX3, nY3, nRed1, nGreen1, nBlue1, nRed2, nGreen2, nBlue2, nRed3, nGreen3, nBlue3, nOpacity); } void DrawGouraudTriangle(uint32 x0, uint32 y0, uint32 x1, uint32 y1, uint32 x2, uint32 y2, uint8 r0, uint8 g0, uint8 b0, uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2, - int32 nOpacity) { + int32 nOpacity) { // Range-check the opacity. if (nOpacity == 0) return; diff --git a/engines/icb/res_man.cpp b/engines/icb/res_man.cpp index 04b5443b643..828be4de2bb 100644 --- a/engines/icb/res_man.cpp +++ b/engines/icb/res_man.cpp @@ -323,8 +323,8 @@ uint32 res_man::Fetch_old_memory(int32 number_of_cycles) { // If hash or cluster_hash == NULL_HASH then the hash of url/cluster_url // is computed and stored in hash/cluster_hash uint8 *res_man::Res_open(const char *url, uint32 &url_hash, const char *cluster, uint32 &cluster_hash, - int32 compressed, // non zero if the resource is compressed - int32 *ret_len) { + int32 compressed, // non zero if the resource is compressed + int32 *ret_len) { // make the hash names if we need to MakeHash(url, url_hash); MakeHash(cluster, cluster_hash); diff --git a/engines/icb/set_pc.cpp b/engines/icb/set_pc.cpp index bf83a802f11..e59942b52f3 100644 --- a/engines/icb/set_pc.cpp +++ b/engines/icb/set_pc.cpp @@ -57,445 +57,445 @@ LRECT full_rect; // used for blting from safe to working buffer, etc //----------- Bookyakasha Rydem and Sparkles !!!!! uint32 sparkle_bmp[6 * 32 * 32] = { - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x05050505, 0x3D3D3D3D, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0E0E0E0E, 0x79797979, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x0C0C0C0C, 0xD2D2D2D2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x3C3C3C3C, 0x77777777, 0xEDEDEDED, 0xFDFDFDFD, 0xD4D4D4D4, 0x99999999, 0x4B4B4B4B, 0x1D1D1D1D, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1F1F1F1F, 0xC2C2C2C2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0F0F0F0F, 0x7D7D7D7D, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x06060606, 0x40404040, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0F0F0F0F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x3D3D3D3D, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E5E5E5E, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x91919191, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xAEAEAEAE, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC9C9C9C9, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xE9E9E9E9, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x85858585, 0xDDDDDDDD, 0x7F7F7F7F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0C0C0C0C, 0x1C1C1C1C, - 0x36363636, 0x4F4F4F4F, 0x8A8A8A8A, 0xB2B2B2B2, 0xD1D1D1D1, 0xEFEFEFEF, 0xFDFDFDFD, 0xF9F9F9F9, 0xF9F9F9F9, 0xF0F0F0F0, 0xDADADADA, 0xC4C4C4C4, 0xA8A8A8A8, 0x82828282, - 0x54545454, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8B8B8B8B, 0xF5F5F5F5, 0x90909090, 0x36363636, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0xF4F4F4F4, 0x06060606, 0x03030303, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xCCCCCCCC, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xAFAFAFAF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x95959595, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x66666666, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x41414141, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x03030303, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0A0A0A0A, 0x02020202, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0A0A0A0A, 0x30303030, 0x02020202, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x37373737, 0x3C3C3C3C, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x55555555, 0x18181818, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x3A3A3A3A, 0x64646464, 0x04040404, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x9B9B9B9B, 0x4F4F4F4F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1B1B1B1B, 0xD3D3D3D3, 0x03030303, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x92929292, 0xA0A0A0A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x27272727, 0x14141414, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x11111111, 0xF3F3F3F3, 0x3A3A3A3A, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1C1C1C1C, 0x53535353, 0x6B6B6B6B, 0x4A4A4A4A, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16161616, 0x92929292, 0xE9E9E9E9, 0x08080808, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x29292929, 0x8D8D8D8D, 0xD1D1D1D1, 0x9B9B9B9B, 0x2A2A2A2A, 0x19191919, 0x16161616, 0x03030303, 0x00000000, 0x58585858, 0xE4E4E4E4, 0xA3A3A3A3, - 0x16161616, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x20202020, 0x8F8F8F8F, 0xF2F2F2F2, 0xDDDDDDDD, 0x98989898, 0x62626262, - 0x59595959, 0xCCCCCCCC, 0xFCFCFCFC, 0x7A7A7A7A, 0x0C0C0C0C, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x2C2C2C2C, 0xA4A4A4A4, 0xF3F3F3F3, 0xF4F4F4F4, 0xD8D8D8D8, 0xF2F2F2F2, 0xF1F1F1F1, 0x7E7E7E7E, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x12121212, 0x40404040, 0xAEAEAEAE, 0xF9F9F9F9, 0xFDFDFDFD, 0xFDFDFDFD, 0xB5B5B5B5, 0x55555555, 0x1A1A1A1A, - 0x03030303, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x43434343, 0xDFDFDFDF, 0xF4F4F4F4, - 0xD8D8D8D8, 0xF4F4F4F4, 0xF7F7F7F7, 0xACACACAC, 0x38383838, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x4E4E4E4E, 0xF8F8F8F8, 0xD3D3D3D3, 0x3D3D3D3D, 0x58585858, 0x93939393, 0xD2D2D2D2, 0xF3F3F3F3, 0x99999999, 0x26262626, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0E0E0E0E, 0x8E8E8E8E, 0xF6F6F6F6, 0x6A6A6A6A, 0x00000000, 0x00000000, 0x14141414, 0x17171717, 0x25252525, 0x88888888, - 0xC5C5C5C5, 0x9A9A9A9A, 0x3F3F3F3F, 0x07070707, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xD4D4D4D4, 0xAFAFAFAF, 0x26262626, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x36363636, 0x89898989, 0x67676767, 0x1F1F1F1F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x18181818, 0xFBFBFBFB, - 0x35353535, 0x03030303, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1B1B1B1B, 0x2A2A2A2A, 0x52525252, 0x34343434, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x89898989, 0xB4B4B4B4, 0x03030303, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0xDEDEDEDE, 0x31313131, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x3B3B3B3B, 0xABABABAB, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01010101, 0x76767676, - 0x3B3B3B3B, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x15151515, 0x76767676, 0x03030303, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46464646, 0x35353535, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x3D3D3D3D, 0x08080808, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x21212121, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x04040404, 0x12121212, 0x07070707, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0F0F0F0F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x18181818, 0x30303030, 0x2C2C2C2C, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x10101010, 0x53535353, 0x0E0E0E0E, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07070707, 0x44444444, - 0x38383838, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07070707, - 0x42424242, 0x70707070, 0x2D2D2D2D, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x23232323, 0x63636363, 0x57575757, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x2C2C2C2C, 0x73737373, 0x41414141, 0x07070707, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x10101010, 0xA6A6A6A6, 0x6E6E6E6E, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x06060606, 0x4F4F4F4F, 0x9B9B9B9B, 0x41414141, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1A1A1A1A, - 0xD1D1D1D1, 0x75757575, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5C5C5C5C, 0xD8D8D8D8, 0x80808080, 0x10101010, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x20202020, 0xEBEBEBEB, 0x88888888, 0x25252525, 0x00000000, 0x00000000, 0x00000000, 0x0C0C0C0C, 0x43434343, 0xB5B5B5B5, - 0x62626262, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56565656, 0xFFFFFFFF, 0xAAAAAAAA, 0x42424242, 0x00000000, - 0x46464646, 0x8A8A8A8A, 0xEDEDEDED, 0xA4A4A4A4, 0x0C0C0C0C, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x09090909, - 0x7E7E7E7E, 0xFBFBFBFB, 0xB6B6B6B6, 0x7C7C7C7C, 0xC1C1C1C1, 0xF0F0F0F0, 0xBEBEBEBE, 0x2D2D2D2D, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0C0C0C0C, 0x8E8E8E8E, 0xFAFAFAFA, 0xE7E7E7E7, 0xF4F4F4F4, 0xE7E7E7E7, 0x37373737, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x68686868, 0xE7E7E7E7, 0xFEFEFEFE, 0xFDFDFDFD, 0xA7A7A7A7, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x18181818, 0xA0A0A0A0, - 0xFEFEFEFE, 0xE9E9E9E9, 0xF1F1F1F1, 0xCCCCCCCC, 0x37373737, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x0D0D0D0D, 0x88888888, 0xFCFCFCFC, 0xC4C4C4C4, 0x54545454, 0x94949494, 0xF4F4F4F4, 0xC0C0C0C0, 0x1E1E1E1E, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4B4B4B4B, 0xD4D4D4D4, 0xA5A5A5A5, 0x36363636, 0x00000000, 0x1B1B1B1B, 0x77777777, 0xF1F1F1F1, 0xA8A8A8A8, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x09090909, 0x73737373, 0xE9E9E9E9, 0x97979797, 0x30303030, 0x07070707, 0x00000000, - 0x00000000, 0x1B1B1B1B, 0x4E4E4E4E, 0xE5E5E5E5, 0x75757575, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4B4B4B4B, 0xC3C3C3C3, 0x8C8C8C8C, - 0x1F1F1F1F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x08080808, 0x22222222, 0xD6D6D6D6, 0x5F5F5F5F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x2D2D2D2D, 0x80808080, 0x48484848, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x21212121, 0xB4B4B4B4, - 0x54545454, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x30303030, 0x83838383, 0x69696969, 0x0E0E0E0E, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x1C1C1C1C, 0xA0A0A0A0, 0x3A3A3A3A, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0C0C0C0C, 0x78787878, 0x40404040, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x19191919, 0x86868686, 0x15151515, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x08080808, 0x58585858, 0x2C2C2C2C, 0x0B0B0B0B, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x25252525, - 0x58585858, 0x1C1C1C1C, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1D1D1D1D, - 0x28282828, 0x08080808, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x06060606, 0x25252525, 0x08080808, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0B0B0B0B, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x15151515, 0x0D0D0D0D, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x20202020, 0x2E2E2E2E, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0C0C0C0C, 0x58585858, 0x03030303, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x7D7D7D7D, 0x31313131, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x58585858, 0x96969696, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC9C9C9C9, 0x31313131, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x77777777, 0xACACACAC, 0x04040404, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1C1C1C1C, 0xF3F3F3F3, 0x40404040, 0x03030303, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x1F1F1F1F, 0x5D5D5D5D, 0x12121212, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0F0F0F0F, 0xD5D5D5D5, 0xAEAEAEAE, 0x1F1F1F1F, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x50505050, 0x81818181, 0x81818181, 0x2C2C2C2C, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0E0E0E0E, 0x8E8E8E8E, - 0xF5F5F5F5, 0x60606060, 0x02020202, 0x0B0B0B0B, 0x18181818, 0x07070707, 0x27272727, 0xA2A2A2A2, 0xD2D2D2D2, 0x99999999, 0x33333333, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x45454545, 0xF5F5F5F5, 0xB9B9B9B9, 0x71717171, 0x76767676, 0x94949494, 0xD7D7D7D7, 0xFBFBFBFB, 0x9E9E9E9E, 0x1F1F1F1F, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x43434343, 0xDBDBDBDB, 0xF7F7F7F7, 0xE8E8E8E8, 0xF6F6F6F6, 0xF4F4F4F4, 0xA5A5A5A5, - 0x22222222, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01010101, 0x13131313, 0x4E4E4E4E, 0xC3C3C3C3, 0xFAFAFAFA, 0xFDFDFDFD, - 0xFCFCFCFC, 0xD9D9D9D9, 0x60606060, 0x1B1B1B1B, 0x04040404, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x20202020, 0xAAAAAAAA, - 0xF8F8F8F8, 0xF8F8F8F8, 0xE4E4E4E4, 0xEAEAEAEA, 0xEBEBEBEB, 0x67676767, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x2A2A2A2A, 0xA7A7A7A7, 0xFDFDFDFD, 0xD2D2D2D2, 0x9B9B9B9B, 0x74747474, 0x38383838, 0xA7A7A7A7, 0xFBFBFBFB, 0x5F5F5F5F, 0x05050505, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x38383838, 0x9A9A9A9A, 0xDFDFDFDF, 0x95959595, 0x20202020, 0x13131313, 0x18181818, 0x00000000, 0x00000000, 0x3F3F3F3F, 0xE9E9E9E9, 0xA8A8A8A8, - 0x14141414, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x15151515, 0x59595959, 0x71717171, 0x45454545, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x14141414, 0x92929292, 0xECECECEC, 0x19191919, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x36363636, 0x2F2F2F2F, 0x0F0F0F0F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x25252525, 0xE9E9E9E9, 0x35353535, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x83838383, 0x9D9D9D9D, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x18181818, 0xCACACACA, 0x07070707, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x90909090, 0x5A5A5A5A, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2C2C2C2C, 0x96969696, 0x04040404, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x7B7B7B7B, 0x1D1D1D1D, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x43434343, 0x3B3B3B3B, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x04040404, 0x39393939, 0x03030303, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x02020202, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x42424242, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x79797979, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x8B8B8B8B, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xAEAEAEAE, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC9C9C9C9, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0xE2E2E2E2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFAFAFAFA, 0x0D0D0D0D, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x13131313, 0xFDFDFDFD, 0x1F1F1F1F, 0x02020202, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x03030303, 0x4A4A4A4A, 0xFAFAFAFA, - 0x4B4B4B4B, 0x04040404, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x09090909, 0x63636363, 0xF9F9F9F9, 0x70707070, 0x08080808, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x10101010, 0xA4A4A4A4, 0xFDFDFDFD, 0xB0B0B0B0, 0x06060606, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x04040404, 0x2F2F2F2F, 0x4E4E4E4E, 0x66666666, 0x7F7F7F7F, 0xC5C5C5C5, 0xFDFDFDFD, 0xD0D0D0D0, 0x7F7F7F7F, - 0x66666666, 0x4E4E4E4E, 0x2F2F2F2F, 0x04040404, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x32323232, 0x52525252, 0x6D6D6D6D, 0x9D9D9D9D, 0xC6C6C6C6, 0xDFDFDFDF, 0xEBEBEBEB, 0xF9F9F9F9, 0xFDFDFDFD, 0xFCFCFCFC, 0xFAFAFAFA, - 0xFCFCFCFC, 0xFDFDFDFD, 0xFDFDFDFD, 0xFDFDFDFD, 0xFDFDFDFD, 0xFBFBFBFB, 0xF5F5F5F5, 0xECECECEC, 0xD9D9D9D9, 0xC0C0C0C0, 0xAFAFAFAF, 0x9C9C9C9C, 0x78787878, 0x3B3B3B3B, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x04040404, - 0x2F2F2F2F, 0x4E4E4E4E, 0x66666666, 0x7F7F7F7F, 0xC5C5C5C5, 0xFDFDFDFD, 0xBDBDBDBD, 0x7F7F7F7F, 0x66666666, 0x4E4E4E4E, 0x2F2F2F2F, 0x04040404, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01010101, 0x01010101, 0x91919191, 0xFDFDFDFD, 0xA0A0A0A0, 0x01010101, 0x01010101, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66666666, 0xFDFDFDFD, - 0x7B7B7B7B, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x48484848, 0xFDFDFDFD, 0x57575757, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1D1D1D1D, 0xFDFDFDFD, 0x2C2C2C2C, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFDFDFDFD, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0xF2F2F2F2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xDADADADA, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xA7A7A7A7, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8A8A8A8A, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x6B6B6B6B, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x3B3B3B3B, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}; + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x05050505, 0x3D3D3D3D, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0E0E0E0E, 0x79797979, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x0C0C0C0C, 0xD2D2D2D2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x3C3C3C3C, 0x77777777, 0xEDEDEDED, 0xFDFDFDFD, 0xD4D4D4D4, 0x99999999, 0x4B4B4B4B, 0x1D1D1D1D, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1F1F1F1F, 0xC2C2C2C2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0F0F0F0F, 0x7D7D7D7D, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x06060606, 0x40404040, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0F0F0F0F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x3D3D3D3D, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5E5E5E5E, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x91919191, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xAEAEAEAE, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC9C9C9C9, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xE9E9E9E9, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x85858585, 0xDDDDDDDD, 0x7F7F7F7F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0C0C0C0C, 0x1C1C1C1C, + 0x36363636, 0x4F4F4F4F, 0x8A8A8A8A, 0xB2B2B2B2, 0xD1D1D1D1, 0xEFEFEFEF, 0xFDFDFDFD, 0xF9F9F9F9, 0xF9F9F9F9, 0xF0F0F0F0, 0xDADADADA, 0xC4C4C4C4, 0xA8A8A8A8, 0x82828282, + 0x54545454, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8B8B8B8B, 0xF5F5F5F5, 0x90909090, 0x36363636, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0xF4F4F4F4, 0x06060606, 0x03030303, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xCCCCCCCC, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xAFAFAFAF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x95959595, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x66666666, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x41414141, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x03030303, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0A0A0A0A, 0x02020202, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0A0A0A0A, 0x30303030, 0x02020202, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x37373737, 0x3C3C3C3C, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x55555555, 0x18181818, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x3A3A3A3A, 0x64646464, 0x04040404, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x9B9B9B9B, 0x4F4F4F4F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1B1B1B1B, 0xD3D3D3D3, 0x03030303, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x92929292, 0xA0A0A0A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x27272727, 0x14141414, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x11111111, 0xF3F3F3F3, 0x3A3A3A3A, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1C1C1C1C, 0x53535353, 0x6B6B6B6B, 0x4A4A4A4A, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x16161616, 0x92929292, 0xE9E9E9E9, 0x08080808, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x29292929, 0x8D8D8D8D, 0xD1D1D1D1, 0x9B9B9B9B, 0x2A2A2A2A, 0x19191919, 0x16161616, 0x03030303, 0x00000000, 0x58585858, 0xE4E4E4E4, 0xA3A3A3A3, + 0x16161616, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x20202020, 0x8F8F8F8F, 0xF2F2F2F2, 0xDDDDDDDD, 0x98989898, 0x62626262, + 0x59595959, 0xCCCCCCCC, 0xFCFCFCFC, 0x7A7A7A7A, 0x0C0C0C0C, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x2C2C2C2C, 0xA4A4A4A4, 0xF3F3F3F3, 0xF4F4F4F4, 0xD8D8D8D8, 0xF2F2F2F2, 0xF1F1F1F1, 0x7E7E7E7E, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x12121212, 0x40404040, 0xAEAEAEAE, 0xF9F9F9F9, 0xFDFDFDFD, 0xFDFDFDFD, 0xB5B5B5B5, 0x55555555, 0x1A1A1A1A, + 0x03030303, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x43434343, 0xDFDFDFDF, 0xF4F4F4F4, + 0xD8D8D8D8, 0xF4F4F4F4, 0xF7F7F7F7, 0xACACACAC, 0x38383838, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x4E4E4E4E, 0xF8F8F8F8, 0xD3D3D3D3, 0x3D3D3D3D, 0x58585858, 0x93939393, 0xD2D2D2D2, 0xF3F3F3F3, 0x99999999, 0x26262626, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0E0E0E0E, 0x8E8E8E8E, 0xF6F6F6F6, 0x6A6A6A6A, 0x00000000, 0x00000000, 0x14141414, 0x17171717, 0x25252525, 0x88888888, + 0xC5C5C5C5, 0x9A9A9A9A, 0x3F3F3F3F, 0x07070707, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xD4D4D4D4, 0xAFAFAFAF, 0x26262626, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x36363636, 0x89898989, 0x67676767, 0x1F1F1F1F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x18181818, 0xFBFBFBFB, + 0x35353535, 0x03030303, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1B1B1B1B, 0x2A2A2A2A, 0x52525252, 0x34343434, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x89898989, 0xB4B4B4B4, 0x03030303, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0xDEDEDEDE, 0x31313131, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x3B3B3B3B, 0xABABABAB, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01010101, 0x76767676, + 0x3B3B3B3B, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x15151515, 0x76767676, 0x03030303, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46464646, 0x35353535, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x3D3D3D3D, 0x08080808, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x21212121, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x04040404, 0x12121212, 0x07070707, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0F0F0F0F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x18181818, 0x30303030, 0x2C2C2C2C, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x10101010, 0x53535353, 0x0E0E0E0E, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07070707, 0x44444444, + 0x38383838, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07070707, + 0x42424242, 0x70707070, 0x2D2D2D2D, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x23232323, 0x63636363, 0x57575757, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x2C2C2C2C, 0x73737373, 0x41414141, 0x07070707, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x10101010, 0xA6A6A6A6, 0x6E6E6E6E, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x06060606, 0x4F4F4F4F, 0x9B9B9B9B, 0x41414141, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1A1A1A1A, + 0xD1D1D1D1, 0x75757575, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5C5C5C5C, 0xD8D8D8D8, 0x80808080, 0x10101010, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x20202020, 0xEBEBEBEB, 0x88888888, 0x25252525, 0x00000000, 0x00000000, 0x00000000, 0x0C0C0C0C, 0x43434343, 0xB5B5B5B5, + 0x62626262, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x56565656, 0xFFFFFFFF, 0xAAAAAAAA, 0x42424242, 0x00000000, + 0x46464646, 0x8A8A8A8A, 0xEDEDEDED, 0xA4A4A4A4, 0x0C0C0C0C, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x09090909, + 0x7E7E7E7E, 0xFBFBFBFB, 0xB6B6B6B6, 0x7C7C7C7C, 0xC1C1C1C1, 0xF0F0F0F0, 0xBEBEBEBE, 0x2D2D2D2D, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0C0C0C0C, 0x8E8E8E8E, 0xFAFAFAFA, 0xE7E7E7E7, 0xF4F4F4F4, 0xE7E7E7E7, 0x37373737, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x68686868, 0xE7E7E7E7, 0xFEFEFEFE, 0xFDFDFDFD, 0xA7A7A7A7, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x18181818, 0xA0A0A0A0, + 0xFEFEFEFE, 0xE9E9E9E9, 0xF1F1F1F1, 0xCCCCCCCC, 0x37373737, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x0D0D0D0D, 0x88888888, 0xFCFCFCFC, 0xC4C4C4C4, 0x54545454, 0x94949494, 0xF4F4F4F4, 0xC0C0C0C0, 0x1E1E1E1E, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4B4B4B4B, 0xD4D4D4D4, 0xA5A5A5A5, 0x36363636, 0x00000000, 0x1B1B1B1B, 0x77777777, 0xF1F1F1F1, 0xA8A8A8A8, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x09090909, 0x73737373, 0xE9E9E9E9, 0x97979797, 0x30303030, 0x07070707, 0x00000000, + 0x00000000, 0x1B1B1B1B, 0x4E4E4E4E, 0xE5E5E5E5, 0x75757575, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4B4B4B4B, 0xC3C3C3C3, 0x8C8C8C8C, + 0x1F1F1F1F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x08080808, 0x22222222, 0xD6D6D6D6, 0x5F5F5F5F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x2D2D2D2D, 0x80808080, 0x48484848, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x21212121, 0xB4B4B4B4, + 0x54545454, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x30303030, 0x83838383, 0x69696969, 0x0E0E0E0E, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x1C1C1C1C, 0xA0A0A0A0, 0x3A3A3A3A, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0C0C0C0C, 0x78787878, 0x40404040, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x19191919, 0x86868686, 0x15151515, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x08080808, 0x58585858, 0x2C2C2C2C, 0x0B0B0B0B, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x25252525, + 0x58585858, 0x1C1C1C1C, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1D1D1D1D, + 0x28282828, 0x08080808, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x06060606, 0x25252525, 0x08080808, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0B0B0B0B, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x15151515, 0x0D0D0D0D, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x20202020, 0x2E2E2E2E, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0C0C0C0C, 0x58585858, 0x03030303, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x7D7D7D7D, 0x31313131, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x58585858, 0x96969696, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC9C9C9C9, 0x31313131, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x77777777, 0xACACACAC, 0x04040404, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1C1C1C1C, 0xF3F3F3F3, 0x40404040, 0x03030303, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x1F1F1F1F, 0x5D5D5D5D, 0x12121212, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0F0F0F0F, 0xD5D5D5D5, 0xAEAEAEAE, 0x1F1F1F1F, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x50505050, 0x81818181, 0x81818181, 0x2C2C2C2C, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0E0E0E0E, 0x8E8E8E8E, + 0xF5F5F5F5, 0x60606060, 0x02020202, 0x0B0B0B0B, 0x18181818, 0x07070707, 0x27272727, 0xA2A2A2A2, 0xD2D2D2D2, 0x99999999, 0x33333333, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x45454545, 0xF5F5F5F5, 0xB9B9B9B9, 0x71717171, 0x76767676, 0x94949494, 0xD7D7D7D7, 0xFBFBFBFB, 0x9E9E9E9E, 0x1F1F1F1F, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x43434343, 0xDBDBDBDB, 0xF7F7F7F7, 0xE8E8E8E8, 0xF6F6F6F6, 0xF4F4F4F4, 0xA5A5A5A5, + 0x22222222, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01010101, 0x13131313, 0x4E4E4E4E, 0xC3C3C3C3, 0xFAFAFAFA, 0xFDFDFDFD, + 0xFCFCFCFC, 0xD9D9D9D9, 0x60606060, 0x1B1B1B1B, 0x04040404, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x20202020, 0xAAAAAAAA, + 0xF8F8F8F8, 0xF8F8F8F8, 0xE4E4E4E4, 0xEAEAEAEA, 0xEBEBEBEB, 0x67676767, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x2A2A2A2A, 0xA7A7A7A7, 0xFDFDFDFD, 0xD2D2D2D2, 0x9B9B9B9B, 0x74747474, 0x38383838, 0xA7A7A7A7, 0xFBFBFBFB, 0x5F5F5F5F, 0x05050505, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x38383838, 0x9A9A9A9A, 0xDFDFDFDF, 0x95959595, 0x20202020, 0x13131313, 0x18181818, 0x00000000, 0x00000000, 0x3F3F3F3F, 0xE9E9E9E9, 0xA8A8A8A8, + 0x14141414, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x15151515, 0x59595959, 0x71717171, 0x45454545, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x14141414, 0x92929292, 0xECECECEC, 0x19191919, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x36363636, 0x2F2F2F2F, 0x0F0F0F0F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x25252525, 0xE9E9E9E9, 0x35353535, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x83838383, 0x9D9D9D9D, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x18181818, 0xCACACACA, 0x07070707, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x90909090, 0x5A5A5A5A, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2C2C2C2C, 0x96969696, 0x04040404, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x7B7B7B7B, 0x1D1D1D1D, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x43434343, 0x3B3B3B3B, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x04040404, 0x39393939, 0x03030303, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x02020202, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x42424242, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x79797979, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x8B8B8B8B, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xAEAEAEAE, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xC9C9C9C9, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0xE2E2E2E2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFAFAFAFA, 0x0D0D0D0D, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x13131313, 0xFDFDFDFD, 0x1F1F1F1F, 0x02020202, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x03030303, 0x4A4A4A4A, 0xFAFAFAFA, + 0x4B4B4B4B, 0x04040404, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x09090909, 0x63636363, 0xF9F9F9F9, 0x70707070, 0x08080808, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x10101010, 0xA4A4A4A4, 0xFDFDFDFD, 0xB0B0B0B0, 0x06060606, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x04040404, 0x2F2F2F2F, 0x4E4E4E4E, 0x66666666, 0x7F7F7F7F, 0xC5C5C5C5, 0xFDFDFDFD, 0xD0D0D0D0, 0x7F7F7F7F, + 0x66666666, 0x4E4E4E4E, 0x2F2F2F2F, 0x04040404, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x32323232, 0x52525252, 0x6D6D6D6D, 0x9D9D9D9D, 0xC6C6C6C6, 0xDFDFDFDF, 0xEBEBEBEB, 0xF9F9F9F9, 0xFDFDFDFD, 0xFCFCFCFC, 0xFAFAFAFA, + 0xFCFCFCFC, 0xFDFDFDFD, 0xFDFDFDFD, 0xFDFDFDFD, 0xFDFDFDFD, 0xFBFBFBFB, 0xF5F5F5F5, 0xECECECEC, 0xD9D9D9D9, 0xC0C0C0C0, 0xAFAFAFAF, 0x9C9C9C9C, 0x78787878, 0x3B3B3B3B, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x04040404, + 0x2F2F2F2F, 0x4E4E4E4E, 0x66666666, 0x7F7F7F7F, 0xC5C5C5C5, 0xFDFDFDFD, 0xBDBDBDBD, 0x7F7F7F7F, 0x66666666, 0x4E4E4E4E, 0x2F2F2F2F, 0x04040404, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01010101, 0x01010101, 0x91919191, 0xFDFDFDFD, 0xA0A0A0A0, 0x01010101, 0x01010101, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66666666, 0xFDFDFDFD, + 0x7B7B7B7B, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x48484848, 0xFDFDFDFD, 0x57575757, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1D1D1D1D, 0xFDFDFDFD, 0x2C2C2C2C, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFDFDFDFD, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0xF2F2F2F2, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xDADADADA, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xA7A7A7A7, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8A8A8A8A, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x6B6B6B6B, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x3B3B3B3B, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}; void ShakeRects(LRECT &sourceRect, LRECT &destRect) { int32 xShift = GetShakeX(); diff --git a/engines/icb/shadow_pc.cpp b/engines/icb/shadow_pc.cpp index 5fe11e0ad6d..6923b668ca4 100644 --- a/engines/icb/shadow_pc.cpp +++ b/engines/icb/shadow_pc.cpp @@ -48,11 +48,11 @@ int32 st2pc; int32 st3pc; void MakeShadowPC(rap_API *srap, SVECTORPC *local, int32 nVertices, SVECTORPC *p_n, int32 p_d, SVECTORPC *ldir, CVECTOR *lcolour, MATRIXPC *world2screen, MATRIXPC *local2world, - int32 debug, SVECTOR *bbox, SVECTOR *minbbox, SVECTOR *maxbbox, int16 xminLocal, int16 xmaxLocal, int16 yminLocal, int16 ymaxLocal, int16 zminLocal, - int16 zmaxLocal); + int32 debug, SVECTOR *bbox, SVECTOR *minbbox, SVECTOR *maxbbox, int16 xminLocal, int16 xmaxLocal, int16 yminLocal, int16 ymaxLocal, int16 zminLocal, + int16 zmaxLocal); void DrawShadow1PC(rap_API *srap, int32 poseBone, MATRIXPC *lw, MATRIXPC *world2screen, MATRIXPC *local2world, int32 nShadows, SVECTORPC *ldirs, CVECTOR *lcolours, SVECTORPC *p_n, - int32 *p_d, int32 debug, SVECTOR **shadowBox, SVECTOR *shadowBoxMin, SVECTOR *shadowBoxMax) { + int32 *p_d, int32 debug, SVECTOR **shadowBox, SVECTOR *shadowBoxMin, SVECTOR *shadowBoxMax) { if (nShadows == 0) return; @@ -90,8 +90,8 @@ void DrawShadow1PC(rap_API *srap, int32 poseBone, MATRIXPC *lw, MATRIXPC *world2 } void MakeShadowPC(rap_API *srap, SVECTORPC *local, int32 nVertices, SVECTORPC *p_n, int32 p_d, SVECTORPC *ldir, CVECTOR *lcolour, MATRIXPC *world2screen, MATRIXPC *local2world, - int32 debug, SVECTOR *bbox, SVECTOR *minbbox, SVECTOR *maxbbox, int16 xminLocal, int16 xmaxLocal, int16 yminLocal, int16 ymaxLocal, int16 zminLocal, - int16 zmaxLocal) { + int32 debug, SVECTOR *bbox, SVECTOR *minbbox, SVECTOR *maxbbox, int16 xminLocal, int16 xmaxLocal, int16 yminLocal, int16 ymaxLocal, int16 zminLocal, + int16 zmaxLocal) { SVECTORPC workVerts[MAX_VECTORS]; SVECTORPC *vertices = NULL; diff --git a/engines/icb/shadow_pc.h b/engines/icb/shadow_pc.h index 5e4a572998e..015cb5d7995 100644 --- a/engines/icb/shadow_pc.h +++ b/engines/icb/shadow_pc.h @@ -40,7 +40,7 @@ namespace ICB { void DrawShadow1PC(rap_API *srap, int32 poseBone, MATRIXPC *lw, MATRIXPC *world2screen, MATRIXPC *local2world, int32 nShadows, SVECTORPC *ldirs, CVECTOR *lcolours, SVECTORPC *p_n, - int32 *p_d, int32 debug, SVECTOR **shadowBox, SVECTOR *shadowBoxMin, SVECTOR *shadowBoxMax); + int32 *p_d, int32 debug, SVECTOR **shadowBox, SVECTOR *shadowBoxMin, SVECTOR *shadowBoxMax); } // End of namespace ICB diff --git a/engines/icb/softskin_pc.cpp b/engines/icb/softskin_pc.cpp index fc693cf2a4b..b07b1ebb65c 100644 --- a/engines/icb/softskin_pc.cpp +++ b/engines/icb/softskin_pc.cpp @@ -34,7 +34,7 @@ namespace ICB { int32 softskinPC(rap_API *rap, int32 poseBone, MATRIXPC *lw, SVECTORPC *local, int16 *xminLocal, int16 *xmaxLocal, int16 *yminLocal, int16 *ymaxLocal, int16 *zminLocal, - int16 *zmaxLocal, int32 screenShift) { + int16 *zmaxLocal, int32 screenShift) { // step 1 : make all the local-world and local-screen matrices // This is done prior to this function // step 2 : take all the offsets from the mesh file diff --git a/engines/icb/softskin_pc.h b/engines/icb/softskin_pc.h index 8dc503a94dd..e029d663b4c 100644 --- a/engines/icb/softskin_pc.h +++ b/engines/icb/softskin_pc.h @@ -34,7 +34,7 @@ namespace ICB { int32 softskinPC(rap_API *rap, int32 poseBone, MATRIXPC *lw, SVECTORPC *local, int16 *xminLocal, int16 *xmaxLocal, int16 *yminLocal, int16 *ymaxLocal, int16 *zminLocal, - int16 *zmaxLocal, int32 screenShift); + int16 *zmaxLocal, int32 screenShift); } // End of namespace ICB diff --git a/engines/icb/sound.cpp b/engines/icb/sound.cpp index 75bee490fb4..89c66f83ea8 100644 --- a/engines/icb/sound.cpp +++ b/engines/icb/sound.cpp @@ -147,7 +147,7 @@ const uint8 volMakerFunction[MAX_VOLUME + 1] = VOL_FUNCTION; class VolMaker { - public: + public: int32 GetVol(int32 i) { if (i < 0) return 0; @@ -1006,7 +1006,7 @@ int32 FindSound(uint32 obj, uint32 sndHash, int32 start = 0) { // fn_play_sfx_offset(sfxName,sndID,x,y,z,isNico) // this is the generic function void RegisterSoundOffset(uint32 obj, const char *offsetName, const char *sfxName, uint32 sfxHash, const char *sndID, PXreal xo, PXreal yo, PXreal zo, int32 isNico, int32 time, - int8 volume_offset) { + int8 volume_offset) { // check we have the hash before we register any sounds...! if (menuSoundIDHash == NULL_HASH) menuSoundIDHash = HashString(menuSoundID); diff --git a/engines/icb/sound.h b/engines/icb/sound.h index 3f9c7fb5d86..1ed37420ad9 100644 --- a/engines/icb/sound.h +++ b/engines/icb/sound.h @@ -230,7 +230,7 @@ int32 GetAssignedSounds(); // these functions have both sfxHash and volume_offset which most calls will not use.... they will use the inlines below... void RegisterSoundOffset(uint32 obj, const char *offsetName, const char *sfxName, uint32 sfxHash, const char *sndID, PXreal xo, PXreal yo, PXreal zo, int32 isNico, int32 time, - int8 volume_offset); + int8 volume_offset); void RegisterSound(uint32 obj, const char *sfxName, uint32 sfxHash, const char *sndID, int8 volume_offset); void RegisterSoundAbsolute(uint32 obj, const char *sfxName, uint32 sfxHash, const char *sndID, PXreal x, PXreal y, PXreal z, int8 volume_offset); void RegisterSoundTime(uint32 obj, const char *sfxName, uint32 sfxHash, const char *sndID, int32 time, int8 volume_offset); diff --git a/engines/icb/speech.cpp b/engines/icb/speech.cpp index 9c11676a0d0..ed7580da5a0 100644 --- a/engines/icb/speech.cpp +++ b/engines/icb/speech.cpp @@ -724,10 +724,10 @@ void _game_session::Format_remora_text(const char *pcText, int32 nLineSpacing, i } void _game_session::Create_remora_text(uint32 x, uint32 y, const char *ascii, - int32 margin, _pin_position pin_pos, int32 lineSpacing, int32 charSpacing, - uint32 maxWidth, - bool8 analysisAlreadyDone, - int32 stopAtLine) { + int32 margin, _pin_position pin_pos, int32 lineSpacing, int32 charSpacing, + uint32 maxWidth, + bool8 analysisAlreadyDone, + int32 stopAtLine) { bool8 bRemoraLeftFormatting; Zdebug("Create_remora_text %d,%d [%s]", x, y, ascii); diff --git a/engines/icb/speech.h b/engines/icb/speech.h index afa7bc545b7..8ad90aad9ff 100644 --- a/engines/icb/speech.h +++ b/engines/icb/speech.h @@ -71,7 +71,7 @@ public: #define MAX_coms 3 class __conversation { - public: +public: __conversation() { for (int32 i = 0; i < MAX_people_talking; i++) subscribers_requested[i] = 0; diff --git a/engines/icb/stage_view.h b/engines/icb/stage_view.h index df6fa208601..78e77f17af6 100644 --- a/engines/icb/stage_view.h +++ b/engines/icb/stage_view.h @@ -33,7 +33,7 @@ namespace ICB { bool8 InitStageView(const char *cameraUrl, const char *walkgridUrl, const char *poseUrl, const char *meshUrl, const char *shadowUrl, const char *textureUrl, - const char *animUrl); // Initalize the stage view module + const char *animUrl); // Initalize the stage view module void StageView(); // Called every cycle. Gets user input, updates character and draws the set } // End of namespace ICB diff --git a/engines/icb/surface_manager.cpp b/engines/icb/surface_manager.cpp index d4fd77e3fce..8c0c846c8c1 100644 --- a/engines/icb/surface_manager.cpp +++ b/engines/icb/surface_manager.cpp @@ -86,11 +86,11 @@ void _surface_manager::PrintDebugLabel(const char *mess, uint32 c) { void _surface_manager::PrintTimer(char label, uint32 time, uint32 limit) { /* static uint32 colours[] = { 0x0000ff00, // 0x - 1x - 0x0000ffff, // 1x - 2x - 0x000000ff, // 2x - 3x - 0x00ffff00, // 3x - 4x - 0x00ff0000, // 4x - 5x - 0x00ffffff }; // 5x + + 0x0000ffff, // 1x - 2x + 0x000000ff, // 2x - 3x + 0x00ffff00, // 3x - 4x + 0x00ff0000, // 4x - 5x + 0x00ffffff }; // 5x + */ static int32 x = 20; @@ -338,7 +338,7 @@ void _surface_manager::Fill_surface(uint32 s_id, uint32 rgb_value) { } static void copyRectToSurface(void *dstBuffer, const void *srcBuffer, int32 srcPitch, int32 dstPitch, int32 width, int32 height, - bool8 colorKeyEnable, uint32 colorKey) { + bool8 colorKeyEnable, uint32 colorKey) { assert(srcBuffer); assert(dstBuffer); @@ -365,8 +365,8 @@ static void copyRectToSurface(void *dstBuffer, const void *srcBuffer, int32 srcP } static void copyRectToSurface(Graphics::Surface *dstSurface, Graphics::Surface *srcSurface, - int32 destX, int32 destY, const Common::Rect subRect, - bool8 colorKeyEnable, uint32 colorKey) { + int32 destX, int32 destY, const Common::Rect subRect, + bool8 colorKeyEnable, uint32 colorKey) { assert(srcSurface->format == dstSurface->format); assert(srcSurface->format.bytesPerPixel == 4); assert(destX >= 0 && destX < dstSurface->w); diff --git a/engines/icb/text_sprites.cpp b/engines/icb/text_sprites.cpp index e5ab279e000..85d6673e2c4 100644 --- a/engines/icb/text_sprites.cpp +++ b/engines/icb/text_sprites.cpp @@ -46,9 +46,9 @@ text_sprite::text_sprite() { text_sprite::~text_sprite() { Zdebug("**destructing text sprite**"); } _TSrtn text_sprite::GetRenderCoords(const int32 pinX, // screen x-coord where we want to position the pin - const int32 pinY, // y-coord -"- - const _pin_position pinPos, // position of pin on text sprite - const int32 margin) // margin to keep sprite within edge of screen, or -1 if allowed anywhere + const int32 pinY, // y-coord -"- + const _pin_position pinPos, // position of pin on text sprite + const int32 margin) // margin to keep sprite within edge of screen, or -1 if allowed anywhere { // first, calculate the render coords based on the pin position & desired pin coords: diff --git a/engines/icb/timer_func.cpp b/engines/icb/timer_func.cpp index afaab3c9fff..e677cd4d8fe 100644 --- a/engines/icb/timer_func.cpp +++ b/engines/icb/timer_func.cpp @@ -62,28 +62,28 @@ int32 timerDanger; #define BOT_BIT 64 const uint8 digitBits[10] = { - // TOP_BIT | TOP_RIGHT_BIT | TOP_LEFT_BIT | MID_BIT | BOT_RIGHT_BIT | BOT_LEFT_BIT | BOT_BIT - TOP_BIT | TOP_RIGHT_BIT | TOP_LEFT_BIT | 0 | BOT_RIGHT_BIT | BOT_LEFT_BIT | BOT_BIT, // 0 - 0 | 0 | TOP_LEFT_BIT | 0 | 0 | BOT_LEFT_BIT | 0, // 1 - TOP_BIT | TOP_RIGHT_BIT | 0 | MID_BIT | 0 | BOT_LEFT_BIT | BOT_BIT, // 2 - TOP_BIT | TOP_RIGHT_BIT | 0 | MID_BIT | BOT_RIGHT_BIT | 0 | BOT_BIT, // 3 - 0 | TOP_RIGHT_BIT | TOP_LEFT_BIT | MID_BIT | BOT_RIGHT_BIT | 0 | 0, // 4 - TOP_BIT | 0 | TOP_LEFT_BIT | MID_BIT | BOT_RIGHT_BIT | 0 | BOT_BIT, // 5 - TOP_BIT | 0 | TOP_LEFT_BIT | MID_BIT | BOT_RIGHT_BIT | BOT_LEFT_BIT | BOT_BIT, // 6 - TOP_BIT | TOP_RIGHT_BIT | 0 | 0 | BOT_RIGHT_BIT | 0 | 0, // 7 - TOP_BIT | TOP_RIGHT_BIT | TOP_LEFT_BIT | MID_BIT | BOT_RIGHT_BIT | BOT_LEFT_BIT | BOT_BIT, // 8 - TOP_BIT | TOP_RIGHT_BIT | TOP_LEFT_BIT | MID_BIT | BOT_RIGHT_BIT | 0 | BOT_BIT, // 9 + // TOP_BIT | TOP_RIGHT_BIT | TOP_LEFT_BIT | MID_BIT | BOT_RIGHT_BIT | BOT_LEFT_BIT | BOT_BIT + TOP_BIT | TOP_RIGHT_BIT | TOP_LEFT_BIT | 0 | BOT_RIGHT_BIT | BOT_LEFT_BIT | BOT_BIT, // 0 + 0 | 0 | TOP_LEFT_BIT | 0 | 0 | BOT_LEFT_BIT | 0, // 1 + TOP_BIT | TOP_RIGHT_BIT | 0 | MID_BIT | 0 | BOT_LEFT_BIT | BOT_BIT, // 2 + TOP_BIT | TOP_RIGHT_BIT | 0 | MID_BIT | BOT_RIGHT_BIT | 0 | BOT_BIT, // 3 + 0 | TOP_RIGHT_BIT | TOP_LEFT_BIT | MID_BIT | BOT_RIGHT_BIT | 0 | 0, // 4 + TOP_BIT | 0 | TOP_LEFT_BIT | MID_BIT | BOT_RIGHT_BIT | 0 | BOT_BIT, // 5 + TOP_BIT | 0 | TOP_LEFT_BIT | MID_BIT | BOT_RIGHT_BIT | BOT_LEFT_BIT | BOT_BIT, // 6 + TOP_BIT | TOP_RIGHT_BIT | 0 | 0 | BOT_RIGHT_BIT | 0 | 0, // 7 + TOP_BIT | TOP_RIGHT_BIT | TOP_LEFT_BIT | MID_BIT | BOT_RIGHT_BIT | BOT_LEFT_BIT | BOT_BIT, // 8 + TOP_BIT | TOP_RIGHT_BIT | TOP_LEFT_BIT | MID_BIT | BOT_RIGHT_BIT | 0 | BOT_BIT, // 9 }; const short barXY[7][2] = { - {1, 0}, // top - {BAR_WIDTH + 1, 1}, // top/right - {0, 1}, // top/left - {1, BAR_HEIGHT + 1}, // mid - {BAR_WIDTH + 1, BAR_HEIGHT + 2}, // bot/right - {0, BAR_HEIGHT + 2}, // bot/left - {1, 2 * BAR_HEIGHT + 2} // bot + {1, 0}, // top + {BAR_WIDTH + 1, 1}, // top/right + {0, 1}, // top/left + {1, BAR_HEIGHT + 1}, // mid + {BAR_WIDTH + 1, BAR_HEIGHT + 2}, // bot/right + {0, BAR_HEIGHT + 2}, // bot/left + {1, 2 * BAR_HEIGHT + 2} // bot }; // DRAW THE SEGMENT - different for psx and pc at the moment ----------------- diff --git a/engines/icb/tracer.cpp b/engines/icb/tracer.cpp index 16e61d4f15a..8ea401bbf80 100644 --- a/engines/icb/tracer.cpp +++ b/engines/icb/tracer.cpp @@ -40,11 +40,11 @@ _tracer *g_oTracer; #define MAX_BARRIERS (256) bool8 _tracer::Trace(const px3DRealPoint &oFrom, // IN: Point to plot from. - const px3DRealPoint &oTo, // IN: Point to plot to. - _barrier_ray_type eRayType, // IN: The type of the ray being plotted. - px3DRealPoint &oPointOfImpact, // OUT: The first point of impact. - _barrier_logic_value /*eImpactType*/ // OUT: For interpretation by high-level logic. - ) { + const px3DRealPoint &oTo, // IN: Point to plot to. + _barrier_ray_type eRayType, // IN: The type of the ray being plotted. + px3DRealPoint &oPointOfImpact, // OUT: The first point of impact. + _barrier_logic_value /*eImpactType*/ // OUT: For interpretation by high-level logic. + ) { uint32 i; uint32 nLoopCount; px2DRealPoint o2DImpactPoint; @@ -246,10 +246,10 @@ void _tracer::GetBarriersForCube(const _XYZ_index &oCubeIndices, uint32 *oThisCu } px3DRealPoint _tracer::CalculateEntryToNextCube(const px3DRealPoint &oCurrentPoint, // IN: Ray start point. - const px3DRealPoint &oTo, // IN: Ray is aimed here. - const _bullet_cube &oThisCube, // IN: The current cube boundaries. - FaceID &eCubeLeavingFace // OUT: The face the ray leaves the current cube through. - ) const { + const px3DRealPoint &oTo, // IN: Ray is aimed here. + const _bullet_cube &oThisCube, // IN: The current cube boundaries. + FaceID &eCubeLeavingFace // OUT: The face the ray leaves the current cube through. + ) const { px3DRealPoint oEntryPoint; PXreal fXNormalDistance, fYNormalDistance, fZNormalDistance; PXreal fCurrentClosest; @@ -312,10 +312,10 @@ px3DRealPoint _tracer::CalculateEntryToNextCube(const px3DRealPoint &oCurrentPoi } px3DRealPoint _tracer::CalculateRayIntersectionWithCubeWall(const px3DRealPoint &oCurrentPoint, // IN: Ray start point. - const px3DRealPoint &oTo, // IN: Ray is aimed here. - const _bullet_cube &oThisCube, // IN: The current cube boundaries. - FaceID eLeavingFace // IN: Face we're leaving through. - ) const { + const px3DRealPoint &oTo, // IN: Ray is aimed here. + const _bullet_cube &oThisCube, // IN: The current cube boundaries. + FaceID eLeavingFace // IN: Face we're leaving through. + ) const { px3DRealPoint oNewPoint(FLOAT_MAX / REAL_TWO, FLOAT_MAX / REAL_TWO, FLOAT_MAX / REAL_TWO); // Point outside the game world. PXreal fWallDistance, fFraction; PXreal fXDistance, fYDistance, fZDistance; diff --git a/engines/illusions/metaengine.cpp b/engines/illusions/metaengine.cpp index 12456248cef..0c84a874833 100644 --- a/engines/illusions/metaengine.cpp +++ b/engines/illusions/metaengine.cpp @@ -51,7 +51,7 @@ public: return "illusions"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; int getMaximumSaveSlot() const override; diff --git a/engines/illusions/sound.cpp b/engines/illusions/sound.cpp index 9a351a29bcd..d22d0bd892c 100644 --- a/engines/illusions/sound.cpp +++ b/engines/illusions/sound.cpp @@ -126,10 +126,10 @@ bool MidiPlayer::play(uint32 musicId) { sysMidiStop(); - _isLooped = isMusicLooping; - if (_isLooped) { + _isLooped = isMusicLooping; + if (_isLooped) { _loopedMusicId = musicId; - } else { + } else { _isPlaying = true; } diff --git a/engines/kingdom/detection.cpp b/engines/kingdom/detection.cpp index 0c98033aa5f..24bddfd5ba3 100644 --- a/engines/kingdom/detection.cpp +++ b/engines/kingdom/detection.cpp @@ -57,15 +57,15 @@ static const ADGameDescription gameDescriptions[] = { }, // Kingdom 3DO, provided by Strangerke - { - "kingdom", - 0, - AD_ENTRY1s("launchme", "60d2c64e3cb3e22859c4fadbc121b0db", 183452), - Common::EN_ANY, - Common::kPlatform3DO, - ADGF_UNSTABLE, - GUIO1(GUIO_NONE) - }, + { + "kingdom", + 0, + AD_ENTRY1s("launchme", "60d2c64e3cb3e22859c4fadbc121b0db", 183452), + Common::EN_ANY, + Common::kPlatform3DO, + ADGF_UNSTABLE, + GUIO1(GUIO_NONE) + }, AD_TABLE_END_MARKER }; diff --git a/engines/kyra/engine/timer_eob.cpp b/engines/kyra/engine/timer_eob.cpp index 5965b3e6366..116c1227a4c 100644 --- a/engines/kyra/engine/timer_eob.cpp +++ b/engines/kyra/engine/timer_eob.cpp @@ -193,10 +193,10 @@ void EoBCoreEngine::advanceTimers(uint32 millis) { for (int ii = 0; ii < 10; ii++) { if (c->timers[ii] > ct) { uint32 chrt = c->timers[ii] - ct; - c->timers[ii] = chrt > millis ? ct + chrt - millis : 1; + c->timers[ii] = chrt > millis ? ct + chrt - millis : 1; } else if (c->timers[ii]) { - c->timers[ii] = 1; - } + c->timers[ii] = 1; + } } } @@ -212,9 +212,9 @@ void EoBCoreEngine::advanceTimers(uint32 millis) { _scriptTimers[i].next = chrt > millis ? ct + chrt - millis : 1; debugC(3, kDebugLevelTimer, "EoBCoreEngine::advanceTimers() - CTIME: %08d SCRIPT TIMER[%02d].NEXT: %08d", ct, i, _scriptTimers[i].next); } else if (_scriptTimers[i].next) { - _scriptTimers[i].next = 1; + _scriptTimers[i].next = 1; debugC(3, kDebugLevelTimer, "EoBCoreEngine::advanceTimers() - CTIME: %08d SCRIPT TIMER[%02d].NEXT: %08d", ct, i, _scriptTimers[i].next); - } + } } } @@ -225,8 +225,8 @@ void EoBCoreEngine::advanceTimers(uint32 millis) { uint32 chrt = _wallsOfForce[i].duration - ct; _wallsOfForce[i].duration = chrt > millis ? ct + chrt - millis : 1; } else { - _wallsOfForce[i].duration = 1; - } + _wallsOfForce[i].duration = 1; + } } } diff --git a/engines/kyra/graphics/screen_eob.cpp b/engines/kyra/graphics/screen_eob.cpp index 28a325392ee..6758e733c2d 100644 --- a/engines/kyra/graphics/screen_eob.cpp +++ b/engines/kyra/graphics/screen_eob.cpp @@ -1836,7 +1836,7 @@ void OldDOSFont::drawChar(uint16 c, byte *dst, int pitch, int bpp) const { uint16 color1 = _colorMap8bit[1]; uint16 color2 = _colorMap8bit[0]; - if (_style == kStyleLeftShadow) { + if (_style == kStyleLeftShadow) { drawCharIntern(c, dst + pitch, pitch, 1, _shadowColor, 0); drawCharIntern(c, dst - 1, pitch, 1, _shadowColor, 0); drawCharIntern(c, dst - 1 + pitch, pitch, 1, _shadowColor, 0); diff --git a/engines/kyra/graphics/screen_mr.cpp b/engines/kyra/graphics/screen_mr.cpp index c0ed48e5ae5..c83ce9dd315 100644 --- a/engines/kyra/graphics/screen_mr.cpp +++ b/engines/kyra/graphics/screen_mr.cpp @@ -26,7 +26,7 @@ namespace Kyra { Screen_MR::Screen_MR(KyraEngine_MR *vm, OSystem *system) - : Screen_v2(vm, system, _screenDimTable, _screenDimTableCount) { + : Screen_v2(vm, system, _screenDimTable, _screenDimTableCount) { } Screen_MR::~Screen_MR() { diff --git a/engines/kyra/graphics/screen_v2.cpp b/engines/kyra/graphics/screen_v2.cpp index cb9fbca1b75..b47a862dc6b 100644 --- a/engines/kyra/graphics/screen_v2.cpp +++ b/engines/kyra/graphics/screen_v2.cpp @@ -278,7 +278,7 @@ void Screen_v2::setTextColorMap(const uint8 *cmap) { } void Screen_v2::wsaFrameAnimationStep(int x1, int y1, int x2, int y2, - int w1, int h1, int w2, int h2, int srcPage, int dstPage, int dim) { + int w1, int h1, int w2, int h2, int srcPage, int dstPage, int dim) { if (!w1 || !h1 || !w2 || !h2) return; diff --git a/engines/kyra/metaengine.cpp b/engines/kyra/metaengine.cpp index 7f4f4aad8bd..f2c1686ac84 100644 --- a/engines/kyra/metaengine.cpp +++ b/engines/kyra/metaengine.cpp @@ -40,11 +40,11 @@ class KyraMetaEngine : public AdvancedMetaEngine { public: - const char *getName() const override { + const char *getName() const override { return "kyra"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; SaveStateList listSaves(const char *target) const override; diff --git a/engines/lastexpress/detection.cpp b/engines/lastexpress/detection.cpp index d402bebe7bb..4530279c856 100644 --- a/engines/lastexpress/detection.cpp +++ b/engines/lastexpress/detection.cpp @@ -204,8 +204,8 @@ static const ADGameDescription gameDescriptions[] = { }; static const char *const directoryGlobs[] = { - "data", // GOG release - 0 + "data", // GOG release + 0 }; class LastExpressMetaEngineDetection : public AdvancedMetaEngineDetection { diff --git a/engines/lure/metaengine.cpp b/engines/lure/metaengine.cpp index aa114f3c976..099510822ab 100644 --- a/engines/lure/metaengine.cpp +++ b/engines/lure/metaengine.cpp @@ -52,7 +52,7 @@ LureLanguage LureEngine::getLureLanguage() const { class LureMetaEngine : public AdvancedMetaEngine { public: - const char *getName() const override { + const char *getName() const override { return "lure"; } diff --git a/engines/made/metaengine.cpp b/engines/made/metaengine.cpp index cb37dca717f..4516ae0bf5f 100644 --- a/engines/made/metaengine.cpp +++ b/engines/made/metaengine.cpp @@ -51,7 +51,7 @@ public: return "made"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; }; diff --git a/engines/mads/compression.h b/engines/mads/compression.h index d04e89b9f9f..cf892b6b248 100644 --- a/engines/mads/compression.h +++ b/engines/mads/compression.h @@ -72,8 +72,8 @@ public: class FabDecompressor { private: - int _bitsLeft; - uint32 _bitBuffer; + int _bitsLeft; + uint32 _bitBuffer; const byte *_srcData, *_srcP; int _srcSize; diff --git a/engines/mads/metaengine.cpp b/engines/mads/metaengine.cpp index 9170c6a1906..72781d2c91e 100644 --- a/engines/mads/metaengine.cpp +++ b/engines/mads/metaengine.cpp @@ -68,7 +68,7 @@ public: return "mads"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; SaveStateList listSaves(const char *target) const override; diff --git a/engines/mohawk/metaengine.cpp b/engines/mohawk/metaengine.cpp index 726fedcae48..6e830fe5c93 100644 --- a/engines/mohawk/metaengine.cpp +++ b/engines/mohawk/metaengine.cpp @@ -122,11 +122,11 @@ bool MohawkEngine_Riven::hasFeature(EngineFeature f) const { class MohawkMetaEngine : public AdvancedMetaEngine { public: - const char *getName() const override { + const char *getName() const override { return "mohawk"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; SaveStateList listSaves(const char *target) const override; diff --git a/engines/mohawk/myst_areas.h b/engines/mohawk/myst_areas.h index dd6605b1a19..f951dd932e0 100644 --- a/engines/mohawk/myst_areas.h +++ b/engines/mohawk/myst_areas.h @@ -224,7 +224,7 @@ public: void handleMouseDrag() override; void setStep(uint16 step); void setPosition(uint16 pos); - void restoreBackground(); + void restoreBackground(); protected: Common::Rect boundingBox(); diff --git a/engines/mohawk/myst_metaengine.h b/engines/mohawk/myst_metaengine.h index 340cacd0872..8083345e5c6 100644 --- a/engines/mohawk/myst_metaengine.h +++ b/engines/mohawk/myst_metaengine.h @@ -35,8 +35,8 @@ struct MystLanguage { class MohawkMetaEngine_Myst { public: - static void registerDefaultSettings(); - static const MystLanguage *listLanguages(); + static void registerDefaultSettings(); + static const MystLanguage *listLanguages(); }; } // End of namespace Mohawk diff --git a/engines/mohawk/myst_stacks/menu.cpp b/engines/mohawk/myst_stacks/menu.cpp index f31eacd8dcb..77429ac823d 100644 --- a/engines/mohawk/myst_stacks/menu.cpp +++ b/engines/mohawk/myst_stacks/menu.cpp @@ -246,8 +246,8 @@ void Menu::drawButtonImages(const Common::U32String &text, MystAreaImageSwitch * } void Menu::replaceButtonSubImageWithText(const Common::U32String &text, const Graphics::TextAlign &align, MystAreaImageSwitch *area, - uint16 subimageIndex, const Common::Rect &backgroundRect, int16 deltaY, - uint8 r, uint8 g, uint8 b) const { + uint16 subimageIndex, const Common::Rect &backgroundRect, int16 deltaY, + uint8 r, uint8 g, uint8 b) const { uint16 cardBackground = _vm->getCard()->getBackgroundImageId(); MystAreaImageSwitch::SubImage highlighted = area->getSubImage(subimageIndex); diff --git a/engines/mohawk/myst_stacks/stoneship.cpp b/engines/mohawk/myst_stacks/stoneship.cpp index e60090ceeeb..5d5c8ece2f5 100644 --- a/engines/mohawk/myst_stacks/stoneship.cpp +++ b/engines/mohawk/myst_stacks/stoneship.cpp @@ -489,11 +489,11 @@ void Stoneship::o_telescopeMove(uint16 var, const ArgumentsArray &args) { _telescopeOldMouse = mouse.x; // Copy image to screen - Common::Rect src = Common::Rect(_telescopePosition, 0, _telescopePosition + 112, 112); - _vm->_gfx->copyImageSectionToScreen(_telescopePanorama, src, display->getRect()); + Common::Rect src = Common::Rect(_telescopePosition, 0, _telescopePosition + 112, 112); + _vm->_gfx->copyImageSectionToScreen(_telescopePanorama, src, display->getRect()); - // Draw lighthouse - telescopeLighthouseDraw(); + // Draw lighthouse + telescopeLighthouseDraw(); } void Stoneship::o_telescopeStop(uint16 var, const ArgumentsArray &args) { diff --git a/engines/mohawk/riven_card.cpp b/engines/mohawk/riven_card.cpp index bb5b139c935..c47112efcde 100644 --- a/engines/mohawk/riven_card.cpp +++ b/engines/mohawk/riven_card.cpp @@ -576,7 +576,7 @@ void RivenCard::moveHotspot(uint16 blstId, const Common::Rect &position) { } void RivenCard::addMenuHotspot(uint16 blstId, const Common::Rect &position, uint16 index, - uint16 externalCommandNameId, const char *externalCommandName) { + uint16 externalCommandNameId, const char *externalCommandName) { RivenHotspot *existingHotspot = getHotspotByBlstId(blstId); if (existingHotspot) { moveHotspot(blstId, position); diff --git a/engines/mohawk/riven_metaengine.h b/engines/mohawk/riven_metaengine.h index 1ebf846b192..db8bddda169 100644 --- a/engines/mohawk/riven_metaengine.h +++ b/engines/mohawk/riven_metaengine.h @@ -35,8 +35,8 @@ struct RivenLanguage { class MohawkMetaEngine_Riven { public: - static void registerDefaultSettings(); - static const RivenLanguage *listLanguages(); + static void registerDefaultSettings(); + static const RivenLanguage *listLanguages(); }; } // End of namespace Mohawk diff --git a/engines/mohawk/riven_saveload.cpp b/engines/mohawk/riven_saveload.cpp index 0aeef7dbbe0..4cff6bdc8d9 100644 --- a/engines/mohawk/riven_saveload.cpp +++ b/engines/mohawk/riven_saveload.cpp @@ -410,7 +410,7 @@ Common::MemoryWriteStreamDynamic *RivenSaveLoad::genMETASection(const Common::St } Common::Error RivenSaveLoad::saveGame(const int slot, const Common::String &description, - const Graphics::Surface *thumbnail, bool autoSave) { + const Graphics::Surface *thumbnail, bool autoSave) { // NOTE: This code is designed to only output a Mohawk archive // for a Riven saved game. It's hardcoded to do this because // (as of right now) this is the only place in the engine diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp index 65e339d93fb..f93cd62afe2 100644 --- a/engines/mohawk/riven_scripts.cpp +++ b/engines/mohawk/riven_scripts.cpp @@ -919,7 +919,7 @@ void RivenSwitchCommand::applyCardPatches(uint32 globalId, int scriptType, uint1 } RivenStackChangeCommand::RivenStackChangeCommand(MohawkEngine_Riven *vm, uint16 stackId, uint32 globalCardId, - bool byStackId, bool byStackCardId) : + bool byStackId, bool byStackCardId) : RivenCommand(vm), _stackId(stackId), _cardId(globalCardId), diff --git a/engines/mohawk/riven_stacks/jspit.cpp b/engines/mohawk/riven_stacks/jspit.cpp index e8c133c288f..adc62e19283 100644 --- a/engines/mohawk/riven_stacks/jspit.cpp +++ b/engines/mohawk/riven_stacks/jspit.cpp @@ -305,9 +305,9 @@ void JSpit::xvga1300_carriage(const ArgumentArray &args) { if (gotClick) { RivenScriptPtr script = _vm->_scriptMan->createScriptFromData(3, - kRivenCommandChangeCard, 1, getCardStackId(0x18D4D), - kRivenCommandTransition, 1, kRivenTransitionPanLeft, - kRivenCommandChangeCard, 1, getCardStackId(0x18AB5)); + kRivenCommandChangeCard, 1, getCardStackId(0x18D4D), + kRivenCommandTransition, 1, kRivenTransitionPanLeft, + kRivenCommandChangeCard, 1, getCardStackId(0x18AB5)); _vm->_scriptMan->runScript(script, false); // FIXME: kRivenCommandStoreMovieOpcode takes more arguments.. does it work with the original engine? diff --git a/engines/myst3/archive.cpp b/engines/myst3/archive.cpp index 1727d0bc64e..e4e537c19ef 100644 --- a/engines/myst3/archive.cpp +++ b/engines/myst3/archive.cpp @@ -154,7 +154,7 @@ const Archive::DirectoryEntry *Archive::getEntry(const Common::String &room, uin } ResourceDescription Archive::getDescription(const Common::String &room, uint32 index, uint16 face, - ResourceType type) { + ResourceType type) { const DirectoryEntry *entry = getEntry(room, index); if (!entry) { return ResourceDescription(); @@ -171,7 +171,7 @@ ResourceDescription Archive::getDescription(const Common::String &room, uint32 i } ResourceDescriptionArray Archive::listFilesMatching(const Common::String &room, uint32 index, uint16 face, - ResourceType type) { + ResourceType type) { const DirectoryEntry *entry = getEntry(room, index); if (!entry) { return ResourceDescriptionArray(); diff --git a/engines/myst3/hotspot.cpp b/engines/myst3/hotspot.cpp index 1235c15329e..2552d908e56 100644 --- a/engines/myst3/hotspot.cpp +++ b/engines/myst3/hotspot.cpp @@ -32,8 +32,8 @@ namespace Myst3 { static void polarRectTo3dRect(const PolarRect &polarRect, - Math::Vector3d &topLeft, Math::Vector3d &topRight, - Math::Vector3d &bottomLeft, Math::Vector3d &bottomRight) { + Math::Vector3d &topLeft, Math::Vector3d &topRight, + Math::Vector3d &bottomLeft, Math::Vector3d &bottomRight) { static const float scale = 50.0; Math::Vector3d direction = Scene::directionToVector(polarRect.centerPitch, 90.0 - polarRect.centerHeading) * scale; @@ -54,7 +54,7 @@ static void polarRectTo3dRect(const PolarRect &polarRect, } bool static rayIntersectsRect(const Math::Ray &ray, const Math::Vector3d &topLeft, const Math::Vector3d &topRight, - const Math::Vector3d &bottomLeft, const Math::Vector3d &bottomRight) { + const Math::Vector3d &bottomLeft, const Math::Vector3d &bottomRight) { // Orthogonal basis in rectangle coordinates Math::Vector3d topRectDir = topRight - topLeft; Math::Vector3d leftRectDir = bottomLeft - topLeft; diff --git a/engines/myst3/myst3.cpp b/engines/myst3/myst3.cpp index 34360442eed..b4a84335763 100644 --- a/engines/myst3/myst3.cpp +++ b/engines/myst3/myst3.cpp @@ -1315,7 +1315,7 @@ void Myst3Engine::loadNodeSubtitles(uint32 id) { } ResourceDescription Myst3Engine::getFileDescription(const Common::String &room, uint32 index, uint16 face, - Archive::ResourceType type) { + Archive::ResourceType type) { Common::String archiveRoom = room; if (archiveRoom == "") { archiveRoom = _db->getRoomName(_state->getLocationRoom(), _state->getLocationAge()); @@ -1338,7 +1338,7 @@ ResourceDescription Myst3Engine::getFileDescription(const Common::String &room, } ResourceDescriptionArray Myst3Engine::listFilesMatching(const Common::String &room, uint32 index, uint16 face, - Archive::ResourceType type) { + Archive::ResourceType type) { Common::String archiveRoom = room; if (archiveRoom == "") { archiveRoom = _db->getRoomName(_state->getLocationRoom(), _state->getLocationAge()); diff --git a/engines/neverhood/graphics.h b/engines/neverhood/graphics.h index 6f4d658c7fe..de9723e89ee 100644 --- a/engines/neverhood/graphics.h +++ b/engines/neverhood/graphics.h @@ -43,11 +43,11 @@ struct NDimensions { struct NRect { int16 x1, y1, x2, y2; - static NRect make(int16 x01, int16 y01, int16 x02, int16 y02) { - NRect r; - r.set(x01, y01, x02, y02); + static NRect make(int16 x01, int16 y01, int16 x02, int16 y02) { + NRect r; + r.set(x01, y01, x02, y02); return r; - } + } void set(int16 x01, int16 y01, int16 x02, int16 y02) { x1 = x01; diff --git a/engines/neverhood/metaengine.cpp b/engines/neverhood/metaengine.cpp index 7c8b3291237..b0da9288c22 100644 --- a/engines/neverhood/metaengine.cpp +++ b/engines/neverhood/metaengine.cpp @@ -62,7 +62,7 @@ public: return "neverhood"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; SaveStateList listSaves(const char *target) const override; diff --git a/engines/neverhood/scene.h b/engines/neverhood/scene.h index 0a848ed98b6..33c63d2e762 100644 --- a/engines/neverhood/scene.h +++ b/engines/neverhood/scene.h @@ -222,7 +222,7 @@ protected: void loadDataResource(uint32 fileHash); uint16 convertMessageNum(uint32 messageNum); - void setHitRects(HitRectList *hitRects); + void setHitRects(HitRectList *hitRects); void clearHitRects(); void clearCollisionSprites(); diff --git a/engines/petka/metaengine.cpp b/engines/petka/metaengine.cpp index 4a7b7be67a8..b341451181e 100644 --- a/engines/petka/metaengine.cpp +++ b/engines/petka/metaengine.cpp @@ -29,11 +29,11 @@ class PetkaMetaEngine : public AdvancedMetaEngine { public: - const char *getName() const override { + const char *getName() const override { return "petka"; } - virtual bool hasFeature(MetaEngineFeature f) const override; + virtual bool hasFeature(MetaEngineFeature f) const override; virtual int getMaximumSaveSlot() const override { return 17; } virtual SaveStateList listSaves(const char *target) const override; virtual void removeSaveState(const char *target, int slot) const override; diff --git a/engines/pink/metaengine.cpp b/engines/pink/metaengine.cpp index c94b73506ae..70813a63d76 100644 --- a/engines/pink/metaengine.cpp +++ b/engines/pink/metaengine.cpp @@ -40,7 +40,7 @@ public: return "pink"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; int getMaximumSaveSlot() const override { return 99; } SaveStateList listSaves(const char *target) const override; diff --git a/engines/plumbers/plumbers.h b/engines/plumbers/plumbers.h index 35b60fc656c..be38b5e45f2 100644 --- a/engines/plumbers/plumbers.h +++ b/engines/plumbers/plumbers.h @@ -155,7 +155,7 @@ private: void initTables(); void readTablesPC(const Common::String &fileName); - void readTables3DO(const Common::String &fileName); + void readTables3DO(const Common::String &fileName); int getSceneNumb(const Common::String &sName); int getMouseHiLite(); diff --git a/engines/prince/detection.cpp b/engines/prince/detection.cpp index d56bdaef49b..80d40df3b68 100644 --- a/engines/prince/detection.cpp +++ b/engines/prince/detection.cpp @@ -79,18 +79,18 @@ static const PrinceGameDescription gameDescriptions[] = { }, kPrinceDataDE }, - { - { - "prince", - "", - AD_ENTRY1s("databank.ptc", "eb702d16e88c8c41f963d449287c8023", 3730152), - Common::RU_RUS, - Common::kPlatformWindows, - GF_RUSPROJEDITION | ADGF_USEEXTRAASTITLE | ADGF_DROPPLATFORM, - GUIO1(GUIO_NONE) - }, - kPrinceDataDE - }, + { + { + "prince", + "", + AD_ENTRY1s("databank.ptc", "eb702d16e88c8c41f963d449287c8023", 3730152), + Common::RU_RUS, + Common::kPlatformWindows, + GF_RUSPROJEDITION | ADGF_USEEXTRAASTITLE | ADGF_DROPPLATFORM, + GUIO1(GUIO_NONE) + }, + kPrinceDataDE + }, { { "prince", diff --git a/engines/prince/detection.h b/engines/prince/detection.h index 79635ce4dda..7fc146d449c 100644 --- a/engines/prince/detection.h +++ b/engines/prince/detection.h @@ -34,10 +34,10 @@ enum PrinceGameType { }; enum { - GF_TRANSLATED = 1 << 0, - GF_EXTRACTED = 1 << 1, - GF_NOVOICES = 1 << 2, - GF_RUSPROJEDITION = 1 << 3 + GF_TRANSLATED = 1 << 0, + GF_EXTRACTED = 1 << 1, + GF_NOVOICES = 1 << 2, + GF_RUSPROJEDITION = 1 << 3 }; struct PrinceGameDescription { diff --git a/engines/prince/hero_set.h b/engines/prince/hero_set.h index fc62cef7571..39a404e44fd 100644 --- a/engines/prince/hero_set.h +++ b/engines/prince/hero_set.h @@ -58,177 +58,177 @@ static HeroSetAnimNames heroSet5 = { }; static HeroSetAnimNames heroSet1 = { - "SL_HERO1.ANI", - "SR_HERO1.ANI", - "SU_HERO1.ANI", - "SD_HERO1.ANI", - "ML_HERO1.ANI", - "MR_HERO1.ANI", - "MU_HERO1.ANI", - "MD_HERO1.ANI", - "TL_HERO1.ANI", - "TR_HERO1.ANI", - "TU_HERO1.ANI", - "TD_HERO1.ANI", - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - "KSI_KURZ.ANI", - "KS_WLOSY.ANI" + "SL_HERO1.ANI", + "SR_HERO1.ANI", + "SU_HERO1.ANI", + "SD_HERO1.ANI", + "ML_HERO1.ANI", + "MR_HERO1.ANI", + "MU_HERO1.ANI", + "MD_HERO1.ANI", + "TL_HERO1.ANI", + "TR_HERO1.ANI", + "TU_HERO1.ANI", + "TD_HERO1.ANI", + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + "KSI_KURZ.ANI", + "KS_WLOSY.ANI" }; static HeroSetAnimNames heroSet2 = { - "SL_HERO2.ANI", - "SR_HERO2.ANI", - "SU_HERO2.ANI", - "SD_HERO2.ANI", - "ML_HERO2.ANI", - "MR_HERO2.ANI", - "MU_HERO2.ANI", - "MD_HERO2.ANI", - "TL_HERO2.ANI", - "TR_HERO2.ANI", - "TU_HERO2.ANI", - "TD_HERO2.ANI", - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - "KSI_KU_S.ANI", - "KS_WLO_S.ANI" + "SL_HERO2.ANI", + "SR_HERO2.ANI", + "SU_HERO2.ANI", + "SD_HERO2.ANI", + "ML_HERO2.ANI", + "MR_HERO2.ANI", + "MU_HERO2.ANI", + "MD_HERO2.ANI", + "TL_HERO2.ANI", + "TR_HERO2.ANI", + "TU_HERO2.ANI", + "TD_HERO2.ANI", + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + "KSI_KU_S.ANI", + "KS_WLO_S.ANI" }; static HeroSetAnimNames heroSet3 = { - "SL_BEAR.ANI", - "SR_BEAR.ANI", - "SU_BEAR.ANI", - "SD_BEAR.ANI", - "NIED-LEW.ANI", - "NIED-PRW.ANI", - "NIED-TYL.ANI", - "NIED-PRZ.ANI", - "SL_BEAR.ANI", - "SR_BEAR.ANI", - "SU_BEAR.ANI", - "SD_BEAR.ANI", - "N_LW-TYL.ANI", - "N_LW-PRZ.ANI", - "N_LW-PR.ANI", - "N_PR-TYL.ANI", - "N_PR-PRZ.ANI", - "N_PR-LW.ANI", - "N_TYL-LW.ANI", - "N_TYL-PR.ANI", - "N_TL-PRZ.ANI", - "N_PRZ-LW.ANI", - "N_PRZ-PR.ANI", - "N_PRZ-TL.ANI", - nullptr, - nullptr, + "SL_BEAR.ANI", + "SR_BEAR.ANI", + "SU_BEAR.ANI", + "SD_BEAR.ANI", + "NIED-LEW.ANI", + "NIED-PRW.ANI", + "NIED-TYL.ANI", + "NIED-PRZ.ANI", + "SL_BEAR.ANI", + "SR_BEAR.ANI", + "SU_BEAR.ANI", + "SD_BEAR.ANI", + "N_LW-TYL.ANI", + "N_LW-PRZ.ANI", + "N_LW-PR.ANI", + "N_PR-TYL.ANI", + "N_PR-PRZ.ANI", + "N_PR-LW.ANI", + "N_TYL-LW.ANI", + "N_TYL-PR.ANI", + "N_TL-PRZ.ANI", + "N_PRZ-LW.ANI", + "N_PRZ-PR.ANI", + "N_PRZ-TL.ANI", + nullptr, + nullptr, }; static HeroSetAnimNames shanSet1 = { - "SL_SHAN.ANI", - "SR_SHAN.ANI", - "SU_SHAN.ANI", - "SD_SHAN.ANI", - "ML_SHAN.ANI", - "MR_SHAN.ANI", - "MU_SHAN.ANI", - "MD_SHAN.ANI", - "TL_SHAN.ANI", - "TR_SHAN.ANI", - "TU_SHAN.ANI", - "TD_SHAN.ANI", - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - "B1_SHAN.ANI", - "B2_SHAN.ANI", + "SL_SHAN.ANI", + "SR_SHAN.ANI", + "SU_SHAN.ANI", + "SD_SHAN.ANI", + "ML_SHAN.ANI", + "MR_SHAN.ANI", + "MU_SHAN.ANI", + "MD_SHAN.ANI", + "TL_SHAN.ANI", + "TR_SHAN.ANI", + "TU_SHAN.ANI", + "TD_SHAN.ANI", + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + "B1_SHAN.ANI", + "B2_SHAN.ANI", }; static HeroSetAnimNames shanSet2 = { - "SL_SHAN2.ANI", - "SR_SHAN2.ANI", - "SU_SHAN.ANI", - "SD_SHAN2.ANI", - "ML_SHAN2.ANI", - "MR_SHAN2.ANI", - "MU_SHAN.ANI", - "MD_SHAN2.ANI", - "TL_SHAN2.ANI", - "TR_SHAN2.ANI", - "TU_SHAN.ANI", - "TD_SHAN2.ANI", - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - "B1_SHAN2.ANI", - "B2_SHAN2.ANI" + "SL_SHAN2.ANI", + "SR_SHAN2.ANI", + "SU_SHAN.ANI", + "SD_SHAN2.ANI", + "ML_SHAN2.ANI", + "MR_SHAN2.ANI", + "MU_SHAN.ANI", + "MD_SHAN2.ANI", + "TL_SHAN2.ANI", + "TR_SHAN2.ANI", + "TU_SHAN.ANI", + "TD_SHAN2.ANI", + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + "B1_SHAN2.ANI", + "B2_SHAN2.ANI" }; static HeroSetAnimNames arivSet1 = { - "SL_ARIV.ANI", - "SR_ARIV.ANI", - "SU_ARIV.ANI", - "SD_ARIV.ANI", - "ML_ARIV.ANI", - "MR_ARIV.ANI", - "MU_ARIV.ANI", - "MD_ARIV.ANI", - "TL_ARIV.ANI", - "TR_ARIV.ANI", - "TU_ARIV.ANI", - "TD_ARIV.ANI", - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr + "SL_ARIV.ANI", + "SR_ARIV.ANI", + "SU_ARIV.ANI", + "SD_ARIV.ANI", + "ML_ARIV.ANI", + "MR_ARIV.ANI", + "MU_ARIV.ANI", + "MD_ARIV.ANI", + "TL_ARIV.ANI", + "TR_ARIV.ANI", + "TU_ARIV.ANI", + "TD_ARIV.ANI", + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr }; const HeroSetAnimNames *heroSetTable[7] = { diff --git a/engines/prince/inventory.cpp b/engines/prince/inventory.cpp index b363126e1ff..631e4f16ac6 100644 --- a/engines/prince/inventory.cpp +++ b/engines/prince/inventory.cpp @@ -531,12 +531,12 @@ void PrinceEngine::checkOptions() { optText = optionsTextEN[i]; break; case Common::RU_RUS: - if (getFeatures() & GF_RUSPROJEDITION) { - optText = optionsTextRU2[i]; - } else { - optText = optionsTextRU[i]; - } - break; + if (getFeatures() & GF_RUSPROJEDITION) { + optText = optionsTextRU2[i]; + } else { + optText = optionsTextRU[i]; + } + break; default: break; }; @@ -587,12 +587,12 @@ void PrinceEngine::checkInvOptions() { invText = invOptionsTextEN[i]; break; case Common::RU_RUS: - if (getFeatures() & GF_RUSPROJEDITION) { - invText = invOptionsTextRU2[i]; - } else { - invText = invOptionsTextRU[i]; - } - break; + if (getFeatures() & GF_RUSPROJEDITION) { + invText = invOptionsTextRU2[i]; + } else { + invText = invOptionsTextRU[i]; + } + break; default: error("Unknown game language %d", getLanguage()); break; diff --git a/engines/prince/metaengine.cpp b/engines/prince/metaengine.cpp index cb54f7ce215..4b16900b7b0 100644 --- a/engines/prince/metaengine.cpp +++ b/engines/prince/metaengine.cpp @@ -46,7 +46,7 @@ Common::Language PrinceEngine::getLanguage() const { class PrinceMetaEngine : public AdvancedMetaEngine { public: - const char *getName() const override { + const char *getName() const override { return "prince"; } diff --git a/engines/prince/videoplayer.cpp b/engines/prince/videoplayer.cpp index 2e73c78a0dc..3c661cfa0c8 100644 --- a/engines/prince/videoplayer.cpp +++ b/engines/prince/videoplayer.cpp @@ -29,14 +29,14 @@ namespace Prince { void PrinceEngine::playVideo(Common::String videoFilename) { - // Set the correct video mode - initGraphics(640, 480, nullptr); - if (_system->getScreenFormat().bytesPerPixel == 1) { - warning("Couldn't switch to a RGB color video mode to play a video."); - return; - } + // Set the correct video mode + initGraphics(640, 480, nullptr); + if (_system->getScreenFormat().bytesPerPixel == 1) { + warning("Couldn't switch to a RGB color video mode to play a video."); + return; + } - debug(2, "Screen format: %s", _system->getScreenFormat().toString().c_str()); + debug(2, "Screen format: %s", _system->getScreenFormat().toString().c_str()); Video::VideoDecoder *videoDecoder = new Video::AVIDecoder(); if (!videoDecoder->loadFile(videoFilename)) { diff --git a/engines/queen/metaengine.cpp b/engines/queen/metaengine.cpp index 5529281adc2..805fdc3beb7 100644 --- a/engines/queen/metaengine.cpp +++ b/engines/queen/metaengine.cpp @@ -31,11 +31,11 @@ class QueenMetaEngine : public AdvancedMetaEngine { public: - const char *getName() const override { + const char *getName() const override { return "queen"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; SaveStateList listSaves(const char *target) const override; int getMaximumSaveSlot() const override { return 99; } diff --git a/engines/saga/metaengine.cpp b/engines/saga/metaengine.cpp index cfe28f1b1ac..e4fe89d3ad7 100644 --- a/engines/saga/metaengine.cpp +++ b/engines/saga/metaengine.cpp @@ -76,7 +76,7 @@ public: return "saga"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; diff --git a/engines/sci/detection_tables.h b/engines/sci/detection_tables.h index bddc2c467c4..aa3e7c0c847 100644 --- a/engines/sci/detection_tables.h +++ b/engines/sci/detection_tables.h @@ -800,14 +800,14 @@ static const struct ADGameDescription SciGameDescriptions[] = { Common::EN_ANY, Common::kPlatformDOS, 0, GUIO_STD16_SPEECH }, #define GUIO_GK1_FLOPPY GUIO2(GUIO_NOSPEECH, \ - GAMEOPTION_ORIGINAL_SAVELOAD) + GAMEOPTION_ORIGINAL_SAVELOAD) #define GUIO_GK1_CD_DOS GUIO4(GUIO_LINKSPEECHTOSFX, \ - GAMEOPTION_ORIGINAL_SAVELOAD, \ - GAMEOPTION_HIGH_RESOLUTION_GRAPHICS, \ - GAMEOPTION_HQ_VIDEO) + GAMEOPTION_ORIGINAL_SAVELOAD, \ + GAMEOPTION_HIGH_RESOLUTION_GRAPHICS, \ + GAMEOPTION_HQ_VIDEO) #define GUIO_GK1_CD_WIN GUIO3(GUIO_LINKSPEECHTOSFX, \ - GAMEOPTION_ORIGINAL_SAVELOAD, \ - GAMEOPTION_HQ_VIDEO) + GAMEOPTION_ORIGINAL_SAVELOAD, \ + GAMEOPTION_HQ_VIDEO) #define GUIO_GK1_MAC GUIO1(GUIO_NOSPEECH) // Gabriel Knight - English DOS Floppy @@ -924,19 +924,19 @@ static const struct ADGameDescription SciGameDescriptions[] = { #undef GUIO_GK1_MAC #define GUIO_GK2_DEMO GUIO8(GUIO_NOSUBTITLES, \ - GUIO_NOMUSIC, \ - GUIO_NOSFX, \ - GUIO_NOSPEECH, \ - GUIO_NOMIDI, \ - GUIO_NOLAUNCHLOAD, \ - GUIO_NOASPECT, \ - GAMEOPTION_HQ_VIDEO) + GUIO_NOMUSIC, \ + GUIO_NOSFX, \ + GUIO_NOSPEECH, \ + GUIO_NOMIDI, \ + GUIO_NOLAUNCHLOAD, \ + GUIO_NOASPECT, \ + GAMEOPTION_HQ_VIDEO) #define GUIO_GK2 GUIO6(GUIO_LINKSPEECHTOSFX, \ - GUIO_NOMIDI, \ - GUIO_NOASPECT, \ - GAMEOPTION_ORIGINAL_SAVELOAD, \ - GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ - GAMEOPTION_HQ_VIDEO) + GUIO_NOMIDI, \ + GUIO_NOASPECT, \ + GAMEOPTION_ORIGINAL_SAVELOAD, \ + GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ + GAMEOPTION_HQ_VIDEO) #define GUIO_GK2_MAC GUIO_GK2 // Gabriel Knight 2 - English Windows Non-Interactive Demo @@ -1288,18 +1288,18 @@ static const struct ADGameDescription SciGameDescriptions[] = { Common::EN_ANY, Common::kPlatformMacintosh, ADGF_MACRESFORK, GUIO_STD16_MAC }, #define GUIO_HOYLE5 GUIO5(GUIO_NOMIDI, \ - GUIO_NOLAUNCHLOAD, \ - GUIO_LINKMUSICTOSFX, \ - GUIO_LINKSPEECHTOSFX, \ - GUIO_NOASPECT) + GUIO_NOLAUNCHLOAD, \ + GUIO_LINKMUSICTOSFX, \ + GUIO_LINKSPEECHTOSFX, \ + GUIO_NOASPECT) // versions with bridge or poker have save/load screens #define GUIO_HOYLE5_SAVELOAD GUIO6(GUIO_NOMIDI, \ - GUIO_NOLAUNCHLOAD, \ - GUIO_LINKMUSICTOSFX, \ - GUIO_LINKSPEECHTOSFX, \ - GUIO_NOASPECT, \ - GAMEOPTION_ORIGINAL_SAVELOAD ) + GUIO_NOLAUNCHLOAD, \ + GUIO_LINKMUSICTOSFX, \ + GUIO_LINKSPEECHTOSFX, \ + GUIO_NOASPECT, \ + GAMEOPTION_ORIGINAL_SAVELOAD ) // Hoyle 5 (Hoyle Classic Games) - Windows demo {"hoyle5", "Demo", { @@ -2123,15 +2123,15 @@ static const struct ADGameDescription SciGameDescriptions[] = { #undef GUIO_KQ6_CD_WINDOWS #define GUIO_KQ7_DEMO GUIO5(GUIO_NOSUBTITLES, \ - GUIO_NOLAUNCHLOAD, \ - GUIO_LINKMUSICTOSFX, \ - GUIO_LINKSPEECHTOSFX, \ - GUIO_NOASPECT) + GUIO_NOLAUNCHLOAD, \ + GUIO_LINKMUSICTOSFX, \ + GUIO_LINKSPEECHTOSFX, \ + GUIO_NOASPECT) #define GUIO_KQ7 GUIO5(GUIO_NOASPECT, \ - GUIO_LINKMUSICTOSFX, \ - GUIO_LINKSPEECHTOSFX, \ - GAMEOPTION_HQ_VIDEO, \ - GAMEOPTION_UPSCALE_VIDEOS) + GUIO_LINKMUSICTOSFX, \ + GUIO_LINKSPEECHTOSFX, \ + GAMEOPTION_HQ_VIDEO, \ + GAMEOPTION_UPSCALE_VIDEOS) // King's Quest 7 - English Windows (from the King's Quest Collection) // Executable scanning reports "2.100.002", VERSION file reports "1.4" @@ -3100,10 +3100,10 @@ static const struct ADGameDescription SciGameDescriptions[] = { Common::EN_ANY, Common::kPlatformDOS, 0, GUIO_STD16 }, #define GUIO_LSL6HIRES GUIO3(GUIO_NOASPECT, \ - GUIO_LINKSPEECHTOSFX, \ - GAMEOPTION_ORIGINAL_SAVELOAD) + GUIO_LINKSPEECHTOSFX, \ + GAMEOPTION_ORIGINAL_SAVELOAD) #define GUIO_LSL6HIRES_MAC GUIO2(GUIO_NOASPECT, \ - GUIO_LINKSPEECHTOSFX) + GUIO_LINKSPEECHTOSFX) // Larry 6 - English/German DOS CD - HIRES // SCI interpreter version 2.100.002 @@ -3151,15 +3151,15 @@ static const struct ADGameDescription SciGameDescriptions[] = { #undef GUIO_LSL6HIRES_MAC #define GUIO_LSL7_DEMO GUIO4(GUIO_NOASPECT, \ - GUIO_NOMIDI, \ - GUIO_NOLAUNCHLOAD, \ - GAMEOPTION_LARRYSCALE) + GUIO_NOMIDI, \ + GUIO_NOLAUNCHLOAD, \ + GAMEOPTION_LARRYSCALE) #define GUIO_LSL7 GUIO6(GUIO_NOASPECT, \ - GUIO_NOMIDI, \ - GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ - GAMEOPTION_ORIGINAL_SAVELOAD, \ - GAMEOPTION_HQ_VIDEO, \ - GAMEOPTION_LARRYSCALE) + GUIO_NOMIDI, \ + GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ + GAMEOPTION_ORIGINAL_SAVELOAD, \ + GAMEOPTION_HQ_VIDEO, \ + GAMEOPTION_LARRYSCALE) // Larry 7 - English DOS Demo (provided by richiefs in bug report #4214) // SCI interpreter version 2.100.002 @@ -3252,26 +3252,26 @@ static const struct ADGameDescription SciGameDescriptions[] = { #undef GUIO_LSL7 #define GUIO_LIGHTHOUSE_DEMO GUIO6(GUIO_NOSPEECH, \ - GUIO_NOMUSIC, \ - GUIO_NOASPECT, \ - GUIO_NOMIDI, \ - GUIO_NOLAUNCHLOAD, \ - GAMEOPTION_HQ_VIDEO) + GUIO_NOMUSIC, \ + GUIO_NOASPECT, \ + GUIO_NOMIDI, \ + GUIO_NOLAUNCHLOAD, \ + GAMEOPTION_HQ_VIDEO) #define GUIO_LIGHTHOUSE GUIO8(GUIO_NOASPECT, \ - GUIO_NOMIDI, \ - GUIO_NOSUBTITLES, \ - GUIO_LINKMUSICTOSFX, \ - GUIO_LINKSPEECHTOSFX, \ - GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ - GAMEOPTION_ORIGINAL_SAVELOAD, \ - GAMEOPTION_HQ_VIDEO) + GUIO_NOMIDI, \ + GUIO_NOSUBTITLES, \ + GUIO_LINKMUSICTOSFX, \ + GUIO_LINKSPEECHTOSFX, \ + GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ + GAMEOPTION_ORIGINAL_SAVELOAD, \ + GAMEOPTION_HQ_VIDEO) #define GUIO_LIGHTHOUSE_MAC GUIO7(GUIO_NOASPECT, \ - GUIO_NOMIDI, \ - GUIO_NOSUBTITLES, \ - GUIO_LINKMUSICTOSFX, \ - GUIO_LINKSPEECHTOSFX, \ - GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ - GAMEOPTION_HQ_VIDEO) + GUIO_NOMIDI, \ + GUIO_NOSUBTITLES, \ + GUIO_LINKMUSICTOSFX, \ + GUIO_LINKSPEECHTOSFX, \ + GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ + GAMEOPTION_HQ_VIDEO) // Lighthouse - English Windows Demo (from jvprat) // Executable scanning reports "2.100.002", VERSION file reports "1.00" @@ -3503,9 +3503,9 @@ static const struct ADGameDescription SciGameDescriptions[] = { Common::JA_JPN, Common::kPlatformFMTowns, ADGF_ADDENGLISH, GUIO5(GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE, GAMEOPTION_RGB_RENDERING) }, #define GUIO_MOTHERGOOSEHIRES GUIO4(GUIO_NOSUBTITLES, \ - GUIO_NOASPECT, \ - GUIO_LINKSPEECHTOSFX, \ - GUIO_NOLAUNCHLOAD) + GUIO_NOASPECT, \ + GUIO_LINKSPEECHTOSFX, \ + GUIO_NOLAUNCHLOAD) // Mixed-Up Mother Goose Deluxe - EN/ES Windows CD (supplied by markcoolio in bug report #4273) // Executable scanning reports "2.100.002" @@ -3544,11 +3544,11 @@ static const struct ADGameDescription SciGameDescriptions[] = { Common::EN_ANY, Common::kPlatformDOS, 0, GUIO_STD16 }, #define GUIO_PHANTASMAGORIA_DEMO GUIO6(GUIO_NOSUBTITLES, \ - GUIO_NOASPECT, \ - GUIO_NOLAUNCHLOAD, \ - GUIO_LINKSPEECHTOSFX, \ - GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ - GAMEOPTION_HQ_VIDEO) + GUIO_NOASPECT, \ + GUIO_NOLAUNCHLOAD, \ + GUIO_LINKSPEECHTOSFX, \ + GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ + GAMEOPTION_HQ_VIDEO) #define GUIO_PHANTASMAGORIA GUIO_PHANTASMAGORIA_DEMO #define GUIO_PHANTASMAGORIA_MAC GUIO_PHANTASMAGORIA_DEMO @@ -3722,24 +3722,24 @@ static const struct ADGameDescription SciGameDescriptions[] = { #undef GUIO_PHANTASMAGORIA_MAC #define GUIO_PHANTASMAGORIA2 GUIO9(GUIO_NOSUBTITLES, \ - GUIO_LINKMUSICTOSFX, \ - GUIO_LINKSPEECHTOSFX, \ - GUIO_NOMIDI, \ - GUIO_NOASPECT, \ - GAMEOPTION_ORIGINAL_SAVELOAD, \ - GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ - GAMEOPTION_HQ_VIDEO, \ - GAMEOPTION_ENABLE_CENSORING) + GUIO_LINKMUSICTOSFX, \ + GUIO_LINKSPEECHTOSFX, \ + GUIO_NOMIDI, \ + GUIO_NOASPECT, \ + GAMEOPTION_ORIGINAL_SAVELOAD, \ + GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ + GAMEOPTION_HQ_VIDEO, \ + GAMEOPTION_ENABLE_CENSORING) // TODO: Learn which are the censored game editions and give them this GUIO // instead #define GUIO_PHANTASMAGORIA2_CENSORED GUIO8(GUIO_NOSUBTITLES, \ - GUIO_LINKMUSICTOSFX, \ - GUIO_LINKSPEECHTOSFX, \ - GUIO_NOMIDI, \ - GUIO_NOASPECT, \ - GAMEOPTION_ORIGINAL_SAVELOAD, \ - GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ - GAMEOPTION_HQ_VIDEO) + GUIO_LINKMUSICTOSFX, \ + GUIO_LINKSPEECHTOSFX, \ + GUIO_NOMIDI, \ + GUIO_NOASPECT, \ + GAMEOPTION_ORIGINAL_SAVELOAD, \ + GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ + GAMEOPTION_HQ_VIDEO) // Some versions of Phantasmagoria 2 were heavily censored. // Censored versions (data files are currently unknown to us): UK, Australia, first English release in Germany @@ -4077,10 +4077,10 @@ static const struct ADGameDescription SciGameDescriptions[] = { Common::EN_ANY, Common::kPlatformDOS, 0, GUIO_STD16 }, #define GUIO_PQ4_FLOPPY GUIO2(GUIO_NOSPEECH, \ - GAMEOPTION_ORIGINAL_SAVELOAD) + GAMEOPTION_ORIGINAL_SAVELOAD) #define GUIO_PQ4_CD GUIO3(GUIO_LINKSPEECHTOSFX, \ - GAMEOPTION_HIGH_RESOLUTION_GRAPHICS, \ - GAMEOPTION_ORIGINAL_SAVELOAD) + GAMEOPTION_HIGH_RESOLUTION_GRAPHICS, \ + GAMEOPTION_ORIGINAL_SAVELOAD) #define GUIO_PQ4_MAC GUIO1(GUIO_LINKSPEECHTOSFX) // Police Quest 4 - English DOS CD (from the Police Quest Collection) @@ -4147,19 +4147,19 @@ static const struct ADGameDescription SciGameDescriptions[] = { #undef GUIO_PQ4_MAC #define GUIO_PQSWAT_DEMO GUIO6(GUIO_NOSUBTITLES, \ - GUIO_NOMIDI, \ - GUIO_LINKMUSICTOSFX, \ - GUIO_LINKSPEECHTOSFX, \ - GUIO_NOASPECT, \ - GUIO_NOLAUNCHLOAD) + GUIO_NOMIDI, \ + GUIO_LINKMUSICTOSFX, \ + GUIO_LINKSPEECHTOSFX, \ + GUIO_NOASPECT, \ + GUIO_NOLAUNCHLOAD) #define GUIO_PQSWAT GUIO8(GUIO_NOSUBTITLES, \ - GUIO_NOMIDI, \ - GUIO_LINKMUSICTOSFX, \ - GUIO_LINKSPEECHTOSFX, \ - GUIO_NOASPECT, \ - GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ - GAMEOPTION_HQ_VIDEO, \ - GAMEOPTION_UPSCALE_VIDEOS) + GUIO_NOMIDI, \ + GUIO_LINKMUSICTOSFX, \ + GUIO_LINKSPEECHTOSFX, \ + GUIO_NOASPECT, \ + GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ + GAMEOPTION_HQ_VIDEO, \ + GAMEOPTION_UPSCALE_VIDEOS) // Police Quest: SWAT - English DOS/Windows Demo (from jvprat) // Executable scanning reports "2.100.002", VERSION file reports "0.001.200" @@ -4610,10 +4610,10 @@ static const struct ADGameDescription SciGameDescriptions[] = { Common::EN_ANY, Common::kPlatformDOS, 0, GUIO_STD16 }, #define GUIO_QFG4_FLOPPY GUIO2(GUIO_NOSPEECH, \ - GAMEOPTION_ORIGINAL_SAVELOAD) + GAMEOPTION_ORIGINAL_SAVELOAD) #define GUIO_QFG4_CD GUIO3(GUIO_LINKSPEECHTOSFX, \ - GAMEOPTION_ORIGINAL_SAVELOAD, \ - GAMEOPTION_HQ_VIDEO) + GAMEOPTION_ORIGINAL_SAVELOAD, \ + GAMEOPTION_HQ_VIDEO) // Quest for Glory 4 1.1 Floppy - English DOS (supplied by markcool in bug report #4280) // SCI interpreter version 2.000.000 (a guess?) @@ -4659,20 +4659,20 @@ static const struct ADGameDescription SciGameDescriptions[] = { #undef GUIO_QFG4_CD #define GUIO_RAMA_DEMO GUIO8(GUIO_NOSUBTITLES, \ - GUIO_NOMIDI, \ - GUIO_NOLAUNCHLOAD, \ - GUIO_NOASPECT, \ - GUIO_LINKSPEECHTOSFX, \ - GUIO_LINKMUSICTOSFX, \ - GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ - GAMEOPTION_HQ_VIDEO) + GUIO_NOMIDI, \ + GUIO_NOLAUNCHLOAD, \ + GUIO_NOASPECT, \ + GUIO_LINKSPEECHTOSFX, \ + GUIO_LINKMUSICTOSFX, \ + GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ + GAMEOPTION_HQ_VIDEO) #define GUIO_RAMA GUIO7(GUIO_NOSUBTITLES, \ - GUIO_NOMIDI, \ - GUIO_NOASPECT, \ - GUIO_LINKSPEECHTOSFX, \ - GAMEOPTION_ORIGINAL_SAVELOAD, \ - GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ - GAMEOPTION_HQ_VIDEO) + GUIO_NOMIDI, \ + GUIO_NOASPECT, \ + GUIO_LINKSPEECHTOSFX, \ + GAMEOPTION_ORIGINAL_SAVELOAD, \ + GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ + GAMEOPTION_HQ_VIDEO) // RAMA - English DOS/Windows Demo // Executable scanning reports "2.100.002", VERSION file reports "000.000.008" @@ -4757,17 +4757,17 @@ static const struct ADGameDescription SciGameDescriptions[] = { #undef GUIO_RAMA #define GUIO_SHIVERS_DEMO GUIO6(GUIO_NOSUBTITLES, \ - GUIO_NOMIDI, \ - GUIO_NOLAUNCHLOAD, \ - GUIO_LINKSPEECHTOSFX, \ - GUIO_LINKMUSICTOSFX, \ - GUIO_NOASPECT) + GUIO_NOMIDI, \ + GUIO_NOLAUNCHLOAD, \ + GUIO_LINKSPEECHTOSFX, \ + GUIO_LINKMUSICTOSFX, \ + GUIO_NOASPECT) #define GUIO_SHIVERS GUIO6(GUIO_NOMIDI, \ - GUIO_LINKSPEECHTOSFX, \ - GUIO_LINKMUSICTOSFX, \ - GUIO_NOASPECT, \ - GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ - GAMEOPTION_HQ_VIDEO) + GUIO_LINKSPEECHTOSFX, \ + GUIO_LINKMUSICTOSFX, \ + GUIO_NOASPECT, \ + GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ + GAMEOPTION_HQ_VIDEO) // Shivers - English Windows (from jvprat) // Executable scanning reports "2.100.002", VERSION file reports "1.02" @@ -5140,13 +5140,13 @@ static const struct ADGameDescription SciGameDescriptions[] = { Common::EN_ANY, Common::kPlatformMacintosh, ADGF_UNSTABLE, GUIO_STD16_PALETTEMODS }, #define GUIO_SQ4_CD GUIO5(GAMEOPTION_SQ4_SILVER_CURSORS, \ - GAMEOPTION_PREFER_DIGITAL_SFX, \ - GAMEOPTION_ORIGINAL_SAVELOAD, \ - GAMEOPTION_MIDI_MODE, \ - GAMEOPTION_RGB_RENDERING) + GAMEOPTION_PREFER_DIGITAL_SFX, \ + GAMEOPTION_ORIGINAL_SAVELOAD, \ + GAMEOPTION_MIDI_MODE, \ + GAMEOPTION_RGB_RENDERING) #define GUIO_SQ4_CD_WINDOWS GUIO6(GUIO_MIDIGM, \ - GAMEOPTION_SQ4_SILVER_CURSORS, \ + GAMEOPTION_SQ4_SILVER_CURSORS, \ GAMEOPTION_PREFER_DIGITAL_SFX, \ GAMEOPTION_ORIGINAL_SAVELOAD, \ GAMEOPTION_MIDI_MODE, \ @@ -5477,17 +5477,17 @@ static const struct ADGameDescription SciGameDescriptions[] = { Common::RU_RUS, Common::kPlatformDOS, 0, GUIO_STD16 }, #define GUIO_SQ6_DEMO GUIO3(GUIO_NOLAUNCHLOAD, \ - GUIO_LINKSPEECHTOSFX, \ - GUIO_NOASPECT) + GUIO_LINKSPEECHTOSFX, \ + GUIO_NOASPECT) #define GUIO_SQ6 GUIO5(GUIO_LINKSPEECHTOSFX, \ - GUIO_NOASPECT, \ - GAMEOPTION_ORIGINAL_SAVELOAD, \ - GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ - GAMEOPTION_HQ_VIDEO) + GUIO_NOASPECT, \ + GAMEOPTION_ORIGINAL_SAVELOAD, \ + GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ + GAMEOPTION_HQ_VIDEO) #define GUIO_SQ6_MAC GUIO4(GUIO_LINKSPEECHTOSFX, \ - GUIO_NOASPECT, \ - GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ - GAMEOPTION_HQ_VIDEO) + GUIO_NOASPECT, \ + GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ + GAMEOPTION_HQ_VIDEO) // Space Quest 6 - English DOS/Win3.11 CD (from the Space Quest Collection) // Executable scanning reports "2.100.002", VERSION file reports "1.0" @@ -5584,13 +5584,13 @@ static const struct ADGameDescription SciGameDescriptions[] = { Common::EN_ANY, Common::kPlatformDOS, ADGF_DEMO, GUIO_STD16 }, #define GUIO_TORIN_DEMO GUIO3(GUIO_NOMIDI, \ - GUIO_NOLAUNCHLOAD, \ - GUIO_NOASPECT) + GUIO_NOLAUNCHLOAD, \ + GUIO_NOASPECT) #define GUIO_TORIN GUIO5(GUIO_NOMIDI, \ - GUIO_NOASPECT, \ - GAMEOPTION_ORIGINAL_SAVELOAD, \ - GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ - GAMEOPTION_HQ_VIDEO) + GUIO_NOASPECT, \ + GAMEOPTION_ORIGINAL_SAVELOAD, \ + GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \ + GAMEOPTION_HQ_VIDEO) #define GUIO_TORIN_MAC GUIO_TORIN // Torin's Passage - English Windows Interactive Demo diff --git a/engines/sci/engine/file.cpp b/engines/sci/engine/file.cpp index c558634bbc0..93d977697fa 100644 --- a/engines/sci/engine/file.cpp +++ b/engines/sci/engine/file.cpp @@ -50,9 +50,9 @@ uint32 MemoryDynamicRWStream::read(void *dataPtr, uint32 dataSize) { } SaveFileRewriteStream::SaveFileRewriteStream(const Common::String &fileName, - Common::SeekableReadStream *inFile, - kFileOpenMode mode, - bool compress) : + Common::SeekableReadStream *inFile, + kFileOpenMode mode, + bool compress) : MemoryDynamicRWStream(DisposeAfterUse::YES), _fileName(fileName), _compress(compress) { diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp index 15f1705f848..772665362ca 100644 --- a/engines/sci/engine/kpathing.cpp +++ b/engines/sci/engine/kpathing.cpp @@ -1880,7 +1880,7 @@ reg_t kIntersections(EngineState *s, int argc, reg_t *argv) { // Compute square of the distance of p to the segment a-b. static float pointSegDistance(const Common::Point &a, const Common::Point &b, - const Common::Point &p) { + const Common::Point &p) { FloatPoint ba(b-a); FloatPoint pa(p-a); FloatPoint bp(b-p); diff --git a/engines/sci/engine/script_patches.cpp b/engines/sci/engine/script_patches.cpp index c6ad41f47bf..90e1e300475 100644 --- a/engines/sci/engine/script_patches.cpp +++ b/engines/sci/engine/script_patches.cpp @@ -6757,15 +6757,15 @@ static const SciScriptPatcherEntry lighthouseSignatures[] = { // Fixes bug: #5264 static const uint16 longbowSignatureShowHandCode[] = { 0x78, // push1 (1 call arg) - // + // 0x78, // push1 (1 call arg) 0x72, SIG_ADDTOOFFSET(+2), // lofsa (letter that was typed) 0x36, // push 0x40, SIG_ADDTOOFFSET(+2), 0x02, // call [localproc], 02 - // + // 0x36, // push (the result is an arg for the next call) 0x40, SIG_ADDTOOFFSET(+2), SIG_MAGICDWORD, 0x02, // call [localproc], 02 - // + // 0x38, SIG_SELECTOR16(setMotion), // pushi setMotion (0x11c in Longbow German) 0x39, SIG_SELECTOR8(x), // pushi x (0x04 in Longbow German) 0x51, 0x1e, // class MoveTo @@ -13032,12 +13032,12 @@ static const uint16 qfg3PatchCombatSpeedThrottling1[] = { 0x8b, 0x01, // lsl local[1] (stack up the local instead, freed +1 byte) 0x1c, // ne? 0x31, 0x0c, // bnt 12d [after sal] - // + // 0x81, 0xd2, // lag global[210] (load into acc instead of stack) 0x76, // push0 (push0 instead of ldi 0, freed +1 byte) 0x22, // lt? (flip the comparison) 0x31, 0x06, // bnt 6d [after sal] - // + // 0xe1, 0xd2, // -ag global[210] 0x81, 0x58, // lag global[88] 0xa3, 0x01, // sal local[1] @@ -13444,7 +13444,7 @@ static const uint16 qfg4InnPathfindingPatch[] = { static const uint16 qfg4AutosaveSignature[] = { 0x30, SIG_ADDTOOFFSET(+2), // bnt ?? [end the loop] 0x78, // push1 (1 call arg) - // + // 0x39, SIG_SELECTOR8(data), // pushi data 0x76, // push0 SIG_ADDTOOFFSET(+2), // (CD="lag global[29]", floppy="lat temp[6]") @@ -13599,18 +13599,18 @@ static const uint16 qfg4AbsentInnkeeperSignature[] = { 0x89, 0x7b, // lsg global[123] 0x35, 0x03, // ldi 3d 0x24, // le? - // (~~ junk begins ~~) + // (~~ junk begins ~~) 0x2f, 0x0f, // bt 15d [after the calle] 0x39, 0x03, // pushi 3d (3 call args) 0x89, 0x7b, // lsg global[123] (needle value) 0x39, 0x04, // pushi 4d (haystack values...) 0x39, 0x05, // pushi 5d 0x46, SIG_UINT16(0xfde7), SIG_UINT16(0x0005), SIG_UINT16(0x0006), // calle [export 5 of script 64999], 6d (is needle in haystack?)) - // (~~ junk ends ~~) + // (~~ junk ends ~~) 0x31, 0x04, // bnt 4d [block 11] 0x35, 0x0a, // ldi 10d 0x33, 0x29, // jmp 41d [done, local[2]=acc] - // + // SIG_ADDTOOFFSET(+25), // (...block 11...) (patch ends after this) SIG_ADDTOOFFSET(+14), // (...block 12...) SIG_ADDTOOFFSET(+2), // (...else 0...) @@ -13623,23 +13623,23 @@ static const uint16 qfg4AbsentInnkeeperPatch[] = { 0x89, 0x7b, // lsg global[123] 0x35, 0x05, // ldi 5d (make it t <= 5) 0x24, // le? - // (*snip*) + // (*snip*) 0x31, 0x07, // bnt 7d [block 11] 0x35, 0x0a, // ldi 10d 0x33, 0x3a, // jmp 58d [done, local[2]=acc] - // + // 0x34, PATCH_UINT16(0x0000), // ldi 0 (waste 3 bytes) - // (14 freed bytes remain.) - // (use 7 freed bytes to prepend block 11) - // (and shift all of block 11 up by 7 bytes) - // (use that new gap below to prepend block 12) - // - // (block 11, prepend a time check) + // (14 freed bytes remain.) + // (use 7 freed bytes to prepend block 11) + // (and shift all of block 11 up by 7 bytes) + // (use that new gap below to prepend block 12) + // + // (block 11, prepend a time check) 0x89, 0x7b, // lsg global[123] 0x35, 0x05, // ldi 5d 0x24, // le? 0x31, 0x19, // bnt 25d [block 12] - // (block 11, original ops shift up) + // (block 11, original ops shift up) 0x78, // push1 (1 call arg) 0x38, PATCH_UINT16(0x0084), // pushi 132d 0x45, 0x04, PATCH_UINT16(0x0002), // callb [export 4 of script 0], 2d (test flag 132) @@ -13651,13 +13651,13 @@ static const uint16 qfg4AbsentInnkeeperPatch[] = { 0x31, 0x04, // bnt 4d [block 12] 0x35, 0x0b, // ldi 11d 0x33, 0x17, // jmp 23d [done, local[2]=acc] - // - // (block 12, prepend a time check) + // + // (block 12, prepend a time check) 0x89, 0x7b, // lsg global[123] 0x35, 0x05, // ldi 5d 0x24, // le? 0x31, 0x0e, // bnt 14d [else block] - // (block 12, original ops continue here) + // (block 12, original ops continue here) PATCH_END }; @@ -14199,7 +14199,7 @@ static const uint16 qfg4SafeDoorEastSignature[] = { 0x45, 0x04, SIG_UINT16(0x0002), // callb [export 4 of script 0], 2d (test flag 215) 0x18, // not 0x31, SIG_ADDTOOFFSET(+1), // bnt ?? [end the else block] - // + // 0x35, 0x00, // ldi 0 0xa3, 0x02, // sal local[2] SIG_END @@ -14208,7 +14208,7 @@ static const uint16 qfg4SafeDoorEastSignature[] = { static const uint16 qfg4SafeDoorEastPatch[] = { 0x35, 0x00, // ldi 0 0xa3, 0x02, // sal local[2] - // + // 0x78, // push1 (1 call arg) 0x38, PATCH_UINT16(0x00d7), // pushi 215d (right door oiled flag) 0x45, 0x04, PATCH_UINT16(0x0002), // callb [export 4 of script 0], 2d (test flag 215) @@ -14277,7 +14277,7 @@ static const uint16 qfg4DreamGateSignature[] = { 0x72, SIG_ADDTOOFFSET(+2), // lofsa fSouth 0x4a, SIG_UINT16(0x0004), // send 4d 0x31, 0x1a, // bnt 26d [skip disposing/nulling] (no heading) - // + // 0x38, SIG_SELECTOR16(dispose), // pushi dispose 0x76, // push0 0x39, SIG_SELECTOR8(heading), // pushi heading @@ -14285,7 +14285,7 @@ static const uint16 qfg4DreamGateSignature[] = { 0x72, SIG_ADDTOOFFSET(+2), // lofsa fSouth 0x4a, SIG_UINT16(0x0004), // send 4d (accumulate heading) 0x4a, SIG_UINT16(0x0004), // send 4d (dispose heading) - // + // 0x39, SIG_SELECTOR8(heading), // pushi heading 0x78, // push1 0x76, // push0 @@ -14302,18 +14302,18 @@ static const uint16 qfg4DreamGatePatch[] = { 0x4a, PATCH_UINT16(0x0004), // send 4d 0xa5, 0x00, // sat temp[0] 0x31, 0x13, // bnt 19d [skip disposing/nulling] (no heading) - // + // 0x38, PATCH_SELECTOR16(dispose), // pushi dispose 0x76, // push0 0x85, 0x00, // lat temp[0] 0x4a, PATCH_UINT16(0x0004), // send 4d (dispose: heading:) - // + // 0x39, PATCH_SELECTOR8(heading), // pushi heading 0x78, // push1 0x76, // push0 0x72, PATCH_GETORIGINALUINT16(4), // lofsa fSouth 0x4a, PATCH_UINT16(0x0006), // send 6d (set fSouth's heading to null) - // + // 0x76, // push0 0xab, 0x02, // ssl local[2] (let doit() watch for nightfall) PATCH_END @@ -14390,10 +14390,10 @@ static const uint16 qfg4RestartSignature[] = { }; static const uint16 qfg4RestartPatch[] = { - // (loop to assign multiples of 45) + // (loop to assign multiples of 45) 0x76, // push0 0xad, 0x00, // sst temp[0] - // + // 0x8d, 0x00, // lst temp[0] (global[144 + n+1] = n*45) 0x35, 0x08, // ldi 8d 0x22, // lt? @@ -14405,12 +14405,12 @@ static const uint16 qfg4RestartPatch[] = { 0xc5, 0x00, // +at temp[0] 0xb1, 0x90, // sagi (global[144 + temp[0]]) 0x33, 0xed, // jmp -19d (loop) - // (that loop freed +30 bytes) + // (that loop freed +30 bytes) 0x35, 0x14, // ldi 20d (leave this assignment as-is) 0xa1, 0xc6, // sag global[198] - // (stack up arbitrary values; then loop to assign them) + // (stack up arbitrary values; then loop to assign them) 0x7a, // push2 (global[367] = 2) 0x3c, // dup (global[368] = 2) 0x39, 0x03, // pushi 3d (global[369] = 3) @@ -14432,10 +14432,10 @@ static const uint16 qfg4RestartPatch[] = { 0x39, 0x07, // pushi 7d (global[385] = 7) 0x39, 0x0a, // pushi 10d (global[386] = 10) 0x3c, // dup (global[387] = 10) - // + // 0x39, 0x15, // pushi 21d (pop() and set, backward from 20 to 0) 0xad, 0x00, // sst temp[0] - // + // 0xed, 0x00, // -st temp[0] 0x35, 0x00, // ldi 0 0x20, // ge? @@ -14443,9 +14443,9 @@ static const uint16 qfg4RestartPatch[] = { 0x85, 0x00, // lat temp[0] 0xb8, PATCH_UINT16(0x016f), // ssgi (global[367 + n] = pop()) 0x33, 0xf2, // jmp -14d (loop) - // (that loop freed +52 bytes) + // (that loop freed +52 bytes) - // (reset properties for a few items) + // (reset properties for a few items) 0x33, 0x1f, // jmp 31d [skip subroutine declaration] 0x38, PATCH_SELECTOR16(loop), // pushi loop 0x78, // push1 @@ -14456,13 +14456,13 @@ static const uint16 qfg4RestartPatch[] = { 0x38, PATCH_SELECTOR16(value), // pushi value (weight) 0x78, // push1 0x7a, // push2 (these items all weigh 2) - // + // 0x39, PATCH_SELECTOR8(at), // pushi at 0x78, // push1 0x8f, 0x01, // lsp param[1] 0x81, 0x09, // global[9] (gloryInv) 0x4a, PATCH_UINT16(0x0006), // send 6d - // + // 0x4a, PATCH_UINT16(0x0012), // send 18d 0x48, // ret @@ -14652,7 +14652,7 @@ static const uint16 qfg4Tarot3TwoOfCupsPatch[] = { 0x39, 0x03, // pushi 3d (call has 3 args) 0x39, 0x6e, // pushi 110d (setScalar, arg 5) 0x38, PATCH_UINT16(0x00d2), // pushi 210d (setMotion, x arg) - // + // 0x8b, 0x00, // lsl local[0] (test the card's View number) 0x34, PATCH_UINT16(0x03ff), // ldi 1023d ("Two of Cups" is special) 0x1a, // eq? @@ -14660,7 +14660,7 @@ static const uint16 qfg4Tarot3TwoOfCupsPatch[] = { 0x39, 0x66, // pushi 102d (setMotion, special y arg) 0x33, 0x02, // jmp 2d [to the call] 0x39, 0x6e, // pushi 110d (setMotion, regular y arg) - // + // 0x41, 0xb0, PATCH_UINT16(0x0006), // call [-80], 6d 0x33, 0x13, // jmp 19d [end the local[2] switch] @@ -14841,7 +14841,7 @@ static const uint16 qfg4PitRopeFighterPatch[] = { PATCH_ADDTOOFFSET(+21), // ... (8 + 13) 0x76, // push0 (null caller, so say won't cue crossByHand) PATCH_ADDTOOFFSET(+5), // ... - // (no jmp, self-cue becomes cycles) + // (no jmp, self-cue becomes cycles) 0x35, 0x20, // ldi 32d 0x65, PATCH_GETORIGINALBYTEADJUST(1, +6), // aTop cycles (property offset = @state + 6d) 0x33, 0x04, // jmp 4d [skip waste bytes, end the switch] @@ -15060,11 +15060,11 @@ static const uint16 qfg4TriggerStaffPatch1[] = { 0x76, // push0 0x81, 0x00, // lag global[0] (hero) 0x4a, PATCH_UINT16(0x0004), // send 4d - // + // 0x39, 0x11, // pushi 17d (push the literal, leave view in acc) 0x22, // lt? (view > 17 becomes 17 < view, set prev = acc) 0x31, PATCH_GETORIGINALBYTEADJUST(15, -8), // bnt ?? [to the not] - // + // 0x60, // pprev (push the view from prev, ldi 21 comparison is next) PATCH_END }; @@ -15295,7 +15295,7 @@ static const uint16 qfg4GuildWalkSignature2[] = { SIG_MAGICDWORD, 0x32, SIG_UINT16(0x00f7), // jmp 247d [end the cond] (2nd condition done) - // (else condition) + // (else condition) 0x38, SIG_SELECTOR16(init), // pushi init 0x76, // push0 0x72, SIG_ADDTOOFFSET(+2), // lofsa secritExit @@ -15317,10 +15317,10 @@ static const uint16 qfg4GuildWalkPatch2[] = { 0x74, PATCH_GETORIGINALUINT16(75), // lofss crack1 0x74, PATCH_GETORIGINALUINT16(91), // lofss crack2 0x74, PATCH_GETORIGINALUINT16(107), // lofss pillar - // + // 0x35, 0x08, // ldi 8d (decrement and send 7 times, while != 0) 0xa5, 0x00, // sat temp[0] - // + // 0xe5, 0x00, // -at temp[0] 0x31, 0x13, // bnt 19d [on 0, end the loop] 0xad, 0x01, // sst temp[1] (pop the next object into a temp var) @@ -15342,20 +15342,20 @@ static const uint16 qfg4GuildWalkPatch2[] = { 0x38, PATCH_SELECTOR16(dispose), // pushi dispose 0x76, // push0 0x4a, PATCH_UINT16(0x0004), // send 4d ((global[2] obstacles?) dispose:) - // + // 0x38, PATCH_SELECTOR16(obstacles), // pushi obstacles (null the "obstacles" property) 0x78, // push1 0x76, // push0 0x81, 0x02, // lag global[2] 0x4a, PATCH_UINT16(0x0006), // send 6d - // + // 0x38, PATCH_SELECTOR16(addObstacle), // pushi addObstacle 0x78, // push1 0x32, PATCH_UINT16(0x020f), // jmp 527d [3rd polygon type, init, and push] - // (That will jmp back here) + // (That will jmp back here) 0x81, 0x02, // lag global[2] 0x4a, PATCH_UINT16(0x0006), // send 6d - // + // 0x38, PATCH_SELECTOR16(init), // pushi init 0x76, // push0 0x72, PATCH_GETORIGINALUINT16(605), // lofsa secritExit @@ -15477,7 +15477,7 @@ static const uint16 qfg4LeftoversPatch[] = { PATCH_ADDTOOFFSET(+15), // (cond 1, preemptively eaten meals) 0x32, PATCH_UINT16(0x00bb), // jmp 187d [end the cond] - // (cond 2) + // (cond 2) 0x39, PATCH_SELECTOR8(at), // pushi at 0x78, // push1 0x39, 0x04, // pushi 4d (itemId 4, theRations) @@ -15528,38 +15528,38 @@ static const uint16 qfg4LeftoversPatch[] = { 0x38, PATCH_SELECTOR16(hide), // pushi hide 0x76, // push0 - // + // 0x7a, // push2 (2 call args) 0x39, 0x24, // pushi 36d 0x78, // push1 0x43, 0x02, PATCH_UINT16(0x0004), // callk ScriptID, 4d (ScriptID 36 1, invItem) - // + // 0x4a, PATCH_UINT16(0x0004), // send 4d (invItem hide:) - // (exhausted item removal end) + // (exhausted item removal end) 0x35, 0x01, // ldi 1d 0xa5, 0x00, // sat temp[0] (eaten) 0x33, 0x54, // jmp 84d [end the cond] - // (cond 3) + // (cond 3) 0x78, // push1 (1 call arg) 0x39, 0x03, // pushi 3d ("hungry" flag) 0x45, 0x04, PATCH_UINT16(0x0002), // callb [export 4 of script 0], 2d (test flag 3) 0x31, 0x26, // bnt 38d [next condition] - // + // 0x38, PATCH_SELECTOR16(useStamina), // pushi useStamina 0x7a, // push2 0x39, 0x08, // pushi 8d 0x76, // push0 0x54, PATCH_UINT16(0x0008), // self 8d (hero useStamina: 8 0) - // + // 0x31, 0x09, // bnt 9d [hero dies] 0x78, // push1 (1 call arg) 0x39, 0x05, // pushi 5d (say cond:5, "You're starving.") 0x41, 0x3a, PATCH_UINT16(0x0002), // call [58], 2d (gloryMessager say: 1 6 5 1 0 28) 0x33, 0x36, // jmp 54d [end the cond] - // + // 0x39, 0x04, // pushi 4d (4 call args) 0x39, 0x08, // pushi 8d 0x39, 0x1c, // pushi 28d @@ -15568,31 +15568,31 @@ static const uint16 qfg4LeftoversPatch[] = { 0x47, 0x1a, 0x00, PATCH_UINT16(0x0008), // calle [export 0 of script 26], 8d (hero dies) 0x33, 0x25, // jmp 37d [end the cond] - // (cond 4) + // (cond 4) 0x78, // push1 (1 call arg) 0x7a, // push2 ("missed meal" flag) 0x45, 0x04, PATCH_UINT16(0x0002), // callb [export 4 of script 0], 2d (test flag 2) 0x31, 0x10, // bnt 16d [next condition] - // + // 0x78, // push1 (1 call arg) 0x39, 0x03, // pushi 3d ("hungry" flag) 0x45, 0x02, PATCH_UINT16(0x0002), // callb [export 2 of script 0], 2d (set flag 3) - // + // 0x78, // push1 (1 call arg) 0x39, 0x06, // pushi 6d (say cond:6, "Really getting hungry.") 0x41, 0x11, PATCH_UINT16(0x0002), // call [17], 2d (gloryMessager say: 1 6 6 1 0 28) 0x33, 0x0d, // jmp 13d [end the cond] - // (cond else) + // (cond else) 0x78, // push1 (1 call arg) 0x7a, // push2 ("missed meal" flag) 0x45, 0x02, PATCH_UINT16(0x0002), // callb [export 2 of script 0], 2d (set flag 2) - // + // 0x78, // push1 (1 call arg) 0x39, 0x04, // pushi 4d (say cond:4, "Get food soon.") 0x41, 0x02, PATCH_UINT16(0x0002), // call [2], 2d (gloryMessager say: 1 6 4 1 0 28) - // (cond end) + // (cond end) 0x33, 0x14, // jmp 20d [skip subroutine declaration] 0x38, PATCH_SELECTOR16(say), // pushi say diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp index 0402ffa4960..69a3edd0b8f 100644 --- a/engines/sci/graphics/frameout.cpp +++ b/engines/sci/graphics/frameout.cpp @@ -352,7 +352,7 @@ void GfxFrameout::deletePlanesForMacRestore() { // their Game:restore script before calling kRestore. // In Mac this work was moved into the interpreter // for some games, while others added it back to - // Game:restore or used their own scripts that took + // Game:restore or used their own scripts that took // care of this in both PC and Mac versions. if (!(g_sci->getGameId() == GID_GK1 || g_sci->getGameId() == GID_PQ4 || diff --git a/engines/sci/graphics/screen.cpp b/engines/sci/graphics/screen.cpp index 979c853c59d..48c8916c5ae 100644 --- a/engines/sci/graphics/screen.cpp +++ b/engines/sci/graphics/screen.cpp @@ -563,10 +563,10 @@ byte GfxScreen::vectorIsFillMatch(int16 x, int16 y, byte screenMask, byte checkF * with flood fill, due to small difference in the Bresenham logic. */ void GfxScreen::drawLine(Common::Point startPoint, Common::Point endPoint, byte color, byte priority, byte control) { - int16 maxWidth = _width - 1; - int16 maxHeight = _height - 1; - // we need to clip values here, lsl3 room 620 background picture draws a line from 0, 199 t 320, 199 - // otherwise we would get heap corruption. + int16 maxWidth = _width - 1; + int16 maxHeight = _height - 1; + // we need to clip values here, lsl3 room 620 background picture draws a line from 0, 199 t 320, 199 + // otherwise we would get heap corruption. int16 left = CLIP(startPoint.x, 0, maxWidth); int16 top = CLIP(startPoint.y, 0, maxHeight); int16 right = CLIP(endPoint.x, 0, maxWidth); diff --git a/engines/sci/graphics/text32.cpp b/engines/sci/graphics/text32.cpp index ce62f6beda1..3d20fd45aa6 100644 --- a/engines/sci/graphics/text32.cpp +++ b/engines/sci/graphics/text32.cpp @@ -56,7 +56,7 @@ GfxText32::GfxText32(SegManager *segMan, GfxCache *fonts) : void GfxText32::init() { _xResolution = g_sci->_gfxFrameout->getScriptWidth(); _yResolution = g_sci->_gfxFrameout->getScriptHeight(); - // GK1 Korean patched version uses doubled resolution for fonts + // GK1 Korean patched version uses doubled resolution for fonts if (g_sci->getGameId() == GID_GK1 && g_sci->getLanguage() == Common::KO_KOR) { _xResolution = _xResolution * 2; _yResolution = _yResolution * 2; diff --git a/engines/sci/metaengine.cpp b/engines/sci/metaengine.cpp index ffc4461cf4a..b01e577bc1d 100644 --- a/engines/sci/metaengine.cpp +++ b/engines/sci/metaengine.cpp @@ -299,7 +299,7 @@ namespace Sci { class SciMetaEngine : public AdvancedMetaEngine { public: - const char *getName() const override { + const char *getName() const override { return "sci"; } diff --git a/engines/sci/parser/said.cpp b/engines/sci/parser/said.cpp index 27ebc587044..f56be50cb1c 100644 --- a/engines/sci/parser/said.cpp +++ b/engines/sci/parser/said.cpp @@ -105,8 +105,8 @@ static ParseTreeNode* said_word_node(ParseTreeNode* pos, int value) { } static ParseTreeNode* said_branch_node(ParseTreeNode* pos, - ParseTreeNode* left, - ParseTreeNode* right) { + ParseTreeNode* left, + ParseTreeNode* right) { pos->type = kParseTreeBranchNode; pos->left = left; pos->right = right; @@ -115,7 +115,7 @@ static ParseTreeNode* said_branch_node(ParseTreeNode* pos, } static ParseTreeNode* said_branch_attach_left(ParseTreeNode* pos, - ParseTreeNode* left) { + ParseTreeNode* left) { pos->type = kParseTreeBranchNode; pos->left = left; @@ -124,7 +124,7 @@ static ParseTreeNode* said_branch_attach_left(ParseTreeNode* pos, } static ParseTreeNode* said_branch_attach_right(ParseTreeNode* pos, - ParseTreeNode* right) { + ParseTreeNode* right) { pos->type = kParseTreeBranchNode; pos->right = right; @@ -133,19 +133,19 @@ static ParseTreeNode* said_branch_attach_right(ParseTreeNode* pos, /* - pos - / \ - . \ - * - / \ - / 0 - * - / \ - / \ - / subtree + pos + / \ + . \ + * + / \ + / 0 + * + / \ + / \ + / subtree major / \ - / . - minor + / . + minor . = unchanged child node * = new branch node @@ -154,7 +154,7 @@ static ParseTreeNode* said_branch_attach_right(ParseTreeNode* pos, */ static bool said_attach_subtree(ParseTreeNode* pos, int major, int minor, - ParseTreeNode* subtree) { + ParseTreeNode* subtree) { bool retval = true; said_branch_attach_right(pos, @@ -689,7 +689,7 @@ enum ScanSaidType { static int matchTrees(ParseTreeNode* parseT, ParseTreeNode* saidT); static int scanSaidChildren(ParseTreeNode* parseT, ParseTreeNode* saidT, - ScanSaidType type); + ScanSaidType type); static int scanParseChildren(ParseTreeNode* parseT, ParseTreeNode* saidT); @@ -706,7 +706,7 @@ static int node_minor(ParseTreeNode* node) { } static bool node_is_terminal(ParseTreeNode* node) { return (node->right->right && - node->right->right->type != kParseTreeBranchNode); + node->right->right->type != kParseTreeBranchNode); } static int node_terminal_value(ParseTreeNode* node) { assert(node_is_terminal(node)); @@ -853,7 +853,7 @@ static int matchTrees(ParseTreeNode* parseT, ParseTreeNode* saidT) { static int scanSaidChildren(ParseTreeNode* parseT, ParseTreeNode* saidT, - ScanSaidType type) { + ScanSaidType type) { outputDepth++; scidprintf("%*sscanSaid(%s) on ", outputDepth, "", type == SCAN_SAID_OR ? "OR" : "AND"); diff --git a/engines/sci/parser/vocabulary.cpp b/engines/sci/parser/vocabulary.cpp index 12a86eb72f5..05ca31f1793 100644 --- a/engines/sci/parser/vocabulary.cpp +++ b/engines/sci/parser/vocabulary.cpp @@ -885,7 +885,7 @@ static int node_major(ParseTreeNode* node) { } static bool node_is_terminal(ParseTreeNode* node) { return (node->right->right && - node->right->right->type != kParseTreeBranchNode); + node->right->right->type != kParseTreeBranchNode); } static int node_terminal_value(ParseTreeNode* node) { assert(node_is_terminal(node)); diff --git a/engines/sci/resource/decompressor.cpp b/engines/sci/resource/decompressor.cpp index fa7dea605ee..7af234a381c 100644 --- a/engines/sci/resource/decompressor.cpp +++ b/engines/sci/resource/decompressor.cpp @@ -45,7 +45,7 @@ int Decompressor::unpack(Common::ReadStream *src, byte *dest, uint32 nPacked, ui } void Decompressor::init(Common::ReadStream *src, byte *dest, uint32 nPacked, - uint32 nUnpacked) { + uint32 nUnpacked) { _src = src; _dest = dest; _szPacked = nPacked; @@ -179,7 +179,7 @@ int DecompressorLZW::unpack(Common::ReadStream *src, byte *dest, uint32 nPacked, } int DecompressorLZW::unpackLZW(Common::ReadStream *src, byte *dest, uint32 nPacked, - uint32 nUnpacked) { + uint32 nUnpacked) { init(src, dest, nPacked, nUnpacked); uint16 token; // The last received value @@ -255,7 +255,7 @@ int DecompressorLZW::unpackLZW(Common::ReadStream *src, byte *dest, uint32 nPack } int DecompressorLZW::unpackLZW1(Common::ReadStream *src, byte *dest, uint32 nPacked, - uint32 nUnpacked) { + uint32 nUnpacked) { init(src, dest, nPacked, nUnpacked); byte *stak = (byte *)malloc(0x1014); @@ -631,7 +631,7 @@ void DecompressorLZW::reorderView(byte *src, byte *dest) { //---------------------------------------------- int DecompressorDCL::unpack(Common::ReadStream *src, byte *dest, uint32 nPacked, - uint32 nUnpacked) { + uint32 nUnpacked) { return Common::decompressDCL(src, dest, nPacked, nUnpacked) ? 0 : SCI_ERROR_DECOMPRESSION_ERROR; } diff --git a/engines/sci/resource/resource.cpp b/engines/sci/resource/resource.cpp index 816505e4fdb..796776686fb 100644 --- a/engines/sci/resource/resource.cpp +++ b/engines/sci/resource/resource.cpp @@ -2243,7 +2243,7 @@ Resource *ResourceManager::updateResource(ResourceId resId, ResourceSource *src, } int Resource::readResourceInfo(ResVersion volVersion, Common::SeekableReadStream *file, - uint32 &szPacked, ResourceCompression &compression) { + uint32 &szPacked, ResourceCompression &compression) { // SCI0 volume format: {wResId wPacked+4 wUnpacked wCompression} = 8 bytes // SCI1 volume format: {bResType wResNumber wPacked+4 wUnpacked wCompression} = 9 bytes // SCI1.1 volume format: {bResType wResNumber wPacked wUnpacked wCompression} = 9 bytes diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index 5a8e4b6f7aa..60dc61030f6 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -830,7 +830,7 @@ bool SciEngine::hasMacIconBar() const { } bool SciEngine::hasMacSaveRestoreDialogs() const { - return _gameDescription->platform == Common::kPlatformMacintosh && + return _gameDescription->platform == Common::kPlatformMacintosh && (getSciVersion() <= SCI_VERSION_2_1_EARLY || getGameId() == GID_GK2 || getGameId() == GID_SQ6 || diff --git a/engines/scumm/costume.cpp b/engines/scumm/costume.cpp index 23c2359c997..3d525dda140 100644 --- a/engines/scumm/costume.cpp +++ b/engines/scumm/costume.cpp @@ -421,16 +421,16 @@ void ClassicCostumeRenderer::procC64(Codec1 &v1, int actor) { #endif extern "C" int ClassicProc3RendererShadowARM(int _scaleY, - ClassicCostumeRenderer::Codec1 *v1, - Graphics::Surface *_out, - const byte *src, - int height, - int _scaleX, - int _scaleIndexX, - byte *_shadow_table, - uint16 _palette[32], - int32 _numStrips, - int _scaleIndexY); + ClassicCostumeRenderer::Codec1 *v1, + Graphics::Surface *_out, + const byte *src, + int height, + int _scaleX, + int _scaleIndexX, + byte *_shadow_table, + uint16 _palette[32], + int32 _numStrips, + int _scaleIndexY); #endif void ClassicCostumeRenderer::proc3(Codec1 &v1) { diff --git a/engines/scumm/dialogs.cpp b/engines/scumm/dialogs.cpp index f8b2746fd1a..c4171ad9faf 100644 --- a/engines/scumm/dialogs.cpp +++ b/engines/scumm/dialogs.cpp @@ -663,7 +663,7 @@ void DebugInputDialog::handleKeyDown(Common::KeyState state) { } LoomTownsDifficultyDialog::LoomTownsDifficultyDialog() - : Dialog("LoomTownsDifficultyDialog"), _difficulty(-1) { + : Dialog("LoomTownsDifficultyDialog"), _difficulty(-1) { GUI::StaticTextWidget *text1 = new GUI::StaticTextWidget(this, "LoomTownsDifficultyDialog.Description1", _("Select a Proficiency Level.")); text1->setAlign(Graphics::kTextAlignCenter); GUI::StaticTextWidget *text2 = new GUI::StaticTextWidget(this, "LoomTownsDifficultyDialog.Description2", _("Refer to your Loom(TM) manual for help.")); diff --git a/engines/scumm/he/logic/football.cpp b/engines/scumm/he/logic/football.cpp index 58b91b0b9d4..cf9e3463de4 100644 --- a/engines/scumm/he/logic/football.cpp +++ b/engines/scumm/he/logic/football.cpp @@ -288,9 +288,9 @@ class LogicHEfootball2002 : public LogicHEfootball { public: LogicHEfootball2002(ScummEngine_v90he *vm) : LogicHEfootball(vm) { _var0 = _var1 = _var2 = _var3 = _var4 = 0.0; - _angle = 0.0; - _maxX = -1; - _minX = 1000000; + _angle = 0.0; + _maxX = -1; + _minX = 1000000; } int32 dispatch(int op, int numArgs, int32 *args) override; diff --git a/engines/scumm/metaengine.cpp b/engines/scumm/metaengine.cpp index 296d62ff7fe..904ed55798d 100644 --- a/engines/scumm/metaengine.cpp +++ b/engines/scumm/metaengine.cpp @@ -217,7 +217,7 @@ bool ScummEngine::isMacM68kIMuse() const { using namespace Scumm; const char *ScummMetaEngine::getName() const { - return "scumm"; + return "scumm"; } bool ScummMetaEngine::hasFeature(MetaEngineFeature f) const { diff --git a/engines/scumm/metaengine.h b/engines/scumm/metaengine.h index d7f190a31b9..404be3dd2f9 100644 --- a/engines/scumm/metaengine.h +++ b/engines/scumm/metaengine.h @@ -26,11 +26,11 @@ #include "engines/metaengine.h" class ScummMetaEngine : public MetaEngine { - virtual const char *getName() const override; + virtual const char *getName() const override; - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; - Common::Error createInstance(OSystem *syst, Engine **engine) const override; + Common::Error createInstance(OSystem *syst, Engine **engine) const override; SaveStateList listSaves(const char *target) const override; int getMaximumSaveSlot() const override; diff --git a/engines/scumm/script_v2.cpp b/engines/scumm/script_v2.cpp index 73183157346..06f53ccd0d0 100644 --- a/engines/scumm/script_v2.cpp +++ b/engines/scumm/script_v2.cpp @@ -31,7 +31,7 @@ namespace Scumm { - // Helper functions for ManiacMansion workarounds + // Helper functions for ManiacMansion workarounds #define MM_SCRIPT(script) (script + (_game.version == 0 ? 0 : 5)) #define MM_VALUE(v0,v1) (_game.version == 0 ? v0 : v1) @@ -1188,44 +1188,44 @@ void ScummEngine_v2::o2_startScript() { } } - // WORKAROUND bug #4556: Purple Tentacle can appear in the lab, after being - // chased out and end up stuck in the room. This bug is triggered if the player - // enters the lab within 45 minutes of first entering the mansion and has chased Purple Tentacle - // out. Eventually the cutscene with Purple Tentacle chasing Sandy in the lab - // will play. This script leaves Purple Tentacle in the room causing him to become - // a permanent resident. - // Our fix is simply to prevent the Cutscene playing, if the lab has already been stormed - if (_game.id == GID_MANIAC) { - if (_game.version >= 1 && script == 155) { - if (VAR(120) == 1) - return; - } - // Script numbers are different in V0 - if (_game.version == 0 && script == 150) { - if (VAR(104) == 1) - return; - } - } + // WORKAROUND bug #4556: Purple Tentacle can appear in the lab, after being + // chased out and end up stuck in the room. This bug is triggered if the player + // enters the lab within 45 minutes of first entering the mansion and has chased Purple Tentacle + // out. Eventually the cutscene with Purple Tentacle chasing Sandy in the lab + // will play. This script leaves Purple Tentacle in the room causing him to become + // a permanent resident. + // Our fix is simply to prevent the Cutscene playing, if the lab has already been stormed + if (_game.id == GID_MANIAC) { + if (_game.version >= 1 && script == 155) { + if (VAR(120) == 1) + return; + } + // Script numbers are different in V0 + if (_game.version == 0 && script == 150) { + if (VAR(104) == 1) + return; + } + } runScript(script, 0, 0, 0); } void ScummEngine_v2::stopScriptCommon(int script) { - // WORKAROUND bug #4112: If you enter the lab while Dr. Fred has the powered turned off - // to repair the Zom-B-Matic, the script will be stopped and the power will never turn - // back on. This fix forces the power on, when the player enters the lab, - // if the script which turned it off is running - if (_game.id == GID_MANIAC && _roomResource == 4 && isScriptRunning(MM_SCRIPT(138))) { + // WORKAROUND bug #4112: If you enter the lab while Dr. Fred has the powered turned off + // to repair the Zom-B-Matic, the script will be stopped and the power will never turn + // back on. This fix forces the power on, when the player enters the lab, + // if the script which turned it off is running + if (_game.id == GID_MANIAC && _roomResource == 4 && isScriptRunning(MM_SCRIPT(138))) { - if (vm.slot[_currentScript].number == MM_VALUE(130, 163)) { + if (vm.slot[_currentScript].number == MM_VALUE(130, 163)) { - if (script == MM_SCRIPT(138)) { + if (script == MM_SCRIPT(138)) { - int obj = MM_VALUE(124, 157); - putState(obj, getState(obj) & ~kObjectState_08); - } - } - } + int obj = MM_VALUE(124, 157); + putState(obj, getState(obj) & ~kObjectState_08); + } + } + } if (_game.id == GID_MANIAC && _roomResource == 26 && vm.slot[_currentScript].number == 10001) { // FIXME: Nasty hack for bug #915575 diff --git a/engines/scumm/smush/codec47.cpp b/engines/scumm/smush/codec47.cpp index 53ac6482bd4..cfd9ad543b2 100644 --- a/engines/scumm/smush/codec47.cpp +++ b/engines/scumm/smush/codec47.cpp @@ -345,19 +345,19 @@ void Codec47Decoder::makeTables47(int width) { #endif extern "C" void ARM_Smush_decode2( byte *dst, - const byte *src, - int width, - int height, - const byte *param_ptr, - int16 *_table, - byte *_tableBig, - int32 offset1, - int32 offset2, - byte *_tableSmall); + const byte *src, + int width, + int height, + const byte *param_ptr, + int16 *_table, + byte *_tableBig, + int32 offset1, + int32 offset2, + byte *_tableSmall); #define decode2(SRC,DST,WIDTH,HEIGHT,PARAM) \ ARM_Smush_decode2(SRC,DST,WIDTH,HEIGHT,PARAM,_table,_tableBig, \ - _offset1,_offset2,_tableSmall) + _offset1,_offset2,_tableSmall) #else void Codec47Decoder::level3(byte *d_dst) { diff --git a/engines/sherlock/metaengine.cpp b/engines/sherlock/metaengine.cpp index 43d233b930a..82e40fc2684 100644 --- a/engines/sherlock/metaengine.cpp +++ b/engines/sherlock/metaengine.cpp @@ -53,7 +53,7 @@ public: return "sherlock"; } - /** + /** * Creates an instance of the game engine */ Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; diff --git a/engines/sherlock/scalpel/scalpel_user_interface.h b/engines/sherlock/scalpel/scalpel_user_interface.h index 2e6f2539b37..d9c7b2dd58e 100644 --- a/engines/sherlock/scalpel/scalpel_user_interface.h +++ b/engines/sherlock/scalpel/scalpel_user_interface.h @@ -157,7 +157,7 @@ private: void printObjectDesc(const Common::String &str, bool firstTime); public: ImageFile *_controlPanel; - ImageFile *_controls; + ImageFile *_controls; int _oldUse; byte _hotkeyLook; diff --git a/engines/sky/compact.cpp b/engines/sky/compact.cpp index cf3055dcc1a..576daa3908f 100644 --- a/engines/sky/compact.cpp +++ b/engines/sky/compact.cpp @@ -129,9 +129,9 @@ SkyCompact::SkyCompact() { Common::String filename = "sky.cpt"; if (!_cptFile->open(filename.c_str())) { const char *msg = _s("Unable to locate the '%s' engine data file."); - Common::U32String errorMessage = Common::U32String::format(_(msg), filename.c_str()); - GUIErrorMessage(errorMessage); - error(msg, filename.c_str()); + Common::U32String errorMessage = Common::U32String::format(_(msg), filename.c_str()); + GUIErrorMessage(errorMessage); + error(msg, filename.c_str()); } uint16 fileVersion = _cptFile->readUint16LE(); diff --git a/engines/sky/metaengine.cpp b/engines/sky/metaengine.cpp index 85326ad4539..32a52dc1e3f 100644 --- a/engines/sky/metaengine.cpp +++ b/engines/sky/metaengine.cpp @@ -36,19 +36,19 @@ #include "sky/sky.h" class SkyMetaEngine : public MetaEngine { - const char *getName() const override { - return "sky"; - } + const char *getName() const override { + return "sky"; + } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; - Common::Error createInstance(OSystem *syst, Engine **engine) const override; + Common::Error createInstance(OSystem *syst, Engine **engine) const override; SaveStateList listSaves(const char *target) const override; int getMaximumSaveSlot() const override; void removeSaveState(const char *target, int slot) const override; - Common::KeymapArray initKeymaps(const char *target) const override; + Common::KeymapArray initKeymaps(const char *target) const override; }; bool SkyMetaEngine::hasFeature(MetaEngineFeature f) const { diff --git a/engines/sky/sky.cpp b/engines/sky/sky.cpp index 1a82b5837d3..12a1382074f 100644 --- a/engines/sky/sky.cpp +++ b/engines/sky/sky.cpp @@ -73,7 +73,7 @@ SystemVars *SkyEngine::_systemVars = nullptr; const char *SkyEngine::shortcutsKeymapId = "sky-shortcuts"; SkyEngine::SkyEngine(OSystem *syst) - : Engine(syst), _fastMode(0), _debugger(0) { + : Engine(syst), _fastMode(0), _debugger(0) { _systemVars = new SystemVars(); _systemVars->systemFlags = 0; _systemVars->gameVersion = 0; diff --git a/engines/stark/formats/biffmesh.cpp b/engines/stark/formats/biffmesh.cpp index 26ac33c9b8a..6b26d396839 100644 --- a/engines/stark/formats/biffmesh.cpp +++ b/engines/stark/formats/biffmesh.cpp @@ -414,7 +414,7 @@ BiffObject *BiffMeshReader::biffObjectBuilder(uint32 type) { } BiffMesh::BiffMesh(const Common::Array &vertices, const Common::Array &faces, - const Common::Array &materials) : + const Common::Array &materials) : _vertices(vertices), _faces(faces), _materials(materials) { diff --git a/engines/stark/formats/tm.cpp b/engines/stark/formats/tm.cpp index d575b9f4d20..83bbecf2ab1 100644 --- a/engines/stark/formats/tm.cpp +++ b/engines/stark/formats/tm.cpp @@ -69,9 +69,9 @@ private: }; Texture::Texture() : - BiffObject(), - _texture(nullptr), - _u(0) { + BiffObject(), + _texture(nullptr), + _u(0) { _type = TYPE; } diff --git a/engines/stark/formats/xrc.cpp b/engines/stark/formats/xrc.cpp index 65ba41b0d28..aa92ddc1b2c 100644 --- a/engines/stark/formats/xrc.cpp +++ b/engines/stark/formats/xrc.cpp @@ -269,13 +269,13 @@ Resources::Object *XRCReader::createResource(XRCReadStream *stream, Resources::O break; case Resources::Type::kLipSync: resource = new Resources::LipSync(parent, subType, index, name); - break; + break; case Resources::Type::kAnimSoundTrigger: resource = new Resources::AnimSoundTrigger(parent, subType, index, name); break; case Resources::Type::kString: resource = new Resources::String(parent, subType, index, name); - break; + break; case Resources::Type::kTextureSet: resource = new Resources::TextureSet(parent, subType, index, name); break; diff --git a/engines/stark/gfx/driver.cpp b/engines/stark/gfx/driver.cpp index 0bfb6eddf78..5c1f0ba00fe 100644 --- a/engines/stark/gfx/driver.cpp +++ b/engines/stark/gfx/driver.cpp @@ -168,7 +168,7 @@ void Driver::flipVertical(Graphics::Surface *s) { } bool Driver::isPosInScreenBounds(const Common::Point &point) const { - return _screenViewport.contains(point); + return _screenViewport.contains(point); } } // End of namespace Gfx diff --git a/engines/stark/movement/shortestpath.cpp b/engines/stark/movement/shortestpath.cpp index 47ae3fea3cf..548bdf814e6 100644 --- a/engines/stark/movement/shortestpath.cpp +++ b/engines/stark/movement/shortestpath.cpp @@ -62,7 +62,7 @@ ShortestPath::NodeList ShortestPath::search(const Resources::FloorEdge *start, c } ShortestPath::NodeList ShortestPath::rebuildPath(const Resources::FloorEdge *start, const Resources::FloorEdge *goal, - const NodePrecedenceMap &cameFrom) const { + const NodePrecedenceMap &cameFrom) const { NodeList path; const Resources::FloorEdge *current = goal; diff --git a/engines/stark/resources/animscript.cpp b/engines/stark/resources/animscript.cpp index 4933a81ab45..5f075d8010b 100644 --- a/engines/stark/resources/animscript.cpp +++ b/engines/stark/resources/animscript.cpp @@ -45,11 +45,11 @@ AnimScript::~AnimScript() { } AnimScript::AnimScript(Object *parent, byte subType, uint16 index, const Common::String &name) : - Object(parent, subType, index, name), - _anim(nullptr), - _nextItemIndex(-1), - _msecsToNextUpdate(0), - _done(false) { + Object(parent, subType, index, name), + _anim(nullptr), + _nextItemIndex(-1), + _msecsToNextUpdate(0), + _done(false) { _type = TYPE; } diff --git a/engines/stark/resources/animsoundtrigger.cpp b/engines/stark/resources/animsoundtrigger.cpp index 688148dcf2a..b559d1b410c 100644 --- a/engines/stark/resources/animsoundtrigger.cpp +++ b/engines/stark/resources/animsoundtrigger.cpp @@ -37,8 +37,8 @@ AnimSoundTrigger::~AnimSoundTrigger() { AnimSoundTrigger::AnimSoundTrigger(Object *parent, byte subType, uint16 index, const Common::String &name) : Object(parent, subType, index, name), - _soundStockType(0), - _soundTriggerTime(0), + _soundStockType(0), + _soundTriggerTime(0), _anim(nullptr), _alreadyPlayed(false), _timeRemainingBeforeLoop(34) { diff --git a/engines/stark/resources/command.cpp b/engines/stark/resources/command.cpp index 37c4a6f5e29..abb7e0e0303 100644 --- a/engines/stark/resources/command.cpp +++ b/engines/stark/resources/command.cpp @@ -1023,7 +1023,7 @@ Command *Command::opLightSetColor(const ResourceReference &lightRef, int32 red, } Command *Command::opLightFollowPath(Script *script, const ResourceReference &itemRef, const ResourceReference &lightRef, - const ResourceReference &pathRef, int32 speed, bool suspend) { + const ResourceReference &pathRef, int32 speed, bool suspend) { ItemVisual *item = itemRef.resolve(); Light *light = lightRef.resolve(); Path *path = pathRef.resolve(); diff --git a/engines/stark/resources/floor.cpp b/engines/stark/resources/floor.cpp index 31f4f50950b..aebb7e6548d 100644 --- a/engines/stark/resources/floor.cpp +++ b/engines/stark/resources/floor.cpp @@ -224,11 +224,11 @@ void Floor::printData() { } FloorEdge::FloorEdge(uint16 vertexIndex1, uint16 vertexIndex2, uint32 faceIndex1) : - _vertexIndex1(vertexIndex1), - _vertexIndex2(vertexIndex2), - _faceIndex1(faceIndex1), - _faceIndex2(-1), - _enabled(true) { + _vertexIndex1(vertexIndex1), + _vertexIndex2(vertexIndex2), + _faceIndex1(faceIndex1), + _faceIndex2(-1), + _enabled(true) { } bool FloorEdge::hasVertices(uint16 vertexIndex1, uint16 vertexIndex2) const { diff --git a/engines/stark/resources/lipsync.cpp b/engines/stark/resources/lipsync.cpp index 06610c22bd1..c0e33544e39 100644 --- a/engines/stark/resources/lipsync.cpp +++ b/engines/stark/resources/lipsync.cpp @@ -48,8 +48,8 @@ LipSync::LipSync(Object *parent, byte subType, uint16 index, const Common::Strin _faceTexture(nullptr), _visual(nullptr), _enabled(false), - _checkForNewVisual(false), - _positionMs(0) { + _checkForNewVisual(false), + _positionMs(0) { _type = TYPE; } diff --git a/engines/stark/resources/pattable.h b/engines/stark/resources/pattable.h index 5cec0fe5eaa..2d891454c42 100644 --- a/engines/stark/resources/pattable.h +++ b/engines/stark/resources/pattable.h @@ -60,7 +60,7 @@ public: void readData(Formats::XRCReadStream *stream) override; void onAllLoaded() override; void onEnterLocation() override; - void saveLoad(ResourceSerializer *serializer) override; + void saveLoad(ResourceSerializer *serializer) override; ActionArray listPossibleActions() const; diff --git a/engines/stark/services/diary.cpp b/engines/stark/services/diary.cpp index a805872f727..221fe9955d9 100644 --- a/engines/stark/services/diary.cpp +++ b/engines/stark/services/diary.cpp @@ -163,8 +163,8 @@ bool Diary::hasUnreadEntries() const { Diary::ConversationLog::ConversationLog() : dialogActive(false), - chapter(0), - characterId(0) { + chapter(0), + characterId(0) { } Diary::ConversationLogLine::ConversationLogLine() : diff --git a/engines/stark/services/gameinterface.cpp b/engines/stark/services/gameinterface.cpp index 3fd7c44b2aa..2f4ab1cc014 100644 --- a/engines/stark/services/gameinterface.cpp +++ b/engines/stark/services/gameinterface.cpp @@ -189,7 +189,7 @@ Resources::ActionArray GameInterface::listActionsPossibleForObject(Resources::It } Resources::ActionArray GameInterface::listActionsPossibleForObjectAt(Resources::ItemVisual *item, - const Common::Point &pos) { + const Common::Point &pos) { if (item == nullptr) { return Resources::ActionArray(); } @@ -221,7 +221,7 @@ Resources::ActionArray GameInterface::listStockActionsPossibleForObject(Resource } Resources::ActionArray GameInterface::listStockActionsPossibleForObjectAt(Resources::ItemVisual *item, - const Common::Point &pos) { + const Common::Point &pos) { Resources::ActionArray actions = listActionsPossibleForObjectAt(item, pos); Resources::ActionArray stockActions; diff --git a/engines/stark/ui/menu/locationscreen.cpp b/engines/stark/ui/menu/locationscreen.cpp index 70fae13b947..ba10244875f 100644 --- a/engines/stark/ui/menu/locationscreen.cpp +++ b/engines/stark/ui/menu/locationscreen.cpp @@ -41,7 +41,7 @@ namespace Stark { StaticLocationScreen::StaticLocationScreen(Gfx::Driver *gfx, Cursor *cursor, - const char *locationName, Screen::Name screenName) : + const char *locationName, Screen::Name screenName) : SingleWindowScreen(screenName, gfx, cursor), _locationName(locationName), _location(nullptr), @@ -145,7 +145,7 @@ void StaticLocationScreen::waitForSoundsToComplete() { } StaticLocationWidget::StaticLocationWidget(const char *renderEntryName, WidgetOnClickCallback *onClickCallback, - WidgetOnMouseMoveCallback *onMouseMoveCallback): + WidgetOnMouseMoveCallback *onMouseMoveCallback): _onClick(onClickCallback), _onMouseMove(onMouseMoveCallback), _renderEntry(nullptr), diff --git a/engines/startrek/bridge.cpp b/engines/startrek/bridge.cpp index c79bc40e6f9..8d6749f7f21 100644 --- a/engines/startrek/bridge.cpp +++ b/engines/startrek/bridge.cpp @@ -592,19 +592,19 @@ struct CrewTextsForChapter { }; CrewTextsForChapter crewTexts[] = { - // -- Chapter 1 ---- + // -- Chapter 1 ---- { kPlanetPollux, kBridgeTalkerSpock, 10, 20, 21, 22 }, { kPlanetPollux, kBridgeTalkerUhura, 9, 16, 19, 19 }, - // -- Chapter 2 ---- + // -- Chapter 2 ---- { kPlanetBetaMyamid, kBridgeTalkerSpock, 13, 5, 17, 27 }, { kPlanetBetaMyamid, kBridgeTalkerUhura, 12, 4, 16, -1 }, - // -- Chapter 3 ---- + // -- Chapter 3 ---- { kPlanetArk7, kBridgeTalkerSpock, 8, 4, -1, 13 }, { kPlanetArk7, kBridgeTalkerUhura, 7, 5, -1, -1 }, - // -- Chapter 4 ---- + // -- Chapter 4 ---- { kPlanetHarlequin, kBridgeTalkerSpock, 21, 4, 22, -1 }, { kPlanetHarlequin, kBridgeTalkerUhura, 19, 3, 20, -1 }, - // -- Chapter 6 ---- + // -- Chapter 6 ---- { kPlanetAlphaProxima, kBridgeTalkerSpock, -1, 11, -1, -1 }, { kPlanetAlphaProxima, kBridgeTalkerUhura, -1, 10, -1, -1 }, // TODO: The rest diff --git a/engines/startrek/lzss.h b/engines/startrek/lzss.h index 29ed1ebb08b..5e51858be9f 100644 --- a/engines/startrek/lzss.h +++ b/engines/startrek/lzss.h @@ -32,24 +32,24 @@ Common::SeekableReadStream *decodeLZSS(Common::SeekableReadStream *indata, uint3 /* class LzssReadStream : public Common::SeekableReadStream { private: - uint8 *_outLzssBufData; - uint32 _size; - uint32 _pos; + uint8 *_outLzssBufData; + uint32 _size; + uint32 _pos; - uint32 decodeLZSS(Common::ReadStream *in, uint8 lengthmask, uint8 lengthbits); + uint32 decodeLZSS(Common::ReadStream *in, uint8 lengthmask, uint8 lengthbits); public: - LzssReadStream(Common::ReadStream *indata, uint8 lengthmask, uint8 lengthbits); - ~LzssReadStream(); + LzssReadStream(Common::ReadStream *indata, uint8 lengthmask, uint8 lengthbits); + ~LzssReadStream(); - bool eos() const; - uint32 read(void *buf, uint32 length); - int32 pos() const { return _pos; } - int32 size() const { return _size; } - bool seek(int32 offset, int whence) { - // TODO - return false; - } + bool eos() const; + uint32 read(void *buf, uint32 length); + int32 pos() const { return _pos; } + int32 size() const { return _size; } + bool seek(int32 offset, int whence) { + // TODO + return false; + } }; */ diff --git a/engines/startrek/metaengine.cpp b/engines/startrek/metaengine.cpp index 1e2eef5a4c9..e6902e091bf 100644 --- a/engines/startrek/metaengine.cpp +++ b/engines/startrek/metaengine.cpp @@ -60,7 +60,7 @@ public: return "startrek"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; SaveStateList listSaves(const char *target) const override; @@ -197,7 +197,7 @@ SaveStateDescriptor StarTrekMetaEngine::querySaveMetaInfos(const char *target, i } #if PLUGIN_ENABLED_DYNAMIC(STARTREK) - REGISTER_PLUGIN_DYNAMIC(STARTREK, PLUGIN_TYPE_ENGINE, StarTrekMetaEngine); + REGISTER_PLUGIN_DYNAMIC(STARTREK, PLUGIN_TYPE_ENGINE, StarTrekMetaEngine); #else - REGISTER_PLUGIN_STATIC(STARTREK, PLUGIN_TYPE_ENGINE, StarTrekMetaEngine); + REGISTER_PLUGIN_STATIC(STARTREK, PLUGIN_TYPE_ENGINE, StarTrekMetaEngine); #endif diff --git a/engines/startrek/rooms/demon0.cpp b/engines/startrek/rooms/demon0.cpp index cb21c69d000..9dd603fb97b 100644 --- a/engines/startrek/rooms/demon0.cpp +++ b/engines/startrek/rooms/demon0.cpp @@ -166,8 +166,8 @@ extern const RoomTextOffsets demon0TextOffsets[] = { }; extern const RoomText demon0Texts[] = { - { TX_DEM0C001, Common::EN_ANY, "All mining equipment use this road." }, - { -1, Common::UNK_LANG, "" } + { TX_DEM0C001, Common::EN_ANY, "All mining equipment use this road." }, + { -1, Common::UNK_LANG, "" } }; void Room::demon0Tick1() { diff --git a/engines/startrek/rooms/demon1.cpp b/engines/startrek/rooms/demon1.cpp index e3db4720b0e..00ba6e7b733 100644 --- a/engines/startrek/rooms/demon1.cpp +++ b/engines/startrek/rooms/demon1.cpp @@ -143,7 +143,7 @@ extern const RoomTextOffsets demon1TextOffsets[] = { { TX_DEM1_007, 3142, 0 }, { TX_DEM1_008, 3285, 0 }, { TX_DEM1_009, 4222, 0 }, - { TX_DEM1_011, 1492, 0 }, + { TX_DEM1_011, 1492, 0 }, { TX_DEM1_012, 6779, 0 }, { TX_DEM1_013, 7645, 0 }, { TX_DEM1_014, 7779, 0 }, @@ -189,7 +189,7 @@ extern const RoomTextOffsets demon1TextOffsets[] = { }; extern const RoomText demon1Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; // BUG: under certain circumstances, the klingons just stop firing? diff --git a/engines/startrek/rooms/demon2.cpp b/engines/startrek/rooms/demon2.cpp index 2ee04bcb9d7..dd0080ffe08 100644 --- a/engines/startrek/rooms/demon2.cpp +++ b/engines/startrek/rooms/demon2.cpp @@ -81,8 +81,8 @@ enum demon2TextIds { // TODO: Finish floppy offsets extern const RoomTextOffsets demon2TextOffsets[] = { { TX_SPEAKER_KIRK, 2890, 0 }, - { TX_SPEAKER_MCCOY, 2901, 0 }, - { TX_SPEAKER_SPOCK, 2911, 0 }, + { TX_SPEAKER_MCCOY, 2901, 0 }, + { TX_SPEAKER_SPOCK, 2911, 0 }, { TX_SPEAKER_EVERTS, 2921, 0 }, { TX_DEM2_001, 3275, 0 }, { TX_DEM2_002, 3732, 0 }, @@ -121,7 +121,7 @@ extern const RoomTextOffsets demon2TextOffsets[] = { }; extern const RoomText demon2Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::demon2Tick1() { diff --git a/engines/startrek/rooms/demon3.cpp b/engines/startrek/rooms/demon3.cpp index 0ab5d46dd0d..438103817b7 100644 --- a/engines/startrek/rooms/demon3.cpp +++ b/engines/startrek/rooms/demon3.cpp @@ -209,7 +209,7 @@ extern const RoomTextOffsets demon3TextOffsets[] = { }; extern const RoomText demon3Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::demon3Tick1() { diff --git a/engines/startrek/rooms/demon4.cpp b/engines/startrek/rooms/demon4.cpp index 78a3fdd71f6..0b2e73b562e 100644 --- a/engines/startrek/rooms/demon4.cpp +++ b/engines/startrek/rooms/demon4.cpp @@ -184,7 +184,7 @@ extern const RoomTextOffsets demon4TextOffsets[] = { }; extern const RoomText demon4Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; // TODO: this room should have animations on computer terminals, but this isn't where diff --git a/engines/startrek/rooms/demon5.cpp b/engines/startrek/rooms/demon5.cpp index 71e5973467e..f795288ebcd 100644 --- a/engines/startrek/rooms/demon5.cpp +++ b/engines/startrek/rooms/demon5.cpp @@ -176,7 +176,7 @@ extern const RoomTextOffsets demon5TextOffsets[] = { }; extern const RoomText demon5Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::demon5Tick1() { diff --git a/engines/startrek/rooms/demon6.cpp b/engines/startrek/rooms/demon6.cpp index 4c9a4445d77..2ce5a777b44 100644 --- a/engines/startrek/rooms/demon6.cpp +++ b/engines/startrek/rooms/demon6.cpp @@ -212,12 +212,12 @@ extern const RoomTextOffsets demon6TextOffsets[] = { { TX_DEM6N022, 3812, 0 }, { TX_DEM6N023, 1687, 0 }, { TX_DEM6N024, 1036, 0 }, - {TX_DIALOG_ERROR, 8214, 0 }, + {TX_DIALOG_ERROR, 8214, 0 }, { -1, 0, 0 } }; extern const RoomText demon6Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::demon6Tick1() { diff --git a/engines/startrek/rooms/feather0.cpp b/engines/startrek/rooms/feather0.cpp index 0f049d1d51a..b6e76c0a693 100644 --- a/engines/startrek/rooms/feather0.cpp +++ b/engines/startrek/rooms/feather0.cpp @@ -147,7 +147,7 @@ extern const RoomTextOffsets feather0TextOffsets[] = { }; extern const RoomText feather0Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::feather0Tick1() { diff --git a/engines/startrek/rooms/feather1.cpp b/engines/startrek/rooms/feather1.cpp index 324a62c72ff..e3f8617c0c7 100644 --- a/engines/startrek/rooms/feather1.cpp +++ b/engines/startrek/rooms/feather1.cpp @@ -255,7 +255,7 @@ extern const RoomTextOffsets feather1TextOffsets[] = { }; extern const RoomText feather1Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::feather1Tick1() { diff --git a/engines/startrek/rooms/feather2.cpp b/engines/startrek/rooms/feather2.cpp index f7662d51349..2c96ff3dc21 100644 --- a/engines/startrek/rooms/feather2.cpp +++ b/engines/startrek/rooms/feather2.cpp @@ -96,7 +96,7 @@ extern const RoomTextOffsets feather2TextOffsets[] = { }; extern const RoomText feather2Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::feather2Tick1() { diff --git a/engines/startrek/rooms/feather3.cpp b/engines/startrek/rooms/feather3.cpp index 4923e575e52..e28031066e2 100644 --- a/engines/startrek/rooms/feather3.cpp +++ b/engines/startrek/rooms/feather3.cpp @@ -169,13 +169,13 @@ extern const RoomTextOffsets feather3TextOffsets[] = { { TX_FEA3N010, 6878, 0 }, { TX_FEA3N011, 3408, 0 }, { TX_FEA3N012, 2883, 0 }, - { TX_LOVA_100, 8620, 0 }, + { TX_LOVA_100, 8620, 0 }, { TX_DIALOG_ERROR, 7022, 0 }, { -1, 0, 0 } }; extern const RoomText feather3Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::feather3Tick1() { diff --git a/engines/startrek/rooms/feather4.cpp b/engines/startrek/rooms/feather4.cpp index 1b3da09ece3..9571bdefc10 100644 --- a/engines/startrek/rooms/feather4.cpp +++ b/engines/startrek/rooms/feather4.cpp @@ -79,7 +79,7 @@ extern const RoomTextOffsets feather4TextOffsets[] = { { TX_SPEAKER_KIRK, 1205, 0 }, { TX_SPEAKER_MCCOY, 1228, 0 }, { TX_SPEAKER_SPOCK, 1238, 0 }, - { TX_SPEAKER_STRAGEY, 1248, 0 }, + { TX_SPEAKER_STRAGEY, 1248, 0 }, { TX_SPEAKER_QUETZECOATL, 1216, 0 }, { TX_FEA4_001, 2525, 0 }, { TX_FEA4_002, 700, 0 }, @@ -106,7 +106,7 @@ extern const RoomTextOffsets feather4TextOffsets[] = { }; extern const RoomText feather4Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::feather4Tick1() { diff --git a/engines/startrek/rooms/feather5.cpp b/engines/startrek/rooms/feather5.cpp index ae15d92fcfb..317a260fecc 100644 --- a/engines/startrek/rooms/feather5.cpp +++ b/engines/startrek/rooms/feather5.cpp @@ -132,13 +132,13 @@ extern const RoomTextOffsets feather5TextOffsets[] = { { TX_SPEAKER_KIRK, 2385, 0 }, { TX_SPEAKER_MCCOY, 2396, 0 }, { TX_SPEAKER_SPOCK, 2406, 0 }, - { TX_SPEAKER_STRAGEY, 2416, 0 }, + { TX_SPEAKER_STRAGEY, 2416, 0 }, { -1, 0, 0 } }; extern const RoomText feather5Texts[] = { { TX_FEA5_001, Common::EN_ANY, "#FEA5\\FEA5_001#This is a very finely crafted knife." }, - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::feather5Tick1() { diff --git a/engines/startrek/rooms/feather6.cpp b/engines/startrek/rooms/feather6.cpp index 6a71b50ac5f..14106f15031 100644 --- a/engines/startrek/rooms/feather6.cpp +++ b/engines/startrek/rooms/feather6.cpp @@ -121,7 +121,7 @@ extern const RoomTextOffsets feather6TextOffsets[] = { { TX_SPEAKER_KIRK, 2326, 0 }, { TX_SPEAKER_MCCOY, 2337, 0 }, { TX_SPEAKER_SPOCK, 2347, 0 }, - { TX_SPEAKER_STRAGEY, 2357, 0 }, + { TX_SPEAKER_STRAGEY, 2357, 0 }, { TX_FEA6_001, 2687, 0 }, { TX_FEA6_002, 5067, 0 }, { TX_FEA6_003, 5632, 0 }, @@ -189,7 +189,7 @@ extern const RoomTextOffsets feather6TextOffsets[] = { }; extern const RoomText feather6Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::feather6Tick1() { diff --git a/engines/startrek/rooms/feather7.cpp b/engines/startrek/rooms/feather7.cpp index c3f8773ad6b..a4f4087deee 100644 --- a/engines/startrek/rooms/feather7.cpp +++ b/engines/startrek/rooms/feather7.cpp @@ -54,7 +54,7 @@ extern const RoomTextOffsets feather7TextOffsets[] = { { TX_SPEAKER_MCCOY, 1075, 0 }, { TX_SPEAKER_SPOCK, 1085, 0 }, { TX_SPEAKER_STRAGEY, 1095, 0 }, - { TX_SPEAKER_QUETZECOATL, 1107, 0 }, + { TX_SPEAKER_QUETZECOATL, 1107, 0 }, { TX_FEA7_001, 4842, 0 }, { TX_FEA7_002, 4802, 0 }, { TX_FEA7_003, 4674, 0 }, @@ -89,7 +89,7 @@ extern const RoomTextOffsets feather7TextOffsets[] = { }; extern const RoomText feather7Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::feather7Tick1() { diff --git a/engines/startrek/rooms/love0.cpp b/engines/startrek/rooms/love0.cpp index c06ba55fff4..dfaf73a05d3 100644 --- a/engines/startrek/rooms/love0.cpp +++ b/engines/startrek/rooms/love0.cpp @@ -203,7 +203,7 @@ extern const RoomTextOffsets love0TextOffsets[] = { }; extern const RoomText love0Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::love0Tick1() { diff --git a/engines/startrek/rooms/love1.cpp b/engines/startrek/rooms/love1.cpp index 58e38147ed0..df975b7ba8f 100644 --- a/engines/startrek/rooms/love1.cpp +++ b/engines/startrek/rooms/love1.cpp @@ -341,7 +341,7 @@ extern const RoomTextOffsets love1TextOffsets[] = { }; extern const RoomText love1Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::love1Tick1() { diff --git a/engines/startrek/rooms/love2.cpp b/engines/startrek/rooms/love2.cpp index e5a0a24dca8..14d035de53c 100644 --- a/engines/startrek/rooms/love2.cpp +++ b/engines/startrek/rooms/love2.cpp @@ -382,7 +382,7 @@ extern const RoomTextOffsets love2TextOffsets[] = { }; extern const RoomText love2Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::love2Tick1() { diff --git a/engines/startrek/rooms/love3.cpp b/engines/startrek/rooms/love3.cpp index 01110cf6493..b3b6589cd1b 100644 --- a/engines/startrek/rooms/love3.cpp +++ b/engines/startrek/rooms/love3.cpp @@ -329,12 +329,12 @@ extern const RoomTextOffsets love3TextOffsets[] = { { TX_LOV3NA22, 10002, 0 }, { TX_LOV3NA23, 1089, 0 }, { TX_LOV3NJ32, 5767, 0 }, - { TX_DIALOG_ERROR, 14528, 0 }, + { TX_DIALOG_ERROR, 14528, 0 }, { -1, 0, 0 } }; extern const RoomText love3Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::love3Tick1() { diff --git a/engines/startrek/rooms/love4.cpp b/engines/startrek/rooms/love4.cpp index 61dc080dc8b..4932405f67a 100644 --- a/engines/startrek/rooms/love4.cpp +++ b/engines/startrek/rooms/love4.cpp @@ -256,7 +256,7 @@ extern const RoomTextOffsets love4TextOffsets[] = { { TX_LOV4N004, 3206, 0 }, { TX_LOV4N005, 2437, 0 }, { TX_LOV4N006, 7309, 0 }, - { TX_LOV4N007, 1473, 0 }, + { TX_LOV4N007, 1473, 0 }, { TX_LOV4N008, 7843, 0 }, { TX_LOV4N009, 7362, 0 }, { TX_LOV4N010, 7495, 0 }, @@ -271,7 +271,7 @@ extern const RoomTextOffsets love4TextOffsets[] = { }; extern const RoomText love4Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::love4Tick1() { diff --git a/engines/startrek/rooms/lovea.cpp b/engines/startrek/rooms/lovea.cpp index 348f26e53b5..a0e7d56cb5c 100644 --- a/engines/startrek/rooms/lovea.cpp +++ b/engines/startrek/rooms/lovea.cpp @@ -84,7 +84,7 @@ extern const RoomTextOffsets loveTextOffsets[] = { { TX_LOV0_106, 12415, 0 }, { TX_LOV0_107, 12483, 0 }, { TX_LOV0_124, 11931, 0 }, - { TX_LOV5_015, 3009, 0 }, + { TX_LOV5_015, 3009, 0 }, { TX_LOV5_019, 2931, 0 }, { TX_LOV5_027, 3444, 0 }, { TX_LOV5_030, 3348, 0 }, @@ -107,7 +107,7 @@ extern const RoomTextOffsets loveTextOffsets[] = { { TX_VENA_F41, 5158, 0 }, { TX_LOV5C001, 3497, 0 }, { TX_SPOKCOFF, 3564, 0 }, - { TX_GENER004, 3924, 0 }, // Game over + { TX_GENER004, 3924, 0 }, // Game over { -1, 0, 0 } }; diff --git a/engines/startrek/rooms/mudd0.cpp b/engines/startrek/rooms/mudd0.cpp index a30cc53bd3f..111d1b8ddb1 100644 --- a/engines/startrek/rooms/mudd0.cpp +++ b/engines/startrek/rooms/mudd0.cpp @@ -180,7 +180,7 @@ extern const RoomTextOffsets mudd0TextOffsets[] = { }; extern const RoomText mudd0Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::mudd0Tick1() { diff --git a/engines/startrek/rooms/mudd1.cpp b/engines/startrek/rooms/mudd1.cpp index 24319d4e15d..1043e537aba 100644 --- a/engines/startrek/rooms/mudd1.cpp +++ b/engines/startrek/rooms/mudd1.cpp @@ -175,7 +175,7 @@ extern const RoomTextOffsets mudd1TextOffsets[] = { extern const RoomText mudd1Texts[] = { { TX_DEM0N009, Common::EN_ANY, "#DEM0\\DEM0N009#Spock raises an eyebrow" }, - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::mudd1Tick1() { diff --git a/engines/startrek/rooms/mudd2.cpp b/engines/startrek/rooms/mudd2.cpp index 03f43019124..480d342e255 100644 --- a/engines/startrek/rooms/mudd2.cpp +++ b/engines/startrek/rooms/mudd2.cpp @@ -196,7 +196,7 @@ extern const RoomTextOffsets mudd2TextOffsets[] = { }; extern const RoomText mudd2Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::mudd2WalkToNorthDoor() { diff --git a/engines/startrek/rooms/mudd4.cpp b/engines/startrek/rooms/mudd4.cpp index 3094d80000a..d75dd63d3cc 100644 --- a/engines/startrek/rooms/mudd4.cpp +++ b/engines/startrek/rooms/mudd4.cpp @@ -191,7 +191,7 @@ extern const RoomTextOffsets mudd4TextOffsets[] = { }; extern const RoomText mudd4Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::mudd4Tick1() { diff --git a/engines/startrek/rooms/mudd5.cpp b/engines/startrek/rooms/mudd5.cpp index 2a2fd6a5f90..92ced4a2a79 100644 --- a/engines/startrek/rooms/mudd5.cpp +++ b/engines/startrek/rooms/mudd5.cpp @@ -165,7 +165,7 @@ extern const RoomTextOffsets mudd5TextOffsets[] = { }; extern const RoomText mudd5Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::mudd5Tick1() { diff --git a/engines/startrek/rooms/sins0.cpp b/engines/startrek/rooms/sins0.cpp index 9577ec553ee..ad9db955e75 100644 --- a/engines/startrek/rooms/sins0.cpp +++ b/engines/startrek/rooms/sins0.cpp @@ -96,8 +96,8 @@ extern const RoomTextOffsets sins0TextOffsets[] = { { TX_SPEAKER_MCCOY, 300, 0 }, { TX_SPEAKER_SPOCK, 310, 0 }, { TX_SPEAKER_SCOTT, 344, 0 }, - { TX_SPEAKER_UHURA, 334, 0 }, - { TX_SPEAKER_MOSHER, 320, 0 }, + { TX_SPEAKER_UHURA, 334, 0 }, + { TX_SPEAKER_MOSHER, 320, 0 }, { TX_SIN0N000, 3805, 0 }, { TX_SIN0N001, 3994, 0 }, { TX_SIN0N002, 3594, 0 }, @@ -148,7 +148,7 @@ extern const RoomTextOffsets sins0TextOffsets[] = { }; extern const RoomText sins0Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::sins0Tick1() { diff --git a/engines/startrek/rooms/sins1.cpp b/engines/startrek/rooms/sins1.cpp index 7470f39b971..4060ed92b12 100644 --- a/engines/startrek/rooms/sins1.cpp +++ b/engines/startrek/rooms/sins1.cpp @@ -163,7 +163,7 @@ extern const RoomTextOffsets sins1TextOffsets[] = { }; extern const RoomText sins1Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::sins1Tick1() { diff --git a/engines/startrek/rooms/sins2.cpp b/engines/startrek/rooms/sins2.cpp index 88d81f4e812..fb578d1d9d7 100644 --- a/engines/startrek/rooms/sins2.cpp +++ b/engines/startrek/rooms/sins2.cpp @@ -180,7 +180,7 @@ extern const RoomTextOffsets sins2TextOffsets[] = { }; extern const RoomText sins2Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::sins2Tick1() { diff --git a/engines/startrek/rooms/sins3.cpp b/engines/startrek/rooms/sins3.cpp index d6c1f446597..3412faffd78 100644 --- a/engines/startrek/rooms/sins3.cpp +++ b/engines/startrek/rooms/sins3.cpp @@ -196,7 +196,7 @@ extern const RoomTextOffsets sins3TextOffsets[] = { }; extern const RoomText sins3Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::sins3Tick1() { diff --git a/engines/startrek/rooms/sins4.cpp b/engines/startrek/rooms/sins4.cpp index d7ff83e696e..e331ec3e89e 100644 --- a/engines/startrek/rooms/sins4.cpp +++ b/engines/startrek/rooms/sins4.cpp @@ -173,7 +173,7 @@ extern const RoomTextOffsets sins4TextOffsets[] = { }; extern const RoomText sins4Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::sins4Tick1() { diff --git a/engines/startrek/rooms/sins5.cpp b/engines/startrek/rooms/sins5.cpp index 175500646fc..1ef1701ed52 100644 --- a/engines/startrek/rooms/sins5.cpp +++ b/engines/startrek/rooms/sins5.cpp @@ -221,7 +221,7 @@ extern const RoomTextOffsets sins5TextOffsets[] = { }; extern const RoomText sins5Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::sins5Tick1() { diff --git a/engines/startrek/rooms/trial0.cpp b/engines/startrek/rooms/trial0.cpp index e50e31e0093..03a59d34afb 100644 --- a/engines/startrek/rooms/trial0.cpp +++ b/engines/startrek/rooms/trial0.cpp @@ -106,11 +106,11 @@ extern const RoomTextOffsets trial0TextOffsets[] = { { TX_SPEAKER_KIRK, 279, 0 }, { TX_SPEAKER_MCCOY, 290, 0 }, { TX_SPEAKER_SPOCK, 300, 0 }, - { TX_SPEAKER_UHURA, 324, 0 }, - { TX_SPEAKER_BENNIE, 310, 0 }, - { TX_SPEAKER_VLICT, 334, 0 }, - { TX_SPEAKER_QUETZECOATL, 354, 0 }, - { TX_SPEAKER_KLINGON_GUARD, 340, 0 }, + { TX_SPEAKER_UHURA, 324, 0 }, + { TX_SPEAKER_BENNIE, 310, 0 }, + { TX_SPEAKER_VLICT, 334, 0 }, + { TX_SPEAKER_QUETZECOATL, 354, 0 }, + { TX_SPEAKER_KLINGON_GUARD, 340, 0 }, { TX_TRI0_001, 2728, 0 }, { TX_TRI0_002, 2315, 0 }, { TX_TRI0_003, 4950, 0 }, @@ -158,7 +158,7 @@ extern const RoomTextOffsets trial0TextOffsets[] = { { TX_TRI0_049, 6054, 0 }, { TX_TRI0_050, 3269, 0 }, { TX_TRI0_051, 5011, 0 }, - { TX_TRI0_052, 10206, 0 }, + { TX_TRI0_052, 10206, 0 }, { TX_TRI0_053, 831, 0 }, { TX_TRI0_054, 1350, 0 }, { TX_TRI0_055, 5619, 0 }, @@ -191,7 +191,7 @@ extern const RoomTextOffsets trial0TextOffsets[] = { }; extern const RoomText trial0Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::trial0Tick1() { diff --git a/engines/startrek/rooms/trial1.cpp b/engines/startrek/rooms/trial1.cpp index 7828fbbcd6a..cacfb0f8775 100644 --- a/engines/startrek/rooms/trial1.cpp +++ b/engines/startrek/rooms/trial1.cpp @@ -287,7 +287,7 @@ extern const RoomTextOffsets trial1TextOffsets[] = { extern const RoomText trial1Texts[] = { { TX_TRI1C001, Common::EN_ANY, "Zzzt! Sptttz! Zzzt! Tttt!" }, { TX_TRI1C002, Common::EN_ANY, "Clunk." }, - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::trial1Tick1() { diff --git a/engines/startrek/rooms/trial2.cpp b/engines/startrek/rooms/trial2.cpp index 6199dbf9c68..f9da24d692d 100644 --- a/engines/startrek/rooms/trial2.cpp +++ b/engines/startrek/rooms/trial2.cpp @@ -203,7 +203,7 @@ extern const RoomTextOffsets trial2TextOffsets[] = { extern const RoomText trial2Texts[] = { { TX_TRI1U080, Common::EN_ANY, "#TRI1\\TRI1U080#Affirmative, sir." }, - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::trial2Tick1() { diff --git a/engines/startrek/rooms/trial3.cpp b/engines/startrek/rooms/trial3.cpp index 48507f72bb9..5940ace91c0 100644 --- a/engines/startrek/rooms/trial3.cpp +++ b/engines/startrek/rooms/trial3.cpp @@ -163,7 +163,7 @@ extern const RoomTextOffsets trial3TextOffsets[] = { }; extern const RoomText trial3Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::trial3Tick1() { diff --git a/engines/startrek/rooms/trial4.cpp b/engines/startrek/rooms/trial4.cpp index 7518299ebd5..4778f884161 100644 --- a/engines/startrek/rooms/trial4.cpp +++ b/engines/startrek/rooms/trial4.cpp @@ -142,7 +142,7 @@ extern const RoomTextOffsets trial4TextOffsets[] = { }; extern const RoomText trial4Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::trial4Tick1() { diff --git a/engines/startrek/rooms/trial5.cpp b/engines/startrek/rooms/trial5.cpp index ab2b65cab66..96e2e65b0d8 100644 --- a/engines/startrek/rooms/trial5.cpp +++ b/engines/startrek/rooms/trial5.cpp @@ -271,7 +271,7 @@ extern const RoomTextOffsets trial5TextOffsets[] = { }; extern const RoomText trial5Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::trial5Tick1() { diff --git a/engines/startrek/rooms/tug0.cpp b/engines/startrek/rooms/tug0.cpp index 3f48d8fe995..5fad002d1a8 100644 --- a/engines/startrek/rooms/tug0.cpp +++ b/engines/startrek/rooms/tug0.cpp @@ -198,7 +198,7 @@ extern const RoomTextOffsets tug0TextOffsets[] = { }; extern const RoomText tug0Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::tug0Tick1() { diff --git a/engines/startrek/rooms/tug1.cpp b/engines/startrek/rooms/tug1.cpp index c6ec4669c68..2f75d52b37d 100644 --- a/engines/startrek/rooms/tug1.cpp +++ b/engines/startrek/rooms/tug1.cpp @@ -152,7 +152,7 @@ extern const RoomTextOffsets tug1TextOffsets[] = { }; extern const RoomText tug1Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::tug1Tick1() { diff --git a/engines/startrek/rooms/tug2.cpp b/engines/startrek/rooms/tug2.cpp index a161a7040d4..800390cda32 100644 --- a/engines/startrek/rooms/tug2.cpp +++ b/engines/startrek/rooms/tug2.cpp @@ -239,8 +239,8 @@ extern const RoomTextOffsets tug2TextOffsets[] = { }; extern const RoomText tug2Texts[] = { - { TX_TUG2C001, Common::EN_ANY, "Snip...snip...snip." }, - { -1, Common::UNK_LANG, "" } + { TX_TUG2C001, Common::EN_ANY, "Snip...snip...snip." }, + { -1, Common::UNK_LANG, "" } }; void Room::tug2Tick1() { diff --git a/engines/startrek/rooms/tug3.cpp b/engines/startrek/rooms/tug3.cpp index 28736413329..e28c11a91c8 100644 --- a/engines/startrek/rooms/tug3.cpp +++ b/engines/startrek/rooms/tug3.cpp @@ -138,7 +138,7 @@ extern const RoomTextOffsets tug3TextOffsets[] = { extern const RoomText tug3Texts[] = { { TX_TUG3_012, Common::EN_ANY, "" }, - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::tug3Tick1() { diff --git a/engines/startrek/rooms/veng0.cpp b/engines/startrek/rooms/veng0.cpp index 9c5e88bfa63..b7576674965 100644 --- a/engines/startrek/rooms/veng0.cpp +++ b/engines/startrek/rooms/veng0.cpp @@ -133,9 +133,9 @@ extern const RoomTextOffsets veng0TextOffsets[] = { { TX_SPEAKER_MCCOY, 6601, 0 }, { TX_SPEAKER_SPOCK, 6611, 0 }, { TX_SPEAKER_SCOTT, 6633, 0 }, - { TX_SPEAKER_CHEKOV, 6661, 0 }, - { TX_SPEAKER_PATTERSON, 6643, 0 }, - { TX_SPEAKER_KIJE, 6621, 0 }, + { TX_SPEAKER_CHEKOV, 6661, 0 }, + { TX_SPEAKER_PATTERSON, 6643, 0 }, + { TX_SPEAKER_KIJE, 6621, 0 }, { TX_VEN0_001, 7593, 0 }, { TX_VEN0_001, 7593, 0 }, { TX_VEN0_002, 7952, 0 }, @@ -231,7 +231,7 @@ extern const RoomTextOffsets veng0TextOffsets[] = { }; extern const RoomText veng0Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::veng0Tick1() { diff --git a/engines/startrek/rooms/veng1.cpp b/engines/startrek/rooms/veng1.cpp index 30f97a57d00..aaa34c21cc6 100644 --- a/engines/startrek/rooms/veng1.cpp +++ b/engines/startrek/rooms/veng1.cpp @@ -212,7 +212,7 @@ extern const RoomTextOffsets veng1TextOffsets[] = { }; extern const RoomText veng1Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::veng1Tick1() { diff --git a/engines/startrek/rooms/veng2.cpp b/engines/startrek/rooms/veng2.cpp index eeea3a6e0f6..5cb1fc8d291 100644 --- a/engines/startrek/rooms/veng2.cpp +++ b/engines/startrek/rooms/veng2.cpp @@ -424,7 +424,7 @@ extern const RoomTextOffsets veng2TextOffsets[] = { }; extern const RoomText veng2Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; #define STRICORDER_POS_X 0x45 diff --git a/engines/startrek/rooms/veng3.cpp b/engines/startrek/rooms/veng3.cpp index dafd0fdb5b0..a6314d9315e 100644 --- a/engines/startrek/rooms/veng3.cpp +++ b/engines/startrek/rooms/veng3.cpp @@ -118,7 +118,7 @@ extern const RoomTextOffsets veng3TextOffsets[] = { }; extern const RoomText veng3Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::veng3Tick1() { diff --git a/engines/startrek/rooms/veng4.cpp b/engines/startrek/rooms/veng4.cpp index de0d26fd2d1..0b70f81e51a 100644 --- a/engines/startrek/rooms/veng4.cpp +++ b/engines/startrek/rooms/veng4.cpp @@ -114,7 +114,7 @@ extern const RoomTextOffsets veng4TextOffsets[] = { }; extern const RoomText veng4Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; #define DOOR_X 0x13f diff --git a/engines/startrek/rooms/veng5.cpp b/engines/startrek/rooms/veng5.cpp index a87f9b0b876..c5425e6a527 100644 --- a/engines/startrek/rooms/veng5.cpp +++ b/engines/startrek/rooms/veng5.cpp @@ -104,7 +104,7 @@ extern const RoomTextOffsets veng5TextOffsets[] = { }; extern const RoomText veng5Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::veng5Tick1() { diff --git a/engines/startrek/rooms/veng6.cpp b/engines/startrek/rooms/veng6.cpp index be7dbe1200c..6297b2f55e0 100644 --- a/engines/startrek/rooms/veng6.cpp +++ b/engines/startrek/rooms/veng6.cpp @@ -147,7 +147,7 @@ extern const RoomTextOffsets veng6TextOffsets[] = { }; extern const RoomText veng6Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; #define DOOR_X 0x13e diff --git a/engines/startrek/rooms/veng7.cpp b/engines/startrek/rooms/veng7.cpp index 2fb592a0456..5415325f63b 100644 --- a/engines/startrek/rooms/veng7.cpp +++ b/engines/startrek/rooms/veng7.cpp @@ -89,7 +89,7 @@ extern const RoomTextOffsets veng7TextOffsets[] = { }; extern const RoomText veng7Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::veng7Tick1() { diff --git a/engines/startrek/rooms/veng8.cpp b/engines/startrek/rooms/veng8.cpp index a130b46e45e..17a44abb8f0 100644 --- a/engines/startrek/rooms/veng8.cpp +++ b/engines/startrek/rooms/veng8.cpp @@ -125,7 +125,7 @@ extern const RoomTextOffsets veng8TextOffsets[] = { }; extern const RoomText veng8Texts[] = { - { -1, Common::UNK_LANG, "" } + { -1, Common::UNK_LANG, "" } }; void Room::veng8Tick1() { diff --git a/engines/supernova/game-manager.cpp b/engines/supernova/game-manager.cpp index 9dfa91b977c..47475c05e9e 100644 --- a/engines/supernova/game-manager.cpp +++ b/engines/supernova/game-manager.cpp @@ -153,8 +153,8 @@ int GameManager::guiStatusCommands[] = { GameManager::GameManager(SupernovaEngine *vm, Sound *sound) : _inventory(&_nullObject, _inventoryScroll) , _vm(vm) - , _sound(sound) - , _mouseClickType(Common::EVENT_INVALID) { + , _sound(sound) + , _mouseClickType(Common::EVENT_INVALID) { initGui(); } diff --git a/engines/supernova/metaengine.cpp b/engines/supernova/metaengine.cpp index 810caa5818f..fbe9a1bdfe0 100644 --- a/engines/supernova/metaengine.cpp +++ b/engines/supernova/metaengine.cpp @@ -36,7 +36,7 @@ public: return "supernova"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; SaveStateList listSaves(const char *target) const override; @@ -173,7 +173,7 @@ SaveStateDescriptor SupernovaMetaEngine::querySaveMetaInfos(const char *target, } #if PLUGIN_ENABLED_DYNAMIC(SUPERNOVA) - REGISTER_PLUGIN_DYNAMIC(SUPERNOVA, PLUGIN_TYPE_ENGINE, SupernovaMetaEngine); + REGISTER_PLUGIN_DYNAMIC(SUPERNOVA, PLUGIN_TYPE_ENGINE, SupernovaMetaEngine); #else - REGISTER_PLUGIN_STATIC(SUPERNOVA, PLUGIN_TYPE_ENGINE, SupernovaMetaEngine); + REGISTER_PLUGIN_STATIC(SUPERNOVA, PLUGIN_TYPE_ENGINE, SupernovaMetaEngine); #endif diff --git a/engines/sword1/metaengine.cpp b/engines/sword1/metaengine.cpp index 4f95ff15c43..34014296f99 100644 --- a/engines/sword1/metaengine.cpp +++ b/engines/sword1/metaengine.cpp @@ -33,13 +33,13 @@ class SwordMetaEngine : public MetaEngine { public: - const char *getName() const override { + const char *getName() const override { return "sword1"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; - SaveStateList listSaves(const char *target) const override; + SaveStateList listSaves(const char *target) const override; int getMaximumSaveSlot() const override; void removeSaveState(const char *target, int slot) const override; SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override; diff --git a/engines/sword1/resman.h b/engines/sword1/resman.h index ac6aa870655..43f00932d10 100644 --- a/engines/sword1/resman.h +++ b/engines/sword1/resman.h @@ -34,8 +34,8 @@ namespace Sword1 { #if defined(__PSP__) #define MAX_OPEN_CLUS 4 // the PSP can't have more than 8 files open simultaneously - // since we also need filehandles for music and sometimes savegames - // set the maximum number of open clusters to 4. + // since we also need filehandles for music and sometimes savegames + // set the maximum number of open clusters to 4. #else #define MAX_OPEN_CLUS 8 // don't open more than 8 files at once #endif diff --git a/engines/sword1/screen.h b/engines/sword1/screen.h index 6186f64250c..e2e76be8c67 100644 --- a/engines/sword1/screen.h +++ b/engines/sword1/screen.h @@ -68,7 +68,7 @@ struct PSXDataCache { // Cache for PSX screen, to avoid decompressing background class ResMan; class ObjectMan; class Text; // Text objects use sprites that are created internally at run-time - // the buffer belongs to Text, so we need a reference here. + // the buffer belongs to Text, so we need a reference here. class Screen { public: diff --git a/engines/sword2/metaengine.cpp b/engines/sword2/metaengine.cpp index acefded1233..1ad0e24bc62 100644 --- a/engines/sword2/metaengine.cpp +++ b/engines/sword2/metaengine.cpp @@ -38,13 +38,13 @@ class Sword2MetaEngine : public MetaEngine { public: - const char *getName() const override { + const char *getName() const override { return "sword2"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; - SaveStateList listSaves(const char *target) const override; + SaveStateList listSaves(const char *target) const override; int getMaximumSaveSlot() const override; void removeSaveState(const char *target, int slot) const override; diff --git a/engines/sword25/gfx/image/art.cpp b/engines/sword25/gfx/image/art.cpp index 3299e363a3e..54ddc2e6718 100644 --- a/engines/sword25/gfx/image/art.cpp +++ b/engines/sword25/gfx/image/art.cpp @@ -95,7 +95,7 @@ int art_svp_seg_compare(const void *s1, const void *s2) { * desired. **/ void art_vpath_add_point(ArtVpath **p_vpath, int *pn_points, int *pn_points_max, - ArtPathcode code, double x, double y) { + ArtPathcode code, double x, double y) { int i; i = (*pn_points)++; @@ -162,7 +162,7 @@ ArtSVP *art_svp_from_vpath(ArtVpath *vpath) { i = 0; x = y = 0; /* unnecessary, given "first code must not be LINETO" invariant, - but it makes gcc -Wall -ansi -pedantic happier */ + but it makes gcc -Wall -ansi -pedantic happier */ x_min = x_max = 0; /* same */ while (vpath[i].code != ART_END) { @@ -324,11 +324,11 @@ ArtSVP *art_svp_from_vpath(ArtVpath *vpath) { * rendering. **/ static void art_vpath_render_bez(ArtVpath **p_vpath, int *pn, int *pn_max, - double x0, double y0, - double x1, double y1, - double x2, double y2, - double x3, double y3, - double flatness) { + double x0, double y0, + double x1, double y1, + double x2, double y2, + double x3, double y3, + double flatness) { /* It's possible to optimize this routine a fair amount. First, once the _dot conditions are met, they will also be met in @@ -508,11 +508,11 @@ ArtVpath *art_bez_path_to_vec(const ArtBpath *bez, double flatness) { curve to the right. */ static void art_svp_vpath_stroke_arc(ArtVpath **p_vpath, int *pn, int *pn_max, - double xc, double yc, - double x0, double y0, - double x1, double y1, - double radius, - double flatness) { + double xc, double yc, + double x0, double y0, + double x1, double y1, + double radius, + double flatness) { double theta; double th_0, th_1; int n_pts; @@ -558,10 +558,10 @@ static void art_svp_vpath_stroke_arc(ArtVpath **p_vpath, int *pn, int *pn_max, Precondition: no zero-length vectors, otherwise a divide by zero will happen. */ static void render_seg(ArtVpath **p_forw, int *pn_forw, int *pn_forw_max, - ArtVpath **p_rev, int *pn_rev, int *pn_rev_max, - ArtVpath *vpath, int i0, int i1, int i2, - ArtPathStrokeJoinType join, - double line_width, double miter_limit, double flatness) { + ArtVpath **p_rev, int *pn_rev, int *pn_rev_max, + ArtVpath *vpath, int i0, int i1, int i2, + ArtPathStrokeJoinType join, + double line_width, double miter_limit, double flatness) { double dx0, dy0; double dx1, dy1; double dlx0, dly0; @@ -719,8 +719,8 @@ static void render_seg(ArtVpath **p_forw, int *pn_forw, int *pn_forw_max, /* caps i1, under the assumption of a vector from i0 */ static void render_cap(ArtVpath **p_result, int *pn_result, int *pn_result_max, - ArtVpath *vpath, int i0, int i1, - ArtPathStrokeCapType cap, double line_width, double flatness) { + ArtVpath *vpath, int i0, int i1, + ArtPathStrokeCapType cap, double line_width, double flatness) { double dx0, dy0; double dlx0, dly0; double scale; @@ -792,11 +792,11 @@ static void render_cap(ArtVpath **p_result, int *pn_result, int *pn_result_max, * Return value: Resulting raw stroked outline in svp format. **/ ArtVpath *art_svp_vpath_stroke_raw(ArtVpath *vpath, - ArtPathStrokeJoinType join, - ArtPathStrokeCapType cap, - double line_width, - double miter_limit, - double flatness) { + ArtPathStrokeJoinType join, + ArtPathStrokeCapType cap, + double line_width, + double miter_limit, + double flatness) { int begin_idx, end_idx; int i; ArtVpath *forw, *rev; @@ -990,11 +990,11 @@ ArtVpath *art_svp_vpath_stroke_raw(ArtVpath *vpath, * Return value: Resulting stroked outline in svp format. **/ ArtSVP *art_svp_vpath_stroke(ArtVpath *vpath, - ArtPathStrokeJoinType join, - ArtPathStrokeCapType cap, - double line_width, - double miter_limit, - double flatness) { + ArtPathStrokeJoinType join, + ArtPathStrokeCapType cap, + double line_width, + double miter_limit, + double flatness) { ArtVpath *vpath_stroke; ArtSVP *svp, *svp2; ArtSvpWriter *swr; @@ -1124,7 +1124,7 @@ struct _ArtSvpWriterRewind { }; static int art_svp_writer_rewind_add_segment(ArtSvpWriter *self, int wind_left, - int delta_wind, double x, double y) { + int delta_wind, double x, double y) { ArtSvpWriterRewind *swr = (ArtSvpWriterRewind *)self; ArtSVP *svp; ArtSVPSeg *seg; @@ -1192,7 +1192,7 @@ static int art_svp_writer_rewind_add_segment(ArtSvpWriter *self, int wind_left, } static void art_svp_writer_rewind_add_point(ArtSvpWriter *self, int seg_id, - double x, double y) { + double x, double y) { ArtSvpWriterRewind *swr = (ArtSvpWriterRewind *)self; ArtSVPSeg *seg; int n_points; @@ -1283,7 +1283,7 @@ struct _ArtActiveSeg { double x[2]; double y0, y1; double a, b, c; /* line equation; ax+by+c = 0 for the line, a^2 + b^2 = 1, - and a>0 */ + and a>0 */ /* bottom point and intersection point stack */ int n_stack; @@ -1400,7 +1400,7 @@ static void art_svp_intersect_add_horiz(ArtIntersectCtx *ctx, ArtActiveSeg *seg) } static void art_svp_intersect_push_pt(ArtIntersectCtx *ctx, ArtActiveSeg *seg, - double x, double y) { + double x, double y) { ArtPriPoint *pri_pt; int n_stack = seg->n_stack; @@ -1437,7 +1437,7 @@ typedef enum { * Return value: x coordinate of break point. */ static double art_svp_intersect_break(ArtIntersectCtx *ctx, ArtActiveSeg *seg, - double x_ref, double y, ArtBreakFlags break_flags) { + double x_ref, double y, ArtBreakFlags break_flags) { double x0, y0, x1, y1; const ArtSVPSeg *in_seg = seg->in_seg; int in_curs = seg->in_curs; @@ -1478,7 +1478,7 @@ static double art_svp_intersect_break(ArtIntersectCtx *ctx, ArtActiveSeg *seg, * NULL if the new point is leftmost. **/ static ArtActiveSeg *art_svp_intersect_add_point(ArtIntersectCtx *ctx, double x, double y, - ArtActiveSeg *seg, ArtBreakFlags break_flags) { + ArtActiveSeg *seg, ArtBreakFlags break_flags) { ArtActiveSeg *left, *right; double x_min = x, x_max = x; bool left_live, right_live; @@ -1567,7 +1567,7 @@ static ArtActiveSeg *art_svp_intersect_add_point(ArtIntersectCtx *ctx, double x, } static void art_svp_intersect_swap_active(ArtIntersectCtx *ctx, - ArtActiveSeg *left_seg, ArtActiveSeg *right_seg) { + ArtActiveSeg *left_seg, ArtActiveSeg *right_seg) { right_seg->left = left_seg->left; if (right_seg->left != NULL) right_seg->left->right = right_seg; @@ -1594,8 +1594,8 @@ static void art_svp_intersect_swap_active(ArtIntersectCtx *ctx, * scan line, indicating further iteration is needed. **/ static bool art_svp_intersect_test_cross(ArtIntersectCtx *ctx, - ArtActiveSeg *left_seg, ArtActiveSeg *right_seg, - ArtBreakFlags break_flags) { + ArtActiveSeg *left_seg, ArtActiveSeg *right_seg, + ArtBreakFlags break_flags) { double left_x0, left_y0, left_x1; double left_y1 = left_seg->y1; double right_y1 = right_seg->y1; @@ -1825,7 +1825,7 @@ static void art_svp_intersect_active_free(ArtActiveSeg *seg) { * Precondition: the line in @seg is not purely horizontal. **/ static void art_svp_intersect_insert_cross(ArtIntersectCtx *ctx, - ArtActiveSeg *seg) { + ArtActiveSeg *seg) { ArtActiveSeg *left = seg, *right = seg; for (;;) { @@ -1873,7 +1873,7 @@ static void art_svp_intersect_insert_cross(ArtIntersectCtx *ctx, * location of @seg to @x1. **/ static void art_svp_intersect_horiz(ArtIntersectCtx *ctx, ArtActiveSeg *seg, - double x0, double x1) { + double x0, double x1) { ArtActiveSeg *hs; if (x0 == x1) @@ -1979,7 +1979,7 @@ static void art_svp_intersect_insert_line(ArtIntersectCtx *ctx, ArtActiveSeg *se } static void art_svp_intersect_process_intersection(ArtIntersectCtx *ctx, - ArtActiveSeg *seg) { + ArtActiveSeg *seg) { int n_stack = --seg->n_stack; seg->x[1] = seg->stack[n_stack - 1].x; seg->y1 = seg->stack[n_stack - 1].y; @@ -1990,7 +1990,7 @@ static void art_svp_intersect_process_intersection(ArtIntersectCtx *ctx, } static void art_svp_intersect_advance_cursor(ArtIntersectCtx *ctx, ArtActiveSeg *seg, - ArtPriPoint *pri_pt) { + ArtPriPoint *pri_pt) { const ArtSVPSeg *in_seg = seg->in_seg; int in_curs = seg->in_curs; ArtSvpWriter *swr = seg->flags & ART_ACTIVE_FLAGS_OUT ? ctx->out : NULL; @@ -2277,7 +2277,7 @@ struct ArtSVPRenderAAIter { }; static void art_svp_render_insert_active(int i, int *active_segs, int n_active_segs, - artfloat *seg_x, artfloat *seg_dx) { + artfloat *seg_x, artfloat *seg_dx) { int j; artfloat x; int tmp1, tmp2; @@ -2350,7 +2350,7 @@ static void art_svp_render_delete_active(int *active_segs, int j, int n_active_s */ ArtSVPRenderAAIter *art_svp_render_aa_iter(const ArtSVP *svp, - int x0, int y0, int x1, int y1) { + int x0, int y0, int x1, int y1) { ArtSVPRenderAAIter *iter = art_new(ArtSVPRenderAAIter, 1); if (!iter) error("[art_svp_render_aa_iter] Cannot allocate memory"); @@ -2398,7 +2398,7 @@ ArtSVPRenderAAIter *art_svp_render_aa_iter(const ArtSVP *svp, } void art_svp_render_aa_iter_step(ArtSVPRenderAAIter *iter, int *p_start, - ArtSVPRenderAAStep **p_steps, int *p_n_steps) { + ArtSVPRenderAAStep **p_steps, int *p_n_steps) { const ArtSVP *svp = iter->svp; int *active_segs = iter->active_segs; int n_active_segs = iter->n_active_segs; @@ -2624,12 +2624,12 @@ void art_svp_render_aa_iter_done(ArtSVPRenderAAIter *iter) { * **/ void art_svp_render_aa(const ArtSVP *svp, - int x0, int y0, int x1, int y1, - void (*callback)(void *callback_data, - int y, - int start, - ArtSVPRenderAAStep *steps, int n_steps), - void *callback_data) { + int x0, int y0, int x1, int y1, + void (*callback)(void *callback_data, + int y, + int start, + ArtSVPRenderAAStep *steps, int n_steps), + void *callback_data) { ArtSVPRenderAAIter *iter; int y; int start; diff --git a/engines/sword25/gfx/image/art.h b/engines/sword25/gfx/image/art.h index 820520012cd..b1af3b45972 100644 --- a/engines/sword25/gfx/image/art.h +++ b/engines/sword25/gfx/image/art.h @@ -122,7 +122,7 @@ struct ArtVpath { /* Some of the functions need to go into their own modules */ void art_vpath_add_point(ArtVpath **p_vpath, int *pn_points, int *pn_points_max, - ArtPathcode code, double x, double y); + ArtPathcode code, double x, double y); ArtVpath *art_bez_path_to_vec(const ArtBpath *bez, double flatness); @@ -173,19 +173,19 @@ enum ArtPathStrokeCapType { }; ArtSVP *art_svp_vpath_stroke(ArtVpath *vpath, - ArtPathStrokeJoinType join, - ArtPathStrokeCapType cap, - double line_width, - double miter_limit, - double flatness); + ArtPathStrokeJoinType join, + ArtPathStrokeCapType cap, + double line_width, + double miter_limit, + double flatness); /* This version may have winding numbers exceeding 1. */ ArtVpath *art_svp_vpath_stroke_raw(ArtVpath *vpath, - ArtPathStrokeJoinType join, - ArtPathStrokeCapType cap, - double line_width, - double miter_limit, - double flatness); + ArtPathStrokeJoinType join, + ArtPathStrokeCapType cap, + double line_width, + double miter_limit, + double flatness); /* The spiffy antialiased renderer for sorted vector paths. */ @@ -198,20 +198,20 @@ struct ArtSVPRenderAAStep { struct ArtSVPRenderAAIter; ArtSVPRenderAAIter *art_svp_render_aa_iter(const ArtSVP *svp, - int x0, int y0, int x1, int y1); + int x0, int y0, int x1, int y1); void art_svp_render_aa_iter_step(ArtSVPRenderAAIter *iter, int *p_start, - ArtSVPRenderAAStep **p_steps, int *p_n_steps); + ArtSVPRenderAAStep **p_steps, int *p_n_steps); void art_svp_render_aa_iter_done(ArtSVPRenderAAIter *iter); void art_svp_render_aa(const ArtSVP *svp, - int x0, int y0, int x1, int y1, - void (*callback)(void *callback_data, - int y, - int start, - ArtSVPRenderAAStep *steps, int n_steps), - void *callback_data); + int x0, int y0, int x1, int y1, + void (*callback)(void *callback_data, + int y, + int start, + ArtSVPRenderAAStep *steps, int n_steps), + void *callback_data); } // End of namespace Sword25 diff --git a/engines/sword25/gfx/image/image.h b/engines/sword25/gfx/image/image.h index f8cb0dfec0d..d3470576e1e 100644 --- a/engines/sword25/gfx/image/image.h +++ b/engines/sword25/gfx/image/image.h @@ -30,10 +30,10 @@ */ /* - BS_Image - -------- + BS_Image + -------- - Autor: Malte Thiesen + Autor: Malte Thiesen */ #ifndef SWORD25_IMAGE_H diff --git a/engines/sword25/gfx/image/swimage.cpp b/engines/sword25/gfx/image/swimage.cpp index 7a3c95b5f93..6edfc988f25 100644 --- a/engines/sword25/gfx/image/swimage.cpp +++ b/engines/sword25/gfx/image/swimage.cpp @@ -69,10 +69,10 @@ SWImage::~SWImage() { bool SWImage::blit(int posX, int posY, - int flipping, - Common::Rect *pPartRect, - uint color, - int width, int height, + int flipping, + Common::Rect *pPartRect, + uint color, + int width, int height, RectangleList *updateRects) { error("Blit() is not supported."); return false; diff --git a/engines/sword25/gfx/image/vectorimage.cpp b/engines/sword25/gfx/image/vectorimage.cpp index 5d35a4f47e4..ca4c875419f 100644 --- a/engines/sword25/gfx/image/vectorimage.cpp +++ b/engines/sword25/gfx/image/vectorimage.cpp @@ -611,10 +611,10 @@ bool VectorImage::setContent(const byte *pixeldata, uint size, uint offset, uint } bool VectorImage::blit(int posX, int posY, - int flipping, - Common::Rect *pPartRect, - uint color, - int width, int height, + int flipping, + Common::Rect *pPartRect, + uint color, + int width, int height, RectangleList *updateRects) { static VectorImage *oldThis = 0; static int oldWidth = -2; diff --git a/engines/sword25/gfx/image/vectorimage.h b/engines/sword25/gfx/image/vectorimage.h index bc10aedb7a0..0fea8e70253 100644 --- a/engines/sword25/gfx/image/vectorimage.h +++ b/engines/sword25/gfx/image/vectorimage.h @@ -47,10 +47,10 @@ namespace Sword25 { class VectorImage; /** - @brief Pfadinformationen zu BS_VectorImageElement Objekten + @brief Pfadinformationen zu BS_VectorImageElement Objekten - Jedes BS_VectorImageElement besteht aus Kantenzügen, oder auch Pfaden. Jeder dieser Pfad hat Eigenschaften, die in Objekten diesen Typs - gespeichert werden. + Jedes BS_VectorImageElement besteht aus Kantenzügen, oder auch Pfaden. Jeder dieser Pfad hat Eigenschaften, die in Objekten diesen Typs + gespeichert werden. */ class VectorPathInfo { @@ -88,8 +88,8 @@ private: }; /** - @brief Ein Element eines Vektorbild. Ein BS_VectorImage besteht aus diesen Elementen, die jeweils einen Teil der Graphik definieren. - Werden alle Elemente eines Vektorbildes übereinandergelegt, ergibt sich das komplette Bild. + @brief Ein Element eines Vektorbild. Ein BS_VectorImage besteht aus diesen Elementen, die jeweils einen Teil der Graphik definieren. + Werden alle Elemente eines Vektorbildes übereinandergelegt, ergibt sich das komplette Bild. */ class VectorImageElement { friend class VectorImage; @@ -148,9 +148,9 @@ private: /** - @brief Eine Vektorgraphik + @brief Eine Vektorgraphik - Objekte dieser Klasse enthalten die Informationen eines SWF-Shapes. + Objekte dieser Klasse enthalten die Informationen eines SWF-Shapes. */ class VectorImage : public Image { diff --git a/engines/sword25/gfx/image/vectorimagerenderer.cpp b/engines/sword25/gfx/image/vectorimagerenderer.cpp index be734c7b987..e7a1fefd69b 100644 --- a/engines/sword25/gfx/image/vectorimagerenderer.cpp +++ b/engines/sword25/gfx/image/vectorimagerenderer.cpp @@ -96,7 +96,7 @@ struct _ArtRgbSVPAlphaData { }; static void art_rgb_svp_alpha_callback1(void *callback_data, int y, - int start, ArtSVPRenderAAStep *steps, int n_steps) { + int start, ArtSVPRenderAAStep *steps, int n_steps) { ArtRgbSVPAlphaData *data = (ArtRgbSVPAlphaData *)callback_data; byte *linebuf; int run_x0, run_x1; @@ -150,8 +150,8 @@ static void art_rgb_svp_alpha_callback1(void *callback_data, int y, } static void art_rgb_svp_alpha_opaque_callback1(void *callback_data, int y, - int start, - ArtSVPRenderAAStep *steps, int n_steps) { + int start, + ArtSVPRenderAAStep *steps, int n_steps) { ArtRgbSVPAlphaData *data = (ArtRgbSVPAlphaData *)callback_data; byte *linebuf; int run_x0, run_x1; @@ -221,9 +221,9 @@ static void art_rgb_svp_alpha_opaque_callback1(void *callback_data, int y, } void art_rgb_svp_alpha1(const ArtSVP *svp, - int x0, int y0, int x1, int y1, - uint32 color, - byte *buf, int rowstride) { + int x0, int y0, int x1, int y1, + uint32 color, + byte *buf, int rowstride) { ArtRgbSVPAlphaData data; byte r, g, b, alpha; int i; diff --git a/engines/sword25/gfx/renderobject.h b/engines/sword25/gfx/renderobject.h index 6391217d89a..7293432d609 100644 --- a/engines/sword25/gfx/renderobject.h +++ b/engines/sword25/gfx/renderobject.h @@ -30,13 +30,13 @@ */ /* - BS_RenderObject - --------------- - Dieses ist die Klasse die sämtliche sichtbaren Objekte beschreibt. Alle anderen sichtbaren Objekte müssen von ihr abgeleitet werden. - Diese Klasse erledigt Aufgaben wie: minimales Neuzeichnen, Renderreihenfolge, Objekthierachie. - Alle BS_RenderObject Instanzen werden von einem BS_RenderObjectManager in einem Baum verwaltet. + BS_RenderObject + --------------- + Dieses ist die Klasse die sämtliche sichtbaren Objekte beschreibt. Alle anderen sichtbaren Objekte müssen von ihr abgeleitet werden. + Diese Klasse erledigt Aufgaben wie: minimales Neuzeichnen, Renderreihenfolge, Objekthierachie. + Alle BS_RenderObject Instanzen werden von einem BS_RenderObjectManager in einem Baum verwaltet. - Autor: Malte Thiesen + Autor: Malte Thiesen */ #ifndef SWORD25_RENDEROBJECT_H @@ -63,11 +63,11 @@ class Text; // Klassendefinition /** - @brief Dieses ist die Klasse die sämtliche sichtbaren Objekte beschreibt. + @brief Dieses ist die Klasse die sämtliche sichtbaren Objekte beschreibt. - Alle anderen sichtbaren Objekte müssen von ihr abgeleitet werden. - Diese Klasse erledigt Aufgaben wie: minimales Neuzeichnen, Renderreihenfolge, Objekthierachie. - Alle BS_RenderObject Instanzen werden von einem BS_RenderObjektManager in einem Baum verwaltet. + Alle anderen sichtbaren Objekte müssen von ihr abgeleitet werden. + Diese Klasse erledigt Aufgaben wie: minimales Neuzeichnen, Renderreihenfolge, Objekthierachie. + Alle BS_RenderObject Instanzen werden von einem BS_RenderObjektManager in einem Baum verwaltet. */ class RenderObject { public: diff --git a/engines/sword25/gfx/renderobjectmanager.h b/engines/sword25/gfx/renderobjectmanager.h index 10e8eaf248d..ccdb114c366 100644 --- a/engines/sword25/gfx/renderobjectmanager.h +++ b/engines/sword25/gfx/renderobjectmanager.h @@ -30,13 +30,13 @@ */ /* - BS_RenderObjectManager - ---------------------- - Diese Klasse ist für die Verwaltung von BS_RenderObjects zuständig. + BS_RenderObjectManager + ---------------------- + Diese Klasse ist für die Verwaltung von BS_RenderObjects zuständig. - Sie sorgt z.B. dafür, dass die BS_RenderObjects in der richtigen Reihenfolge gerendert werden. + Sie sorgt z.B. dafür, dass die BS_RenderObjects in der richtigen Reihenfolge gerendert werden. - Autor: Malte Thiesen + Autor: Malte Thiesen */ #ifndef SWORD25_RENDEROBJECTMANAGER_H @@ -71,10 +71,10 @@ public: }; /** - @brief Diese Klasse ist für die Verwaltung von BS_RenderObjects zuständig. + @brief Diese Klasse ist für die Verwaltung von BS_RenderObjects zuständig. - Sie sorgt dafür, dass die BS_RenderObjects in der richtigen Reihenfolge gerendert werden und ermöglicht den Zugriff auf die - BS_RenderObjects über einen String. + Sie sorgt dafür, dass die BS_RenderObjects in der richtigen Reihenfolge gerendert werden und ermöglicht den Zugriff auf die + BS_RenderObjects über einen String. */ class RenderObjectManager : public Persistable { public: diff --git a/engines/sword25/gfx/timedrenderobject.h b/engines/sword25/gfx/timedrenderobject.h index 60fdd2f762b..89180b1bc5a 100644 --- a/engines/sword25/gfx/timedrenderobject.h +++ b/engines/sword25/gfx/timedrenderobject.h @@ -35,7 +35,7 @@ namespace Sword25 { /** - @brief + @brief */ class TimedRenderObject : public RenderObject { diff --git a/engines/sword25/math/line.h b/engines/sword25/math/line.h index 9e2a50fac38..90e20d90a57 100644 --- a/engines/sword25/math/line.h +++ b/engines/sword25/math/line.h @@ -30,15 +30,15 @@ */ /* - BS_Line - ------- - This class contains only static methods, which have to do with straight line - segments. There is no real straight line segment class. Calculations will be - used with polygons, and it is important the process of starting and selecting - endpoints of lines is dynamic. This would prhobit a polygon from a set - being formed by fixed line segments + BS_Line + ------- + This class contains only static methods, which have to do with straight line + segments. There is no real straight line segment class. Calculations will be + used with polygons, and it is important the process of starting and selecting + endpoints of lines is dynamic. This would prhobit a polygon from a set + being formed by fixed line segments - Autor: Malte Thiesen + Autor: Malte Thiesen */ #ifndef SWORD25_LINE_H diff --git a/engines/sword25/math/polygon.h b/engines/sword25/math/polygon.h index a9c52de9dc3..1ffaedf6f47 100644 --- a/engines/sword25/math/polygon.h +++ b/engines/sword25/math/polygon.h @@ -42,7 +42,7 @@ namespace Sword25 { class Vertex; /** - @brief Eine Polygonklasse. + @brief Eine Polygonklasse. */ class Polygon : public Persistable { public: diff --git a/engines/sword25/math/vertex.h b/engines/sword25/math/vertex.h index 537742b4581..80bd9ee8940 100644 --- a/engines/sword25/math/vertex.h +++ b/engines/sword25/math/vertex.h @@ -30,10 +30,10 @@ */ /* - BS_Vertex - --------- + BS_Vertex + --------- - Autor: Malte Thiesen + Autor: Malte Thiesen */ #ifndef SWORD25_VERTEX_H diff --git a/engines/sword25/math/walkregion.cpp b/engines/sword25/math/walkregion.cpp index 4c53a625c1b..7f0d2a1211c 100644 --- a/engines/sword25/math/walkregion.cpp +++ b/engines/sword25/math/walkregion.cpp @@ -97,7 +97,7 @@ struct DijkstraNode { }; static void initDijkstraNodes(DijkstraNode::Container &dijkstraNodes, const Region ®ion, - const Vertex &start, const Common::Array &nodes) { + const Vertex &start, const Common::Array &nodes) { // Allocate sufficient space in the array dijkstraNodes.resize(nodes.size()); @@ -126,8 +126,8 @@ static DijkstraNode::Iter chooseClosestNode(DijkstraNode::Container &nodes) { } static void relaxNodes(DijkstraNode::Container &nodes, - const Common::Array< Common::Array > &visibilityMatrix, - const DijkstraNode::ConstIter &curNodeIter) { + const Common::Array< Common::Array > &visibilityMatrix, + const DijkstraNode::ConstIter &curNodeIter) { // All the successors of the current node that have not been chosen will be // inserted into the boundary node list, and the cost will be updated if // a shorter path has been found to them. @@ -146,10 +146,10 @@ static void relaxNodes(DijkstraNode::Container &nodes, } static void relaxEndPoint(const Vertex &curNodePos, - const DijkstraNode::ConstIter &curNodeIter, - const Vertex &endPointPos, - DijkstraNode &endPoint, - const Region ®ion) { + const DijkstraNode::ConstIter &curNodeIter, + const Vertex &endPointPos, + DijkstraNode &endPoint, + const Region ®ion) { if (region.isLineOfSight(curNodePos, endPointPos)) { int totalCost = (*curNodeIter).cost + curNodePos.distance(endPointPos); if (totalCost < endPoint.cost) { diff --git a/engines/sword25/metaengine.cpp b/engines/sword25/metaengine.cpp index 7641240e0bb..52aff22df18 100644 --- a/engines/sword25/metaengine.cpp +++ b/engines/sword25/metaengine.cpp @@ -33,14 +33,14 @@ uint32 Sword25Engine::getGameFlags() const { return _gameDescription->flags; } class Sword25MetaEngine : public AdvancedMetaEngine { public: - const char *getName() const override { + const char *getName() const override { return "sword25"; } Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; bool hasFeature(MetaEngineFeature f) const override; - int getMaximumSaveSlot() const override { return Sword25::PersistenceService::getSlotCount(); } + int getMaximumSaveSlot() const override { return Sword25::PersistenceService::getSlotCount(); } SaveStateList listSaves(const char *target) const override; }; diff --git a/engines/teenagent/metaengine.cpp b/engines/teenagent/metaengine.cpp index 692e6277b1d..848b8ce9f15 100644 --- a/engines/teenagent/metaengine.cpp +++ b/engines/teenagent/metaengine.cpp @@ -37,11 +37,11 @@ enum { class TeenAgentMetaEngine : public AdvancedMetaEngine { public: - const char *getName() const override { + const char *getName() const override { return "teenagent"; } - bool hasFeature(MetaEngineFeature f) const override { + bool hasFeature(MetaEngineFeature f) const override { switch (f) { case kSupportsListSaves: case kSupportsDeleteSave: diff --git a/engines/testbed/metaengine.cpp b/engines/testbed/metaengine.cpp index ea774f5f911..c5747a3568c 100644 --- a/engines/testbed/metaengine.cpp +++ b/engines/testbed/metaengine.cpp @@ -31,7 +31,7 @@ class TestbedMetaEngine : public AdvancedMetaEngine { public: - const char *getName() const override { + const char *getName() const override { return "testbed"; } diff --git a/engines/tinsel/cursor.h b/engines/tinsel/cursor.h index 750058dfc51..465a7c16ead 100644 --- a/engines/tinsel/cursor.h +++ b/engines/tinsel/cursor.h @@ -110,9 +110,9 @@ private: int _numTrails; int _nextTrail; - // Auxillary cursor image's animation offsets + // Auxillary cursor image's animation offsets short _auxCursorOffsetX; - short _auxCursorOffsetY; + short _auxCursorOffsetY; struct { ANIM trailAnim; // Animation structure diff --git a/engines/tinsel/dialogs.cpp b/engines/tinsel/dialogs.cpp index adff91d2018..25645da8d93 100644 --- a/engines/tinsel/dialogs.cpp +++ b/engines/tinsel/dialogs.cpp @@ -261,22 +261,22 @@ enum PARTS_INDEX { #define CURSOR_CHAR '_' char sCursor[2] = {CURSOR_CHAR, 0}; static const int hFillers[MAXHICONS] = { - IX_H26, // 2 icons wide - IX_H52, // 3 - IX_H78, // 4 - IX_H104, // 5 - IX_H130, // 6 - IX_H156, // 7 - IX_H182, // 8 - IX_H208, // 9 - IX_H234 // 10 icons wide + IX_H26, // 2 icons wide + IX_H52, // 3 + IX_H78, // 4 + IX_H104, // 5 + IX_H130, // 6 + IX_H156, // 7 + IX_H182, // 8 + IX_H208, // 9 + IX_H234 // 10 icons wide }; static const int vFillers[MAXVICONS] = { - IX_V26, // 2 icons high - IX_V52, // 3 - IX_V78, // 4 - IX_V104, // 5 - IX_V130 // 6 icons high + IX_V26, // 2 icons high + IX_V52, // 3 + IX_V78, // 4 + IX_V104, // 5 + IX_V130 // 6 icons high }; //----- Data pertinant to configure (incl. load/save game) ----- @@ -362,19 +362,19 @@ struct CONFINIT { static CONFBOX t1OptionBox[] = { - {AATBUT, OPENLOAD, TM_NONE, NULL, SIX_LOAD_OPTION, FBX, FBY, EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0}, - {AATBUT, OPENSAVE, TM_NONE, NULL, SIX_SAVE_OPTION, FBX, FBY + (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0}, - {AATBUT, OPENREST, TM_NONE, NULL, SIX_RESTART_OPTION, FBX, FBY + 2 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0}, - {AATBUT, OPENSOUND, TM_NONE, NULL, SIX_SOUND_OPTION, FBX, FBY + 3 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0}, - {AATBUT, OPENCONT, TM_NONE, NULL, SIX_CONTROL_OPTION, FBX, FBY + 4 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0}, + {AATBUT, OPENLOAD, TM_NONE, NULL, SIX_LOAD_OPTION, FBX, FBY, EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0}, + {AATBUT, OPENSAVE, TM_NONE, NULL, SIX_SAVE_OPTION, FBX, FBY + (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0}, + {AATBUT, OPENREST, TM_NONE, NULL, SIX_RESTART_OPTION, FBX, FBY + 2 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0}, + {AATBUT, OPENSOUND, TM_NONE, NULL, SIX_SOUND_OPTION, FBX, FBY + 3 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0}, + {AATBUT, OPENCONT, TM_NONE, NULL, SIX_CONTROL_OPTION, FBX, FBY + 4 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0}, #ifdef JAPAN - // TODO: If in JAPAN mode, simply disable the subtitles button? - {AATBUT, OPENQUIT, NULL, SIX_QUIT_OPTION, FBX, FBY + 5 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0}, - {AATBUT, CLOSEWIN, NULL, SIX_RESUME_OPTION, FBX, FBY + 6 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0} + // TODO: If in JAPAN mode, simply disable the subtitles button? + {AATBUT, OPENQUIT, NULL, SIX_QUIT_OPTION, FBX, FBY + 5 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0}, + {AATBUT, CLOSEWIN, NULL, SIX_RESUME_OPTION, FBX, FBY + 6 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0} #else - {AATBUT, OPENSUBT, TM_NONE, NULL, SIX_SUBTITLES_OPTION, FBX, FBY + 5 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0}, - {AATBUT, OPENQUIT, TM_NONE, NULL, SIX_QUIT_OPTION, FBX, FBY + 6 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0}, - {AATBUT, CLOSEWIN, TM_NONE, NULL, SIX_RESUME_OPTION, FBX, FBY + 7 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0} + {AATBUT, OPENSUBT, TM_NONE, NULL, SIX_SUBTITLES_OPTION, FBX, FBY + 5 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0}, + {AATBUT, OPENQUIT, TM_NONE, NULL, SIX_QUIT_OPTION, FBX, FBY + 6 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0}, + {AATBUT, CLOSEWIN, TM_NONE, NULL, SIX_RESUME_OPTION, FBX, FBY + 7 * (BOX_HEIGHT + 2), EDIT_BOX1_WIDTH, BOX_HEIGHT, NULL, 0} #endif }; @@ -383,11 +383,11 @@ static CONFINIT t1ciOption = {6, 5, 72, 23, false, t1OptionBox, ARRAYSIZE(t1Opti static CONFBOX t2OptionBox[] = { - {AATBUT, OPENLOAD, TM_INDEX, NULL, SS_LOAD_OPTION, T2_OPTX, T2_OPTY, T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {AATBUT, OPENSAVE, TM_INDEX, NULL, SS_SAVE_OPTION, T2_OPTX, T2_OPTY + (T2_BOX_HEIGHT + T2_BOX_V_SEP), T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {AATBUT, OPENREST, TM_INDEX, NULL, SS_RESTART_OPTION, T2_OPTX, T2_OPTY + 2 * (T2_BOX_HEIGHT + T2_BOX_V_SEP), T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {AATBUT, OPENSOUND, TM_INDEX, NULL, SS_SOUND_OPTION, T2_OPTX, T2_OPTY + 3 * (T2_BOX_HEIGHT + T2_BOX_V_SEP), T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {AATBUT, OPENQUIT, TM_INDEX, NULL, SS_QUIT_OPTION, T2_OPTX, T2_OPTY + 4 * (T2_BOX_HEIGHT + T2_BOX_V_SEP), T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0} + {AATBUT, OPENLOAD, TM_INDEX, NULL, SS_LOAD_OPTION, T2_OPTX, T2_OPTY, T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {AATBUT, OPENSAVE, TM_INDEX, NULL, SS_SAVE_OPTION, T2_OPTX, T2_OPTY + (T2_BOX_HEIGHT + T2_BOX_V_SEP), T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {AATBUT, OPENREST, TM_INDEX, NULL, SS_RESTART_OPTION, T2_OPTX, T2_OPTY + 2 * (T2_BOX_HEIGHT + T2_BOX_V_SEP), T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {AATBUT, OPENSOUND, TM_INDEX, NULL, SS_SOUND_OPTION, T2_OPTX, T2_OPTY + 3 * (T2_BOX_HEIGHT + T2_BOX_V_SEP), T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {AATBUT, OPENQUIT, TM_INDEX, NULL, SS_QUIT_OPTION, T2_OPTX, T2_OPTY + 4 * (T2_BOX_HEIGHT + T2_BOX_V_SEP), T2_EDIT_BOX1_WIDTH, T2_BOX_HEIGHT, NULL, 0} }; @@ -411,65 +411,65 @@ static CONFINIT t2ciOption = {6, 4, 144, 60, false, t2OptionBox, sizeof(t2Option #endif static CONFBOX t1LoadBox[NUM_RGROUP_BOXES + 2] = { - {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY, EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, - {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, - {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 2 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, - {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 3 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, - {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 4 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, - {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 5 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, - {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 6 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, + {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY, EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, + {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, + {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 2 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, + {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 3 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, + {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 4 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, + {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 5 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, + {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 6 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, #ifndef JAPAN - {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 7 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, - {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 8 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, + {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 7 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, + {RGROUP, LOADGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 8 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, #endif - {ARSGBUT, LOADGAME, TM_NONE, NULL, USE_POINTER, 230, 44, 23, 19, NULL, IX1_TICK1}, - {AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 230, 44 + 47, 23, 19, NULL, IX1_CROSS1}}; + {ARSGBUT, LOADGAME, TM_NONE, NULL, USE_POINTER, 230, 44, 23, 19, NULL, IX1_TICK1}, + {AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 230, 44 + 47, 23, 19, NULL, IX1_CROSS1}}; static CONFBOX t2LoadBox[] = { - {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY, T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 2 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 3 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 4 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 5 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 6 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 7 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 8 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY, T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 2 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 3 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 4 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 5 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 6 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 7 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, LOADGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 8 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {ARSGBUT, LOADGAME, TM_NONE, NULL, 0, 460, 100, BW, BH, NULL, IX2_TICK1}, - {AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 100 + 100, BW, BH, NULL, IX2_CROSS1}}; + {ARSGBUT, LOADGAME, TM_NONE, NULL, 0, 460, 100, BW, BH, NULL, IX2_TICK1}, + {AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 100 + 100, BW, BH, NULL, IX2_CROSS1}}; static CONFINIT t1ciLoad = {10, 6, 20, 16, true, t1LoadBox, ARRAYSIZE(t1LoadBox), SIX_LOAD_HEADING}; static CONFINIT t2ciLoad = {10, 6, 40, 16, true, t2LoadBox, sizeof(t2LoadBox) / sizeof(CONFBOX), SS_LOAD_HEADING}; static CONFBOX t1SaveBox[NUM_RGROUP_BOXES + 2] = { - {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY, EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, - {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, - {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 2 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, - {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 3 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, - {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 4 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, - {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 5 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, - {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 6 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, + {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY, EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, + {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, + {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 2 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, + {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 3 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, + {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 4 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, + {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 5 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, + {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 6 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, #ifndef JAPAN - {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 7 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, - {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 8 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, + {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 7 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, + {RGROUP, SAVEGAME, TM_NONE, NULL, USE_POINTER, 28, SY + 8 * (BOX_HEIGHT + 2), EDIT_BOX2_WIDTH, BOX_HEIGHT, NULL, 0}, #endif - {ARSGBUT, SAVEGAME, TM_NONE, NULL, USE_POINTER, 230, 44, 23, 19, NULL, IX1_TICK1}, - {AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 230, 44 + 47, 23, 19, NULL, IX1_CROSS1}}; + {ARSGBUT, SAVEGAME, TM_NONE, NULL, USE_POINTER, 230, 44, 23, 19, NULL, IX1_TICK1}, + {AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 230, 44 + 47, 23, 19, NULL, IX1_CROSS1}}; static CONFBOX t2SaveBox[] = { - {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY, T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 2 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 3 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 4 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 5 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 6 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 7 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 8 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY, T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 2 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 3 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 4 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 5 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 6 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 7 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, SAVEGAME, TM_POINTER, NULL, 0, BOXX, BOXY + 8 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {ARSGBUT, SAVEGAME, TM_NONE, NULL, 0, 460, 100, BW, BH, NULL, IX2_TICK1}, - {AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 100 + 100, BW, BH, NULL, IX2_CROSS1}}; + {ARSGBUT, SAVEGAME, TM_NONE, NULL, 0, 460, 100, BW, BH, NULL, IX2_TICK1}, + {AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 100 + 100, BW, BH, NULL, IX2_CROSS1}}; static CONFINIT t1ciSave = {10, 6, 20, 16, true, t1SaveBox, ARRAYSIZE(t1SaveBox), SIX_SAVE_HEADING}; static CONFINIT t2ciSave = {10, 6, 40, 16, true, t2SaveBox, sizeof(t2SaveBox) / sizeof(CONFBOX), SS_SAVE_HEADING}; @@ -485,21 +485,21 @@ static CONFINIT t2ciSave = {10, 6, 40, 16, true, t2SaveBox, sizeof(t2SaveBox) / static CONFBOX t1RestartBox[] = { #ifdef JAPAN - {AAGBUT, INITGAME, TM_NONE, NULL, USE_POINTER, 96, 44, 23, 19, NULL, IX_TICK1}, - {AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 56, 44, 23, 19, NULL, IX_CROSS1} + {AAGBUT, INITGAME, TM_NONE, NULL, USE_POINTER, 96, 44, 23, 19, NULL, IX_TICK1}, + {AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 56, 44, 23, 19, NULL, IX_CROSS1} #else - {AAGBUT, INITGAME, TM_NONE, NULL, USE_POINTER, 70, 28, 23, 19, NULL, IX1_TICK1}, - {AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 30, 28, 23, 19, NULL, IX1_CROSS1} + {AAGBUT, INITGAME, TM_NONE, NULL, USE_POINTER, 70, 28, 23, 19, NULL, IX1_TICK1}, + {AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 30, 28, 23, 19, NULL, IX1_CROSS1} #endif }; static CONFBOX t1RestartBoxPSX[] = { - {AAGBUT, INITGAME, TM_NONE, NULL, USE_POINTER, 122, 48, 23, 19, NULL, IX1_TICK1}, - {AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 82, 48, 23, 19, NULL, IX1_CROSS1}}; + {AAGBUT, INITGAME, TM_NONE, NULL, USE_POINTER, 122, 48, 23, 19, NULL, IX1_TICK1}, + {AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 82, 48, 23, 19, NULL, IX1_CROSS1}}; static CONFBOX t2RestartBox[] = { - {AAGBUT, INITGAME, TM_NONE, NULL, 0, 140, 78, BW, BH, NULL, IX2_TICK1}, - {AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 60, 78, BW, BH, NULL, IX2_CROSS1}}; + {AAGBUT, INITGAME, TM_NONE, NULL, 0, 140, 78, BW, BH, NULL, IX2_TICK1}, + {AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 60, 78, BW, BH, NULL, IX2_CROSS1}}; #ifdef JAPAN static CONFINIT t1ciRestart = {6, 2, 72, 53, false, t1RestartBox, ARRAYSIZE(t1RestartBox), SIX_RESTART_HEADING}; @@ -517,18 +517,18 @@ static CONFINIT t2ciRestart = {4, 2, 196, 53, false, t2RestartBox, sizeof(t2Rest \*-------------------------------------------------------------*/ static CONFBOX t1SoundBox[] = { - {SLIDER, MUSICVOL, TM_NONE, NULL, SIX_MVOL_SLIDER, 142, 25, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_musicVolume*/, 0}, - {SLIDER, NOFUNC, TM_NONE, NULL, SIX_SVOL_SLIDER, 142, 25 + 40, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_soundVolume*/, 0}, - {SLIDER, NOFUNC, TM_NONE, NULL, SIX_VVOL_SLIDER, 142, 25 + 2 * 40, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_voiceVolume*/, 0}}; + {SLIDER, MUSICVOL, TM_NONE, NULL, SIX_MVOL_SLIDER, 142, 25, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_musicVolume*/, 0}, + {SLIDER, NOFUNC, TM_NONE, NULL, SIX_SVOL_SLIDER, 142, 25 + 40, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_soundVolume*/, 0}, + {SLIDER, NOFUNC, TM_NONE, NULL, SIX_VVOL_SLIDER, 142, 25 + 2 * 40, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_voiceVolume*/, 0}}; static CONFBOX t2SoundBox[] = { - {SLIDER, MUSICVOL, TM_INDEX, NULL, SS_MVOL_SLIDER, 280, 50, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_musicVolume*/, 0}, - {SLIDER, NOFUNC, TM_INDEX, NULL, SS_SVOL_SLIDER, 280, 50 + 30, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_soundVolume*/, 0}, - {SLIDER, NOFUNC, TM_INDEX, NULL, SS_VVOL_SLIDER, 280, 50 + 2 * 30, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_voiceVolume*/, 0}, + {SLIDER, MUSICVOL, TM_INDEX, NULL, SS_MVOL_SLIDER, 280, 50, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_musicVolume*/, 0}, + {SLIDER, NOFUNC, TM_INDEX, NULL, SS_SVOL_SLIDER, 280, 50 + 30, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_soundVolume*/, 0}, + {SLIDER, NOFUNC, TM_INDEX, NULL, SS_VVOL_SLIDER, 280, 50 + 2 * 30, Audio::Mixer::kMaxChannelVolume, 2, 0 /*&_vm->_config->_voiceVolume*/, 0}, - {SLIDER, NOFUNC, TM_INDEX, NULL, SS_TSPEED_SLIDER, 280, 160, 100, 2, 0 /*&_vm->_config->_textSpeed*/, 0}, - {TOGGLE2, NOFUNC, TM_INDEX, NULL, SS_STITLE_TOGGLE, 100, 220, BW, BH, 0 /*&_vm->_config->_useSubtitles*/, 0}, - {ROTATE, NOFUNC, TM_INDEX, NULL, SS_LANGUAGE_SELECT, 320, 220, BW, BH, NULL, 0}}; + {SLIDER, NOFUNC, TM_INDEX, NULL, SS_TSPEED_SLIDER, 280, 160, 100, 2, 0 /*&_vm->_config->_textSpeed*/, 0}, + {TOGGLE2, NOFUNC, TM_INDEX, NULL, SS_STITLE_TOGGLE, 100, 220, BW, BH, 0 /*&_vm->_config->_useSubtitles*/, 0}, + {ROTATE, NOFUNC, TM_INDEX, NULL, SS_LANGUAGE_SELECT, 320, 220, BW, BH, NULL, 0}}; static CONFINIT t1ciSound = {10, 5, 20, 16, false, t1SoundBox, ARRAYSIZE(t1SoundBox), NO_HEADING}; static CONFINIT t2ciSound = {10, 5, 40, 16, false, t2SoundBox, sizeof(t2SoundBox) / sizeof(CONFBOX), SS_SOUND_HEADING}; @@ -542,12 +542,12 @@ static CONFINIT t2ciSound = {10, 5, 40, 16, false, t2SoundBox, sizeof(t2SoundBox static int bFlipped = 0; // looks like this is just so the code has something to alter! static CONFBOX controlBox[] = { - {SLIDER, NOFUNC, TM_NONE, NULL, SIX_DCLICK_SLIDER, 142, 25, 3 * DOUBLE_CLICK_TIME, 1, 0 /*&_vm->_config->_dclickSpeed*/, 0}, - {FLIP, NOFUNC, TM_NONE, NULL, SIX_DCLICK_TEST, 142, 25 + 30, 23, 19, &bFlipped, IX1_CIRCLE1}, + {SLIDER, NOFUNC, TM_NONE, NULL, SIX_DCLICK_SLIDER, 142, 25, 3 * DOUBLE_CLICK_TIME, 1, 0 /*&_vm->_config->_dclickSpeed*/, 0}, + {FLIP, NOFUNC, TM_NONE, NULL, SIX_DCLICK_TEST, 142, 25 + 30, 23, 19, &bFlipped, IX1_CIRCLE1}, #ifdef JAPAN - {TOGGLE, NOFUNC, TM_NONE, NULL, SIX_SWAP_TOGGLE, 205, 25 + 70, 23, 19, 0 /*&_vm->_config->_swapButtons*/, 0} + {TOGGLE, NOFUNC, TM_NONE, NULL, SIX_SWAP_TOGGLE, 205, 25 + 70, 23, 19, 0 /*&_vm->_config->_swapButtons*/, 0} #else - {TOGGLE, NOFUNC, TM_NONE, NULL, SIX_SWAP_TOGGLE, 155, 25 + 70, 23, 19, 0 /*&_vm->_config->_swapButtons*/, 0} + {TOGGLE, NOFUNC, TM_NONE, NULL, SIX_SWAP_TOGGLE, 155, 25 + 70, 23, 19, 0 /*&_vm->_config->_swapButtons*/, 0} #endif }; @@ -558,45 +558,45 @@ static CONFINIT ciControl = {10, 5, 20, 16, false, controlBox, ARRAYSIZE(control \*-------------------------------------------------------------*/ static CONFBOX subtitlesBox[] = { - {SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, 0 /*&_vm->_config->_textSpeed*/, 0}, - {TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20 + 40, 23, 19, 0 /*&_vm->_config->_useSubtitles*/, 0}, + {SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, 0 /*&_vm->_config->_textSpeed*/, 0}, + {TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20 + 40, 23, 19, 0 /*&_vm->_config->_useSubtitles*/, 0}, }; static CONFBOX subtitlesBox3Flags[] = { - {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 15, 118, 56, 32, NULL, FIX_FR}, - {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 85, 118, 56, 32, NULL, FIX_GR}, - {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 155, 118, 56, 32, NULL, FIX_SP}, + {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 15, 118, 56, 32, NULL, FIX_FR}, + {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 85, 118, 56, 32, NULL, FIX_GR}, + {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 155, 118, 56, 32, NULL, FIX_SP}, - {SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, 0 /*&_vm->_config->_textSpeed*/, 0}, - {TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20 + 40, 23, 19, 0 /*&_vm->_config->_useSubtitles*/, 0}, + {SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, 0 /*&_vm->_config->_textSpeed*/, 0}, + {TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20 + 40, 23, 19, 0 /*&_vm->_config->_useSubtitles*/, 0}, - {ARSGBUT, CLANG, TM_NONE, NULL, USE_POINTER, 230, 110, 23, 19, NULL, IX1_TICK1}, - {AAGBUT, RLANG, TM_NONE, NULL, USE_POINTER, 230, 140, 23, 19, NULL, IX1_CROSS1}}; + {ARSGBUT, CLANG, TM_NONE, NULL, USE_POINTER, 230, 110, 23, 19, NULL, IX1_TICK1}, + {AAGBUT, RLANG, TM_NONE, NULL, USE_POINTER, 230, 140, 23, 19, NULL, IX1_CROSS1}}; static CONFBOX subtitlesBox4Flags[] = { - {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 20, 100, 56, 32, NULL, FIX_FR}, - {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 108, 100, 56, 32, NULL, FIX_GR}, - {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 64, 137, 56, 32, NULL, FIX_IT}, - {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 152, 137, 56, 32, NULL, FIX_SP}, + {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 20, 100, 56, 32, NULL, FIX_FR}, + {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 108, 100, 56, 32, NULL, FIX_GR}, + {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 64, 137, 56, 32, NULL, FIX_IT}, + {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 152, 137, 56, 32, NULL, FIX_SP}, - {SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, 0 /*&_vm->_config->_textSpeed*/, 0}, - {TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20 + 40, 23, 19, 0 /*&_vm->_config->_useSubtitles*/, 0}, + {SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, 0 /*&_vm->_config->_textSpeed*/, 0}, + {TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20 + 40, 23, 19, 0 /*&_vm->_config->_useSubtitles*/, 0}, - {ARSGBUT, CLANG, TM_NONE, NULL, USE_POINTER, 230, 110, 23, 19, NULL, IX1_TICK1}, - {AAGBUT, RLANG, TM_NONE, NULL, USE_POINTER, 230, 140, 23, 19, NULL, IX1_CROSS1}}; + {ARSGBUT, CLANG, TM_NONE, NULL, USE_POINTER, 230, 110, 23, 19, NULL, IX1_TICK1}, + {AAGBUT, RLANG, TM_NONE, NULL, USE_POINTER, 230, 140, 23, 19, NULL, IX1_CROSS1}}; static CONFBOX subtitlesBox5Flags[] = { - {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 15, 100, 56, 32, NULL, FIX_UK}, - {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 85, 100, 56, 32, NULL, FIX_FR}, - {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 155, 100, 56, 32, NULL, FIX_GR}, - {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 50, 137, 56, 32, NULL, FIX_IT}, - {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 120, 137, 56, 32, NULL, FIX_SP}, + {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 15, 100, 56, 32, NULL, FIX_UK}, + {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 85, 100, 56, 32, NULL, FIX_FR}, + {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 155, 100, 56, 32, NULL, FIX_GR}, + {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 50, 137, 56, 32, NULL, FIX_IT}, + {FRGROUP, NOFUNC, TM_NONE, NULL, USE_POINTER, 120, 137, 56, 32, NULL, FIX_SP}, - {SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, 0 /*&_vm->_config->_textSpeed*/, 0}, - {TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20 + 40, 23, 19, 0 /*&_vm->_config->_useSubtitles*/, 0}, + {SLIDER, NOFUNC, TM_NONE, NULL, SIX_TSPEED_SLIDER, 142, 20, 100, 2, 0 /*&_vm->_config->_textSpeed*/, 0}, + {TOGGLE, NOFUNC, TM_NONE, NULL, SIX_STITLE_TOGGLE, 142, 20 + 40, 23, 19, 0 /*&_vm->_config->_useSubtitles*/, 0}, - {ARSGBUT, CLANG, TM_NONE, NULL, USE_POINTER, 230, 110, 23, 19, NULL, IX1_TICK1}, - {AAGBUT, RLANG, TM_NONE, NULL, USE_POINTER, 230, 140, 23, 19, NULL, IX1_CROSS1}}; + {ARSGBUT, CLANG, TM_NONE, NULL, USE_POINTER, 230, 110, 23, 19, NULL, IX1_TICK1}, + {AAGBUT, RLANG, TM_NONE, NULL, USE_POINTER, 230, 140, 23, 19, NULL, IX1_CROSS1}}; /*-------------------------------------------------------------*\ | This is the quit confirmation 'menu'. | @@ -604,17 +604,17 @@ static CONFBOX subtitlesBox5Flags[] = { static CONFBOX t1QuitBox[] = { #ifdef JAPAN - {AAGBUT, IQUITGAME, TM_NONE, NULL, USE_POINTER, 70, 44, 23, 19, NULL, IX_TICK1}, - {AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 30, 44, 23, 19, NULL, IX_CROSS1} + {AAGBUT, IQUITGAME, TM_NONE, NULL, USE_POINTER, 70, 44, 23, 19, NULL, IX_TICK1}, + {AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 30, 44, 23, 19, NULL, IX_CROSS1} #else - {AAGBUT, IQUITGAME, TM_NONE, NULL, USE_POINTER, 70, 28, 23, 19, NULL, IX1_TICK1}, - {AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 30, 28, 23, 19, NULL, IX1_CROSS1} + {AAGBUT, IQUITGAME, TM_NONE, NULL, USE_POINTER, 70, 28, 23, 19, NULL, IX1_TICK1}, + {AAGBUT, CLOSEWIN, TM_NONE, NULL, USE_POINTER, 30, 28, 23, 19, NULL, IX1_CROSS1} #endif }; static CONFBOX t2QuitBox[] = { - {AAGBUT, IQUITGAME, TM_NONE, NULL, 0, 140, 78, BW, BH, NULL, IX2_TICK1}, - {AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 60, 78, BW, BH, NULL, IX2_CROSS1}}; + {AAGBUT, IQUITGAME, TM_NONE, NULL, 0, 140, 78, BW, BH, NULL, IX2_TICK1}, + {AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 60, 78, BW, BH, NULL, IX2_CROSS1}}; static CONFINIT t1ciQuit = {4, 2, 98, 53, false, t1QuitBox, ARRAYSIZE(t1QuitBox), SIX_QUIT_HEADING}; static CONFINIT t2ciQuit = {4, 2, 196, 53, false, t2QuitBox, sizeof(t2QuitBox) / sizeof(CONFBOX), SS_QUIT_HEADING}; @@ -627,34 +627,34 @@ static CONFINIT t2ciQuit = {4, 2, 196, 53, false, t2QuitBox, sizeof(t2QuitBox) / \***************************************************************************/ static CONFBOX hopperBox1[] = { - {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY, T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 2 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 3 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 4 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 5 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 6 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 7 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 8 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY, T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 2 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 3 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 4 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 5 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 6 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 7 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, HOPPER2, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 8 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {ARSGBUT, HOPPER2, TM_NONE, NULL, 0, 460, 100, BW, BH, NULL, IX2_TICK1}, - {AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 100 + 100, BW, BH, NULL, IX2_CROSS1}}; + {ARSGBUT, HOPPER2, TM_NONE, NULL, 0, 460, 100, BW, BH, NULL, IX2_TICK1}, + {AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 100 + 100, BW, BH, NULL, IX2_CROSS1}}; static CONFINIT ciHopper1 = {10, 6, 40, 16, true, hopperBox1, sizeof(hopperBox1) / sizeof(CONFBOX), SS_HOPPER1}; static CONFBOX hopperBox2[] = { - {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY, T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 2 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 3 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 4 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 5 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 6 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 7 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 8 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY, T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 2 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 3 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 4 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 5 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 6 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 7 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, + {RGROUP, BF_CHANGESCENE, TM_STRINGNUM, NULL, 0, BOXX, BOXY + 8 * (T2_BOX_HEIGHT + T2_BOX_V2_SEP), T2_EDIT_BOX2_WIDTH, T2_BOX_HEIGHT, NULL, 0}, - {ARSGBUT, BF_CHANGESCENE, TM_NONE, NULL, 0, 460, 50, BW, BH, NULL, IX2_TICK1}, - {AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 200, BW, BH, NULL, IX2_CROSS1}}; + {ARSGBUT, BF_CHANGESCENE, TM_NONE, NULL, 0, 460, 50, BW, BH, NULL, IX2_TICK1}, + {AAGBUT, CLOSEWIN, TM_NONE, NULL, 0, 460, 200, BW, BH, NULL, IX2_CROSS1}}; static CONFINIT ciHopper2 = {10, 6, 40, 16, true, hopperBox2, sizeof(hopperBox2) / sizeof(CONFBOX), NO_HEADING}; @@ -662,7 +662,7 @@ static CONFINIT ciHopper2 = {10, 6, 40, 16, true, hopperBox2, sizeof(hopperBox2) |**************************** Top Window *****************************| \***************************************************************************/ static CONFBOX topwinBox[] = { - {NOTHING, NOFUNC, TM_NONE, NULL, USE_POINTER, 0, 0, 0, 0, NULL, 0}}; + {NOTHING, NOFUNC, TM_NONE, NULL, USE_POINTER, 0, 0, 0, 0, NULL, 0}}; static CONFINIT ciSubtitles = {10, 3, 20, 16, false, subtitlesBox, ARRAYSIZE(subtitlesBox), NO_HEADING}; @@ -684,8 +684,8 @@ static struct { int extraBase; int numSaved; } cd = { - NULL, 0, false, 0, false, - NOBOX, NOBOX, 0, 0, 0}; + NULL, 0, false, 0, false, + NOBOX, NOBOX, 0, 0, 0}; #define HL1 0 // Hilight that moves with the cursor #define HL2 1 // Hilight on selected RGROUP box @@ -5115,10 +5115,10 @@ void Dialogs::setConfigStrings(SCNHANDLE *tp) { * - Declare the heading text and dimensions etc. */ void Dialogs::idec_inv(int num, SCNHANDLE text, int MaxContents, - int MinWidth, int MinHeight, - int StartWidth, int StartHeight, - int MaxWidth, int MaxHeight, - int startx, int starty, bool moveable) { + int MinWidth, int MinHeight, + int StartWidth, int StartHeight, + int MaxWidth, int MaxHeight, + int startx, int starty, bool moveable) { if (MaxWidth > MAXHICONS) MaxWidth = MAXHICONS; // Max window width if (MaxHeight > MAXVICONS) @@ -5168,9 +5168,9 @@ void Dialogs::idec_inv(int num, SCNHANDLE text, int MaxContents, * - Declare the heading text and dimensions etc. */ void Dialogs::idec_convw(SCNHANDLE text, int MaxContents, - int MinWidth, int MinHeight, - int StartWidth, int StartHeight, - int MaxWidth, int MaxHeight) { + int MinWidth, int MinHeight, + int StartWidth, int StartHeight, + int MaxWidth, int MaxHeight) { idec_inv(INV_CONV, text, MaxContents, MinWidth, MinHeight, StartWidth, StartHeight, MaxWidth, MaxHeight, 20, 8, true); @@ -5181,9 +5181,9 @@ void Dialogs::idec_convw(SCNHANDLE text, int MaxContents, * - Declare the heading text and dimensions etc. */ void Dialogs::idec_inv1(SCNHANDLE text, int MaxContents, - int MinWidth, int MinHeight, - int StartWidth, int StartHeight, - int MaxWidth, int MaxHeight) { + int MinWidth, int MinHeight, + int StartWidth, int StartHeight, + int MaxWidth, int MaxHeight) { idec_inv(INV_1, text, MaxContents, MinWidth, MinHeight, StartWidth, StartHeight, MaxWidth, MaxHeight, 100, 100, true); @@ -5194,9 +5194,9 @@ void Dialogs::idec_inv1(SCNHANDLE text, int MaxContents, * - Declare the heading text and dimensions etc. */ void Dialogs::idec_inv2(SCNHANDLE text, int MaxContents, - int MinWidth, int MinHeight, - int StartWidth, int StartHeight, - int MaxWidth, int MaxHeight) { + int MinWidth, int MinHeight, + int StartWidth, int StartHeight, + int MaxWidth, int MaxHeight) { idec_inv(INV_2, text, MaxContents, MinWidth, MinHeight, StartWidth, StartHeight, MaxWidth, MaxHeight, 100, 100, true); @@ -5228,7 +5228,7 @@ void Dialogs::InvSetLimit(int invno, int MaxContents) { * Called from Glitter function 'SetInvSize()' */ void Dialogs::InvSetSize(int invno, int MinWidth, int MinHeight, - int StartWidth, int StartHeight, int MaxWidth, int MaxHeight) { + int StartWidth, int StartHeight, int MaxWidth, int MaxHeight) { assert(invno == INV_1 || invno == INV_2); // only INV_1 and INV_2 supported if (StartWidth > MaxWidth) diff --git a/engines/tinsel/metaengine.cpp b/engines/tinsel/metaengine.cpp index 6edb4bf03df..b95853c8373 100644 --- a/engines/tinsel/metaengine.cpp +++ b/engines/tinsel/metaengine.cpp @@ -71,7 +71,7 @@ public: Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; SaveStateList listSaves(const char *target) const override; int getMaximumSaveSlot() const override; SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override; diff --git a/engines/titanic/star_control/matrix_inv.h b/engines/titanic/star_control/matrix_inv.h index 642c4147179..5a43dcdecec 100644 --- a/engines/titanic/star_control/matrix_inv.h +++ b/engines/titanic/star_control/matrix_inv.h @@ -55,134 +55,134 @@ namespace Titanic { template bool matrix4Inverse(const T m[16], T invOut[16]) { - T temp_inv[16]; - T determinant; - T determinant_inv; - int i; + T temp_inv[16]; + T determinant; + T determinant_inv; + int i; - temp_inv[0] = m[5] * m[10] * m[15] - - m[5] * m[11] * m[14] - - m[9] * m[6] * m[15] + - m[9] * m[7] * m[14] + - m[13] * m[6] * m[11] - - m[13] * m[7] * m[10]; + temp_inv[0] = m[5] * m[10] * m[15] - + m[5] * m[11] * m[14] - + m[9] * m[6] * m[15] + + m[9] * m[7] * m[14] + + m[13] * m[6] * m[11] - + m[13] * m[7] * m[10]; - temp_inv[4] = -m[4] * m[10] * m[15] + - m[4] * m[11] * m[14] + - m[8] * m[6] * m[15] - - m[8] * m[7] * m[14] - - m[12] * m[6] * m[11] + - m[12] * m[7] * m[10]; + temp_inv[4] = -m[4] * m[10] * m[15] + + m[4] * m[11] * m[14] + + m[8] * m[6] * m[15] - + m[8] * m[7] * m[14] - + m[12] * m[6] * m[11] + + m[12] * m[7] * m[10]; - temp_inv[8] = m[4] * m[9] * m[15] - - m[4] * m[11] * m[13] - - m[8] * m[5] * m[15] + - m[8] * m[7] * m[13] + - m[12] * m[5] * m[11] - - m[12] * m[7] * m[9]; + temp_inv[8] = m[4] * m[9] * m[15] - + m[4] * m[11] * m[13] - + m[8] * m[5] * m[15] + + m[8] * m[7] * m[13] + + m[12] * m[5] * m[11] - + m[12] * m[7] * m[9]; - temp_inv[12] = -m[4] * m[9] * m[14] + - m[4] * m[10] * m[13] + - m[8] * m[5] * m[14] - - m[8] * m[6] * m[13] - - m[12] * m[5] * m[10] + - m[12] * m[6] * m[9]; + temp_inv[12] = -m[4] * m[9] * m[14] + + m[4] * m[10] * m[13] + + m[8] * m[5] * m[14] - + m[8] * m[6] * m[13] - + m[12] * m[5] * m[10] + + m[12] * m[6] * m[9]; - temp_inv[1] = -m[1] * m[10] * m[15] + - m[1] * m[11] * m[14] + - m[9] * m[2] * m[15] - - m[9] * m[3] * m[14] - - m[13] * m[2] * m[11] + - m[13] * m[3] * m[10]; + temp_inv[1] = -m[1] * m[10] * m[15] + + m[1] * m[11] * m[14] + + m[9] * m[2] * m[15] - + m[9] * m[3] * m[14] - + m[13] * m[2] * m[11] + + m[13] * m[3] * m[10]; - temp_inv[5] = m[0] * m[10] * m[15] - - m[0] * m[11] * m[14] - - m[8] * m[2] * m[15] + - m[8] * m[3] * m[14] + - m[12] * m[2] * m[11] - - m[12] * m[3] * m[10]; + temp_inv[5] = m[0] * m[10] * m[15] - + m[0] * m[11] * m[14] - + m[8] * m[2] * m[15] + + m[8] * m[3] * m[14] + + m[12] * m[2] * m[11] - + m[12] * m[3] * m[10]; - temp_inv[9] = -m[0] * m[9] * m[15] + - m[0] * m[11] * m[13] + - m[8] * m[1] * m[15] - - m[8] * m[3] * m[13] - - m[12] * m[1] * m[11] + - m[12] * m[3] * m[9]; + temp_inv[9] = -m[0] * m[9] * m[15] + + m[0] * m[11] * m[13] + + m[8] * m[1] * m[15] - + m[8] * m[3] * m[13] - + m[12] * m[1] * m[11] + + m[12] * m[3] * m[9]; - temp_inv[13] = m[0] * m[9] * m[14] - - m[0] * m[10] * m[13] - - m[8] * m[1] * m[14] + - m[8] * m[2] * m[13] + - m[12] * m[1] * m[10] - - m[12] * m[2] * m[9]; + temp_inv[13] = m[0] * m[9] * m[14] - + m[0] * m[10] * m[13] - + m[8] * m[1] * m[14] + + m[8] * m[2] * m[13] + + m[12] * m[1] * m[10] - + m[12] * m[2] * m[9]; - temp_inv[2] = m[1] * m[6] * m[15] - - m[1] * m[7] * m[14] - - m[5] * m[2] * m[15] + - m[5] * m[3] * m[14] + - m[13] * m[2] * m[7] - - m[13] * m[3] * m[6]; + temp_inv[2] = m[1] * m[6] * m[15] - + m[1] * m[7] * m[14] - + m[5] * m[2] * m[15] + + m[5] * m[3] * m[14] + + m[13] * m[2] * m[7] - + m[13] * m[3] * m[6]; - temp_inv[6] = -m[0] * m[6] * m[15] + - m[0] * m[7] * m[14] + - m[4] * m[2] * m[15] - - m[4] * m[3] * m[14] - - m[12] * m[2] * m[7] + - m[12] * m[3] * m[6]; + temp_inv[6] = -m[0] * m[6] * m[15] + + m[0] * m[7] * m[14] + + m[4] * m[2] * m[15] - + m[4] * m[3] * m[14] - + m[12] * m[2] * m[7] + + m[12] * m[3] * m[6]; - temp_inv[10] = m[0] * m[5] * m[15] - - m[0] * m[7] * m[13] - - m[4] * m[1] * m[15] + - m[4] * m[3] * m[13] + - m[12] * m[1] * m[7] - - m[12] * m[3] * m[5]; + temp_inv[10] = m[0] * m[5] * m[15] - + m[0] * m[7] * m[13] - + m[4] * m[1] * m[15] + + m[4] * m[3] * m[13] + + m[12] * m[1] * m[7] - + m[12] * m[3] * m[5]; - temp_inv[14] = -m[0] * m[5] * m[14] + - m[0] * m[6] * m[13] + - m[4] * m[1] * m[14] - - m[4] * m[2] * m[13] - - m[12] * m[1] * m[6] + - m[12] * m[2] * m[5]; + temp_inv[14] = -m[0] * m[5] * m[14] + + m[0] * m[6] * m[13] + + m[4] * m[1] * m[14] - + m[4] * m[2] * m[13] - + m[12] * m[1] * m[6] + + m[12] * m[2] * m[5]; - temp_inv[3] = -m[1] * m[6] * m[11] + - m[1] * m[7] * m[10] + - m[5] * m[2] * m[11] - - m[5] * m[3] * m[10] - - m[9] * m[2] * m[7] + - m[9] * m[3] * m[6]; + temp_inv[3] = -m[1] * m[6] * m[11] + + m[1] * m[7] * m[10] + + m[5] * m[2] * m[11] - + m[5] * m[3] * m[10] - + m[9] * m[2] * m[7] + + m[9] * m[3] * m[6]; - temp_inv[7] = m[0] * m[6] * m[11] - - m[0] * m[7] * m[10] - - m[4] * m[2] * m[11] + - m[4] * m[3] * m[10] + - m[8] * m[2] * m[7] - - m[8] * m[3] * m[6]; + temp_inv[7] = m[0] * m[6] * m[11] - + m[0] * m[7] * m[10] - + m[4] * m[2] * m[11] + + m[4] * m[3] * m[10] + + m[8] * m[2] * m[7] - + m[8] * m[3] * m[6]; - temp_inv[11] = -m[0] * m[5] * m[11] + - m[0] * m[7] * m[9] + - m[4] * m[1] * m[11] - - m[4] * m[3] * m[9] - - m[8] * m[1] * m[7] + - m[8] * m[3] * m[5]; + temp_inv[11] = -m[0] * m[5] * m[11] + + m[0] * m[7] * m[9] + + m[4] * m[1] * m[11] - + m[4] * m[3] * m[9] - + m[8] * m[1] * m[7] + + m[8] * m[3] * m[5]; - temp_inv[15] = m[0] * m[5] * m[10] - - m[0] * m[6] * m[9] - - m[4] * m[1] * m[10] + - m[4] * m[2] * m[9] + - m[8] * m[1] * m[6] - - m[8] * m[2] * m[5]; + temp_inv[15] = m[0] * m[5] * m[10] - + m[0] * m[6] * m[9] - + m[4] * m[1] * m[10] + + m[4] * m[2] * m[9] + + m[8] * m[1] * m[6] - + m[8] * m[2] * m[5]; - determinant = m[0] * temp_inv[0] + m[1] * temp_inv[4] + m[2] * temp_inv[8] + m[3] * temp_inv[12]; + determinant = m[0] * temp_inv[0] + m[1] * temp_inv[4] + m[2] * temp_inv[8] + m[3] * temp_inv[12]; - if (determinant == 0) - return false; + if (determinant == 0) + return false; - determinant_inv = 1.0 / determinant; + determinant_inv = 1.0 / determinant; - for (i = 0; i < 16; i++) - invOut[i] = temp_inv[i] * determinant_inv; + for (i = 0; i < 16; i++) + invOut[i] = temp_inv[i] * determinant_inv; - return true; + return true; } } // End of namespace Titanic diff --git a/engines/toltecs/metaengine.cpp b/engines/toltecs/metaengine.cpp index bcac79f5e0a..c7860445b0b 100644 --- a/engines/toltecs/metaengine.cpp +++ b/engines/toltecs/metaengine.cpp @@ -49,10 +49,10 @@ public: return "toltecs"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; - SaveStateList listSaves(const char *target) const override; + SaveStateList listSaves(const char *target) const override; int getMaximumSaveSlot() const override; void removeSaveState(const char *target, int slot) const override; SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override; diff --git a/engines/toltecs/render.h b/engines/toltecs/render.h index 5150903146f..e348d5528a0 100644 --- a/engines/toltecs/render.h +++ b/engines/toltecs/render.h @@ -83,13 +83,13 @@ protected: MicroTileArray *_updateUta; bool rectIntersectsItem(const Common::Rect &rect); - RenderQueueItem *findItemInQueue(RenderQueueArray *queue, const RenderQueueItem &item); - bool hasItemChanged(const RenderQueueItem &item1, const RenderQueueItem &item2); - void invalidateItemsByRect(const Common::Rect &rect, const RenderQueueItem *item); + RenderQueueItem *findItemInQueue(RenderQueueArray *queue, const RenderQueueItem &item); + bool hasItemChanged(const RenderQueueItem &item1, const RenderQueueItem &item2); + void invalidateItemsByRect(const Common::Rect &rect, const RenderQueueItem *item); - void addDirtyRect(const Common::Rect &rect); - void restoreDirtyBackground(); - void updateDirtyRects(); + void addDirtyRect(const Common::Rect &rect); + void restoreDirtyBackground(); + void updateDirtyRects(); }; diff --git a/engines/tony/metaengine.cpp b/engines/tony/metaengine.cpp index 8d93c7e59b9..be402f170d1 100644 --- a/engines/tony/metaengine.cpp +++ b/engines/tony/metaengine.cpp @@ -57,7 +57,7 @@ public: return "tony"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; SaveStateList listSaves(const char *target) const override; diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 56448a554dd..f27efb7e75f 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -188,7 +188,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * @returns Version number (0x1232 = 1.2.3b) */ #define mpalQueryVersion() \ - (uint16)mpalQueryDWORD(MPQ_VERSION) + (uint16)mpalQueryDWORD(MPQ_VERSION) /** * Gets the numerical value of a global variable @@ -200,7 +200,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * within the library. */ #define mpalQueryGlobalVar(lpszVarName) \ - mpalQueryDWORD(MPQ_GLOBAL_VAR, (const char *)(lpszVarName)) + mpalQueryDWORD(MPQ_GLOBAL_VAR, (const char *)(lpszVarName)) /** * Provides access to a resource inside the .MPC file @@ -209,7 +209,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * @returns Handle to a memory area containing the resource, ready for use. */ #define mpalQueryResource(dwResId) \ - mpalQueryHANDLE(MPQ_RESOURCE, (uint32)(dwResId)) + mpalQueryHANDLE(MPQ_RESOURCE, (uint32)(dwResId)) /** * Returns a message. @@ -220,14 +220,14 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * after use. The message will be in ASCIIZ format. */ #define mpalQueryMessage(nMsg) \ - (char *)mpalQueryHANDLE(MPQ_MESSAGE, (uint32)(nMsg)) + (char *)mpalQueryHANDLE(MPQ_MESSAGE, (uint32)(nMsg)) /** * Provides a location image * @return Returns a picture handle */ #define mpalQueryLocationImage(nLoc) \ - mpalQueryHANDLE(MPQ_LOCATION_IMAGE, (uint32)(nLoc)) + mpalQueryHANDLE(MPQ_LOCATION_IMAGE, (uint32)(nLoc)) /** * Request the x or y size of a location in pixels @@ -237,7 +237,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * @returns Size */ #define mpalQueryLocationSize(nLoc, dwCoord) \ - mpalQueryDWORD(MPQ_LOCATION_SIZE, (uint32)(nLoc), (uint32)(dwCoord)) + mpalQueryDWORD(MPQ_LOCATION_SIZE, (uint32)(nLoc), (uint32)(dwCoord)) /** * Provides the list of objects in a location. @@ -247,7 +247,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; */ // TODO: Determine if this is endian safe #define mpalQueryItemList(nLoc) \ - (uint32 *)mpalQueryHANDLE(MPQ_ITEM_LIST, (uint32)(nLoc)) + (uint32 *)mpalQueryHANDLE(MPQ_ITEM_LIST, (uint32)(nLoc)) /** * Provides information on an item @@ -256,7 +256,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * @returns Structure filled with requested information */ #define mpalQueryItemData(nItem) \ - (LpItem)mpalQueryHANDLE(MPQ_ITEM_DATA, (uint32)(nItem)) + (LpItem)mpalQueryHANDLE(MPQ_ITEM_DATA, (uint32)(nItem)) /** * Provides the current pattern of an item @@ -266,7 +266,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * @remarks By default, the pattern of 0 indicates that we should do nothing. */ #define mpalQueryItemPattern(nItem) \ - mpalQueryDWORD(MPQ_ITEM_PATTERN, (uint32)(nItem)) + mpalQueryDWORD(MPQ_ITEM_PATTERN, (uint32)(nItem)) /** * Returns true if an item is active @@ -275,7 +275,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * @returns TRUE if the item is active, FALSE otherwise */ #define mpalQueryItemIsActive(nItem) \ - (bool)mpalQueryDWORD(MPQ_ITEM_IS_ACTIVE, (uint32)(nItem)) + (bool)mpalQueryDWORD(MPQ_ITEM_IS_ACTIVE, (uint32)(nItem)) /** * Returns the name of an item @@ -287,7 +287,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * is less than or equal to 0), the string will be empty. */ #define mpalQueryItemName(nItem, lpszName) \ - mpalQueryHANDLE(MPQ_ITEM_NAME, (uint32)(nItem), (char *)(lpszName)) + mpalQueryHANDLE(MPQ_ITEM_NAME, (uint32)(nItem), (char *)(lpszName)) /** * Returns a sentence of dialog. @@ -300,14 +300,14 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * string terminated with 0. */ #define mpalQueryDialogPeriod(nPeriod) \ - (char *)mpalQueryHANDLE(MPQ_DIALOG_PERIOD, (uint32)(nPeriod)) + (char *)mpalQueryHANDLE(MPQ_DIALOG_PERIOD, (uint32)(nPeriod)) /** * Wait until the moment in which the need is signaled to make a choice by the user. * @returns Number of choice to be made, or -1 if the dialogue is finished. */ #define mpalQueryDialogWaitForChoice(dwRet) \ - CORO_INVOKE_2(mpalQueryCORO, MPQ_DIALOG_WAITFORCHOICE, dwRet) + CORO_INVOKE_2(mpalQueryCORO, MPQ_DIALOG_WAITFORCHOICE, dwRet) /** * Requires a list of various options for some choice within the current dialog. @@ -319,7 +319,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * The pointer msut be freed after use using the memory memory. */ #define mpalQueryDialogSelectList(nChoice) \ - (uint32 *)mpalQueryHANDLE(MPQ_DIALOG_SELECTLIST, (uint32)(nChoice)) + (uint32 *)mpalQueryHANDLE(MPQ_DIALOG_SELECTLIST, (uint32)(nChoice)) /** * Warns the library that the user has selected, in a certain choice of the current dialog, @@ -333,10 +333,10 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * remains on hold again for another chosen by mpalQueryDialogWaitForChoice (). */ #define mpalQueryDialogSelection(nChoice, dwData) \ - (bool)mpalQueryDWORD(MPQ_DIALOG_SELECTION, (uint32)(nChoice), (uint32)(dwData)) + (bool)mpalQueryDWORD(MPQ_DIALOG_SELECTION, (uint32)(nChoice), (uint32)(dwData)) #define mpalQueryDialogSelectionDWORD(nChoice, dwData) \ - mpalQueryDWORD(MPQ_DIALOG_SELECTION, (uint32)(nChoice), (uint32)(dwData)) + mpalQueryDWORD(MPQ_DIALOG_SELECTION, (uint32)(nChoice), (uint32)(dwData)) /** * Warns the library an action was performed on a Object. @@ -352,7 +352,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * if the item is active, ie if its status is a positive number greater than 0. */ #define mpalQueryDoAction(nAction, nItem, dwParam) \ - mpalQueryDWORD(MPQ_DO_ACTION, (uint32)(nAction), (uint32)(nItem), (uint32)(dwParam)) + mpalQueryDWORD(MPQ_DO_ACTION, (uint32)(nAction), (uint32)(nItem), (uint32)(dwParam)) /** * Warns the library a dialogue was required. @@ -363,7 +363,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * CORO_INVALID_PID_VALUE if the dialogue does not exist. */ #define mpalQueryDoDialog(nDialog, nGroup) \ - mpalQueryDWORD(MPQ_DO_DIALOG, (uint32)(nDialog), (uint32)(nGroup)) + mpalQueryDWORD(MPQ_DO_DIALOG, (uint32)(nDialog), (uint32)(nGroup)) /** * @defgroup Functions exported to the main game @@ -378,7 +378,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * @returns TRUE if all OK, FALSE on failure */ bool mpalInit(const char *lpszFileName, const char *lpszMprFileName, - LPLPCUSTOMFUNCTION lplpcfArray, Common::String *lpcfStrings); + LPLPCUSTOMFUNCTION lplpcfArray, Common::String *lpcfStrings); /** * Frees resources allocated by the MPAL subsystem diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 8c88e9467b9..1a0eb155669 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -566,7 +566,7 @@ void RMTony::put(int nWhere, int nPart) { } bool RMTony::startTalkCalculate(CharacterTalkType nTalkType, int &headStartPat, int &bodyStartPat, - int &headLoopPat, int &bodyLoopPat) { + int &headLoopPat, int &bodyLoopPat) { assert(!_bIsTalking); _bIsTalking = true; @@ -1590,7 +1590,7 @@ void RMTony::endTalk(CORO_PARAM) { } void RMTony::startStaticCalculate(CharacterTalkType nTalk, int &headPat, int &headLoopPat, - int &bodyStartPat, int &bodyLoopPat) { + int &bodyStartPat, int &bodyLoopPat) { int nPat = getCurPattern(); headLoopPat = -1; diff --git a/engines/toon/metaengine.cpp b/engines/toon/metaengine.cpp index f9b313fbea4..8e5e72e3fe4 100644 --- a/engines/toon/metaengine.cpp +++ b/engines/toon/metaengine.cpp @@ -30,7 +30,7 @@ class ToonMetaEngine : public AdvancedMetaEngine { public: - const char *getName() const override { + const char *getName() const override { return "toon"; } diff --git a/engines/tsage/metaengine.cpp b/engines/tsage/metaengine.cpp index 6c6f4a0a033..84cbf76122f 100644 --- a/engines/tsage/metaengine.cpp +++ b/engines/tsage/metaengine.cpp @@ -65,7 +65,7 @@ public: return "tsage"; } - bool hasFeature(MetaEngineFeature f) const override { + bool hasFeature(MetaEngineFeature f) const override { switch (f) { case kSupportsListSaves: case kSupportsDeleteSave: diff --git a/engines/tucker/metaengine.cpp b/engines/tucker/metaengine.cpp index d63e33dccae..5564fdc97fc 100644 --- a/engines/tucker/metaengine.cpp +++ b/engines/tucker/metaengine.cpp @@ -35,7 +35,7 @@ public: return "tucker"; } - bool hasFeature(MetaEngineFeature f) const override { + bool hasFeature(MetaEngineFeature f) const override { switch (f) { case kSupportsListSaves: case kSupportsLoadingDuringStartup: @@ -55,7 +55,7 @@ public: return Common::kNoError; } - SaveStateList listSaves(const char *target) const override { + SaveStateList listSaves(const char *target) const override { Common::String pattern = Tucker::generateGameStateFileName(target, 0, true); Common::StringArray filenames = g_system->getSavefileManager()->listSavefiles(pattern); Tucker::TuckerEngine::SavegameHeader header; diff --git a/engines/twine/menu/menu.cpp b/engines/twine/menu/menu.cpp index 0ae1590a861..76bcaaaea32 100644 --- a/engines/twine/menu/menu.cpp +++ b/engines/twine/menu/menu.cpp @@ -730,26 +730,26 @@ int32 Menu::optionsMenu() { } static const byte cursorArrow[] = { - 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 1, 0, 1, 3, 3, 3, 3, 3, 3, 3, 3, - 1, 0, 0, 1, 3, 3, 3, 3, 3, 3, 3, - 1, 0, 0, 0, 1, 3, 3, 3, 3, 3, 3, - 1, 0, 0, 0, 0, 1, 3, 3, 3, 3, 3, - 1, 0, 0, 0, 0, 0, 1, 3, 3, 3, 3, - 1, 0, 0, 0, 0, 0, 0, 1, 3, 3, 3, - 1, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, - 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, - 1, 0, 0, 1, 0, 0, 1, 3, 3, 3, 3, - 1, 0, 1, 3, 1, 0, 0, 1, 3, 3, 3, - 1, 1, 3, 3, 1, 0, 0, 1, 3, 3, 3, - 1, 3, 3, 3, 3, 1, 0, 0, 1, 3, 3, - 3, 3, 3, 3, 3, 1, 0, 0, 1, 3, 3, - 3, 3, 3, 3, 3, 3, 1, 1, 1, 3, 3}; + 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 1, 0, 1, 3, 3, 3, 3, 3, 3, 3, 3, + 1, 0, 0, 1, 3, 3, 3, 3, 3, 3, 3, + 1, 0, 0, 0, 1, 3, 3, 3, 3, 3, 3, + 1, 0, 0, 0, 0, 1, 3, 3, 3, 3, 3, + 1, 0, 0, 0, 0, 0, 1, 3, 3, 3, 3, + 1, 0, 0, 0, 0, 0, 0, 1, 3, 3, 3, + 1, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, + 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, + 1, 0, 0, 1, 0, 0, 1, 3, 3, 3, 3, + 1, 0, 1, 3, 1, 0, 0, 1, 3, 3, 3, + 1, 1, 3, 3, 1, 0, 0, 1, 3, 3, 3, + 1, 3, 3, 3, 3, 1, 0, 0, 1, 3, 3, + 3, 3, 3, 3, 3, 1, 0, 0, 1, 3, 3, + 3, 3, 3, 3, 3, 3, 1, 1, 1, 3, 3}; static const byte cursorPalette[] = { - 0, 0, 0, - 0xff, 0xff, 0xff}; + 0, 0, 0, + 0xff, 0xff, 0xff}; bool Menu::init() { // load menu effect file only once diff --git a/engines/twine/renderer/shadeangletab.h b/engines/twine/renderer/shadeangletab.h index 1f0b4a42684..9d422eb31a4 100644 --- a/engines/twine/renderer/shadeangletab.h +++ b/engines/twine/renderer/shadeangletab.h @@ -32,1030 +32,1030 @@ namespace TwinE { * @brief Caches sin cos table for all possible angles (0-1024 = 0-360 degree) */ const int16 shadeAngleTable[ANGLE_360] = { - 0, // tab1 - 101, - 201, - 302, - 402, - 503, - 603, - 704, - 804, - 904, - 1005, - 1105, - 1205, - 1306, - 1406, - 1506, - 1606, - 1706, - 1806, - 1906, - 2006, - 2105, - 2205, - 2305, - 2404, - 2503, - 2603, - 2702, - 2801, - 2900, - 2999, - 3098, - 3196, - 3295, - 3393, - 3492, - 3590, - 3688, - 3786, - 3883, - 3981, - 4078, - 4176, - 4273, - 4370, - 4467, - 4563, - 4660, - 4756, - 4852, - 4948, - 5044, - 5139, - 5235, - 5330, - 5425, - 5520, - 5614, - 5708, - 5803, - 5897, - 5990, - 6084, - 6177, - 6270, - 6363, - 6455, - 6547, - 6639, - 6731, - 6823, - 6914, - 7005, - 7096, - 7186, - 7276, - 7366, - 7456, - 7545, - 7635, - 7723, - 7812, - 7900, - 7988, - 8076, - 8163, - 8250, - 8337, - 8423, - 8509, - 8595, - 8680, - 8765, - 8850, - 8935, - 9019, - 9102, - 9186, - 9269, - 9352, - 9434, - 9516, - 9598, - 9679, - 9760, - 9841, - 9921, - 10001, - 10080, - 10159, - 10238, - 10316, - 10394, - 10471, - 10549, - 10625, - 10702, - 10778, - 10853, - 10928, - 11003, - 11077, - 11151, - 11224, - 11297, - 11370, - 11442, - 11514, - 11585, - 11656, - 11727, - 11797, - 11866, - 11935, - 12004, - 12072, - 12140, - 12207, - 12274, - 12340, - 12406, - 12472, - 12537, - 12601, - 12665, - 12729, - 12792, - 12854, - 12916, - 12978, - 13039, - 13100, - 13160, - 13219, - 13279, - 13337, - 13395, - 13453, - 13510, - 13567, - 13623, - 13678, - 13733, - 13788, - 13842, - 13896, - 13949, - 14001, - 14053, - 14104, - 14155, - 14206, - 14256, - 14305, - 14354, - 14402, - 14449, - 14497, - 14543, - 14589, - 14635, - 14680, - 14724, - 14768, - 14811, - 14854, - 14896, - 14937, - 14978, - 15019, - 15059, - 15098, - 15137, - 15175, - 15213, - 15250, - 15286, - 15322, - 15357, - 15392, - 15426, - 15460, - 15493, - 15525, - 15557, - 15588, - 15619, - 15649, - 15679, - 15707, - 15736, - 15763, - 15791, - 15817, - 15843, - 15868, - 15893, - 15917, - 15941, - 15964, - 15986, - 16008, - 16029, - 16049, - 16069, - 16088, - 16107, - 16125, - 16143, - 16160, - 16176, - 16192, - 16207, - 16221, - 16235, - 16248, - 16261, - 16273, - 16284, - 16295, - 16305, - 16315, - 16324, - 16332, - 16340, - 16347, - 16353, - 16359, - 16364, - 16369, - 16373, - 16376, - 16379, - 16381, - 16383, - 16384, - 16384, // tab2 - 16384, - 16383, - 16381, - 16379, - 16376, - 16373, - 16369, - 16364, - 16359, - 16353, - 16347, - 16340, - 16332, - 16324, - 16315, - 16305, - 16295, - 16284, - 16273, - 16261, - 16248, - 16235, - 16221, - 16207, - 16192, - 16176, - 16160, - 16143, - 16125, - 16107, - 16088, - 16069, - 16049, - 16029, - 16008, - 15986, - 15964, - 15941, - 15917, - 15893, - 15868, - 15843, - 15817, - 15791, - 15763, - 15736, - 15707, - 15679, - 15649, - 15619, - 15588, - 15557, - 15525, - 15493, - 15460, - 15426, - 15392, - 15357, - 15322, - 15286, - 15250, - 15213, - 15175, - 15137, - 15098, - 15059, - 15019, - 14978, - 14937, - 14896, - 14854, - 14811, - 14768, - 14724, - 14680, - 14635, - 14589, - 14543, - 14497, - 14449, - 14402, - 14354, - 14305, - 14256, - 14206, - 14155, - 14104, - 14053, - 14001, - 13949, - 13896, - 13842, - 13788, - 13733, - 13678, - 13623, - 13567, - 13510, - 13453, - 13395, - 13337, - 13279, - 13219, - 13160, - 13100, - 13039, - 12978, - 12916, - 12854, - 12792, - 12729, - 12665, - 12601, - 12537, - 12472, - 12406, - 12340, - 12274, - 12207, - 12140, - 12072, - 12004, - 11935, - 11866, - 11797, - 11727, - 11656, - 11585, // tab3 - 11514, - 11442, - 11370, - 11297, - 11224, - 11151, - 11077, - 11003, - 10928, - 10853, - 10778, - 10702, - 10625, - 10549, - 10471, - 10394, - 10316, - 10238, - 10159, - 10080, - 10001, - 9921, - 9841, - 9760, - 9679, - 9598, - 9516, - 9434, - 9352, - 9269, - 9186, - 9102, - 9019, - 8935, - 8850, - 8765, - 8680, - 8595, - 8509, - 8423, - 8337, - 8250, - 8163, - 8076, - 7988, - 7900, - 7812, - 7723, - 7635, - 7545, - 7456, - 7366, - 7276, - 7186, - 7096, - 7005, - 6914, - 6823, - 6731, - 6639, - 6547, - 6455, - 6363, - 6270, - 6177, - 6084, - 5990, - 5897, - 5803, - 5708, - 5614, - 5520, - 5425, - 5330, - 5235, - 5139, - 5044, - 4948, - 4852, - 4756, - 4660, - 4563, - 4467, - 4370, - 4273, - 4176, - 4078, - 3981, - 3883, - 3786, - 3688, - 3590, - 3492, - 3393, - 3295, - 3196, - 3098, - 2999, - 2900, - 2801, - 2702, - 2603, - 2503, - 2404, - 2305, - 2205, - 2105, - 2006, - 1906, - 1806, - 1706, - 1606, - 1506, - 1406, - 1306, - 1205, - 1105, - 1005, - 904, - 804, - 704, - 603, - 503, - 402, - 302, - 201, - 101, - 0, - -101, - -201, - -302, - -402, - -503, - -603, - -704, - -804, - -904, - -1005, - -1105, - -1205, - -1306, - -1406, - -1506, - -1606, - -1706, - -1806, - -1906, - -2006, - -2105, - -2205, - -2305, - -2404, - -2503, - -2603, - -2702, - -2801, - -2900, - -2999, - -3098, - -3196, - -3295, - -3393, - -3492, - -3590, - -3688, - -3786, - -3883, - -3981, - -4078, - -4176, - -4273, - -4370, - -4467, - -4563, - -4660, - -4756, - -4852, - -4948, - -5044, - -5139, - -5235, - -5330, - -5425, - -5520, - -5614, - -5708, - -5803, - -5897, - -5990, - -6084, - -6177, - -6270, - -6363, - -6455, - -6547, - -6639, - -6731, - -6823, - -6914, - -7005, - -7096, - -7186, - -7276, - -7366, - -7456, - -7545, - -7635, - -7723, - -7812, - -7900, - -7988, - -8076, - -8163, - -8250, - -8337, - -8423, - -8509, - -8595, - -8680, - -8765, - -8850, - -8935, - -9019, - -9102, - -9186, - -9269, - -9352, - -9434, - -9516, - -9598, - -9679, - -9760, - -9841, - -9921, - -10001, - -10080, - -10159, - -10238, - -10316, - -10394, - -10471, - -10549, - -10625, - -10702, - -10778, - -10853, - -10928, - -11003, - -11077, - -11151, - -11224, - -11297, - -11370, - -11442, - -11514, - -11585, - -11656, - -11727, - -11797, - -11866, - -11935, - -12004, - -12072, - -12140, - -12207, - -12274, - -12340, - -12406, - -12472, - -12537, - -12601, - -12665, - -12729, - -12792, - -12854, - -12916, - -12978, - -13039, - -13100, - -13160, - -13219, - -13279, - -13337, - -13395, - -13453, - -13510, - -13567, - -13623, - -13678, - -13733, - -13788, - -13842, - -13896, - -13949, - -14001, - -14053, - -14104, - -14155, - -14206, - -14256, - -14305, - -14354, - -14402, - -14449, - -14497, - -14543, - -14589, - -14635, - -14680, - -14724, - -14768, - -14811, - -14854, - -14896, - -14937, - -14978, - -15019, - -15059, - -15098, - -15137, - -15175, - -15213, - -15250, - -15286, - -15322, - -15357, - -15392, - -15426, - -15460, - -15493, - -15525, - -15557, - -15588, - -15619, - -15649, - -15679, - -15707, - -15736, - -15763, - -15791, - -15817, - -15843, - -15868, - -15893, - -15917, - -15941, - -15964, - -15986, - -16008, - -16029, - -16049, - -16069, - -16088, - -16107, - -16125, - -16143, - -16160, - -16176, - -16192, - -16207, - -16221, - -16235, - -16248, - -16261, - -16273, - -16284, - -16295, - -16305, - -16315, - -16324, - -16332, - -16340, - -16347, - -16353, - -16359, - -16364, - -16369, - -16373, - -16376, - -16379, - -16381, - -16383, - -16384, - -16384, - -16384, - -16383, - -16381, - -16379, - -16376, - -16373, - -16369, - -16364, - -16359, - -16353, - -16347, - -16340, - -16332, - -16324, - -16315, - -16305, - -16295, - -16284, - -16273, - -16261, - -16248, - -16235, - -16221, - -16207, - -16192, - -16176, - -16160, - -16143, - -16125, - -16107, - -16088, - -16069, - -16049, - -16029, - -16008, - -15986, - -15964, - -15941, - -15917, - -15893, - -15868, - -15843, - -15817, - -15791, - -15763, - -15736, - -15707, - -15679, - -15649, - -15619, - -15588, - -15557, - -15525, - -15493, - -15460, - -15426, - -15392, - -15357, - -15322, - -15286, - -15250, - -15213, - -15175, - -15137, - -15098, - -15059, - -15019, - -14978, - -14937, - -14896, - -14854, - -14811, - -14768, - -14724, - -14680, - -14635, - -14589, - -14543, - -14497, - -14449, - -14402, - -14354, - -14305, - -14256, - -14206, - -14155, - -14104, - -14053, - -14001, - -13949, - -13896, - -13842, - -13788, - -13733, - -13678, - -13623, - -13567, - -13510, - -13453, - -13395, - -13337, - -13279, - -13219, - -13160, - -13100, - -13039, - -12978, - -12916, - -12854, - -12792, - -12729, - -12665, - -12601, - -12537, - -12472, - -12406, - -12340, - -12274, - -12207, - -12140, - -12072, - -12004, - -11935, - -11866, - -11797, - -11727, - -11656, - -11585, - -11514, - -11442, - -11370, - -11297, - -11224, - -11151, - -11077, - -11003, - -10928, - -10853, - -10778, - -10702, - -10625, - -10549, - -10471, - -10394, - -10316, - -10238, - -10159, - -10080, - -10001, - -9921, - -9841, - -9760, - -9679, - -9598, - -9516, - -9434, - -9352, - -9269, - -9186, - -9102, - -9019, - -8935, - -8850, - -8765, - -8680, - -8595, - -8509, - -8423, - -8337, - -8250, - -8163, - -8076, - -7988, - -7900, - -7812, - -7723, - -7635, - -7545, - -7456, - -7366, - -7276, - -7186, - -7096, - -7005, - -6914, - -6823, - -6731, - -6639, - -6547, - -6455, - -6363, - -6270, - -6177, - -6084, - -5990, - -5897, - -5803, - -5708, - -5614, - -5520, - -5425, - -5330, - -5235, - -5139, - -5044, - -4948, - -4852, - -4756, - -4660, - -4563, - -4467, - -4370, - -4273, - -4176, - -4078, - -3981, - -3883, - -3786, - -3688, - -3590, - -3492, - -3393, - -3295, - -3196, - -3098, - -2999, - -2900, - -2801, - -2702, - -2603, - -2503, - -2404, - -2305, - -2205, - -2105, - -2006, - -1906, - -1806, - -1706, - -1606, - -1506, - -1406, - -1306, - -1205, - -1105, - -1005, - -904, - -804, - -704, - -603, - -503, - -402, - -302, - -201, - -101, + 0, // tab1 + 101, + 201, + 302, + 402, + 503, + 603, + 704, + 804, + 904, + 1005, + 1105, + 1205, + 1306, + 1406, + 1506, + 1606, + 1706, + 1806, + 1906, + 2006, + 2105, + 2205, + 2305, + 2404, + 2503, + 2603, + 2702, + 2801, + 2900, + 2999, + 3098, + 3196, + 3295, + 3393, + 3492, + 3590, + 3688, + 3786, + 3883, + 3981, + 4078, + 4176, + 4273, + 4370, + 4467, + 4563, + 4660, + 4756, + 4852, + 4948, + 5044, + 5139, + 5235, + 5330, + 5425, + 5520, + 5614, + 5708, + 5803, + 5897, + 5990, + 6084, + 6177, + 6270, + 6363, + 6455, + 6547, + 6639, + 6731, + 6823, + 6914, + 7005, + 7096, + 7186, + 7276, + 7366, + 7456, + 7545, + 7635, + 7723, + 7812, + 7900, + 7988, + 8076, + 8163, + 8250, + 8337, + 8423, + 8509, + 8595, + 8680, + 8765, + 8850, + 8935, + 9019, + 9102, + 9186, + 9269, + 9352, + 9434, + 9516, + 9598, + 9679, + 9760, + 9841, + 9921, + 10001, + 10080, + 10159, + 10238, + 10316, + 10394, + 10471, + 10549, + 10625, + 10702, + 10778, + 10853, + 10928, + 11003, + 11077, + 11151, + 11224, + 11297, + 11370, + 11442, + 11514, + 11585, + 11656, + 11727, + 11797, + 11866, + 11935, + 12004, + 12072, + 12140, + 12207, + 12274, + 12340, + 12406, + 12472, + 12537, + 12601, + 12665, + 12729, + 12792, + 12854, + 12916, + 12978, + 13039, + 13100, + 13160, + 13219, + 13279, + 13337, + 13395, + 13453, + 13510, + 13567, + 13623, + 13678, + 13733, + 13788, + 13842, + 13896, + 13949, + 14001, + 14053, + 14104, + 14155, + 14206, + 14256, + 14305, + 14354, + 14402, + 14449, + 14497, + 14543, + 14589, + 14635, + 14680, + 14724, + 14768, + 14811, + 14854, + 14896, + 14937, + 14978, + 15019, + 15059, + 15098, + 15137, + 15175, + 15213, + 15250, + 15286, + 15322, + 15357, + 15392, + 15426, + 15460, + 15493, + 15525, + 15557, + 15588, + 15619, + 15649, + 15679, + 15707, + 15736, + 15763, + 15791, + 15817, + 15843, + 15868, + 15893, + 15917, + 15941, + 15964, + 15986, + 16008, + 16029, + 16049, + 16069, + 16088, + 16107, + 16125, + 16143, + 16160, + 16176, + 16192, + 16207, + 16221, + 16235, + 16248, + 16261, + 16273, + 16284, + 16295, + 16305, + 16315, + 16324, + 16332, + 16340, + 16347, + 16353, + 16359, + 16364, + 16369, + 16373, + 16376, + 16379, + 16381, + 16383, + 16384, + 16384, // tab2 + 16384, + 16383, + 16381, + 16379, + 16376, + 16373, + 16369, + 16364, + 16359, + 16353, + 16347, + 16340, + 16332, + 16324, + 16315, + 16305, + 16295, + 16284, + 16273, + 16261, + 16248, + 16235, + 16221, + 16207, + 16192, + 16176, + 16160, + 16143, + 16125, + 16107, + 16088, + 16069, + 16049, + 16029, + 16008, + 15986, + 15964, + 15941, + 15917, + 15893, + 15868, + 15843, + 15817, + 15791, + 15763, + 15736, + 15707, + 15679, + 15649, + 15619, + 15588, + 15557, + 15525, + 15493, + 15460, + 15426, + 15392, + 15357, + 15322, + 15286, + 15250, + 15213, + 15175, + 15137, + 15098, + 15059, + 15019, + 14978, + 14937, + 14896, + 14854, + 14811, + 14768, + 14724, + 14680, + 14635, + 14589, + 14543, + 14497, + 14449, + 14402, + 14354, + 14305, + 14256, + 14206, + 14155, + 14104, + 14053, + 14001, + 13949, + 13896, + 13842, + 13788, + 13733, + 13678, + 13623, + 13567, + 13510, + 13453, + 13395, + 13337, + 13279, + 13219, + 13160, + 13100, + 13039, + 12978, + 12916, + 12854, + 12792, + 12729, + 12665, + 12601, + 12537, + 12472, + 12406, + 12340, + 12274, + 12207, + 12140, + 12072, + 12004, + 11935, + 11866, + 11797, + 11727, + 11656, + 11585, // tab3 + 11514, + 11442, + 11370, + 11297, + 11224, + 11151, + 11077, + 11003, + 10928, + 10853, + 10778, + 10702, + 10625, + 10549, + 10471, + 10394, + 10316, + 10238, + 10159, + 10080, + 10001, + 9921, + 9841, + 9760, + 9679, + 9598, + 9516, + 9434, + 9352, + 9269, + 9186, + 9102, + 9019, + 8935, + 8850, + 8765, + 8680, + 8595, + 8509, + 8423, + 8337, + 8250, + 8163, + 8076, + 7988, + 7900, + 7812, + 7723, + 7635, + 7545, + 7456, + 7366, + 7276, + 7186, + 7096, + 7005, + 6914, + 6823, + 6731, + 6639, + 6547, + 6455, + 6363, + 6270, + 6177, + 6084, + 5990, + 5897, + 5803, + 5708, + 5614, + 5520, + 5425, + 5330, + 5235, + 5139, + 5044, + 4948, + 4852, + 4756, + 4660, + 4563, + 4467, + 4370, + 4273, + 4176, + 4078, + 3981, + 3883, + 3786, + 3688, + 3590, + 3492, + 3393, + 3295, + 3196, + 3098, + 2999, + 2900, + 2801, + 2702, + 2603, + 2503, + 2404, + 2305, + 2205, + 2105, + 2006, + 1906, + 1806, + 1706, + 1606, + 1506, + 1406, + 1306, + 1205, + 1105, + 1005, + 904, + 804, + 704, + 603, + 503, + 402, + 302, + 201, + 101, + 0, + -101, + -201, + -302, + -402, + -503, + -603, + -704, + -804, + -904, + -1005, + -1105, + -1205, + -1306, + -1406, + -1506, + -1606, + -1706, + -1806, + -1906, + -2006, + -2105, + -2205, + -2305, + -2404, + -2503, + -2603, + -2702, + -2801, + -2900, + -2999, + -3098, + -3196, + -3295, + -3393, + -3492, + -3590, + -3688, + -3786, + -3883, + -3981, + -4078, + -4176, + -4273, + -4370, + -4467, + -4563, + -4660, + -4756, + -4852, + -4948, + -5044, + -5139, + -5235, + -5330, + -5425, + -5520, + -5614, + -5708, + -5803, + -5897, + -5990, + -6084, + -6177, + -6270, + -6363, + -6455, + -6547, + -6639, + -6731, + -6823, + -6914, + -7005, + -7096, + -7186, + -7276, + -7366, + -7456, + -7545, + -7635, + -7723, + -7812, + -7900, + -7988, + -8076, + -8163, + -8250, + -8337, + -8423, + -8509, + -8595, + -8680, + -8765, + -8850, + -8935, + -9019, + -9102, + -9186, + -9269, + -9352, + -9434, + -9516, + -9598, + -9679, + -9760, + -9841, + -9921, + -10001, + -10080, + -10159, + -10238, + -10316, + -10394, + -10471, + -10549, + -10625, + -10702, + -10778, + -10853, + -10928, + -11003, + -11077, + -11151, + -11224, + -11297, + -11370, + -11442, + -11514, + -11585, + -11656, + -11727, + -11797, + -11866, + -11935, + -12004, + -12072, + -12140, + -12207, + -12274, + -12340, + -12406, + -12472, + -12537, + -12601, + -12665, + -12729, + -12792, + -12854, + -12916, + -12978, + -13039, + -13100, + -13160, + -13219, + -13279, + -13337, + -13395, + -13453, + -13510, + -13567, + -13623, + -13678, + -13733, + -13788, + -13842, + -13896, + -13949, + -14001, + -14053, + -14104, + -14155, + -14206, + -14256, + -14305, + -14354, + -14402, + -14449, + -14497, + -14543, + -14589, + -14635, + -14680, + -14724, + -14768, + -14811, + -14854, + -14896, + -14937, + -14978, + -15019, + -15059, + -15098, + -15137, + -15175, + -15213, + -15250, + -15286, + -15322, + -15357, + -15392, + -15426, + -15460, + -15493, + -15525, + -15557, + -15588, + -15619, + -15649, + -15679, + -15707, + -15736, + -15763, + -15791, + -15817, + -15843, + -15868, + -15893, + -15917, + -15941, + -15964, + -15986, + -16008, + -16029, + -16049, + -16069, + -16088, + -16107, + -16125, + -16143, + -16160, + -16176, + -16192, + -16207, + -16221, + -16235, + -16248, + -16261, + -16273, + -16284, + -16295, + -16305, + -16315, + -16324, + -16332, + -16340, + -16347, + -16353, + -16359, + -16364, + -16369, + -16373, + -16376, + -16379, + -16381, + -16383, + -16384, + -16384, + -16384, + -16383, + -16381, + -16379, + -16376, + -16373, + -16369, + -16364, + -16359, + -16353, + -16347, + -16340, + -16332, + -16324, + -16315, + -16305, + -16295, + -16284, + -16273, + -16261, + -16248, + -16235, + -16221, + -16207, + -16192, + -16176, + -16160, + -16143, + -16125, + -16107, + -16088, + -16069, + -16049, + -16029, + -16008, + -15986, + -15964, + -15941, + -15917, + -15893, + -15868, + -15843, + -15817, + -15791, + -15763, + -15736, + -15707, + -15679, + -15649, + -15619, + -15588, + -15557, + -15525, + -15493, + -15460, + -15426, + -15392, + -15357, + -15322, + -15286, + -15250, + -15213, + -15175, + -15137, + -15098, + -15059, + -15019, + -14978, + -14937, + -14896, + -14854, + -14811, + -14768, + -14724, + -14680, + -14635, + -14589, + -14543, + -14497, + -14449, + -14402, + -14354, + -14305, + -14256, + -14206, + -14155, + -14104, + -14053, + -14001, + -13949, + -13896, + -13842, + -13788, + -13733, + -13678, + -13623, + -13567, + -13510, + -13453, + -13395, + -13337, + -13279, + -13219, + -13160, + -13100, + -13039, + -12978, + -12916, + -12854, + -12792, + -12729, + -12665, + -12601, + -12537, + -12472, + -12406, + -12340, + -12274, + -12207, + -12140, + -12072, + -12004, + -11935, + -11866, + -11797, + -11727, + -11656, + -11585, + -11514, + -11442, + -11370, + -11297, + -11224, + -11151, + -11077, + -11003, + -10928, + -10853, + -10778, + -10702, + -10625, + -10549, + -10471, + -10394, + -10316, + -10238, + -10159, + -10080, + -10001, + -9921, + -9841, + -9760, + -9679, + -9598, + -9516, + -9434, + -9352, + -9269, + -9186, + -9102, + -9019, + -8935, + -8850, + -8765, + -8680, + -8595, + -8509, + -8423, + -8337, + -8250, + -8163, + -8076, + -7988, + -7900, + -7812, + -7723, + -7635, + -7545, + -7456, + -7366, + -7276, + -7186, + -7096, + -7005, + -6914, + -6823, + -6731, + -6639, + -6547, + -6455, + -6363, + -6270, + -6177, + -6084, + -5990, + -5897, + -5803, + -5708, + -5614, + -5520, + -5425, + -5330, + -5235, + -5139, + -5044, + -4948, + -4852, + -4756, + -4660, + -4563, + -4467, + -4370, + -4273, + -4176, + -4078, + -3981, + -3883, + -3786, + -3688, + -3590, + -3492, + -3393, + -3295, + -3196, + -3098, + -2999, + -2900, + -2801, + -2702, + -2603, + -2503, + -2404, + -2305, + -2205, + -2105, + -2006, + -1906, + -1806, + -1706, + -1606, + -1506, + -1406, + -1306, + -1205, + -1105, + -1005, + -904, + -804, + -704, + -603, + -503, + -402, + -302, + -201, + -101, }; } diff --git a/engines/twine/scene/animations.cpp b/engines/twine/scene/animations.cpp index 8f517035370..affec949f77 100644 --- a/engines/twine/scene/animations.cpp +++ b/engines/twine/scene/animations.cpp @@ -44,12 +44,12 @@ namespace TwinE { static const int32 magicLevelStrengthOfHit[] = { - MagicballStrengthType::kNoBallStrength, - MagicballStrengthType::kYellowBallStrength, - MagicballStrengthType::kGreenBallStrength, - MagicballStrengthType::kRedBallStrength, - MagicballStrengthType::kFireBallStrength, - 0}; + MagicballStrengthType::kNoBallStrength, + MagicballStrengthType::kYellowBallStrength, + MagicballStrengthType::kGreenBallStrength, + MagicballStrengthType::kRedBallStrength, + MagicballStrengthType::kFireBallStrength, + 0}; Animations::Animations(TwinEEngine *engine) : _engine(engine) { } diff --git a/engines/twine/scene/movements.cpp b/engines/twine/scene/movements.cpp index 9c0f55df185..790d5361215 100644 --- a/engines/twine/scene/movements.cpp +++ b/engines/twine/scene/movements.cpp @@ -77,15 +77,15 @@ void Movements::setActorAngle(int16 startAngle, int16 endAngle, int16 stepAngle, int32 Movements::getAngleAndSetTargetActorDistance(int32 x1, int32 z1, int32 x2, int32 z2) { /* //Pythagoras - targetActorDistance = (int32)sqrt((float)(((z2 - z1)*(z2 - z1) + (x2 - x1)*(x2 - x1)))); + targetActorDistance = (int32)sqrt((float)(((z2 - z1)*(z2 - z1) + (x2 - x1)*(x2 - x1)))); if (targetActorDistance == 0) - return 0; + return 0; - //given two points, we calculate its arc-tangent in radians - //Then we convert from radians (360 degrees == 2*M_PI) to a 10bit value (360 degrees == 1024) and invert the rotation direction - //Then we add an offset of 90 degrees (256) and limit it to the 10bit value range. - return (256 + ((int32)floor((-1024 * atan2((float)(z2-z1), (int32)(x2-x1))) / (2*M_PI)))) % 1024; + //given two points, we calculate its arc-tangent in radians + //Then we convert from radians (360 degrees == 2*M_PI) to a 10bit value (360 degrees == 1024) and invert the rotation direction + //Then we add an offset of 90 degrees (256) and limit it to the 10bit value range. + return (256 + ((int32)floor((-1024 * atan2((float)(z2-z1), (int32)(x2-x1))) / (2*M_PI)))) % 1024; */ int32 difZ = z2 - z1; diff --git a/engines/twine/script/script_life_v1.cpp b/engines/twine/script/script_life_v1.cpp index 2faef8bcb75..bbb5792d48f 100644 --- a/engines/twine/script/script_life_v1.cpp +++ b/engines/twine/script/script_life_v1.cpp @@ -1760,112 +1760,112 @@ static int32 lBRUTAL_EXIT(TwinEEngine *engine, LifeScriptContext &ctx) { } static const ScriptLifeFunction function_map[] = { - /*0x00*/ MAPFUNC("END", lEND), - /*0x01*/ MAPFUNC("NOP", lNOP), - /*0x02*/ MAPFUNC("SNIF", lSNIF), - /*0x03*/ MAPFUNC("OFFSET", lOFFSET), - /*0x04*/ MAPFUNC("NEVERIF", lNEVERIF), - /*0x05*/ MAPFUNC("", lEMPTY), // unused - /*0x06*/ MAPFUNC("NO_IF", lNO_IF), - /*0x07*/ MAPFUNC("", lEMPTY), // unused - /*0x08*/ MAPFUNC("", lEMPTY), // unused - /*0x09*/ MAPFUNC("", lEMPTY), // unused - /*0x0A*/ MAPFUNC("LABEL", lLABEL), - /*0x0B*/ MAPFUNC("RETURN", lRETURN), - /*0x0C*/ MAPFUNC("IF", lIF), - /*0x0D*/ MAPFUNC("SWIF", lSWIF), - /*0x0E*/ MAPFUNC("ONEIF", lONEIF), - /*0x0F*/ MAPFUNC("ELSE", lELSE), - /*0x10*/ MAPFUNC("ENDIF", lEMPTY), // End of a conditional statement (e.g. IF) - /*0x11*/ MAPFUNC("BODY", lBODY), - /*0x12*/ MAPFUNC("BODY_OBJ", lBODY_OBJ), - /*0x13*/ MAPFUNC("ANIM", lANIM), - /*0x14*/ MAPFUNC("ANIM_OBJ", lANIM_OBJ), - /*0x15*/ MAPFUNC("SET_LIFE", lSET_LIFE), - /*0x16*/ MAPFUNC("SET_LIFE_OBJ", lSET_LIFE_OBJ), - /*0x17*/ MAPFUNC("SET_TRACK", lSET_TRACK), - /*0x18*/ MAPFUNC("SET_TRACK_OBJ", lSET_TRACK_OBJ), - /*0x19*/ MAPFUNC("MESSAGE", lMESSAGE), - /*0x1A*/ MAPFUNC("FALLABLE", lFALLABLE), - /*0x1B*/ MAPFUNC("SET_DIRMODE", lSET_DIRMODE), - /*0x1C*/ MAPFUNC("SET_DIRMODE_OBJ", lSET_DIRMODE_OBJ), - /*0x1D*/ MAPFUNC("CAM_FOLLOW", lCAM_FOLLOW), - /*0x1E*/ MAPFUNC("SET_BEHAVIOUR", lSET_BEHAVIOUR), - /*0x1F*/ MAPFUNC("SET_FLAG_CUBE", lSET_FLAG_CUBE), - /*0x20*/ MAPFUNC("COMPORTEMENT", lCOMPORTEMENT), - /*0x21*/ MAPFUNC("SET_COMPORTEMENT", lSET_COMPORTEMENT), - /*0x22*/ MAPFUNC("SET_COMPORTEMENT_OBJ", lSET_COMPORTEMENT_OBJ), - /*0x23*/ MAPFUNC("END_COMPORTEMENT", lEND_COMPORTEMENT), - /*0x24*/ MAPFUNC("SET_FLAG_GAME", lSET_FLAG_GAME), - /*0x25*/ MAPFUNC("KILL_OBJ", lKILL_OBJ), - /*0x26*/ MAPFUNC("SUICIDE", lSUICIDE), - /*0x27*/ MAPFUNC("USE_ONE_LITTLE_KEY", lUSE_ONE_LITTLE_KEY), - /*0x28*/ MAPFUNC("GIVE_GOLD_PIECES", lGIVE_GOLD_PIECES), - /*0x29*/ MAPFUNC("END_LIFE", lEND_LIFE), - /*0x2A*/ MAPFUNC("STOP_L_TRACK", lSTOP_L_TRACK), - /*0x2B*/ MAPFUNC("RESTORE_L_TRACK", lRESTORE_L_TRACK), - /*0x2C*/ MAPFUNC("MESSAGE_OBJ", lMESSAGE_OBJ), - /*0x2D*/ MAPFUNC("INC_CHAPTER", lINC_CHAPTER), - /*0x2E*/ MAPFUNC("FOUND_OBJECT", lFOUND_OBJECT), - /*0x2F*/ MAPFUNC("SET_DOOR_LEFT", lSET_DOOR_LEFT), - /*0x30*/ MAPFUNC("SET_DOOR_RIGHT", lSET_DOOR_RIGHT), - /*0x31*/ MAPFUNC("SET_DOOR_UP", lSET_DOOR_UP), - /*0x32*/ MAPFUNC("SET_DOOR_DOWN", lSET_DOOR_DOWN), - /*0x33*/ MAPFUNC("GIVE_BONUS", lGIVE_BONUS), - /*0x34*/ MAPFUNC("CHANGE_CUBE", lCHANGE_CUBE), - /*0x35*/ MAPFUNC("OBJ_COL", lOBJ_COL), - /*0x36*/ MAPFUNC("BRICK_COL", lBRICK_COL), - /*0x37*/ MAPFUNC("OR_IF", lOR_IF), - /*0x38*/ MAPFUNC("INVISIBLE", lINVISIBLE), - /*0x39*/ MAPFUNC("ZOOM", lZOOM), - /*0x3A*/ MAPFUNC("POS_POINT", lPOS_POINT), - /*0x3B*/ MAPFUNC("SET_MAGIC_LEVEL", lSET_MAGIC_LEVEL), - /*0x3C*/ MAPFUNC("SUB_MAGIC_POINT", lSUB_MAGIC_POINT), - /*0x3D*/ MAPFUNC("SET_LIFE_POINT_OBJ", lSET_LIFE_POINT_OBJ), - /*0x3E*/ MAPFUNC("SUB_LIFE_POINT_OBJ", lSUB_LIFE_POINT_OBJ), - /*0x3F*/ MAPFUNC("HIT_OBJ", lHIT_OBJ), - /*0x40*/ MAPFUNC("PLAY_FLA", lPLAY_FLA), - /*0x41*/ MAPFUNC("PLAY_MIDI", lPLAY_MIDI), - /*0x42*/ MAPFUNC("INC_CLOVER_BOX", lINC_CLOVER_BOX), - /*0x43*/ MAPFUNC("SET_USED_INVENTORY", lSET_USED_INVENTORY), - /*0x44*/ MAPFUNC("ADD_CHOICE", lADD_CHOICE), - /*0x45*/ MAPFUNC("ASK_CHOICE", lASK_CHOICE), - /*0x46*/ MAPFUNC("BIG_MESSAGE", lBIG_MESSAGE), - /*0x47*/ MAPFUNC("INIT_PINGOUIN", lINIT_PINGOUIN), - /*0x48*/ MAPFUNC("SET_HOLO_POS", lSET_HOLO_POS), - /*0x49*/ MAPFUNC("CLR_HOLO_POS", lCLR_HOLO_POS), - /*0x4A*/ MAPFUNC("ADD_FUEL", lADD_FUEL), - /*0x4B*/ MAPFUNC("SUB_FUEL", lSUB_FUEL), - /*0x4C*/ MAPFUNC("SET_GRM", lSET_GRM), - /*0x4D*/ MAPFUNC("SAY_MESSAGE", lSAY_MESSAGE), - /*0x4E*/ MAPFUNC("SAY_MESSAGE_OBJ", lSAY_MESSAGE_OBJ), - /*0x4F*/ MAPFUNC("FULL_POINT", lFULL_POINT), - /*0x50*/ MAPFUNC("BETA", lBETA), - /*0x51*/ MAPFUNC("GRM_OFF", lGRM_OFF), - /*0x52*/ MAPFUNC("FADE_PAL_RED", lFADE_PAL_RED), - /*0x53*/ MAPFUNC("FADE_ALARM_RED", lFADE_ALARM_RED), - /*0x54*/ MAPFUNC("FADE_ALARM_PAL", lFADE_ALARM_PAL), - /*0x55*/ MAPFUNC("FADE_RED_PAL", lFADE_RED_PAL), - /*0x56*/ MAPFUNC("FADE_RED_ALARM", lFADE_RED_ALARM), - /*0x57*/ MAPFUNC("FADE_PAL_ALARM", lFADE_PAL_ALARM), - /*0x58*/ MAPFUNC("EXPLODE_OBJ", lEXPLODE_OBJ), - /*0x59*/ MAPFUNC("BUBBLE_ON", lBUBBLE_ON), - /*0x5A*/ MAPFUNC("BUBBLE_OFF", lBUBBLE_OFF), - /*0x5B*/ MAPFUNC("ASK_CHOICE_OBJ", lASK_CHOICE_OBJ), - /*0x5C*/ MAPFUNC("SET_DARK_PAL", lSET_DARK_PAL), - /*0x5D*/ MAPFUNC("SET_NORMAL_PAL", lSET_NORMAL_PAL), - /*0x5E*/ MAPFUNC("MESSAGE_SENDELL", lMESSAGE_SENDELL), - /*0x5F*/ MAPFUNC("ANIM_SET", lANIM_SET), - /*0x60*/ MAPFUNC("HOLOMAP_TRAJ", lHOLOMAP_TRAJ), - /*0x61*/ MAPFUNC("GAME_OVER", lGAME_OVER), - /*0x62*/ MAPFUNC("THE_END", lTHE_END), - /*0x63*/ MAPFUNC("MIDI_OFF", lMIDI_OFF), - /*0x64*/ MAPFUNC("PLAY_CD_TRACK", lPLAY_CD_TRACK), - /*0x65*/ MAPFUNC("PROJ_ISO", lPROJ_ISO), - /*0x66*/ MAPFUNC("PROJ_3D", lPROJ_3D), - /*0x67*/ MAPFUNC("TEXT", lTEXT), - /*0x68*/ MAPFUNC("CLEAR_TEXT", lCLEAR_TEXT), - /*0x69*/ MAPFUNC("BRUTAL_EXIT", lBRUTAL_EXIT)}; + /*0x00*/ MAPFUNC("END", lEND), + /*0x01*/ MAPFUNC("NOP", lNOP), + /*0x02*/ MAPFUNC("SNIF", lSNIF), + /*0x03*/ MAPFUNC("OFFSET", lOFFSET), + /*0x04*/ MAPFUNC("NEVERIF", lNEVERIF), + /*0x05*/ MAPFUNC("", lEMPTY), // unused + /*0x06*/ MAPFUNC("NO_IF", lNO_IF), + /*0x07*/ MAPFUNC("", lEMPTY), // unused + /*0x08*/ MAPFUNC("", lEMPTY), // unused + /*0x09*/ MAPFUNC("", lEMPTY), // unused + /*0x0A*/ MAPFUNC("LABEL", lLABEL), + /*0x0B*/ MAPFUNC("RETURN", lRETURN), + /*0x0C*/ MAPFUNC("IF", lIF), + /*0x0D*/ MAPFUNC("SWIF", lSWIF), + /*0x0E*/ MAPFUNC("ONEIF", lONEIF), + /*0x0F*/ MAPFUNC("ELSE", lELSE), + /*0x10*/ MAPFUNC("ENDIF", lEMPTY), // End of a conditional statement (e.g. IF) + /*0x11*/ MAPFUNC("BODY", lBODY), + /*0x12*/ MAPFUNC("BODY_OBJ", lBODY_OBJ), + /*0x13*/ MAPFUNC("ANIM", lANIM), + /*0x14*/ MAPFUNC("ANIM_OBJ", lANIM_OBJ), + /*0x15*/ MAPFUNC("SET_LIFE", lSET_LIFE), + /*0x16*/ MAPFUNC("SET_LIFE_OBJ", lSET_LIFE_OBJ), + /*0x17*/ MAPFUNC("SET_TRACK", lSET_TRACK), + /*0x18*/ MAPFUNC("SET_TRACK_OBJ", lSET_TRACK_OBJ), + /*0x19*/ MAPFUNC("MESSAGE", lMESSAGE), + /*0x1A*/ MAPFUNC("FALLABLE", lFALLABLE), + /*0x1B*/ MAPFUNC("SET_DIRMODE", lSET_DIRMODE), + /*0x1C*/ MAPFUNC("SET_DIRMODE_OBJ", lSET_DIRMODE_OBJ), + /*0x1D*/ MAPFUNC("CAM_FOLLOW", lCAM_FOLLOW), + /*0x1E*/ MAPFUNC("SET_BEHAVIOUR", lSET_BEHAVIOUR), + /*0x1F*/ MAPFUNC("SET_FLAG_CUBE", lSET_FLAG_CUBE), + /*0x20*/ MAPFUNC("COMPORTEMENT", lCOMPORTEMENT), + /*0x21*/ MAPFUNC("SET_COMPORTEMENT", lSET_COMPORTEMENT), + /*0x22*/ MAPFUNC("SET_COMPORTEMENT_OBJ", lSET_COMPORTEMENT_OBJ), + /*0x23*/ MAPFUNC("END_COMPORTEMENT", lEND_COMPORTEMENT), + /*0x24*/ MAPFUNC("SET_FLAG_GAME", lSET_FLAG_GAME), + /*0x25*/ MAPFUNC("KILL_OBJ", lKILL_OBJ), + /*0x26*/ MAPFUNC("SUICIDE", lSUICIDE), + /*0x27*/ MAPFUNC("USE_ONE_LITTLE_KEY", lUSE_ONE_LITTLE_KEY), + /*0x28*/ MAPFUNC("GIVE_GOLD_PIECES", lGIVE_GOLD_PIECES), + /*0x29*/ MAPFUNC("END_LIFE", lEND_LIFE), + /*0x2A*/ MAPFUNC("STOP_L_TRACK", lSTOP_L_TRACK), + /*0x2B*/ MAPFUNC("RESTORE_L_TRACK", lRESTORE_L_TRACK), + /*0x2C*/ MAPFUNC("MESSAGE_OBJ", lMESSAGE_OBJ), + /*0x2D*/ MAPFUNC("INC_CHAPTER", lINC_CHAPTER), + /*0x2E*/ MAPFUNC("FOUND_OBJECT", lFOUND_OBJECT), + /*0x2F*/ MAPFUNC("SET_DOOR_LEFT", lSET_DOOR_LEFT), + /*0x30*/ MAPFUNC("SET_DOOR_RIGHT", lSET_DOOR_RIGHT), + /*0x31*/ MAPFUNC("SET_DOOR_UP", lSET_DOOR_UP), + /*0x32*/ MAPFUNC("SET_DOOR_DOWN", lSET_DOOR_DOWN), + /*0x33*/ MAPFUNC("GIVE_BONUS", lGIVE_BONUS), + /*0x34*/ MAPFUNC("CHANGE_CUBE", lCHANGE_CUBE), + /*0x35*/ MAPFUNC("OBJ_COL", lOBJ_COL), + /*0x36*/ MAPFUNC("BRICK_COL", lBRICK_COL), + /*0x37*/ MAPFUNC("OR_IF", lOR_IF), + /*0x38*/ MAPFUNC("INVISIBLE", lINVISIBLE), + /*0x39*/ MAPFUNC("ZOOM", lZOOM), + /*0x3A*/ MAPFUNC("POS_POINT", lPOS_POINT), + /*0x3B*/ MAPFUNC("SET_MAGIC_LEVEL", lSET_MAGIC_LEVEL), + /*0x3C*/ MAPFUNC("SUB_MAGIC_POINT", lSUB_MAGIC_POINT), + /*0x3D*/ MAPFUNC("SET_LIFE_POINT_OBJ", lSET_LIFE_POINT_OBJ), + /*0x3E*/ MAPFUNC("SUB_LIFE_POINT_OBJ", lSUB_LIFE_POINT_OBJ), + /*0x3F*/ MAPFUNC("HIT_OBJ", lHIT_OBJ), + /*0x40*/ MAPFUNC("PLAY_FLA", lPLAY_FLA), + /*0x41*/ MAPFUNC("PLAY_MIDI", lPLAY_MIDI), + /*0x42*/ MAPFUNC("INC_CLOVER_BOX", lINC_CLOVER_BOX), + /*0x43*/ MAPFUNC("SET_USED_INVENTORY", lSET_USED_INVENTORY), + /*0x44*/ MAPFUNC("ADD_CHOICE", lADD_CHOICE), + /*0x45*/ MAPFUNC("ASK_CHOICE", lASK_CHOICE), + /*0x46*/ MAPFUNC("BIG_MESSAGE", lBIG_MESSAGE), + /*0x47*/ MAPFUNC("INIT_PINGOUIN", lINIT_PINGOUIN), + /*0x48*/ MAPFUNC("SET_HOLO_POS", lSET_HOLO_POS), + /*0x49*/ MAPFUNC("CLR_HOLO_POS", lCLR_HOLO_POS), + /*0x4A*/ MAPFUNC("ADD_FUEL", lADD_FUEL), + /*0x4B*/ MAPFUNC("SUB_FUEL", lSUB_FUEL), + /*0x4C*/ MAPFUNC("SET_GRM", lSET_GRM), + /*0x4D*/ MAPFUNC("SAY_MESSAGE", lSAY_MESSAGE), + /*0x4E*/ MAPFUNC("SAY_MESSAGE_OBJ", lSAY_MESSAGE_OBJ), + /*0x4F*/ MAPFUNC("FULL_POINT", lFULL_POINT), + /*0x50*/ MAPFUNC("BETA", lBETA), + /*0x51*/ MAPFUNC("GRM_OFF", lGRM_OFF), + /*0x52*/ MAPFUNC("FADE_PAL_RED", lFADE_PAL_RED), + /*0x53*/ MAPFUNC("FADE_ALARM_RED", lFADE_ALARM_RED), + /*0x54*/ MAPFUNC("FADE_ALARM_PAL", lFADE_ALARM_PAL), + /*0x55*/ MAPFUNC("FADE_RED_PAL", lFADE_RED_PAL), + /*0x56*/ MAPFUNC("FADE_RED_ALARM", lFADE_RED_ALARM), + /*0x57*/ MAPFUNC("FADE_PAL_ALARM", lFADE_PAL_ALARM), + /*0x58*/ MAPFUNC("EXPLODE_OBJ", lEXPLODE_OBJ), + /*0x59*/ MAPFUNC("BUBBLE_ON", lBUBBLE_ON), + /*0x5A*/ MAPFUNC("BUBBLE_OFF", lBUBBLE_OFF), + /*0x5B*/ MAPFUNC("ASK_CHOICE_OBJ", lASK_CHOICE_OBJ), + /*0x5C*/ MAPFUNC("SET_DARK_PAL", lSET_DARK_PAL), + /*0x5D*/ MAPFUNC("SET_NORMAL_PAL", lSET_NORMAL_PAL), + /*0x5E*/ MAPFUNC("MESSAGE_SENDELL", lMESSAGE_SENDELL), + /*0x5F*/ MAPFUNC("ANIM_SET", lANIM_SET), + /*0x60*/ MAPFUNC("HOLOMAP_TRAJ", lHOLOMAP_TRAJ), + /*0x61*/ MAPFUNC("GAME_OVER", lGAME_OVER), + /*0x62*/ MAPFUNC("THE_END", lTHE_END), + /*0x63*/ MAPFUNC("MIDI_OFF", lMIDI_OFF), + /*0x64*/ MAPFUNC("PLAY_CD_TRACK", lPLAY_CD_TRACK), + /*0x65*/ MAPFUNC("PROJ_ISO", lPROJ_ISO), + /*0x66*/ MAPFUNC("PROJ_3D", lPROJ_3D), + /*0x67*/ MAPFUNC("TEXT", lTEXT), + /*0x68*/ MAPFUNC("CLEAR_TEXT", lCLEAR_TEXT), + /*0x69*/ MAPFUNC("BRUTAL_EXIT", lBRUTAL_EXIT)}; ScriptLife::ScriptLife(TwinEEngine *engine) : _engine(engine) { lTextYPos = 0; diff --git a/engines/twine/script/script_move_v1.cpp b/engines/twine/script/script_move_v1.cpp index 80b3fa6dfc6..a64c93dd485 100644 --- a/engines/twine/script/script_move_v1.cpp +++ b/engines/twine/script/script_move_v1.cpp @@ -674,41 +674,41 @@ static int32 mANGLE_RND(TwinEEngine *engine, MoveScriptContext &ctx) { } static const ScriptMoveFunction function_map[] = { - /*0x00*/ MAPFUNC("END", mEND), - /*0x01*/ MAPFUNC("NOP", mNOP), - /*0x02*/ MAPFUNC("BODY", mBODY), - /*0x03*/ MAPFUNC("ANIM", mANIM), - /*0x04*/ MAPFUNC("GOTO_POINT", mGOTO_POINT), - /*0x05*/ MAPFUNC("WAIT_ANIM", mWAIT_ANIM), - /*0x06*/ MAPFUNC("LOOP", mLOOP), - /*0x07*/ MAPFUNC("ANGLE", mANGLE), - /*0x08*/ MAPFUNC("POS_POINT", mPOS_POINT), - /*0x09*/ MAPFUNC("LABEL", mLABEL), - /*0x0A*/ MAPFUNC("GOTO", mGOTO), - /*0x0B*/ MAPFUNC("STOP", mSTOP), - /*0x0C*/ MAPFUNC("GOTO_SYM_POINT", mGOTO_SYM_POINT), - /*0x0D*/ MAPFUNC("WAIT_NUM_ANIM", mWAIT_NUM_ANIM), - /*0x0E*/ MAPFUNC("SAMPLE", mSAMPLE), - /*0x0F*/ MAPFUNC("GOTO_POINT_3D", mGOTO_POINT_3D), - /*0x10*/ MAPFUNC("SPEED", mSPEED), - /*0x11*/ MAPFUNC("BACKGROUND", mBACKGROUND), - /*0x12*/ MAPFUNC("WAIT_NUM_SECOND", mWAIT_NUM_SECOND), - /*0x13*/ MAPFUNC("NO_BODY", mNO_BODY), - /*0x14*/ MAPFUNC("BETA", mBETA), - /*0x15*/ MAPFUNC("OPEN_LEFT", mOPEN_LEFT), - /*0x16*/ MAPFUNC("OPEN_RIGHT", mOPEN_RIGHT), - /*0x17*/ MAPFUNC("OPEN_UP", mOPEN_UP), - /*0x18*/ MAPFUNC("OPEN_DOWN", mOPEN_DOWN), - /*0x19*/ MAPFUNC("CLOSE", mCLOSE), - /*0x1A*/ MAPFUNC("WAIT_DOOR", mWAIT_DOOR), - /*0x1B*/ MAPFUNC("SAMPLE_RND", mSAMPLE_RND), - /*0x1C*/ MAPFUNC("SAMPLE_ALWAYS", mSAMPLE_ALWAYS), - /*0x1D*/ MAPFUNC("SAMPLE_STOP", mSAMPLE_STOP), - /*0x1E*/ MAPFUNC("PLAY_FLA", mPLAY_FLA), - /*0x1F*/ MAPFUNC("REPEAT_SAMPLE", mREPEAT_SAMPLE), - /*0x20*/ MAPFUNC("SIMPLE_SAMPLE", mSIMPLE_SAMPLE), - /*0x21*/ MAPFUNC("FACE_HERO", mFACE_HERO), - /*0x22*/ MAPFUNC("ANGLE_RND", mANGLE_RND)}; + /*0x00*/ MAPFUNC("END", mEND), + /*0x01*/ MAPFUNC("NOP", mNOP), + /*0x02*/ MAPFUNC("BODY", mBODY), + /*0x03*/ MAPFUNC("ANIM", mANIM), + /*0x04*/ MAPFUNC("GOTO_POINT", mGOTO_POINT), + /*0x05*/ MAPFUNC("WAIT_ANIM", mWAIT_ANIM), + /*0x06*/ MAPFUNC("LOOP", mLOOP), + /*0x07*/ MAPFUNC("ANGLE", mANGLE), + /*0x08*/ MAPFUNC("POS_POINT", mPOS_POINT), + /*0x09*/ MAPFUNC("LABEL", mLABEL), + /*0x0A*/ MAPFUNC("GOTO", mGOTO), + /*0x0B*/ MAPFUNC("STOP", mSTOP), + /*0x0C*/ MAPFUNC("GOTO_SYM_POINT", mGOTO_SYM_POINT), + /*0x0D*/ MAPFUNC("WAIT_NUM_ANIM", mWAIT_NUM_ANIM), + /*0x0E*/ MAPFUNC("SAMPLE", mSAMPLE), + /*0x0F*/ MAPFUNC("GOTO_POINT_3D", mGOTO_POINT_3D), + /*0x10*/ MAPFUNC("SPEED", mSPEED), + /*0x11*/ MAPFUNC("BACKGROUND", mBACKGROUND), + /*0x12*/ MAPFUNC("WAIT_NUM_SECOND", mWAIT_NUM_SECOND), + /*0x13*/ MAPFUNC("NO_BODY", mNO_BODY), + /*0x14*/ MAPFUNC("BETA", mBETA), + /*0x15*/ MAPFUNC("OPEN_LEFT", mOPEN_LEFT), + /*0x16*/ MAPFUNC("OPEN_RIGHT", mOPEN_RIGHT), + /*0x17*/ MAPFUNC("OPEN_UP", mOPEN_UP), + /*0x18*/ MAPFUNC("OPEN_DOWN", mOPEN_DOWN), + /*0x19*/ MAPFUNC("CLOSE", mCLOSE), + /*0x1A*/ MAPFUNC("WAIT_DOOR", mWAIT_DOOR), + /*0x1B*/ MAPFUNC("SAMPLE_RND", mSAMPLE_RND), + /*0x1C*/ MAPFUNC("SAMPLE_ALWAYS", mSAMPLE_ALWAYS), + /*0x1D*/ MAPFUNC("SAMPLE_STOP", mSAMPLE_STOP), + /*0x1E*/ MAPFUNC("PLAY_FLA", mPLAY_FLA), + /*0x1F*/ MAPFUNC("REPEAT_SAMPLE", mREPEAT_SAMPLE), + /*0x20*/ MAPFUNC("SIMPLE_SAMPLE", mSIMPLE_SAMPLE), + /*0x21*/ MAPFUNC("FACE_HERO", mFACE_HERO), + /*0x22*/ MAPFUNC("ANGLE_RND", mANGLE_RND)}; ScriptMove::ScriptMove(TwinEEngine *engine) : _engine(engine) { } diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp index 6f1b6be80bb..5891f90cee4 100644 --- a/engines/twine/twine.cpp +++ b/engines/twine/twine.cpp @@ -114,7 +114,7 @@ FrameMarker::~FrameMarker() { } TwinEEngine::TwinEEngine(OSystem *system, Common::Language language, uint32 flags, TwineGameType gameType) - : Engine(system), _gameType(gameType), _gameLang(language), _gameFlags(flags), _rnd("twine") { + : Engine(system), _gameType(gameType), _gameLang(language), _gameFlags(flags), _rnd("twine") { // Add default file directories const Common::FSNode gameDataDir(ConfMan.get("path")); SearchMan.addSubDirectoryMatching(gameDataDir, "fla"); diff --git a/engines/twine/twine.h b/engines/twine/twine.h index fbe9506aee4..b095894e614 100644 --- a/engines/twine/twine.h +++ b/engines/twine/twine.h @@ -56,12 +56,12 @@ static const struct TwinELanguage { const char *name; const char *id; } LanguageTypes[] = { - {"English", "EN_"}, - {"French", "FR_"}, - {"German", "DE_"}, - {"Spanish", "SP_"}, - {"Italian", "IT_"}, - {"Portuguese", ""}}; + {"English", "EN_"}, + {"French", "FR_"}, + {"German", "DE_"}, + {"Spanish", "SP_"}, + {"Italian", "IT_"}, + {"Portuguese", ""}}; enum MidiFileType { MIDIFILE_NONE, diff --git a/engines/ultima/detection.cpp b/engines/ultima/detection.cpp index a537f976071..e61303e3415 100644 --- a/engines/ultima/detection.cpp +++ b/engines/ultima/detection.cpp @@ -58,7 +58,7 @@ static const ADExtraGuiOptionsMap optionsList[] = { false } }, - AD_EXTRA_GUI_OPTIONS_TERMINATOR + AD_EXTRA_GUI_OPTIONS_TERMINATOR }; } // End of namespace Ultima diff --git a/engines/ultima/nuvie/actors/actor.cpp b/engines/ultima/nuvie/actors/actor.cpp index 32952a05327..2d2aca29873 100644 --- a/engines/ultima/nuvie/actors/actor.cpp +++ b/engines/ultima/nuvie/actors/actor.cpp @@ -1311,15 +1311,15 @@ uint16 Actor::getSchedulePos(uint8 hour, uint8 day_of_week) for(j=i;sched[j] != NULL && sched[j]->hour == sched[i]->hour;j++) { if(sched[j]->day_of_week > day_of_week) - { - if(j != i) - return j-1; - else // hour is in the last schedule entry. - { - for(;sched[j+1] != NULL && sched[j+1]->hour == sched[i]->hour;) // move to the last schedule entry. - j++; - } - } + { + if(j != i) + return j-1; + else // hour is in the last schedule entry. + { + for(;sched[j+1] != NULL && sched[j+1]->hour == sched[i]->hour;) // move to the last schedule entry. + j++; + } + } } if(j==i) @@ -1336,32 +1336,32 @@ inline uint16 Actor::getSchedulePos(uint8 hour) for(i=0;sched[i] != NULL;i++) { if(sched[i]->hour > hour) - { - if(i != 0) - return i-1; - else // hour is in the last schedule entry. - { - for(;sched[i+1] != NULL;) // move to the last schedule entry. - i++; + { + if(i != 0) + return i-1; + else // hour is in the last schedule entry. + { + for(;sched[i+1] != NULL;) // move to the last schedule entry. + i++; - if(sched[i]->day_of_week > 0) //rewind to the start of the hour set. - { - cur_hour = sched[i]->hour; - for(;i >= 1 && sched[i-1]->hour == cur_hour;) - i--; - } - } - } + if(sched[i]->day_of_week > 0) //rewind to the start of the hour set. + { + cur_hour = sched[i]->hour; + for(;i >= 1 && sched[i-1]->hour == cur_hour;) + i--; + } + } + } else - for(;sched[i+1] != NULL && sched[i+1]->hour == sched[i]->hour;) //skip to next hour set. - i++; + for(;sched[i+1] != NULL && sched[i+1]->hour == sched[i]->hour;) //skip to next hour set. + i++; } if(sched[i] != NULL && sched[i]->day_of_week > 0) //rewind to the start of the hour set. { - cur_hour = sched[i]->hour; - for(;i >= 1 && sched[i-1]->hour == cur_hour;) - i--; + cur_hour = sched[i]->hour; + for(;i >= 1 && sched[i-1]->hour == cur_hour;) + i--; } if(i==0) diff --git a/engines/ultima/nuvie/actors/u6_actor.cpp b/engines/ultima/nuvie/actors/u6_actor.cpp index d6814deb21a..881d37b99f8 100644 --- a/engines/ultima/nuvie/actors/u6_actor.cpp +++ b/engines/ultima/nuvie/actors/u6_actor.cpp @@ -923,21 +923,21 @@ void U6Actor::setup_walk_to_location() { if(NUVIE_RAND()%8 == 1) { - new_direction = NUVIE_RAND()%4; + new_direction = NUVIE_RAND()%4; - switch(new_direction) - { - case NUVIE_DIR_N : rel_y = -1; break; - case NUVIE_DIR_E : rel_x = 1; break; - case NUVIE_DIR_S : rel_y = 1; break; - case NUVIE_DIR_W : rel_x = -1; break; - } + switch(new_direction) + { + case NUVIE_DIR_N : rel_y = -1; break; + case NUVIE_DIR_E : rel_x = 1; break; + case NUVIE_DIR_S : rel_y = 1; break; + case NUVIE_DIR_W : rel_x = -1; break; + } - if(obj_manager->get_obj_of_type_from_location(OBJ_U6_FENCE,x + rel_x, y + rel_y, z) == NULL) - { - if(moveRelative(rel_x,rel_y)) - set_direction(new_direction); - } + if(obj_manager->get_obj_of_type_from_location(OBJ_U6_FENCE,x + rel_x, y + rel_y, z) == NULL) + { + if(moveRelative(rel_x,rel_y)) + set_direction(new_direction); + } } else set_moves_left(moves - 5); diff --git a/engines/ultima/nuvie/conf/configuration.cpp b/engines/ultima/nuvie/conf/configuration.cpp index f2ef7c010c0..2008a89ff7c 100644 --- a/engines/ultima/nuvie/conf/configuration.cpp +++ b/engines/ultima/nuvie/conf/configuration.cpp @@ -52,7 +52,7 @@ Configuration::~Configuration() { } bool Configuration::readConfigFile(Std::string fname, Std::string root, - bool readonly) { + bool readonly) { _configFilename = fname; Shared::XMLTree *tree = new Shared::XMLTree(); @@ -82,7 +82,7 @@ void Configuration::clear() { } void Configuration::value(const Std::string &key, Std::string &ret, - const char *defaultvalue) { + const char *defaultvalue) { // Check for a .cfg file value in the trees for (Std::vector::reverse_iterator i = _trees.rbegin(); i != _trees.rend(); ++i) { diff --git a/engines/ultima/nuvie/conf/configuration.h b/engines/ultima/nuvie/conf/configuration.h index a5b396b55d4..e7d56b03213 100644 --- a/engines/ultima/nuvie/conf/configuration.h +++ b/engines/ultima/nuvie/conf/configuration.h @@ -62,15 +62,15 @@ class ConfigNode; class Configuration { private: Std::vector _trees; - Common::HashMap _localKeys; + Common::HashMap _localKeys; Common::HashMap _settings; Std::string _configFilename; - bool _configChanged; + bool _configChanged; - // Sets default configurations common to both enhanced and unhenaced - void setCommonDefaults(GameId gameType); + // Sets default configurations common to both enhanced and unhenaced + void setCommonDefaults(GameId gameType); // sets up unenhanced version defaults void setUnenhancedDefaults(GameId gameType); @@ -84,8 +84,8 @@ public: // read config file. Multiple files may be read. Order is important. bool readConfigFile(Std::string fname, Std::string root, bool readonly = true); - // Returns true if default settings for game have previously been set - bool isDefaultsSet() const; + // Returns true if default settings for game have previously been set + bool isDefaultsSet() const; // Loads up the configuration settings void load(GameId gameId, bool isEnhanced); diff --git a/engines/ultima/nuvie/core/anim_manager.cpp b/engines/ultima/nuvie/core/anim_manager.cpp index 847c954aded..d1c845b8287 100644 --- a/engines/ultima/nuvie/core/anim_manager.cpp +++ b/engines/ultima/nuvie/core/anim_manager.cpp @@ -215,7 +215,7 @@ void AnimManager::drawText(Font *font, const char *text, uint16 x, uint16 y) { /* Draw tile on viewsurf at map location wx,wy (offset by add_x,add_y). */ void AnimManager::drawTileAtWorldCoords(Tile *tile, uint16 wx, uint16 wy, - uint16 add_x, uint16 add_y) { + uint16 add_x, uint16 add_y) { sint16 cur_x = map_window->cur_x; sint16 cur_y = map_window->cur_y; drawTile(tile, ((wx - cur_x) * tile_pitch) + add_x, @@ -328,7 +328,7 @@ void TileAnim::display() { /* Add tile to list for this Anim, relative to the Anim coordinates. */ PositionedTile *TileAnim::add_tile(Tile *tile, sint16 x, sint16 y, - uint16 add_x, uint16 add_y) { + uint16 add_x, uint16 add_y) { PositionedTile *new_tile = new PositionedTile; new_tile->tile = tile; new_tile->pos_x = x; diff --git a/engines/ultima/nuvie/core/converse.cpp b/engines/ultima/nuvie/core/converse.cpp index 0426026d9af..72ea84bc17f 100644 --- a/engines/ultima/nuvie/core/converse.cpp +++ b/engines/ultima/nuvie/core/converse.cpp @@ -80,7 +80,7 @@ Converse::Converse() { */ void Converse::init(Configuration *cfg, nuvie_game_t t, MsgScroll *s, ActorManager *a, - GameClock *c, Player *p, ViewManager *v, ObjManager *o) { + GameClock *c, Player *p, ViewManager *v, ObjManager *o) { Std::string townsdir; config = cfg; diff --git a/engines/ultima/nuvie/core/debugger.h b/engines/ultima/nuvie/core/debugger.h index 8cf5c88956a..0bc75e3cd7d 100644 --- a/engines/ultima/nuvie/core/debugger.h +++ b/engines/ultima/nuvie/core/debugger.h @@ -34,7 +34,7 @@ namespace Nuvie { class Debugger : public Shared::Debugger { public: Debugger(); - ~Debugger() override {} + ~Debugger() override {} }; } // End of namespace Nuvie diff --git a/engines/ultima/nuvie/core/effect.cpp b/engines/ultima/nuvie/core/effect.cpp index 48999c509e9..5a5e2e19372 100644 --- a/engines/ultima/nuvie/core/effect.cpp +++ b/engines/ultima/nuvie/core/effect.cpp @@ -722,8 +722,8 @@ void DropEffect::hit_target() { /*** MissileEffect ***/ MissileEffect::MissileEffect(uint16 tile_num, uint16 obj_n, const MapCoord &source, - const MapCoord &target, uint8 dmg, - uint8 intercept, uint16 speed) { + const MapCoord &target, uint8 dmg, + uint8 intercept, uint16 speed) { actor_manager = game->get_actor_manager(); hit_actor = 0; hit_obj = 0; @@ -733,8 +733,8 @@ MissileEffect::MissileEffect(uint16 tile_num, uint16 obj_n, const MapCoord &sour /* Start effect. If target is unset then the actor is the target. */ void MissileEffect::init(uint16 tile_num, uint16 obj_n, - const MapCoord &source, const MapCoord &target, - uint32 dmg, uint8 intercept, uint32 speed) { + const MapCoord &source, const MapCoord &target, + uint32 dmg, uint8 intercept, uint32 speed) { assert(tile_num || obj_n); // at least obj_n must be set // (although it might work if throw_obj is already set) assert(speed != 0); diff --git a/engines/ultima/nuvie/core/events.cpp b/engines/ultima/nuvie/core/events.cpp index 5c0dfaf7029..e59513f14fb 100644 --- a/engines/ultima/nuvie/core/events.cpp +++ b/engines/ultima/nuvie/core/events.cpp @@ -131,7 +131,7 @@ void Events::clear() { } bool Events::init(ObjManager *om, MapWindow *mw, MsgScroll *ms, Player *p, Magic *mg, - GameClock *gc, ViewManager *vm, UseCode *uc, GUI *g, KeyBinder *kb) { + GameClock *gc, ViewManager *vm, UseCode *uc, GUI *g, KeyBinder *kb) { clear(); gui = g; @@ -409,9 +409,9 @@ void Events::get_target(const MapCoord &init, const char *prompt) { /* Switch focus to MsgScroll and start getting user input. */ void Events::get_scroll_input(const char *allowed, - bool can_escape, - bool using_target_cursor, - bool set_numbers_only_to_true) { + bool can_escape, + bool using_target_cursor, + bool set_numbers_only_to_true) { assert(scroll); if (!using_target_cursor) { assert(mode != INPUT_MODE); @@ -3684,9 +3684,9 @@ void Events::display_not_aboard_vehicle(bool show_prompt) { } bool Events::can_move_obj_between_actors(Obj *obj, - Actor *src_actor, - Actor *target_actor, - bool display_name) { // exchange inventory + Actor *src_actor, + Actor *target_actor, + bool display_name) { // exchange inventory MapCoord from = src_actor->get_location(); if (target_actor) { diff --git a/engines/ultima/nuvie/core/map.cpp b/engines/ultima/nuvie/core/map.cpp index a15aee8855c..00afe2d1d14 100644 --- a/engines/ultima/nuvie/core/map.cpp +++ b/engines/ultima/nuvie/core/map.cpp @@ -761,7 +761,7 @@ bool Map::testIntersection(int x, int y, uint8 level, uint8 flags, LineTestResul // returns true if a line hits something travelling from (start_x, start_y) to // (end_x, end_y). If a hit occurs Result is filled in with the relevant info. bool Map::lineTest(int start_x, int start_y, int end_x, int end_y, uint8 level, - uint8 flags, LineTestResult &Result, uint32 skip, Obj *excluded_obj) { + uint8 flags, LineTestResult &Result, uint32 skip, Obj *excluded_obj) { // standard Bresenham's algorithm. int deltax = abs(end_x - start_x); int deltay = abs(end_y - start_y); diff --git a/engines/ultima/nuvie/core/obj_manager.cpp b/engines/ultima/nuvie/core/obj_manager.cpp index a530365f7fd..4777cdafb6e 100644 --- a/engines/ultima/nuvie/core/obj_manager.cpp +++ b/engines/ultima/nuvie/core/obj_manager.cpp @@ -40,11 +40,11 @@ namespace Ultima { namespace Nuvie { static const int obj_egg_table[5] = {0, // NUVIE_GAME_NONE - 335, // NUVIE_GAME_U6 - 466, // NUVIE_GAME_MD - 0, - 230 - }; // NUVIE_GAME_SE + 335, // NUVIE_GAME_U6 + 466, // NUVIE_GAME_MD + 0, + 230 + }; // NUVIE_GAME_SE static iAVLKey get_iAVLKey(const void *item) { return ((const ObjTreeNode *)item)->key; @@ -439,8 +439,8 @@ U6LList *ObjManager::get_obj_superchunk(uint16 x, uint16 y, uint8 level) if(level == 0) { - i = y * 8 + x; - return surface[i]; + i = y * 8 + x; + return surface[i]; } return dungeon[level-1]; @@ -1820,9 +1820,9 @@ inline U6LList *ObjManager::get_schunk_list(uint16 x, uint16 y, uint8 level) if(level == 0) { - sx = x / 128; - sy = y / 128; - return surface[sy * 8 + sx]; + sx = x / 128; + sy = y / 128; + return surface[sy * 8 + sx]; } return dungeon[level-1]; @@ -2172,9 +2172,9 @@ bool ObjManager::unlink_from_engine(Obj *obj, bool run_usecode) { break; // inventory_remove_obj unreadies case OBJ_LOC_READIED :/* a = (Actor *)obj->parent; - a->remove_readied_object(obj, run_usecode); - a->inventory_remove_obj(obj, run_usecode); - break; + a->remove_readied_object(obj, run_usecode); + a->inventory_remove_obj(obj, run_usecode); + break; */ case OBJ_LOC_INV : a = (Actor *)obj->parent; diff --git a/engines/ultima/nuvie/core/tile_manager.cpp b/engines/ultima/nuvie/core/tile_manager.cpp index bf0ac403d56..d8277a1222a 100644 --- a/engines/ultima/nuvie/core/tile_manager.cpp +++ b/engines/ultima/nuvie/core/tile_manager.cpp @@ -44,10 +44,10 @@ namespace Nuvie { static char article_tbl[][5] = {"", "a ", "an ", "the "}; static const uint16 U6_ANIM_SRC_TILE[32] = {0x16, 0x16, 0x1a, 0x1a, 0x1e, 0x1e, 0x12, 0x12, - 0x1a, 0x1e, 0x16, 0x12, 0x16, 0x1a, 0x1e, 0x12, - 0x1a, 0x1e, 0x1e, 0x12, 0x12, 0x16, 0x16, 0x1a, - 0x12, 0x16, 0x1e, 0x1a, 0x1a, 0x1e, 0x12, 0x16 - }; + 0x1a, 0x1e, 0x16, 0x12, 0x16, 0x1a, 0x1e, 0x12, + 0x1a, 0x1e, 0x1e, 0x12, 0x12, 0x16, 0x16, 0x1a, + 0x12, 0x16, 0x1e, 0x1a, 0x1a, 0x1e, 0x12, 0x16 + }; //static const uint16 U6_WALL_TYPES[1][2] = {{156,176}}; diff --git a/engines/ultima/nuvie/core/timed_event.cpp b/engines/ultima/nuvie/core/timed_event.cpp index 7b2cb850b99..5f40fa47aaf 100644 --- a/engines/ultima/nuvie/core/timed_event.cpp +++ b/engines/ultima/nuvie/core/timed_event.cpp @@ -445,7 +445,7 @@ bool TimedPartyMove::fall_in() { /* Party movement to vehicle. Second target is unused. */ TimedPartyMoveToVehicle::TimedPartyMoveToVehicle(MapCoord *d, Obj *obj, - uint32 step_delay) + uint32 step_delay) : TimedPartyMove(d, NULL, step_delay) { ship_obj = obj; } diff --git a/engines/ultima/nuvie/files/u6_lzw.cpp b/engines/ultima/nuvie/files/u6_lzw.cpp index 10d02dc4bfd..c78dc09aed6 100644 --- a/engines/ultima/nuvie/files/u6_lzw.cpp +++ b/engines/ultima/nuvie/files/u6_lzw.cpp @@ -54,7 +54,7 @@ U6Lzw::~U6Lzw() { * compressed, it just makes it suitable to be read by an LZW decoder. */ unsigned char *U6Lzw::compress_buffer(unsigned char *src, uint32 src_len, - uint32 &dest_len) { + uint32 &dest_len) { // FIXME - didnt bother fixing this since its output will be larger than // the uncompressed data uint32 blocks = 0; //, block = 0, b = 0, d = 0, rshift = 0; diff --git a/engines/ultima/nuvie/files/utils.cpp b/engines/ultima/nuvie/files/utils.cpp index 8939718f27a..b10452f3402 100644 --- a/engines/ultima/nuvie/files/utils.cpp +++ b/engines/ultima/nuvie/files/utils.cpp @@ -39,16 +39,16 @@ using Std::string; */ bool openFile(Common::ReadStream *&in, const char *fname) { - Common::File *f = new Common::File(); - Common::String filename(fname); + Common::File *f = new Common::File(); + Common::String filename(fname); - if (f->open(filename)) { + if (f->open(filename)) { in = f; return true; - } else { + } else { delete f; return false; - } + } } /* diff --git a/engines/ultima/nuvie/files/utils.h b/engines/ultima/nuvie/files/utils.h index 75dee1e14d4..be0416a772b 100644 --- a/engines/ultima/nuvie/files/utils.h +++ b/engines/ultima/nuvie/files/utils.h @@ -30,8 +30,8 @@ namespace Ultima { namespace Nuvie { bool openFile( - Common::ReadStream *&in, // Input stream to open. - const char *fname // Filename + Common::ReadStream *&in, // Input stream to open. + const char *fname // Filename ); extern bool fileExists(const char *fname); diff --git a/engines/ultima/nuvie/fonts/bmp_font.cpp b/engines/ultima/nuvie/fonts/bmp_font.cpp index 22321c7f7bd..d32ced407f9 100644 --- a/engines/ultima/nuvie/fonts/bmp_font.cpp +++ b/engines/ultima/nuvie/fonts/bmp_font.cpp @@ -106,7 +106,7 @@ uint16 BMPFont::getCharWidth(uint8 c) { } uint16 BMPFont::drawChar(Screen *screen, uint8 char_num, uint16 x, uint16 y, - uint8 color) { + uint8 color) { Common::Rect src; Common::Rect dst; diff --git a/engines/ultima/nuvie/fonts/conv_font.cpp b/engines/ultima/nuvie/fonts/conv_font.cpp index 79fe6ba409a..a77db97058e 100644 --- a/engines/ultima/nuvie/fonts/conv_font.cpp +++ b/engines/ultima/nuvie/fonts/conv_font.cpp @@ -41,8 +41,8 @@ ConvFont::~ConvFont() { } bool ConvFont::init(unsigned char *data, uint8 *width_data, uint16 num_c, uint16 char_offset) { - assert(data && width_data); - data_offset = char_offset; + assert(data && width_data); + data_offset = char_offset; num_chars = num_c; f_data = data; @@ -57,7 +57,7 @@ uint16 ConvFont::getCharWidth(uint8 c) { } uint16 ConvFont::drawChar(Screen *screen, uint8 char_num, uint16 x, uint16 y, - uint8 color) { + uint8 color) { unsigned char *buf = (unsigned char *)f_data + (data_offset * 64) + (char_num % 16) * 8 + (char_num / 16) * 128 * 8; screen->blit(x, y, buf, 8, 8, 8, 128, true, NULL); diff --git a/engines/ultima/nuvie/fonts/u6_font.cpp b/engines/ultima/nuvie/fonts/u6_font.cpp index ec9c328a0fc..c15f796d597 100644 --- a/engines/ultima/nuvie/fonts/u6_font.cpp +++ b/engines/ultima/nuvie/fonts/u6_font.cpp @@ -50,7 +50,7 @@ bool U6Font::init(unsigned char *data, uint16 num_c, uint16 char_offset) { } uint16 U6Font::drawChar(Screen *screen, uint8 char_num, uint16 x, uint16 y, - uint8 color) { + uint8 color) { unsigned char buf[64]; unsigned char *pixels; uint16 i, j; diff --git a/engines/ultima/nuvie/fonts/wou_font.cpp b/engines/ultima/nuvie/fonts/wou_font.cpp index 962cc73a28b..250a4639b75 100644 --- a/engines/ultima/nuvie/fonts/wou_font.cpp +++ b/engines/ultima/nuvie/fonts/wou_font.cpp @@ -106,7 +106,7 @@ uint16 WOUFont::getCharWidth(uint8 c) { uint16 WOUFont::drawChar(Screen *screen, uint8 char_num, uint16 x, uint16 y, - uint8 color) { + uint8 color) { unsigned char *pixels; uint16 width; @@ -143,7 +143,7 @@ uint16 WOUFont::drawStringToShape(U6Shape *shp, const char *str, uint16 x, uint1 } uint8 WOUFont::drawCharToShape(U6Shape *shp, uint8 char_num, uint16 x, uint16 y, - uint8 color) { + uint8 color) { unsigned char *pixels; uint16 i, j; unsigned char *font; diff --git a/engines/ultima/nuvie/gui/gui_area.cpp b/engines/ultima/nuvie/gui/gui_area.cpp index 3b6bfca9db6..ee376006fb6 100644 --- a/engines/ultima/nuvie/gui/gui_area.cpp +++ b/engines/ultima/nuvie/gui/gui_area.cpp @@ -39,7 +39,7 @@ GUI_Area:: GUI_Area(int x, int y, int w, int h, uint8 r, uint8 g, uint8 b, int a } GUI_Area:: GUI_Area(int x, int y, int w, int h, uint8 r, uint8 g, uint8 b, - uint8 fr, uint8 fg, uint8 fb, int fthick, int aShape) + uint8 fr, uint8 fg, uint8 fb, int fthick, int aShape) : GUI_Widget(NULL, x, y, w, h) { R = r; G = g; diff --git a/engines/ultima/nuvie/gui/gui_button.cpp b/engines/ultima/nuvie/gui/gui_button.cpp index a264f1363bd..73427ab24b5 100644 --- a/engines/ultima/nuvie/gui/gui_button.cpp +++ b/engines/ultima/nuvie/gui/gui_button.cpp @@ -32,7 +32,7 @@ Graphics::ManagedSurface *checkmarks = NULL; GUI_Button:: GUI_Button(void *data, int x, int y, Graphics::ManagedSurface *image, - Graphics::ManagedSurface *image2, GUI_CallBack *callback, bool free_surfaces) + Graphics::ManagedSurface *image2, GUI_CallBack *callback, bool free_surfaces) : GUI_Widget(data, x, y, image->w, image->h) { callback_object = callback; @@ -52,7 +52,7 @@ GUI_Button:: GUI_Button(void *data, int x, int y, Graphics::ManagedSurface *imag } GUI_Button:: GUI_Button(void *data, int x, int y, int w, int h, - GUI_CallBack *callback) + GUI_CallBack *callback) : GUI_Widget(data, x, y, w, h) { callback_object = callback; @@ -72,8 +72,8 @@ GUI_Button:: GUI_Button(void *data, int x, int y, int w, int h, } GUI_Button::GUI_Button(void *data, int x, int y, int w, int h, const char *text, - GUI_Font *font, int alignment, int is_checkbutton, - GUI_CallBack *callback, int flat) + GUI_Font *font, int alignment, int is_checkbutton, + GUI_CallBack *callback, int flat) : GUI_Widget(data, x, y, w, h) { callback_object = callback; diff --git a/engines/ultima/nuvie/gui/gui_load_image.h b/engines/ultima/nuvie/gui/gui_load_image.h index b2b1127db37..e52a54079ac 100644 --- a/engines/ultima/nuvie/gui/gui_load_image.h +++ b/engines/ultima/nuvie/gui/gui_load_image.h @@ -33,7 +33,7 @@ namespace Nuvie { Use 'genimage' to turn an 8-bit BMP file into a C image, and include the output in your application, either directly or as a header file. Create an SDL surface in your program: - surface = GUI_LoadImage(image_w, image_h, image_pal, image_data); + surface = GUI_LoadImage(image_w, image_h, image_pal, image_data); */ /************************************************************************/ diff --git a/engines/ultima/nuvie/gui/gui_text_input.cpp b/engines/ultima/nuvie/gui/gui_text_input.cpp index 1d6aea492b2..33f7d79795f 100644 --- a/engines/ultima/nuvie/gui/gui_text_input.cpp +++ b/engines/ultima/nuvie/gui/gui_text_input.cpp @@ -30,7 +30,7 @@ namespace Ultima { namespace Nuvie { GUI_TextInput:: GUI_TextInput(int x, int y, uint8 r, uint8 g, uint8 b, const char *str, - GUI_Font *gui_font, uint16 width, uint16 height, GUI_CallBack *callback) + GUI_Font *gui_font, uint16 width, uint16 height, GUI_CallBack *callback) : GUI_Text(x, y, r, g, b, gui_font, width) { max_height = height; callback_object = callback; diff --git a/engines/ultima/nuvie/gui/gui_text_toggle_button.cpp b/engines/ultima/nuvie/gui/gui_text_toggle_button.cpp index ea7d5976fda..6df741bd201 100644 --- a/engines/ultima/nuvie/gui/gui_text_toggle_button.cpp +++ b/engines/ultima/nuvie/gui/gui_text_toggle_button.cpp @@ -27,9 +27,9 @@ namespace Ultima { namespace Nuvie { GUI_TextToggleButton::GUI_TextToggleButton(void *data, int x, int y, int w, int h, - const char *const *texts_, int count_, int selection_, - GUI_Font *font, int alignment_, - GUI_CallBack *callback, int flat) + const char *const *texts_, int count_, int selection_, + GUI_Font *font, int alignment_, + GUI_CallBack *callback, int flat) : GUI_Button(data, x, y, w, h, "", font, alignment_, 0, callback, flat) { count = count_; assert(count > 0); diff --git a/engines/ultima/nuvie/gui/gui_yes_no_dialog.h b/engines/ultima/nuvie/gui/gui_yes_no_dialog.h index 0d1d2294d4e..4b2e0f3bd4e 100644 --- a/engines/ultima/nuvie/gui/gui_yes_no_dialog.h +++ b/engines/ultima/nuvie/gui/gui_yes_no_dialog.h @@ -46,7 +46,7 @@ private: public: GUI_YesNoDialog(GUI *gui, int x, int y, int w, int h, const char *msg, - CallBack *yesCallback, CallBack *noCallback); + CallBack *yesCallback, CallBack *noCallback); ~GUI_YesNoDialog() override; GUI_status KeyDown(const Common::KeyState &key) override; diff --git a/engines/ultima/nuvie/gui/widgets/command_bar.cpp b/engines/ultima/nuvie/gui/widgets/command_bar.cpp index e6363da0ab8..dfbab97db6c 100644 --- a/engines/ultima/nuvie/gui/widgets/command_bar.cpp +++ b/engines/ultima/nuvie/gui/widgets/command_bar.cpp @@ -289,14 +289,14 @@ GUI_status CommandBar::hit(uint8 num) { } static const EventMode U6_mode_tbl[] = { ATTACK_MODE, CAST_MODE, TALK_MODE, LOOK_MODE, GET_MODE, - DROP_MODE, PUSH_MODE, USE_MODE, REST_MODE, COMBAT_MODE - }; + DROP_MODE, PUSH_MODE, USE_MODE, REST_MODE, COMBAT_MODE + }; static const EventMode MD_mode_tbl[] = { ATTACK_MODE, TALK_MODE, LOOK_MODE, GET_MODE, - DROP_MODE, PUSH_MODE, USE_MODE, COMBAT_MODE - }; + DROP_MODE, PUSH_MODE, USE_MODE, COMBAT_MODE + }; static const EventMode SE_mode_tbl[] = { PUSH_MODE, GET_MODE, DROP_MODE, USE_MODE, TALK_MODE, - LOOK_MODE, ATTACK_MODE, REST_MODE, COMBAT_MODE - }; + LOOK_MODE, ATTACK_MODE, REST_MODE, COMBAT_MODE + }; /* * return true if target is needed (only used for original CommandBar commands) diff --git a/engines/ultima/nuvie/gui/widgets/command_bar_new_ui.cpp b/engines/ultima/nuvie/gui/widgets/command_bar_new_ui.cpp index 6e60c651a35..e96ef9b32a6 100644 --- a/engines/ultima/nuvie/gui/widgets/command_bar_new_ui.cpp +++ b/engines/ultima/nuvie/gui/widgets/command_bar_new_ui.cpp @@ -274,10 +274,10 @@ const char *CommandBarNewUI::get_command_name(sint8 command_num) { /* void CommandBarNewUI::display_information() { - string infostring(game->get_clock()->get_date_string()); - infostring += " Wind:"; - infostring += wind; - text->drawString(screen, infostring.c_str(), area.left + 8, area.top, 0); + string infostring(game->get_clock()->get_date_string()); + infostring += " Wind:"; + infostring += wind; + text->drawString(screen, infostring.c_str(), area.left + 8, area.top, 0); } */ diff --git a/engines/ultima/nuvie/gui/widgets/converse_gump.cpp b/engines/ultima/nuvie/gui/widgets/converse_gump.cpp index c0d0b635b1a..d8854952084 100644 --- a/engines/ultima/nuvie/gui/widgets/converse_gump.cpp +++ b/engines/ultima/nuvie/gui/widgets/converse_gump.cpp @@ -321,9 +321,9 @@ void ConverseGump::clear_permitted_input() { /* void ConverseGump::add_token(MsgText *token) { - DEBUG(0,LEVEL_ALERT, "TOKEN: %s\n", token->s.c_str()); + DEBUG(0,LEVEL_ALERT, "TOKEN: %s\n", token->s.c_str()); - display_text.push_back(*token); + display_text.push_back(*token); } */ diff --git a/engines/ultima/nuvie/gui/widgets/map_window.cpp b/engines/ultima/nuvie/gui/widgets/map_window.cpp index ba61f421523..51f1f06e0d7 100644 --- a/engines/ultima/nuvie/gui/widgets/map_window.cpp +++ b/engines/ultima/nuvie/gui/widgets/map_window.cpp @@ -1131,7 +1131,7 @@ inline void MapWindow::drawObj(Obj *obj, bool draw_lowertiles, bool toptile) { * used with animated tiles. It only applies to the base tile in multi-tiles. */ inline void MapWindow::drawTile(Tile *tile, uint16 x, uint16 y, bool toptile, - bool use_tile_data) { + bool use_tile_data) { bool dbl_width, dbl_height; uint16 tile_num; diff --git a/engines/ultima/nuvie/keybinding/keys.cpp b/engines/ultima/nuvie/keybinding/keys.cpp index 0107f3f3a7a..44023814ad9 100644 --- a/engines/ultima/nuvie/keybinding/keys.cpp +++ b/engines/ultima/nuvie/keybinding/keys.cpp @@ -331,7 +331,7 @@ KeyBinder::~KeyBinder() { } void KeyBinder::AddKeyBinding(Common::KeyCode key, byte mod, const Action *action, - int nparams, int *params) { + int nparams, int *params) { Common::KeyState k; ActionType a; a.action = action; diff --git a/engines/ultima/nuvie/misc/iavl_tree.cpp b/engines/ultima/nuvie/misc/iavl_tree.cpp index e5a02d4f07e..9575231bf10 100644 --- a/engines/ultima/nuvie/misc/iavl_tree.cpp +++ b/engines/ultima/nuvie/misc/iavl_tree.cpp @@ -30,8 +30,8 @@ static iAVLNode *iAVLCloseSearchNode(iAVLTree const *avltree, iAVLKey key); static void iAVLRebalanceNode(iAVLTree *avltree, iAVLNode *avlnode); static void iAVLFreeBranch(iAVLNode *avlnode, void (freeitem)(void *item)); static void iAVLFillVacancy(iAVLTree *avltree, - iAVLNode *origparent, iAVLNode **superparent, - iAVLNode *left, iAVLNode *right); + iAVLNode *origparent, iAVLNode **superparent, + iAVLNode *left, iAVLNode *right); #define MAX(x, y) ((x) > (y) ? (x) : (y)) #define MIN(x, y) ((x) < (y) ? (x) : (y)) @@ -415,8 +415,8 @@ void iAVLFreeBranch(iAVLNode *avlnode, void (freeitem)(void *item)) { * component pointer, fill that vacancy. */ void iAVLFillVacancy(iAVLTree *avltree, - iAVLNode *origparent, iAVLNode **superparent, - iAVLNode *left, iAVLNode *right) { + iAVLNode *origparent, iAVLNode **superparent, + iAVLNode *left, iAVLNode *right) { iAVLNode *avlnode; iAVLNode *balnode; iAVLNode *nextbalnode; diff --git a/engines/ultima/nuvie/misc/u6_misc.cpp b/engines/ultima/nuvie/misc/u6_misc.cpp index 3e5662b04c0..ccc9a703eed 100644 --- a/engines/ultima/nuvie/misc/u6_misc.cpp +++ b/engines/ultima/nuvie/misc/u6_misc.cpp @@ -722,7 +722,7 @@ void scaleLine8Bit(unsigned char *Target, unsigned char *Source, int SrcWidth, i //Coarse 2D scaling from http://www.compuphase.com/graphic/scale.htm void scale_rect_8bit(unsigned char *Source, unsigned char *Target, int SrcWidth, int SrcHeight, - int TgtWidth, int TgtHeight) { + int TgtWidth, int TgtHeight) { int NumPixels = TgtHeight; int IntPart = (SrcHeight / TgtHeight) * SrcWidth; int FractPart = SrcHeight % TgtHeight; diff --git a/engines/ultima/nuvie/nuvie.h b/engines/ultima/nuvie/nuvie.h index 3614074c491..e55cb4da821 100644 --- a/engines/ultima/nuvie/nuvie.h +++ b/engines/ultima/nuvie/nuvie.h @@ -57,12 +57,12 @@ private: bool playIntro(); protected: - bool initialize() override; + bool initialize() override; - /** - * Returns the data archive folder and version that's required - */ - bool isDataRequired(Common::String &folder, int &majorVersion, int &minorVersion) override; + /** + * Returns the data archive folder and version that's required + */ + bool isDataRequired(Common::String &folder, int &majorVersion, int &minorVersion) override; public: const Std::string c_empty_string; public: diff --git a/engines/ultima/nuvie/pathfinder/actor_path_finder.h b/engines/ultima/nuvie/pathfinder/actor_path_finder.h index dd44186f83d..c2863128d9a 100644 --- a/engines/ultima/nuvie/pathfinder/actor_path_finder.h +++ b/engines/ultima/nuvie/pathfinder/actor_path_finder.h @@ -42,7 +42,7 @@ public: virtual bool update_location(); /* get location from actor (use any time) */ virtual void actor_moved(); /* the actor moved ON PATH... - (use after get_next_move()) */ + (use after get_next_move()) */ bool check_loc(const MapCoord &loc) override; diff --git a/engines/ultima/nuvie/pathfinder/astar_path.cpp b/engines/ultima/nuvie/pathfinder/astar_path.cpp index d904e2283ce..e7ea7bab4dd 100644 --- a/engines/ultima/nuvie/pathfinder/astar_path.cpp +++ b/engines/ultima/nuvie/pathfinder/astar_path.cpp @@ -45,7 +45,7 @@ AStarPath::AStarPath() : final_node(0) { set_path_size(step_count); }/* Get a new neighbor to nnode and score it, returning true if it's usable. */ bool AStarPath::score_to_neighbor(sint8 dir, astar_node *nnode, astar_node *neighbor, - sint32 &nnode_to_neighbor) { + sint32 &nnode_to_neighbor) { sint8 sx = -1, sy = -1; DirFinder::get_adjacent_dir(sx, sy, dir); // sx,sy = neighbor -1,-1 + dir // get neighbor of nnode towards sx,sy, and cost to that neighbor @@ -58,8 +58,8 @@ bool AStarPath::score_to_neighbor(sint8 dir, astar_node *nnode, astar_node *neig return true; }/* Compare a node's score to the start node to already scored neighbors. */ bool AStarPath::compare_neighbors(astar_node *nnode, astar_node *neighbor, - sint32 nnode_to_neighbor, astar_node *in_open, - astar_node *in_closed) { + sint32 nnode_to_neighbor, astar_node *in_open, + astar_node *in_closed) { neighbor->to_start = nnode->to_start + nnode_to_neighbor; // ignore this neighbor if already checked and closer to start if ((in_open && in_open->to_start <= neighbor->to_start) @@ -70,7 +70,7 @@ bool AStarPath::compare_neighbors(astar_node *nnode, astar_node *neighbor, return true; }/* Check all neighbors of a node (location) and save them to the "seen" list. */ bool AStarPath::search_node_neighbors(astar_node *nnode, MapCoord &goal, - const uint32 max_score) { + const uint32 max_score) { for (uint32 dir = 1; dir < 8; dir += 2) { astar_node *neighbor = new astar_node; sint32 nnode_to_neighbor = -1; diff --git a/engines/ultima/nuvie/pathfinder/path_finder.h b/engines/ultima/nuvie/pathfinder/path_finder.h index d163e2be3e6..ab95ced7d39 100644 --- a/engines/ultima/nuvie/pathfinder/path_finder.h +++ b/engines/ultima/nuvie/pathfinder/path_finder.h @@ -35,7 +35,7 @@ protected: MapCoord start, goal, loc; /* source, destination, current location */ Path *search; /* contains path-search algorithms, and - game-specific step costs */ + game-specific step costs */ void new_search(Path *new_path); // bool is_hazardous(MapCoord &loc); will have to check objects and tiles diff --git a/engines/ultima/nuvie/pathfinder/seek_path.cpp b/engines/ultima/nuvie/pathfinder/seek_path.cpp index 2bf2c0a48fe..42e0dc0b6f4 100644 --- a/engines/ultima/nuvie/pathfinder/seek_path.cpp +++ b/engines/ultima/nuvie/pathfinder/seek_path.cpp @@ -40,8 +40,8 @@ SeekPath::~SeekPath() { /* Get two relative directions that a line can travel to trace around an obstacle towards `xdir',`ydir'. */ bool SeekPath::get_obstacle_tracer(MapCoord &start, sint32 xdir, sint32 ydir, - sint32 &Axdir, sint32 &Aydir, - sint32 &Bxdir, sint32 &Bydir) { + sint32 &Axdir, sint32 &Aydir, + sint32 &Bxdir, sint32 &Bydir) { if (xdir && ydir) { // original direction is diagonal MapCoord checkA(start.x + xdir, start.y, start.z); MapCoord checkB(start.x, start.y + ydir, start.z); diff --git a/engines/ultima/nuvie/screen/scale.cpp b/engines/ultima/nuvie/screen/scale.cpp index d340661c025..7a2ffbcbe69 100644 --- a/engines/ultima/nuvie/screen/scale.cpp +++ b/engines/ultima/nuvie/screen/scale.cpp @@ -242,7 +242,7 @@ const ScalerStruct *ScalerRegistry::GetPointScaler() { // void Application::show_8to16_blur ( - int x, int y, int w, int h // Area to show. + int x, int y, int w, int h // Area to show. ) { Manip8to16 manip(palette, sdl_surf->format); @@ -257,7 +257,7 @@ void Application::show_8to16_blur void Application::show_8to555_blur ( - int x, int y, int w, int h // Area to show. + int x, int y, int w, int h // Area to show. ) { Manip8to555 manip(palette); BlurFilter @@ -271,7 +271,7 @@ void Application::show_8to555_blur void Application::show_8to565_blur ( - int x, int y, int w, int h // Area to show. + int x, int y, int w, int h // Area to show. ) { Manip8to565 manip(palette); BlurFilter @@ -285,7 +285,7 @@ void Application::show_8to565_blur void Application::show_8to32_blur ( - int x, int y, int w, int h // Area to show. + int x, int y, int w, int h // Area to show. ) { Manip8to32 manip(palette, sdl_surf->format); @@ -356,7 +356,7 @@ void Application::show_8to32_blur void Application::show_8to16_rotated ( - int x, int y, int w, int h // Area to show. + int x, int y, int w, int h // Area to show. ) { Manip8to16 manip(palette, sdl_surf->format); @@ -365,7 +365,7 @@ void Application::show_8to16_rotated void Application::show_8to555_rotated ( - int x, int y, int w, int h // Area to show. + int x, int y, int w, int h // Area to show. ) { Manip8to555 manip(palette); RotatorFunc(uint16); @@ -373,7 +373,7 @@ void Application::show_8to555_rotated void Application::show_8to565_rotated ( - int x, int y, int w, int h // Area to show. + int x, int y, int w, int h // Area to show. ) { Manip8to565 manip(palette); RotatorFunc(uint16); @@ -381,7 +381,7 @@ void Application::show_8to565_rotated void Application::show_8to32_rotated ( - int x, int y, int w, int h // Area to show. + int x, int y, int w, int h // Area to show. ) { Manip8to32 manip(palette, sdl_surf->format); RotatorFunc(uint32); diff --git a/engines/ultima/nuvie/screen/screen.cpp b/engines/ultima/nuvie/screen/screen.cpp index c2ea16c29ba..9bbfebd75e2 100644 --- a/engines/ultima/nuvie/screen/screen.cpp +++ b/engines/ultima/nuvie/screen/screen.cpp @@ -1401,7 +1401,7 @@ byte *Screen::copy_area(Common::Rect *area, byte *buf) { // byte * -> target (src area still means location on screen, not relative to target) // (NULL area = entire screen) void Screen::restore_area(byte *pixels, Common::Rect *area, - byte *target, Common::Rect *target_area, bool free_src) { + byte *target, Common::Rect *target_area, bool free_src) { Common::Rect screen_area(0, 0, _renderSurface->w, _renderSurface->h); if (!area) area = &screen_area; @@ -1458,7 +1458,7 @@ byte *Screen::copy_area32(Common::Rect *area, byte *buf) { void Screen::restore_area32(byte *pixels, Common::Rect *area, - byte *target, Common::Rect *target_area, bool free_src) { + byte *target, Common::Rect *target_area, bool free_src) { uint32 *src = (uint32 *)pixels; uint32 *dest = (uint32 *)_renderSurface->pixels; dest += area->top * _renderSurface->w + area->left; @@ -1523,7 +1523,7 @@ byte *Screen::copy_area16(Common::Rect *area, byte *buf) { void Screen::restore_area16(byte *pixels, Common::Rect *area, - byte *target, Common::Rect *target_area, bool free_src) { + byte *target, Common::Rect *target_area, bool free_src) { uint16 *src = (uint16 *)pixels; uint16 *dest = (uint16 *)_renderSurface->pixels; dest += area->top * _renderSurface->w + area->left; diff --git a/engines/ultima/nuvie/script/script.cpp b/engines/ultima/nuvie/script/script.cpp index d23f61397ed..4c06b7487c2 100644 --- a/engines/ultima/nuvie/script/script.cpp +++ b/engines/ultima/nuvie/script/script.cpp @@ -72,9 +72,9 @@ An in-game object @int qty quantity @string[readonly] name The object name from the 'look' table. @string[readonly] look_string A printable look description - a book - an elephant - 5 torches + a book + an elephant + 5 torches @bool[readonly] on_map Is the object on the map? @bool[readonly] in_container Is the object in a container? @field parent (Obj|Actor) The parent of this object. Either an object if this object is in a container. Or an Actor if this object is in an inventory. @@ -1787,10 +1787,10 @@ static int nscript_obj_gc(lua_State *L) { { if(s_obj) { - if(s_obj->obj_ptr) - return s_obj->obj_ptr; - else - return &s_obj->script_obj; + if(s_obj->obj_ptr) + return s_obj->obj_ptr; + else + return &s_obj->script_obj; } return NULL; @@ -2342,8 +2342,8 @@ static int nscript_display_prompt(lua_State *L) { @function nuvie_load @param path lua file relative to data/scripts directory @return contents of the lua file as a function block on success. - A string is returned on compilation failure. - nil is returned if the file cannot be opened + A string is returned on compilation failure. + nil is returned if the file cannot be opened */ static int nscript_load(lua_State *L) { const char *file = luaL_checkstring(L, 1); @@ -3398,13 +3398,13 @@ to iterate through a list of Actors and Objects that were hit by the explosion. @int y @treturn table A table containing the hit Actor and Obj objects. @usage - local hit_items = explosion_start(0x17e, actor.x, actor.y) + local hit_items = explosion_start(0x17e, actor.x, actor.y) - for k,v in pairs(hit_items) do - if v.luatype == "actor" then - actor_hit(v, random(1, 0x14)) - end - end + for k,v in pairs(hit_items) do + if v.luatype == "actor" then + actor_hit(v, random(1, 0x14)) + end + end @within effects */ static int nscript_explosion_start(lua_State *L) { @@ -3848,7 +3848,7 @@ Iterate through party members. @usage local actor for actor in party_members() do - actor.poisoned = false + actor.poisoned = false end @within party */ @@ -3966,9 +3966,9 @@ Iterate through all objects of a specific type on a given map level. @usage local loc = player_get_location() for obj in find_obj(loc.z, 223, 1) do - if obj ~= nil then - explode_obj(obj) - end + if obj ~= nil then + explode_obj(obj) + end end @within Object */ @@ -4355,11 +4355,11 @@ Iterate through objects in a container. @usage local child for child in container_objs(obj) do -- look through container for effect object. - if child.obj_n == 337 then --effect - found = true - print("\nIt's trapped.\n"); - break - end + if child.obj_n == 337 then --effect + found = true + print("\nIt's trapped.\n"); + break + end end @within Object */ diff --git a/engines/ultima/nuvie/script/script_actor.cpp b/engines/ultima/nuvie/script/script_actor.cpp index d28789903fb..76c5d85320d 100644 --- a/engines/ultima/nuvie/script/script_actor.cpp +++ b/engines/ultima/nuvie/script/script_actor.cpp @@ -1740,12 +1740,12 @@ Iterate through objects in the actor's inventory. local obj for obj in actor_inventory(actor) do - if obj.readied then - local armour = armour_tbl[obj.obj_n] - if armour ~= nil then - ac = ac + armour - end - end + if obj.readied then + local armour = armour_tbl[obj.obj_n] + if armour ~= nil then + ac = ac + armour + end + end end @within Actor */ diff --git a/engines/ultima/nuvie/sound/adplug/fm_opl.cpp b/engines/ultima/nuvie/sound/adplug/fm_opl.cpp index 20233c39b68..5cbd46371a6 100644 --- a/engines/ultima/nuvie/sound/adplug/fm_opl.cpp +++ b/engines/ultima/nuvie/sound/adplug/fm_opl.cpp @@ -680,7 +680,7 @@ INLINE void advancex(FM_OPL *OPL) { op->volume += (~op->volume * (eg_inc[op->eg_sel_ar + ((OPL->eg_cnt>>op->eg_sh_ar)&7)]) - ) >>3; + ) >>3; if (op->volume <= MIN_ATT_INDEX) { @@ -1470,7 +1470,7 @@ static void OPLWriteReg(FM_OPL *OPL, int r, int v) case 0x08: /* MODE,DELTA-T : CSM,NOTESEL,x,x,smpl,da/ad,64k,rom */ OPL->mode = v; #if !(BUILD_Y8950) - break; + break; #endif #if BUILD_Y8950 diff --git a/engines/ultima/nuvie/sound/adplug/opl_class.cpp b/engines/ultima/nuvie/sound/adplug/opl_class.cpp index 51d13de764b..475b5cf5fbb 100644 --- a/engines/ultima/nuvie/sound/adplug/opl_class.cpp +++ b/engines/ultima/nuvie/sound/adplug/opl_class.cpp @@ -289,12 +289,12 @@ static const uint8 mul_tab[16] = { Length: 210 elements. - Each of the elements has to be repeated - exactly 64 times (on 64 consecutive samples). - The whole table takes: 64 * 210 = 13440 samples. + Each of the elements has to be repeated + exactly 64 times (on 64 consecutive samples). + The whole table takes: 64 * 210 = 13440 samples. - When AM = 1 data is used directly - When AM = 0 data is divided by 4 before being used (loosing precision is important) + When AM = 1 data is used directly + When AM = 0 data is divided by 4 before being used (loosing precision is important) */ #define LFO_AM_TAB_ELEMENTS 210 @@ -707,9 +707,9 @@ INLINE void OplClass::OPL_CALC_CH(OPL_CH *CH) { } /* - operators used in the rhythm sounds generation process: + operators used in the rhythm sounds generation process: - Envelope Generator: + Envelope Generator: channel operator register number Bass High Snare Tom Top / slot number TL ARDR SLRR Wave Drum Hat Drum Tom Cymbal @@ -720,7 +720,7 @@ channel operator register number Bass High Snare Tom Top 8 / 0 14 52 72 92 f2 + 8 / 1 17 55 75 95 f5 + - Phase Generator: + Phase Generator: channel operator register number Bass High Snare Tom Top / slot number MULTIPLE Drum Hat Drum Tom Cymbal diff --git a/engines/ultima/nuvie/sound/decoder/wave/adpcm.h b/engines/ultima/nuvie/sound/decoder/wave/adpcm.h index 6610ccb1387..62527cecd72 100644 --- a/engines/ultima/nuvie/sound/decoder/wave/adpcm.h +++ b/engines/ultima/nuvie/sound/decoder/wave/adpcm.h @@ -80,12 +80,12 @@ enum typesADPCM { * @return a new RewindableAudioStream, or NULL, if an error occurred */ RewindableAudioStream *makeADPCMStream( - Common::SeekableReadStream *stream, - DisposeAfterUse::Flag disposeAfterUse, - uint32 size, typesADPCM type, - int rate = 22050, - int channels = 2, - uint32 blockAlign = 0); + Common::SeekableReadStream *stream, + DisposeAfterUse::Flag disposeAfterUse, + uint32 size, typesADPCM type, + int rate = 22050, + int channels = 2, + uint32 blockAlign = 0); } // End of namespace Audio diff --git a/engines/ultima/nuvie/sound/decoder/wave/raw.cpp b/engines/ultima/nuvie/sound/decoder/wave/raw.cpp index 11f66d5a43b..b4772786e47 100644 --- a/engines/ultima/nuvie/sound/decoder/wave/raw.cpp +++ b/engines/ultima/nuvie/sound/decoder/wave/raw.cpp @@ -316,10 +316,10 @@ bool RawStream::seek(const Timestamp &where) { return new RawStream(rate, isStereo, disposeAfterUse, stream, blockList) SeekableAudioStream *makeRawStream(Common::SeekableReadStream *stream, - const RawStreamBlockList &blockList, - int rate, - uint8 flags, - DisposeAfterUse::Flag disposeAfterUse) { + const RawStreamBlockList &blockList, + int rate, + uint8 flags, + DisposeAfterUse::Flag disposeAfterUse) { const bool isStereo = (flags & Audio::FLAG_STEREO) != 0; const bool is16Bit = (flags & Audio::FLAG_16BITS) != 0; const bool isUnsigned = (flags & Audio::FLAG_UNSIGNED) != 0; @@ -340,8 +340,8 @@ SeekableAudioStream *makeRawStream(Common::SeekableReadStream *stream, } SeekableAudioStream *makeRawStream(Common::SeekableReadStream *stream, - int rate, uint8 flags, - DisposeAfterUse::Flag disposeAfterUse) { + int rate, uint8 flags, + DisposeAfterUse::Flag disposeAfterUse) { RawStreamBlockList blocks; RawStreamBlock block; block.pos = 0; @@ -359,13 +359,13 @@ SeekableAudioStream *makeRawStream(Common::SeekableReadStream *stream, SeekableAudioStream *makeRawStream(const uint8 *buffer, uint32 size, - int rate, uint8 flags, - DisposeAfterUse::Flag disposeAfterUse) { + int rate, uint8 flags, + DisposeAfterUse::Flag disposeAfterUse) { return makeRawStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, flags, DisposeAfterUse::YES); } SeekableAudioStream *makeRawDiskStream_OLD(Common::SeekableReadStream *stream, RawStreamBlock *block, int numBlocks, - int rate, uint8 flags, DisposeAfterUse::Flag disposeStream) { + int rate, uint8 flags, DisposeAfterUse::Flag disposeStream) { assert(numBlocks > 0); RawStreamBlockList blocks; for (int i = 0; i < numBlocks; ++i) diff --git a/engines/ultima/nuvie/sound/decoder/wave/raw.h b/engines/ultima/nuvie/sound/decoder/wave/raw.h index aefbaac8f0f..6168f5888be 100644 --- a/engines/ultima/nuvie/sound/decoder/wave/raw.h +++ b/engines/ultima/nuvie/sound/decoder/wave/raw.h @@ -92,8 +92,8 @@ typedef Common::List RawStreamBlockList; * @return The new SeekableAudioStream (or 0 on failure). */ SeekableAudioStream *makeRawStream(const uint8 *buffer, uint32 size, - int rate, uint8 flags, - DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); + int rate, uint8 flags, + DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); /** * Creates an audio stream, which plays from the given stream. @@ -106,8 +106,8 @@ SeekableAudioStream *makeRawStream(const uint8 *buffer, uint32 size, * @return The new SeekableAudioStream (or 0 on failure). */ SeekableAudioStream *makeRawStream(Common::SeekableReadStream *stream, - int rate, uint8 flags, - DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); + int rate, uint8 flags, + DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); /** * Creates an audio stream, which plays from the given stream. @@ -124,10 +124,10 @@ SeekableAudioStream *makeRawStream(Common::SeekableReadStream *stream, */ SeekableAudioStream *makeRawStream(Common::SeekableReadStream *stream, - const RawStreamBlockList &blockList, - int rate, - uint8 flags, - DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); + const RawStreamBlockList &blockList, + int rate, + uint8 flags, + DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); /** @@ -147,9 +147,9 @@ SeekableAudioStream *makeRawStream(Common::SeekableReadStream *stream, * @return The new SeekableAudioStream (or 0 on failure). */ SeekableAudioStream *makeRawDiskStream_OLD(Common::SeekableReadStream *stream, - RawStreamBlock *block, int numBlocks, - int rate, uint8 flags, - DisposeAfterUse::Flag disposeStream); + RawStreamBlock *block, int numBlocks, + int rate, uint8 flags, + DisposeAfterUse::Flag disposeStream); } // End of namespace Audio diff --git a/engines/ultima/nuvie/sound/decoder/wave/stream.cpp b/engines/ultima/nuvie/sound/decoder/wave/stream.cpp index f921b130b32..85e332701e9 100644 --- a/engines/ultima/nuvie/sound/decoder/wave/stream.cpp +++ b/engines/ultima/nuvie/sound/decoder/wave/stream.cpp @@ -36,7 +36,7 @@ namespace Common { /* void WriteStream::writeString(const String &str) { - write(str.c_str(), str.size()); + write(str.c_str(), str.size()); } */ SeekableReadStream *ReadStream::readStream(uint32 dataSize) { @@ -89,28 +89,28 @@ bool MemoryReadStream::seek(sint32 offs, int whence) { } /* bool MemoryWriteStreamDynamic::seek(int32 offs, int whence) { - // Pre-Condition - assert(_pos <= _size); - switch (whence) { - case SEEK_END: - // SEEK_END works just like SEEK_SET, only 'reversed', - // i.e. from the end. - offs = _size + offs; - // Fall through - case SEEK_SET: - _ptr = _data + offs; - _pos = offs; - break; + // Pre-Condition + assert(_pos <= _size); + switch (whence) { + case SEEK_END: + // SEEK_END works just like SEEK_SET, only 'reversed', + // i.e. from the end. + offs = _size + offs; + // Fall through + case SEEK_SET: + _ptr = _data + offs; + _pos = offs; + break; - case SEEK_CUR: - _ptr += offs; - _pos += offs; - break; - } - // Post-Condition - assert(_pos <= _size); + case SEEK_CUR: + _ptr += offs; + _pos += offs; + break; + } + // Post-Condition + assert(_pos <= _size); - return true; // FIXME: STREAM REWRITE + return true; // FIXME: STREAM REWRITE } */ #pragma mark - @@ -203,50 +203,50 @@ Std::string SeekableReadStream::readLine() { /* uint32 SubReadStream::read(void *dataPtr, uint32 dataSize) { - if (dataSize > _end - _pos) { - dataSize = _end - _pos; - _eos = true; - } + if (dataSize > _end - _pos) { + dataSize = _end - _pos; + _eos = true; + } - dataSize = _parentStream->read(dataPtr, dataSize); - _eos |= _parentStream->eos(); - _pos += dataSize; + dataSize = _parentStream->read(dataPtr, dataSize); + _eos |= _parentStream->eos(); + _pos += dataSize; - return dataSize; + return dataSize; } SeekableSubReadStream::SeekableSubReadStream(SeekableReadStream *parentStream, uint32 begin, uint32 end, DisposeAfterUse::Flag disposeParentStream) - : SubReadStream(parentStream, end, disposeParentStream), - _parentStream(parentStream), - _begin(begin) { - assert(_begin <= _end); - _pos = _begin; - _parentStream->seek(_pos); - _eos = false; + : SubReadStream(parentStream, end, disposeParentStream), + _parentStream(parentStream), + _begin(begin) { + assert(_begin <= _end); + _pos = _begin; + _parentStream->seek(_pos); + _eos = false; } bool SeekableSubReadStream::seek(int32 offset, int whence) { - assert(_pos >= _begin); - assert(_pos <= _end); + assert(_pos >= _begin); + assert(_pos <= _end); - switch (whence) { - case SEEK_END: - offset = size() + offset; - // fallthrough - case SEEK_SET: - _pos = _begin + offset; - break; - case SEEK_CUR: - _pos += offset; - } + switch (whence) { + case SEEK_END: + offset = size() + offset; + // fallthrough + case SEEK_SET: + _pos = _begin + offset; + break; + case SEEK_CUR: + _pos += offset; + } - assert(_pos >= _begin); - assert(_pos <= _end); + assert(_pos >= _begin); + assert(_pos <= _end); - bool ret = _parentStream->seek(_pos); - if (ret) _eos = false; // reset eos on successful seek + bool ret = _parentStream->seek(_pos); + if (ret) _eos = false; // reset eos on successful seek - return ret; + return ret; } */ diff --git a/engines/ultima/nuvie/sound/decoder/wave/wave.h b/engines/ultima/nuvie/sound/decoder/wave/wave.h index 352850a85da..b70b1a168d6 100644 --- a/engines/ultima/nuvie/sound/decoder/wave/wave.h +++ b/engines/ultima/nuvie/sound/decoder/wave/wave.h @@ -60,12 +60,12 @@ class RewindableAudioStream; * raw PCM data, MS IMA ADPCM and MS ADPCM (uses makeADPCMStream internally). */ extern bool loadWAVFromStream( - Common::SeekableReadStream &stream, - int &size, - int &rate, - uint8 &flags, - uint16 *wavType = 0, - int *blockAlign = 0); + Common::SeekableReadStream &stream, + int &size, + int &rate, + uint8 &flags, + uint16 *wavType = 0, + int *blockAlign = 0); /** * Try to load a WAVE from the given seekable stream and create an AudioStream @@ -79,8 +79,8 @@ extern bool loadWAVFromStream( * @return a new RewindableAudioStream, or NULL, if an error occurred */ RewindableAudioStream *makeWAVStream( - Common::SeekableReadStream *stream, - DisposeAfterUse::Flag disposeAfterUse); + Common::SeekableReadStream *stream, + DisposeAfterUse::Flag disposeAfterUse); } // End of namespace Audio diff --git a/engines/ultima/nuvie/sound/song.cpp b/engines/ultima/nuvie/sound/song.cpp index 23a9a3e1805..456dcb0509b 100644 --- a/engines/ultima/nuvie/sound/song.cpp +++ b/engines/ultima/nuvie/sound/song.cpp @@ -26,17 +26,17 @@ /* Song::Song() { - m_Filename=""; - m_pMusic=NULL; + m_Filename=""; + m_pMusic=NULL; // m_Paused=false; } Song::~Song() { - if (m_pMusic!=NULL) { - Mix_HaltMusic(); - Mix_FreeMusic(m_pMusic); - m_pMusic=NULL; - } + if (m_pMusic!=NULL) { + Mix_HaltMusic(); + Mix_FreeMusic(m_pMusic); + m_pMusic=NULL; + } } */ diff --git a/engines/ultima/nuvie/sound/sound_manager.cpp b/engines/ultima/nuvie/sound/sound_manager.cpp index de403df30b5..a3d0815caaf 100644 --- a/engines/ultima/nuvie/sound/sound_manager.cpp +++ b/engines/ultima/nuvie/sound/sound_manager.cpp @@ -337,49 +337,49 @@ bool SoundManager::LoadObjectSamples (string sound_dir) build_path(sound_dir, "obj_samples.cfg", scriptname); if(niof.open (scriptname) == false) - return false; + return false; sz = (char *) niof.readAll (); token1 = strtok (sz, seps); while ((token1 != NULL) && ((token2 = strtok (NULL, seps)) != NULL)) - { - int id = atoi (token1); - DEBUG(0,LEVEL_DEBUGGING,"%d : %s\n", id, token2); - Sound *ps; - ps = SampleExists (token2); - if (ps == NULL) - { - Sample *s; - s = new Sample; - build_path(sound_dir, token2, samplename); - if (!s->Init (samplename.c_str ())) - { - DEBUG(0,LEVEL_ERROR,"could not load %s\n", samplename.c_str ()); - } - ps = s; - m_Samples.push_back (ps); //add it to our global list - } - if (ps != NULL) - { //we have a valid sound - SoundCollection *psc; - Std::map < int, SoundCollection * >::iterator it; - it = m_ObjectSampleMap.find (id); - if (it == m_ObjectSampleMap.end ()) - { //is there already a collection for this entry? - psc = new SoundCollection; //no, create a new sound collection - psc->m_Sounds.push_back (ps); //add this sound to the collection - m_ObjectSampleMap.insert (Std::make_pair (id, psc)); //insert this pair into the map - } - else - { - psc = (*it).second; //yes, get the existing - psc->m_Sounds.push_back (ps); //add this sound to the collection - } - } - token1 = strtok (NULL, seps); - } + { + int id = atoi (token1); + DEBUG(0,LEVEL_DEBUGGING,"%d : %s\n", id, token2); + Sound *ps; + ps = SampleExists (token2); + if (ps == NULL) + { + Sample *s; + s = new Sample; + build_path(sound_dir, token2, samplename); + if (!s->Init (samplename.c_str ())) + { + DEBUG(0,LEVEL_ERROR,"could not load %s\n", samplename.c_str ()); + } + ps = s; + m_Samples.push_back (ps); //add it to our global list + } + if (ps != NULL) + { //we have a valid sound + SoundCollection *psc; + Std::map < int, SoundCollection * >::iterator it; + it = m_ObjectSampleMap.find (id); + if (it == m_ObjectSampleMap.end ()) + { //is there already a collection for this entry? + psc = new SoundCollection; //no, create a new sound collection + psc->m_Sounds.push_back (ps); //add this sound to the collection + m_ObjectSampleMap.insert (Std::make_pair (id, psc)); //insert this pair into the map + } + else + { + psc = (*it).second; //yes, get the existing + psc->m_Sounds.push_back (ps); //add this sound to the collection + } + } + token1 = strtok (NULL, seps); + } return true; }; @@ -396,52 +396,52 @@ bool SoundManager::LoadTileSamples (string sound_dir) build_path(sound_dir, "tile_samples.cfg", scriptname); if(niof.open (scriptname) == false) - { - DEBUG(0,LEVEL_ERROR,"opening %s\n",scriptname.c_str()); - return false; - } + { + DEBUG(0,LEVEL_ERROR,"opening %s\n",scriptname.c_str()); + return false; + } sz = (char *) niof.readAll (); token1 = strtok (sz, seps); while ((token1 != NULL) && ((token2 = strtok (NULL, seps)) != NULL)) - { - int id = atoi (token1); - DEBUG(0,LEVEL_DEBUGGING,"%d : %s\n", id, token2); - Sound *ps; - ps = SampleExists (token2); - if (ps == NULL) - { - Sample *s; - s = new Sample; - build_path(sound_dir, token2, samplename); - if (!s->Init (samplename.c_str ())) - { - DEBUG(0,LEVEL_ERROR,"could not load %s\n", samplename.c_str ()); - } - ps = s; - m_Samples.push_back (ps); //add it to our global list - } - if (ps != NULL) - { //we have a valid sound - SoundCollection *psc; - Std::map < int, SoundCollection * >::iterator it; - it = m_TileSampleMap.find (id); - if (it == m_TileSampleMap.end ()) - { //is there already a collection for this entry? - psc = new SoundCollection; //no, create a new sound collection - psc->m_Sounds.push_back (ps); //add this sound to the collection - m_TileSampleMap.insert (Std::make_pair (id, psc)); //insert this pair into the map - } - else - { - psc = (*it).second; //yes, get the existing - psc->m_Sounds.push_back (ps); //add this sound to the collection - } - } - token1 = strtok (NULL, seps); - } + { + int id = atoi (token1); + DEBUG(0,LEVEL_DEBUGGING,"%d : %s\n", id, token2); + Sound *ps; + ps = SampleExists (token2); + if (ps == NULL) + { + Sample *s; + s = new Sample; + build_path(sound_dir, token2, samplename); + if (!s->Init (samplename.c_str ())) + { + DEBUG(0,LEVEL_ERROR,"could not load %s\n", samplename.c_str ()); + } + ps = s; + m_Samples.push_back (ps); //add it to our global list + } + if (ps != NULL) + { //we have a valid sound + SoundCollection *psc; + Std::map < int, SoundCollection * >::iterator it; + it = m_TileSampleMap.find (id); + if (it == m_TileSampleMap.end ()) + { //is there already a collection for this entry? + psc = new SoundCollection; //no, create a new sound collection + psc->m_Sounds.push_back (ps); //add this sound to the collection + m_TileSampleMap.insert (Std::make_pair (id, psc)); //insert this pair into the map + } + else + { + psc = (*it).second; //yes, get the existing + psc->m_Sounds.push_back (ps); //add this sound to the collection + } + } + token1 = strtok (NULL, seps); + } return true; }; */ diff --git a/engines/ultima/nuvie/views/view_manager.h b/engines/ultima/nuvie/views/view_manager.h index 21765ea0d1f..7dc773e8501 100644 --- a/engines/ultima/nuvie/views/view_manager.h +++ b/engines/ultima/nuvie/views/view_manager.h @@ -52,8 +52,8 @@ class MDSkyStripWidget; using Std::list; typedef enum { CURSOR_HEAD, CURSOR_NECK, CURSOR_CHEST, CURSOR_RIGHT_HAND, CURSOR_LEFT_HAND, CURSOR_RIGHT_RING, CURSOR_LEFT_RING, CURSOR_FEET, - CURSOR_LEFT, CURSOR_RIGHT, CURSOR_COMBAT, CURSOR_CHECK, CURSOR_HEART, CURSOR_PARTY, CURSOR_INVENTORY - } gumpCursorPos; + CURSOR_LEFT, CURSOR_RIGHT, CURSOR_COMBAT, CURSOR_CHECK, CURSOR_HEART, CURSOR_PARTY, CURSOR_INVENTORY + } gumpCursorPos; class ViewManager { protected: diff --git a/engines/ultima/shared/conf/xml_node.cpp b/engines/ultima/shared/conf/xml_node.cpp index 5d358d6eff5..8549d1fe3bc 100644 --- a/engines/ultima/shared/conf/xml_node.cpp +++ b/engines/ultima/shared/conf/xml_node.cpp @@ -462,7 +462,7 @@ XMLNode *XMLNode::xmlParseFile(XMLTree *tree, const Common::String &fname) { } bool XMLNode::searchPairs(KeyTypeList &ktl, const Common::String &basekey, - const Common::String currkey, const unsigned int pos) { + const Common::String currkey, const unsigned int pos) { /* If our 'current key' is longer then the key we're serching for we've obviously gone too deep in this branch, and we won't find it here. */ diff --git a/engines/ultima/shared/conf/xml_tree.cpp b/engines/ultima/shared/conf/xml_tree.cpp index 967cb218838..b813e4ed426 100644 --- a/engines/ultima/shared/conf/xml_tree.cpp +++ b/engines/ultima/shared/conf/xml_tree.cpp @@ -129,7 +129,7 @@ bool XMLTree::checkRoot(const Common::String &key) const { } void XMLTree::value(const Common::String &key, Common::String &ret, - const char *defaultvalue) const { + const char *defaultvalue) const { const XMLNode *sub = _tree->subtree(key); if (sub) ret = sub->text(); @@ -138,7 +138,7 @@ void XMLTree::value(const Common::String &key, Common::String &ret, } void XMLTree::value(const Common::String &key, int &ret, - int defaultvalue) const { + int defaultvalue) const { const XMLNode *sub = _tree->subtree(key); if (sub) ret = strtol(sub->text().c_str(), 0, 0); @@ -147,7 +147,7 @@ void XMLTree::value(const Common::String &key, int &ret, } void XMLTree::value(const Common::String &key, bool &ret, - bool defaultvalue) const { + bool defaultvalue) const { const XMLNode *sub = _tree->subtree(key); if (sub) ret = sub->text().equalsIgnoreCase("YES"); diff --git a/engines/ultima/shared/engine/data_archive.h b/engines/ultima/shared/engine/data_archive.h index 32973ac05b6..e95d7b60b22 100644 --- a/engines/ultima/shared/engine/data_archive.h +++ b/engines/ultima/shared/engine/data_archive.h @@ -38,12 +38,12 @@ namespace Shared { */ class UltimaDataArchive : public Common::Archive { private: - Common::Archive *_zip; + Common::Archive *_zip; Common::String _publicFolder; Common::String _innerfolder; - UltimaDataArchive(Common::Archive *zip, const Common::String &subfolder) : + UltimaDataArchive(Common::Archive *zip, const Common::String &subfolder) : _zip(zip), _publicFolder("data/"), _innerfolder(subfolder + "/") {} Common::String innerToPublic(const Common::String &filename) const { @@ -60,7 +60,7 @@ public: * if the required data is found, it returns the new archive. * Otherwise, returns an error message in the errorMsg field */ - static bool load(const Common::String &subfolder, + static bool load(const Common::String &subfolder, int reqMajorVersion, int reqMinorVersion, Common::U32String &errorMsg); public: ~UltimaDataArchive() override { diff --git a/engines/ultima/shared/engine/debugger.h b/engines/ultima/shared/engine/debugger.h index 523e003ca31..9e08f0c43b6 100644 --- a/engines/ultima/shared/engine/debugger.h +++ b/engines/ultima/shared/engine/debugger.h @@ -54,7 +54,7 @@ protected: void splitString(const Common::String &str, Common::StringArray &argv); public: Debugger(); - ~Debugger() override {} + ~Debugger() override {} /** * Executes the given command diff --git a/engines/ultima/shared/std/containers.h b/engines/ultima/shared/std/containers.h index 0f079bbdd77..d488310a4ca 100644 --- a/engines/ultima/shared/std/containers.h +++ b/engines/ultima/shared/std/containers.h @@ -250,7 +250,7 @@ struct PointerHash { }; template, - class EqualFunc = Common::EqualTo > + class EqualFunc = Common::EqualTo > class map : public Common::HashMap { public: void insert(Std::pair elem) { diff --git a/engines/ultima/ultima1/core/debugger.h b/engines/ultima/ultima1/core/debugger.h index 257e1170453..40ae9e859dc 100644 --- a/engines/ultima/ultima1/core/debugger.h +++ b/engines/ultima/ultima1/core/debugger.h @@ -36,7 +36,7 @@ private: bool cmdSpell(int argc, const char **argv); public: Debugger(); - ~Debugger() override {} + ~Debugger() override {} }; } // End of namespace Ultima1 diff --git a/engines/ultima/ultima4/controllers/game_controller.cpp b/engines/ultima/ultima4/controllers/game_controller.cpp index cae641b0ef2..7ecbfe8fe88 100644 --- a/engines/ultima/ultima4/controllers/game_controller.cpp +++ b/engines/ultima/ultima4/controllers/game_controller.cpp @@ -500,9 +500,9 @@ void GameController::avatarMoved(MoveEvent &event) { g_debugger->jimmyAt(new_coords); event._result = (MoveResult)(MOVE_SUCCEEDED | MOVE_END_TURN); } /*else if (mapPersonAt(c->location->map, new_coords) != nullptr) { - talkAtCoord(newx, newy, 1, nullptr); - event.result = MOVE_SUCCEEDED | MOVE_END_TURN; - }*/ + talkAtCoord(newx, newy, 1, nullptr); + event.result = MOVE_SUCCEEDED | MOVE_END_TURN; + }*/ } /* if we're still blocked */ diff --git a/engines/ultima/ultima4/game/script.h b/engines/ultima/ultima4/game/script.h index 8f827ba0673..8e5aba5db79 100644 --- a/engines/ultima/ultima4/game/script.h +++ b/engines/ultima/ultima4/game/script.h @@ -427,7 +427,7 @@ private: Common::String _nounName; /**< The name that identifies a node name of noun nodes */ Common::String _idPropName; /**< The name of the property that uniquely identifies a noun node - and is used to find a new translation context */ + and is used to find a new translation context */ Common::String _choices; int _iterator; diff --git a/engines/ultima/ultima4/game/spell.h b/engines/ultima/ultima4/game/spell.h index 70a2f97ab67..eb8da7fc9a8 100644 --- a/engines/ultima/ultima4/game/spell.h +++ b/engines/ultima/ultima4/game/spell.h @@ -38,7 +38,7 @@ enum SpellCastError { CASTERR_MPTOOLOW, /* caster doesn't have enough mp */ CASTERR_FAILED, /* the spell failed */ CASTERR_WRONGCONTEXT, /* generic 'wrong-context' error (generrally finds the correct - context error message on its own) */ + context error message on its own) */ CASTERR_COMBATONLY, /* e.g. spell must be cast in combat */ CASTERR_DUNGEONONLY, /* e.g. spell must be cast in dungeons */ CASTERR_WORLDMAPONLY /* e.g. spell must be cast on the world map */ diff --git a/engines/ultima/ultima4/gfx/image.cpp b/engines/ultima/ultima4/gfx/image.cpp index 9537b9401f6..fdd1231c012 100644 --- a/engines/ultima/ultima4/gfx/image.cpp +++ b/engines/ultima/ultima4/gfx/image.cpp @@ -281,8 +281,8 @@ void Image::makeBackgroundColorTransparent(int haloSize, int shadowOpacity) { } void Image::performTransparencyHack(uint colorValue, uint numFrames, - uint currentFrameIndex, uint haloWidth, - uint haloOpacityIncrementByPixelDistance) { + uint currentFrameIndex, uint haloWidth, + uint haloOpacityIncrementByPixelDistance) { Common::List > opaqueXYs; uint x, y; byte t_r, t_g, t_b; diff --git a/engines/ultima/ultima4/gfx/screen.cpp b/engines/ultima/ultima4/gfx/screen.cpp index 02bc8194877..8379afdb789 100644 --- a/engines/ultima/ultima4/gfx/screen.cpp +++ b/engines/ultima/ultima4/gfx/screen.cpp @@ -56,10 +56,10 @@ namespace Ultima4 { Screen *g_screen; Screen::Screen() : _filterScaler(nullptr), _currentMouseCursor(-1), - _gemLayout(nullptr), _tileAnims(nullptr), _charSetInfo(nullptr), - _gemTilesInfo(nullptr), _needPrompt(1), _currentCycle(0), - _cursorStatus(0), _cursorEnabled(1), _priorFrameTime(0) - /* , _continueScreenRefresh(true) */ { + _gemLayout(nullptr), _tileAnims(nullptr), _charSetInfo(nullptr), + _gemTilesInfo(nullptr), _needPrompt(1), _currentCycle(0), + _cursorStatus(0), _cursorEnabled(1), _priorFrameTime(0) + /* , _continueScreenRefresh(true) */ { g_screen = this; Common::fill(&_mouseCursors[0], &_mouseCursors[5], (MouseCursorSurface *)nullptr); Common::fill(&_los[0][0], &_los[0][0] + (VIEWPORT_W * VIEWPORT_H), 0); diff --git a/engines/ultima/ultima4/map/location.cpp b/engines/ultima/ultima4/map/location.cpp index 3d2f78581c5..a2af067f633 100644 --- a/engines/ultima/ultima4/map/location.cpp +++ b/engines/ultima/ultima4/map/location.cpp @@ -57,7 +57,7 @@ static Location *locationPop(Location **stack) { /*-------------------------------------------------------------------*/ Location::Location(MapCoords coords, Map *map, int viewmode, LocationContext ctx, - TurnCompleter *turnCompleter, Location *prev) { + TurnCompleter *turnCompleter, Location *prev) { this->_coords = coords; this->_map = map; diff --git a/engines/ultima/ultima4/views/menuitem.cpp b/engines/ultima/ultima4/views/menuitem.cpp index 868ceec02e6..828908205c4 100644 --- a/engines/ultima/ultima4/views/menuitem.cpp +++ b/engines/ultima/ultima4/views/menuitem.cpp @@ -130,7 +130,7 @@ void BoolMenuItem::activate(MenuEvent &event) { } StringMenuItem::StringMenuItem(Common::String text, short xp, short yp, int shortcutKey, - Common::String *val, const Std::vector &validSettings) : + Common::String *val, const Std::vector &validSettings) : MenuItem(text, xp, yp, shortcutKey), _val(val), _validSettings(validSettings) { @@ -166,7 +166,7 @@ void StringMenuItem::activate(MenuEvent &event) { } IntMenuItem::IntMenuItem(Common::String text, short xp, short yp, int shortcutKey, int *val, - int min, int max, int increment, menuOutputType output) : + int min, int max, int increment, menuOutputType output) : MenuItem(text, xp, yp, shortcutKey), _val(val), _min(min), diff --git a/engines/ultima/ultima8/audio/audio_process.cpp b/engines/ultima/ultima8/audio/audio_process.cpp index d755c344612..027ee61ca75 100644 --- a/engines/ultima/ultima8/audio/audio_process.cpp +++ b/engines/ultima/ultima8/audio/audio_process.cpp @@ -244,8 +244,8 @@ int AudioProcess::playSample(AudioSample *sample, int priority, int loops, uint3 } void AudioProcess::playSFX(int sfxNum, int priority, ObjId objId, int loops, - bool no_duplicates, uint32 pitchShift, uint16 volume, - int16 lVol, int16 rVol, bool ambient) { + bool no_duplicates, uint32 pitchShift, uint16 volume, + int16 lVol, int16 rVol, bool ambient) { SoundFlex *soundflx = GameData::get_instance()->getSoundFlex(); diff --git a/engines/ultima/ultima8/audio/music_process.cpp b/engines/ultima/ultima8/audio/music_process.cpp index 0a3571fe2e7..99a331259b6 100644 --- a/engines/ultima/ultima8/audio/music_process.cpp +++ b/engines/ultima/ultima8/audio/music_process.cpp @@ -40,13 +40,13 @@ MusicProcess::~MusicProcess() { } uint32 MusicProcess::I_stopMusic(const uint8 * /*args*/, - unsigned int /*argsize*/) { + unsigned int /*argsize*/) { if (_theMusicProcess) _theMusicProcess->playMusic_internal(0); return 0; } uint32 MusicProcess::I_playMusic(const uint8 *args, - unsigned int /*argsize*/) { + unsigned int /*argsize*/) { ARG_UINT8(song); if (_theMusicProcess) _theMusicProcess->playMusic(song & 0x7F); return 0; diff --git a/engines/ultima/ultima8/audio/raw_audio_sample.cpp b/engines/ultima/ultima8/audio/raw_audio_sample.cpp index 5f5a4fe7c1f..8e25e19bdb5 100644 --- a/engines/ultima/ultima8/audio/raw_audio_sample.cpp +++ b/engines/ultima/ultima8/audio/raw_audio_sample.cpp @@ -27,7 +27,7 @@ namespace Ultima { namespace Ultima8 { RawAudioSample::RawAudioSample(const uint8 *buffer, uint32 size, uint32 rate, - bool signedData, bool stereo) + bool signedData, bool stereo) : AudioSample(buffer, size, 8, stereo, false), _signedData(signedData) { _sampleRate = rate; _frameSize = 512; diff --git a/engines/ultima/ultima8/audio/sonarc_audio_sample.cpp b/engines/ultima/ultima8/audio/sonarc_audio_sample.cpp index 65118945cf8..0a5b6b39ddf 100644 --- a/engines/ultima/ultima8/audio/sonarc_audio_sample.cpp +++ b/engines/ultima/ultima8/audio/sonarc_audio_sample.cpp @@ -79,8 +79,8 @@ void SonarcAudioSample::GenerateOneTable() { } void SonarcAudioSample::decode_EC(int mode, int samplecount, - const uint8 *source, int sourcesize, - uint8 *dest) { + const uint8 *source, int sourcesize, + uint8 *dest) { bool zerospecial = false; uint32 data = 0; int inputbits = 0; // current 'fill rate' of data window @@ -149,7 +149,7 @@ void SonarcAudioSample::decode_EC(int mode, int samplecount, } void SonarcAudioSample::decode_LPC(int order, int nsamples, - uint8 *dest, const uint8 *factors) { + uint8 *dest, const uint8 *factors) { uint8 *startdest = dest; dest -= order; diff --git a/engines/ultima/ultima8/audio/speech_flex.cpp b/engines/ultima/ultima8/audio/speech_flex.cpp index 3bfe1b453f1..595fe723c37 100644 --- a/engines/ultima/ultima8/audio/speech_flex.cpp +++ b/engines/ultima/ultima8/audio/speech_flex.cpp @@ -60,7 +60,7 @@ SpeechFlex::~SpeechFlex(void) { } int SpeechFlex::getIndexForPhrase(const Std::string &phrase, - uint32 start, uint32 &end) const { + uint32 start, uint32 &end) const { Std::vector::const_iterator it; int i = 1; diff --git a/engines/ultima/ultima8/games/treasure_loader.cpp b/engines/ultima/ultima8/games/treasure_loader.cpp index cbc2a1e8e63..d24b5b260b8 100644 --- a/engines/ultima/ultima8/games/treasure_loader.cpp +++ b/engines/ultima/ultima8/games/treasure_loader.cpp @@ -57,7 +57,7 @@ void TreasureLoader::loadDefaults() { } bool TreasureLoader::parse(const Std::string &desc, - Std::vector &treasure) { + Std::vector &treasure) { treasure.clear(); Std::vector tr; @@ -77,7 +77,7 @@ bool TreasureLoader::parse(const Std::string &desc, } bool TreasureLoader::internalParse(const Std::string &desc, TreasureInfo &ti, - bool loadingDefault) { + bool loadingDefault) { ti._special = ""; ti._chance = 1; ti._map = 0; @@ -148,7 +148,7 @@ bool TreasureLoader::internalParse(const Std::string &desc, TreasureInfo &ti, } bool TreasureLoader::parseUInt32Vector(const Std::string &val_, - Std::vector &vec) { + Std::vector &vec) { Std::string val = val_; vec.clear(); @@ -179,7 +179,7 @@ bool TreasureLoader::parseUInt32Vector(const Std::string &val_, } bool TreasureLoader::parseUIntRange(const Std::string &val, - unsigned int &min, unsigned int &max) { + unsigned int &min, unsigned int &max) { Std::string::size_type pos = val.find('-'); if (pos == 0 || pos == Std::string::npos || pos + 1 >= val.size()) return false; diff --git a/engines/ultima/ultima8/graphics/fonts/font.cpp b/engines/ultima/ultima8/graphics/fonts/font.cpp index f3413dc2255..ba60a6e55c8 100644 --- a/engines/ultima/ultima8/graphics/fonts/font.cpp +++ b/engines/ultima/ultima8/graphics/fonts/font.cpp @@ -36,10 +36,10 @@ Font::~Font() { void Font::getTextSize(const Std::string &text, - int32 &resultwidth, int32 &resultheight, - unsigned int &remaining, - int32 width, int32 height, TextAlign align, - bool u8specials) { + int32 &resultwidth, int32 &resultheight, + unsigned int &remaining, + int32 width, int32 height, TextAlign align, + bool u8specials) { Std::list tmp; tmp = typesetText(this, text, remaining, width, height, align, u8specials, @@ -146,7 +146,7 @@ bool Font::SJISTraits::canBreakAfter(Std::string::const_iterator &i) { template static void findWordEnd(const Std::string &text, - Std::string::const_iterator &iter, bool u8specials) { + Std::string::const_iterator &iter, bool u8specials) { while (iter != text.end()) { if (T::isSpace(iter, u8specials)) return; T::advance(iter); @@ -155,7 +155,7 @@ static void findWordEnd(const Std::string &text, template static void passSpace(const Std::string &text, - Std::string::const_iterator &iter, bool u8specials) { + Std::string::const_iterator &iter, bool u8specials) { while (iter != text.end()) { if (!T::isSpace(iter, u8specials)) return; T::advance(iter); diff --git a/engines/ultima/ultima8/graphics/fonts/font_manager.cpp b/engines/ultima/ultima8/graphics/fonts/font_manager.cpp index 20a39edf6b1..4eb4203947d 100644 --- a/engines/ultima/ultima8/graphics/fonts/font_manager.cpp +++ b/engines/ultima/ultima8/graphics/fonts/font_manager.cpp @@ -73,7 +73,7 @@ void FontManager::resetGameFonts() { _ttfFonts.clear();} Font *FontManager::getGameFont(unsigned int fontnum, - bool allowOverride) { + bool allowOverride) { if (allowOverride && fontnum < _overrides.size() && _overrides[fontnum]) return _overrides[fontnum]; @@ -140,8 +140,8 @@ void FontManager::setOverride(unsigned int fontnum, Font *newFont) { bool FontManager::addTTFOverride(unsigned int fontnum, const Std::string &filename, - int pointsize, uint32 rgb, int bordersize, - bool SJIS) { + int pointsize, uint32 rgb, int bordersize, + bool SJIS) { bool antialiasing = ConfMan.getBool("font_antialiasing"); Graphics::Font *f = getTTF_Font(filename, pointsize, antialiasing); if (!f) @@ -161,7 +161,7 @@ bool FontManager::addTTFOverride(unsigned int fontnum, const Std::string &filena } bool FontManager::addJPOverride(unsigned int fontnum, - unsigned int jpfont, uint32 rgb) { + unsigned int jpfont, uint32 rgb) { ShapeFont *jf = dynamic_cast(GameData::get_instance()->getFonts()->getFont(jpfont)); if (!jf) return false; @@ -194,7 +194,7 @@ bool FontManager::addJPOverride(unsigned int fontnum, bool FontManager::loadTTFont(unsigned int fontnum, const Std::string &filename, - int pointsize, uint32 rgb, int bordersize) { + int pointsize, uint32 rgb, int bordersize) { bool antialiasing = ConfMan.getBool("font_antialiasing"); Graphics::Font *f = getTTF_Font(filename, pointsize, antialiasing); if (!f) diff --git a/engines/ultima/ultima8/graphics/fonts/jp_font.cpp b/engines/ultima/ultima8/graphics/fonts/jp_font.cpp index be884edce5c..76f74fc058d 100644 --- a/engines/ultima/ultima8/graphics/fonts/jp_font.cpp +++ b/engines/ultima/ultima8/graphics/fonts/jp_font.cpp @@ -75,10 +75,10 @@ void JPFont::getStringSize(const Std::string &text, int32 &width, int32 &height) } void JPFont::getTextSize(const Std::string &text, - int32 &resultwidth, int32 &resultheight, - unsigned int &remaining, - int32 width, int32 height, TextAlign align, - bool u8specials) { + int32 &resultwidth, int32 &resultheight, + unsigned int &remaining, + int32 width, int32 height, TextAlign align, + bool u8specials) { Std::list tmp; tmp = typesetText(this, text, remaining, width, height, align, u8specials, @@ -86,10 +86,10 @@ void JPFont::getTextSize(const Std::string &text, } RenderedText *JPFont::renderText(const Std::string &text, - unsigned int &remaining, - int32 width, int32 height, TextAlign align, - bool u8specials, - Std::string::size_type cursor) { + unsigned int &remaining, + int32 width, int32 height, TextAlign align, + bool u8specials, + Std::string::size_type cursor) { int32 resultwidth, resultheight; Std::list lines; lines = typesetText(this, text, remaining, diff --git a/engines/ultima/ultima8/graphics/fonts/jp_rendered_text.cpp b/engines/ultima/ultima8/graphics/fonts/jp_rendered_text.cpp index a1c9b24dbb8..af5c358822e 100644 --- a/engines/ultima/ultima8/graphics/fonts/jp_rendered_text.cpp +++ b/engines/ultima/ultima8/graphics/fonts/jp_rendered_text.cpp @@ -86,7 +86,7 @@ void JPRenderedText::draw(RenderSurface *surface, int x, int y, bool /*destmaske } void JPRenderedText::drawBlended(RenderSurface *surface, int x, int y, - uint32 col, bool /*destmasked*/) { + uint32 col, bool /*destmasked*/) { // TODO Support masking here?? PaletteManager *palman = PaletteManager::get_instance(); diff --git a/engines/ultima/ultima8/graphics/fonts/shape_font.cpp b/engines/ultima/ultima8/graphics/fonts/shape_font.cpp index 014f1f57042..8d19928b9e9 100644 --- a/engines/ultima/ultima8/graphics/fonts/shape_font.cpp +++ b/engines/ultima/ultima8/graphics/fonts/shape_font.cpp @@ -30,8 +30,8 @@ namespace Ultima { namespace Ultima8 { ShapeFont::ShapeFont(const uint8 *data, uint32 size, - const ConvertShapeFormat *format, - const uint16 flexId, const uint32 shapeNum) + const ConvertShapeFormat *format, + const uint16 flexId, const uint32 shapeNum) : Font(), Shape(data, size, format, flexId, shapeNum), _height(0), _baseLine(0), _vLead(-1), _hLead(0) { _crusaderCharMap = GAME_IS_CRUSADER && shapeNum == 1; @@ -120,10 +120,10 @@ int ShapeFont::charToFrameNum(char c) const { } RenderedText *ShapeFont::renderText(const Std::string &text, - unsigned int &remaining, - int32 width, int32 height, TextAlign align, - bool u8specials, - Std::string::size_type cursor) { + unsigned int &remaining, + int32 width, int32 height, TextAlign align, + bool u8specials, + Std::string::size_type cursor) { int32 resultwidth, resultheight; Std::list lines; lines = typesetText(this, text, remaining, diff --git a/engines/ultima/ultima8/graphics/fonts/shape_rendered_text.cpp b/engines/ultima/ultima8/graphics/fonts/shape_rendered_text.cpp index 7f418fcfdcb..fb4ad952c38 100644 --- a/engines/ultima/ultima8/graphics/fonts/shape_rendered_text.cpp +++ b/engines/ultima/ultima8/graphics/fonts/shape_rendered_text.cpp @@ -30,8 +30,8 @@ namespace Ultima { namespace Ultima8 { ShapeRenderedText::ShapeRenderedText(const Std::list &lines, - int width, int height, int vLead, - ShapeFont *font) + int width, int height, int vLead, + ShapeFont *font) : _lines(lines), _font(font) { _width = width; _height = height; @@ -76,7 +76,7 @@ void ShapeRenderedText::draw(RenderSurface *surface, int x, int y, bool /*destma } void ShapeRenderedText::drawBlended(RenderSurface *surface, int x, int y, - uint32 col, bool /*destmasked*/) { + uint32 col, bool /*destmasked*/) { // TODO Support masking here ???? Std::list::const_iterator iter; diff --git a/engines/ultima/ultima8/graphics/fonts/tt_font.cpp b/engines/ultima/ultima8/graphics/fonts/tt_font.cpp index 689f6de75c9..51285e54c85 100644 --- a/engines/ultima/ultima8/graphics/fonts/tt_font.cpp +++ b/engines/ultima/ultima8/graphics/fonts/tt_font.cpp @@ -104,10 +104,10 @@ void TTFont::getStringSize(const Std::string &text, int32 &width, int32 &height) } void TTFont::getTextSize(const Std::string &text, - int32 &resultWidth, int32 &resultHeight, - unsigned int &remaining, - int32 width, int32 height, TextAlign align, - bool u8specials) { + int32 &resultWidth, int32 &resultHeight, + unsigned int &remaining, + int32 width, int32 height, TextAlign align, + bool u8specials) { Std::list tmp; if (!_SJIS) tmp = typesetText(this, text, remaining, diff --git a/engines/ultima/ultima8/graphics/inverter_process.cpp b/engines/ultima/ultima8/graphics/inverter_process.cpp index 22889f9b107..b42d55763b9 100644 --- a/engines/ultima/ultima8/graphics/inverter_process.cpp +++ b/engines/ultima/ultima8/graphics/inverter_process.cpp @@ -30,16 +30,16 @@ namespace Ultima { namespace Ultima8 { static unsigned int states[] = { 0, 8, 63, 211, 493, 945, 1594, 2459, 3552, - 4870, 6406, 8139, 10042, 12078, 14207, 16384, - 18561, 20690, 22726, 24629, 26362, 27898, - 29216, 30308, 31174, 31823, 32274, 32556, - 32704, 32760, 32768, - 32775, 32831, 32979, 33261, 33713, 34362, - 35227, 36320, 37638, 39174, 40907, 42810, - 44846, 46975, 49152, 51328, 53457, 55494, - 57396, 59129, 60665, 61984, 63076, 63942, - 64591, 65042, 65324, 65472, 65528, 65536 - }; + 4870, 6406, 8139, 10042, 12078, 14207, 16384, + 18561, 20690, 22726, 24629, 26362, 27898, + 29216, 30308, 31174, 31823, 32274, 32556, + 32704, 32760, 32768, + 32775, 32831, 32979, 33261, 33713, 34362, + 35227, 36320, 37638, 39174, 40907, 42810, + 44846, 46975, 49152, 51328, 53457, 55494, + 57396, 59129, 60665, 61984, 63076, 63942, + 64591, 65042, 65324, 65472, 65528, 65536 + }; InverterProcess *InverterProcess::_inverter = nullptr; @@ -106,7 +106,7 @@ ProcId InverterProcess::invertScreen() { uint32 InverterProcess::I_invertScreen(const uint8 *args, - unsigned int /*argsize*/) { + unsigned int /*argsize*/) { return invertScreen(); } diff --git a/engines/ultima/ultima8/graphics/palette_fader_process.cpp b/engines/ultima/ultima8/graphics/palette_fader_process.cpp index 0524d8ef258..841240e287f 100644 --- a/engines/ultima/ultima8/graphics/palette_fader_process.cpp +++ b/engines/ultima/ultima8/graphics/palette_fader_process.cpp @@ -37,7 +37,7 @@ PaletteFaderProcess::PaletteFaderProcess() : Process(), _priority(0), } PaletteFaderProcess::PaletteFaderProcess(PalTransforms trans, - int priority, int frames) : _priority(priority), + int priority, int frames) : _priority(priority), _counter(frames), _maxCounter(frames) { PaletteManager *pm = PaletteManager::get_instance(); Palette *pal = pm->getPalette(PaletteManager::Pal_Game); @@ -47,7 +47,7 @@ PaletteFaderProcess::PaletteFaderProcess(PalTransforms trans, } PaletteFaderProcess::PaletteFaderProcess(uint32 col32, bool from, - int priority, int frames, bool current) : _priority(priority), + int priority, int frames, bool current) : _priority(priority), _counter(frames), _maxCounter(frames) { PaletteManager *pm = PaletteManager::get_instance(); Palette *pal = pm->getPalette(PaletteManager::Pal_Game); @@ -67,7 +67,7 @@ PaletteFaderProcess::PaletteFaderProcess(uint32 col32, bool from, } PaletteFaderProcess::PaletteFaderProcess(const int16 from[12], const int16 to[12], - int priority, int frames) : _priority(priority), + int priority, int frames) : _priority(priority), _counter(frames), _maxCounter(frames) { int i; for (i = 0; i < 12; i++) _oldMatrix[i] = from[i]; @@ -126,7 +126,7 @@ bool PaletteFaderProcess::loadData(Common::ReadStream *rs, uint32 version) { } uint32 PaletteFaderProcess::I_fadeToPaletteTransform(const uint8 *args, - unsigned int /*argsize*/) { + unsigned int /*argsize*/) { ARG_UINT16(transform); ARG_UINT16(priority); @@ -143,7 +143,7 @@ uint32 PaletteFaderProcess::I_fadeToPaletteTransform(const uint8 *args, } uint32 PaletteFaderProcess::I_fadeToBlack(const uint8 *args, - unsigned int argsize) { + unsigned int argsize) { if (_fader && _fader->_priority > 0x7FFF) return 0; else if (_fader && !_fader->is_terminated()) @@ -164,7 +164,7 @@ uint32 PaletteFaderProcess::I_fadeToBlack(const uint8 *args, } uint32 PaletteFaderProcess::I_fadeFromBlack(const uint8 *args, - unsigned int argsize) { + unsigned int argsize) { if (_fader && _fader->_priority > 0x7FFF) return 0; else if (_fader && !_fader->is_terminated()) @@ -185,7 +185,7 @@ uint32 PaletteFaderProcess::I_fadeFromBlack(const uint8 *args, } uint32 PaletteFaderProcess::I_fadeToWhite(const uint8 * /*args*/, - unsigned int /*argsize*/) { + unsigned int /*argsize*/) { if (_fader && _fader->_priority > 0x7FFF) return 0; else if (_fader && !_fader->is_terminated()) @@ -196,7 +196,7 @@ uint32 PaletteFaderProcess::I_fadeToWhite(const uint8 * /*args*/, } uint32 PaletteFaderProcess::I_fadeFromWhite(const uint8 * /*args*/, - unsigned int /*argsize*/) { + unsigned int /*argsize*/) { if (_fader && _fader->_priority > 0x7FFF) return 0; else if (_fader && !_fader->is_terminated()) @@ -207,7 +207,7 @@ uint32 PaletteFaderProcess::I_fadeFromWhite(const uint8 * /*args*/, } uint32 PaletteFaderProcess::I_lightningBolt(const uint8 * /*args*/, - unsigned int /*argsize*/) { + unsigned int /*argsize*/) { if (_fader && _fader->_priority > -1) return 0; else if (_fader && !_fader->is_terminated()) @@ -268,7 +268,7 @@ uint32 PaletteFaderProcess::I_fadeToGivenColor(const uint8 *args, uint32 PaletteFaderProcess::I_jumpToGreyScale(const uint8 * /*args*/, - unsigned int /*argsize*/) { + unsigned int /*argsize*/) { if (_fader && _fader->_priority > 0x7FFF) return 0; else if (_fader) _fader->terminate(); @@ -278,7 +278,7 @@ uint32 PaletteFaderProcess::I_jumpToGreyScale(const uint8 * /*args*/, } uint32 PaletteFaderProcess::I_jumpToAllBlack(const uint8 * /*args*/, - unsigned int /*argsize*/) { + unsigned int /*argsize*/) { if (_fader && _fader->_priority > 0x7FFF) return 0; else if (_fader) _fader->terminate(); @@ -288,7 +288,7 @@ uint32 PaletteFaderProcess::I_jumpToAllBlack(const uint8 * /*args*/, } uint32 PaletteFaderProcess::I_jumpToAllGrey(const uint8 * /*args*/, - unsigned int /*argsize*/) { + unsigned int /*argsize*/) { if (_fader && _fader->_priority > 0x7FFF) return 0; else if (_fader) _fader->terminate(); diff --git a/engines/ultima/ultima8/graphics/raw_shape_frame.cpp b/engines/ultima/ultima8/graphics/raw_shape_frame.cpp index 36012abac3b..6ad64edf949 100644 --- a/engines/ultima/ultima8/graphics/raw_shape_frame.cpp +++ b/engines/ultima/ultima8/graphics/raw_shape_frame.cpp @@ -35,7 +35,7 @@ namespace Ultima8 { parse data and fill class */ RawShapeFrame::RawShapeFrame(const uint8 *data, uint32 size, const ConvertShapeFormat *format, - const uint8 special[256], ConvertShapeFrame *prev) : _line_offsets(0), + const uint8 special[256], ConvertShapeFrame *prev) : _line_offsets(0), _rle_data(nullptr) { // Load it as u8 if (!format || format == &U8ShapeFormat || format == &U82DShapeFormat) diff --git a/engines/ultima/ultima8/graphics/shape.cpp b/engines/ultima/ultima8/graphics/shape.cpp index 8d3591f7294..c4a6e83d3bf 100644 --- a/engines/ultima/ultima8/graphics/shape.cpp +++ b/engines/ultima/ultima8/graphics/shape.cpp @@ -35,7 +35,7 @@ namespace Ultima { namespace Ultima8 { Shape::Shape(const uint8 *data, uint32 size, const ConvertShapeFormat *format, - const uint16 id, const uint32 shape) + const uint16 id, const uint32 shape) : _flexId(id), _shapeNum(shape), _palette(nullptr) { // NB: U8 style! loadFrames(data, size, format); diff --git a/engines/ultima/ultima8/graphics/skf_player.cpp b/engines/ultima/ultima8/graphics/skf_player.cpp index 8e86862e31a..bb9bab5fcce 100644 --- a/engines/ultima/ultima8/graphics/skf_player.cpp +++ b/engines/ultima/ultima8/graphics/skf_player.cpp @@ -68,7 +68,7 @@ SKFPlayer::SKFPlayer(Common::SeekableReadStream *rs, int width, int height, bool : _width(width), _height(height), _curFrame(0), _curObject(0), _curAction(0), _curEvent(0), _playing(false), _timer(0), _frameRate(15), _fadeColour(0), _fadeLevel(0), _buffer(nullptr), _subs(nullptr), _introMusicHack(introMusicHack), - _lastUpdate(0), _subtitleY(0) { + _lastUpdate(0), _subtitleY(0) { _skf = new RawArchive(rs); Common::ReadStream *eventlist = _skf->get_datasource(0); if (!eventlist) { diff --git a/engines/ultima/ultima8/graphics/texture.h b/engines/ultima/ultima8/graphics/texture.h index 9512ec67098..7c069fa2d19 100644 --- a/engines/ultima/ultima8/graphics/texture.h +++ b/engines/ultima/ultima8/graphics/texture.h @@ -48,11 +48,11 @@ namespace Ultima8 { #define TEX32_R(col32) (((col32)&TEX32_R_MASK)>>TEX32_R_SHIFT) #define TEX32_PACK_RGBA(r,g,b,a) (((a)<>8)<>8)<>8)<>8)<>8)<>8)<>8)<= _overlay.size()) return nullptr; if (!_overlay[action]) diff --git a/engines/ultima/ultima8/gumps/container_gump.cpp b/engines/ultima/ultima8/gumps/container_gump.cpp index f4ca09337e1..fbf178eb83d 100644 --- a/engines/ultima/ultima8/gumps/container_gump.cpp +++ b/engines/ultima/ultima8/gumps/container_gump.cpp @@ -50,7 +50,7 @@ ContainerGump::ContainerGump() } ContainerGump::ContainerGump(const Shape *shape, uint32 frameNum, uint16 owner, - uint32 flags, int32 layer) + uint32 flags, int32 layer) : ItemRelativeGump(0, 0, 5, 5, owner, flags, layer), _displayDragging(false), _draggingShape(0), _draggingFrame(0), _draggingFlags(0), _draggingX(0), _draggingY(0) { @@ -189,7 +189,7 @@ uint16 ContainerGump::TraceObjId(int32 mx, int32 my) { // get item coords relative to self bool ContainerGump::GetLocationOfItem(uint16 itemid, int32 &gx, int32 &gy, - int32 lerp_factor) { + int32 lerp_factor) { Item *item = getItem(itemid); if (!item) return false; Item *parent = item->getParentAsContainer(); diff --git a/engines/ultima/ultima8/gumps/credits_gump.cpp b/engines/ultima/ultima8/gumps/credits_gump.cpp index a57c5e5dba2..c005ab0096a 100644 --- a/engines/ultima/ultima8/gumps/credits_gump.cpp +++ b/engines/ultima/ultima8/gumps/credits_gump.cpp @@ -47,7 +47,7 @@ CreditsGump::CreditsGump() } CreditsGump::CreditsGump(const Std::string &text, int parskip, - uint32 flags, int32 layer) + uint32 flags, int32 layer) : ModalGump(0, 0, 320, 200, 0, flags, layer), _text(text), _parSkip(parskip), _timer(0), _title(nullptr), _nextTitle(nullptr), _state(CS_PLAYING), _nextTitleSurf(0), _currentSurface(0), _currentY(0) { @@ -102,7 +102,7 @@ void CreditsGump::Close(bool no_del) { } void CreditsGump::extractLine(Std::string &text, - char &modifier, Std::string &line) { + char &modifier, Std::string &line) { if (!text.empty() && (text[0] == '+' || text[0] == '&' || text[0] == '}' || text[0] == '~' || text[0] == '@')) { modifier = text[0]; diff --git a/engines/ultima/ultima8/gumps/cru_pickup_area_gump.h b/engines/ultima/ultima8/gumps/cru_pickup_area_gump.h index 9cc247ce421..a090e6625b5 100644 --- a/engines/ultima/ultima8/gumps/cru_pickup_area_gump.h +++ b/engines/ultima/ultima8/gumps/cru_pickup_area_gump.h @@ -55,7 +55,7 @@ public: static CruPickupAreaGump *get_instance(); private: - static CruPickupAreaGump *_instance; + static CruPickupAreaGump *_instance; }; } // End of namespace Ultima8 diff --git a/engines/ultima/ultima8/gumps/game_map_gump.cpp b/engines/ultima/ultima8/gumps/game_map_gump.cpp index 694d060c8bb..55aae5a69ab 100644 --- a/engines/ultima/ultima8/gumps/game_map_gump.cpp +++ b/engines/ultima/ultima8/gumps/game_map_gump.cpp @@ -65,7 +65,7 @@ GameMapGump::~GameMapGump() { } void GameMapGump::GetCameraLocation(int32 &lx, int32 &ly, int32 &lz, - int lerp_factor) { + int lerp_factor) { CameraProcess *camera = CameraProcess::GetCameraProcess(); if (!camera) { CameraProcess::GetCameraLocation(lx, ly, lz); @@ -179,7 +179,7 @@ uint16 GameMapGump::TraceObjId(int32 mx, int32 my) { } uint16 GameMapGump::TraceCoordinates(int mx, int my, int32 coords[3], - int offsetx, int offsety, Item *item) { + int offsetx, int offsety, Item *item) { int32 dxd = 0, dyd = 0, dzd = 0; if (item) item->getFootpadWorld(dxd, dyd, dzd); @@ -231,7 +231,7 @@ uint16 GameMapGump::TraceCoordinates(int mx, int my, int32 coords[3], } bool GameMapGump::GetLocationOfItem(uint16 itemid, int32 &gx, int32 &gy, - int32 lerp_factor) { + int32 lerp_factor) { Item *item = getItem(itemid); if (!item) return false; diff --git a/engines/ultima/ultima8/gumps/gump.cpp b/engines/ultima/ultima8/gumps/gump.cpp index ac47d6f3a53..e0d6a43e725 100644 --- a/engines/ultima/ultima8/gumps/gump.cpp +++ b/engines/ultima/ultima8/gumps/gump.cpp @@ -43,7 +43,7 @@ Gump::Gump() : Object(), _parent(nullptr), _owner(0), } Gump::Gump(int inX, int inY, int width, int height, uint16 inOwner, - uint32 inFlags, int32 inLayer) : + uint32 inFlags, int32 inLayer) : Object(), _owner(inOwner), _parent(nullptr), _x(inX), _y(inY), _dims(0, 0, width, height), _flags(inFlags), _layer(inLayer), _index(-1), _shape(nullptr), _frameNum(0), _children(), _focusChild(nullptr), @@ -289,7 +289,7 @@ void Gump::PaintChildren(RenderSurface *surf, int32 lerp_factor, bool scaled) { } void Gump::PaintCompositing(RenderSurface *surf, int32 lerp_factor, - int32 sx, int32 sy) { + int32 sx, int32 sy) { // Don't paint if hidden if (IsHidden()) return; @@ -527,7 +527,7 @@ uint16 Gump::TraceObjId(int32 mx, int32 my) { } bool Gump::GetLocationOfItem(uint16 itemid, int32 &gx, int32 &gy, - int32 lerp_factor) { + int32 lerp_factor) { gx = 0; gy = 0; return false; diff --git a/engines/ultima/ultima8/gumps/item_relative_gump.cpp b/engines/ultima/ultima8/gumps/item_relative_gump.cpp index ae29940730c..8e2011df7ba 100644 --- a/engines/ultima/ultima8/gumps/item_relative_gump.cpp +++ b/engines/ultima/ultima8/gumps/item_relative_gump.cpp @@ -34,7 +34,7 @@ ItemRelativeGump::ItemRelativeGump() : Gump(), _ix(0), _iy(0) { } ItemRelativeGump::ItemRelativeGump(int32 x, int32 y, int32 width, int32 height, - uint16 owner, uint32 flags, int32 layer) + uint16 owner, uint32 flags, int32 layer) : Gump(x, y, width, height, owner, flags, layer), _ix(0), _iy(0) { } diff --git a/engines/ultima/ultima8/gumps/message_box_gump.cpp b/engines/ultima/ultima8/gumps/message_box_gump.cpp index 8ca40b69848..84c2baa376b 100644 --- a/engines/ultima/ultima8/gumps/message_box_gump.cpp +++ b/engines/ultima/ultima8/gumps/message_box_gump.cpp @@ -39,7 +39,7 @@ MessageBoxGump::MessageBoxGump() } MessageBoxGump::MessageBoxGump(const Std::string &title, const Std::string &message, uint32 titleColour, - Std::vector *buttons) : + Std::vector *buttons) : ModalGump(0, 0, 100, 100), _title(title), _message(message), _titleColour(titleColour) { if (buttons) buttons->swap(_buttons); diff --git a/engines/ultima/ultima8/gumps/modal_gump.cpp b/engines/ultima/ultima8/gumps/modal_gump.cpp index e0144cf227e..3d4ad8b0208 100644 --- a/engines/ultima/ultima8/gumps/modal_gump.cpp +++ b/engines/ultima/ultima8/gumps/modal_gump.cpp @@ -37,7 +37,7 @@ ModalGump::ModalGump() : Gump() { ModalGump::ModalGump(int x, int y, int width, int height, uint16 owner, - uint32 flags, int32 layer) + uint32 flags, int32 layer) : Gump(x, y, width, height, owner, flags, layer) { } diff --git a/engines/ultima/ultima8/gumps/movie_gump.cpp b/engines/ultima/ultima8/gumps/movie_gump.cpp index dae84a38dc6..c310689c831 100644 --- a/engines/ultima/ultima8/gumps/movie_gump.cpp +++ b/engines/ultima/ultima8/gumps/movie_gump.cpp @@ -47,7 +47,7 @@ MovieGump::MovieGump() : ModalGump(), _player(nullptr) { } MovieGump::MovieGump(int width, int height, Common::SeekableReadStream *rs, - bool introMusicHack, bool noScale, const byte *overridePal, + bool introMusicHack, bool noScale, const byte *overridePal, uint32 flags, int32 layer) : ModalGump(50, 50, width, height, 0, flags, layer), _subtitleWidget(0) { uint32 stream_id = rs->readUint32BE(); @@ -248,7 +248,7 @@ static Common::SeekableReadStream *_tryLoadCruSubtitle(const Std::string &filena } uint32 MovieGump::I_playMovieOverlay(const uint8 *args, - unsigned int /*argsize*/) { + unsigned int /*argsize*/) { ARG_ITEM_FROM_PTR(item); ARG_STRING(name); ARG_UINT16(x); diff --git a/engines/ultima/ultima8/gumps/paperdoll_gump.cpp b/engines/ultima/ultima8/gumps/paperdoll_gump.cpp index ee3e352dc9f..4cb987951cf 100644 --- a/engines/ultima/ultima8/gumps/paperdoll_gump.cpp +++ b/engines/ultima/ultima8/gumps/paperdoll_gump.cpp @@ -137,7 +137,7 @@ void PaperdollGump::Close(bool no_del) { } void PaperdollGump::PaintStat(RenderSurface *surf, unsigned int n, - Std::string text, int val) { + Std::string text, int val) { assert(n < 7); // constant! Font *font, *descfont; @@ -261,7 +261,7 @@ uint16 PaperdollGump::TraceObjId(int32 mx, int32 my) { // get item coords relative to self bool PaperdollGump::GetLocationOfItem(uint16 itemid, int32 &gx, int32 &gy, - int32 lerp_factor) { + int32 lerp_factor) { Item *item = getItem(itemid); if (!item) diff --git a/engines/ultima/ultima8/gumps/shape_viewer_gump.cpp b/engines/ultima/ultima8/gumps/shape_viewer_gump.cpp index 7fcab0a5cbb..12126589635 100644 --- a/engines/ultima/ultima8/gumps/shape_viewer_gump.cpp +++ b/engines/ultima/ultima8/gumps/shape_viewer_gump.cpp @@ -57,8 +57,8 @@ ShapeViewerGump::ShapeViewerGump() } ShapeViewerGump::ShapeViewerGump(int x, int y, int width, int height, - Std::vector > &flexes, - uint32 flags, int32 layer) + Std::vector > &flexes, + uint32 flags, int32 layer) : ModalGump(x, y, width, height, 0, flags, layer), _flexes(flexes), _curFlex(0), _curShape(0), _curFrame(0), _background(0), _fontNo(0), _shapeW(0), _shapeH(0), _shapeX(0), _shapeY(0) { diff --git a/engines/ultima/ultima8/gumps/slider_gump.cpp b/engines/ultima/ultima8/gumps/slider_gump.cpp index 5574afcd17a..440b57dc594 100644 --- a/engines/ultima/ultima8/gumps/slider_gump.cpp +++ b/engines/ultima/ultima8/gumps/slider_gump.cpp @@ -44,7 +44,7 @@ SliderGump::SliderGump() : ModalGump(), _renderedText(nullptr), _min(0), _max(0) SliderGump::SliderGump(int x, int y, int16 min, int16 max, - int16 value, int16 delta) + int16 value, int16 delta) : ModalGump(x, y, 5, 5), _min(min), _max(max), _delta(delta), _value(value), _usecodeNotifyPID(0), _renderedText(nullptr), _renderedValue(-1) { } diff --git a/engines/ultima/ultima8/gumps/widgets/button_widget.cpp b/engines/ultima/ultima8/gumps/widgets/button_widget.cpp index e6dec494112..0a1a342cdbe 100644 --- a/engines/ultima/ultima8/gumps/widgets/button_widget.cpp +++ b/engines/ultima/ultima8/gumps/widgets/button_widget.cpp @@ -40,8 +40,8 @@ ButtonWidget::ButtonWidget() : Gump(), _shapeUp(nullptr), _shapeDown(nullptr), } ButtonWidget::ButtonWidget(int x, int y, Std::string txt, bool gamefont, - int font, uint32 mouseOverBlendCol, - int w, int h, int32 layer) : + int font, uint32 mouseOverBlendCol, + int w, int h, int32 layer) : Gump(x, y, w, h, 0, 0, layer), _shapeUp(nullptr), _shapeDown(nullptr), _mouseOver(false), _origW(w), _origH(h), _frameNumUp(0), _frameNumDown(0) { TextWidget *widget = new TextWidget(0, 0, txt, gamefont, font, w, h); @@ -51,7 +51,7 @@ ButtonWidget::ButtonWidget(int x, int y, Std::string txt, bool gamefont, } ButtonWidget::ButtonWidget(int x, int y, FrameID frame_up, FrameID frame_down, - bool mouseOver, int32 layer) + bool mouseOver, int32 layer) : Gump(x, y, 5, 5, 0, 0, layer), _textWidget(0), _mouseOver(mouseOver), _origW(0), _origH(0), _mouseOverBlendCol(0) { _shapeUp = GameData::get_instance()->getShape(frame_up); diff --git a/engines/ultima/ultima8/gumps/widgets/edit_widget.cpp b/engines/ultima/ultima8/gumps/widgets/edit_widget.cpp index ceb3a8da8f7..4adbda89c77 100644 --- a/engines/ultima/ultima8/gumps/widgets/edit_widget.cpp +++ b/engines/ultima/ultima8/gumps/widgets/edit_widget.cpp @@ -33,7 +33,7 @@ namespace Ultima8 { DEFINE_RUNTIME_CLASSTYPE_CODE(EditWidget) EditWidget::EditWidget(int x, int y, Std::string txt, bool gamefont, int font, - int w, int h, unsigned int maxlength, bool multiline) + int w, int h, unsigned int maxlength, bool multiline) : Gump(x, y, w, h), _text(txt), _gameFont(gamefont), _fontNum(font), _maxLength(maxlength), _multiLine(multiline), _cursorChanged(0), _cursorVisible(true), _cachedText(nullptr) { diff --git a/engines/ultima/ultima8/gumps/widgets/text_widget.cpp b/engines/ultima/ultima8/gumps/widgets/text_widget.cpp index 3bb522ca557..bab2759e5d7 100644 --- a/engines/ultima/ultima8/gumps/widgets/text_widget.cpp +++ b/engines/ultima/ultima8/gumps/widgets/text_widget.cpp @@ -39,7 +39,7 @@ TextWidget::TextWidget() : Gump(), _gameFont(false), _fontNum(0), _blendColour(0 } TextWidget::TextWidget(int x, int y, const Std::string &txt, bool gamefont, int font, - int w, int h, Font::TextAlign align) : + int w, int h, Font::TextAlign align) : Gump(x, y, w, h), _text(txt), _gameFont(gamefont), _fontNum(font), _blendColour(0), _currentStart(0), _currentEnd(0), _tx(0), _ty(0), _targetWidth(w), _targetHeight(h), _cachedText(nullptr), _textAlign(align) { diff --git a/engines/ultima/ultima8/kernel/object.cpp b/engines/ultima/ultima8/kernel/object.cpp index 5bce0a75dbf..d2d995362cb 100644 --- a/engines/ultima/ultima8/kernel/object.cpp +++ b/engines/ultima/ultima8/kernel/object.cpp @@ -56,7 +56,7 @@ void Object::dumpInfo() const { } ProcId Object::callUsecode(uint16 classid, uint16 offset, - const uint8 *args, int argsize) { + const uint8 *args, int argsize) { uint32 objptr = UCMachine::objectToPtr(getObjId()); UCProcess *p = new UCProcess(classid, offset, objptr, 2, args, argsize); return Kernel::get_instance()->addProcess(p); diff --git a/engines/ultima/ultima8/kernel/object_manager.cpp b/engines/ultima/ultima8/kernel/object_manager.cpp index bb9ecde0af4..671c547d711 100644 --- a/engines/ultima/ultima8/kernel/object_manager.cpp +++ b/engines/ultima/ultima8/kernel/object_manager.cpp @@ -310,7 +310,7 @@ Object *ObjectManager::loadObject(Common::ReadStream *rs, uint32 version) { } Object *ObjectManager::loadObject(Common::ReadStream *rs, Std::string classname, - uint32 version) { + uint32 version) { Std::map::iterator iter; iter = _objectLoaders.find(classname); diff --git a/engines/ultima/ultima8/misc/util.cpp b/engines/ultima/ultima8/misc/util.cpp index eb341a3dba6..f93a340246a 100644 --- a/engines/ultima/ultima8/misc/util.cpp +++ b/engines/ultima/ultima8/misc/util.cpp @@ -158,7 +158,7 @@ template void TabsToSpaces(istring &str, unsigned int n); template void SplitString(const T &args, char sep, - Std::vector &argv) { + Std::vector &argv) { // Clear the vector argv.clear(); @@ -186,7 +186,7 @@ template void SplitString(const istring &args, char sep, Std::vector void SplitStringKV(const T &args, char sep, - Std::vector > &argv) { + Std::vector > &argv) { // Clear the vector argv.clear(); diff --git a/engines/ultima/ultima8/misc/util.h b/engines/ultima/ultima8/misc/util.h index 9708026a171..8211625b8fb 100644 --- a/engines/ultima/ultima8/misc/util.h +++ b/engines/ultima/ultima8/misc/util.h @@ -39,7 +39,7 @@ template void TabsToSpaces(T &str, unsigned int nspaces); template void SplitString(const T &args, char sep, Std::vector &argv); template void SplitStringKV(const T &args, char sep, - Std::vector > &argv); + Std::vector > &argv); } // End of namespace Ultima8 } // End of namespace Ultima diff --git a/engines/ultima/ultima8/usecode/byte_set.cpp b/engines/ultima/ultima8/usecode/byte_set.cpp index 8f9c6cbf53f..6c77b7d7b70 100644 --- a/engines/ultima/ultima8/usecode/byte_set.cpp +++ b/engines/ultima/ultima8/usecode/byte_set.cpp @@ -52,11 +52,11 @@ uint32 ByteSet::getEntries(unsigned int pos, unsigned int n) const { assert(pos + n <= _size); if (n == 0) return 0; - if (n == 1) { - return _data[pos]; - } else if (n == 2) { - return (_data[pos] << 8) | _data[pos + 1]; - } + if (n == 1) { + return _data[pos]; + } else if (n == 2) { + return (_data[pos] << 8) | _data[pos + 1]; + } return 0; } @@ -65,12 +65,12 @@ void ByteSet::setEntries(unsigned int pos, unsigned int n, uint32 val) { assert(pos + n <= _size); if (n == 0) return; - if (n == 1) { - _data[pos] = static_cast(val); - } else if (n == 2) { - _data[pos] = static_cast((val & 0xFF00) >> 8); - _data[pos + 1] = static_cast(val & 0xFF); - } + if (n == 1) { + _data[pos] = static_cast(val); + } else if (n == 2) { + _data[pos] = static_cast((val & 0xFF00) >> 8); + _data[pos + 1] = static_cast(val & 0xFF); + } } void ByteSet::save(Common::WriteStream *ws) { diff --git a/engines/ultima/ultima8/usecode/remorse_intrinsics.h b/engines/ultima/ultima8/usecode/remorse_intrinsics.h index f3cb28b37dd..2d1468e265f 100644 --- a/engines/ultima/ultima8/usecode/remorse_intrinsics.h +++ b/engines/ultima/ultima8/usecode/remorse_intrinsics.h @@ -362,10 +362,10 @@ Intrinsic RemorseIntrinsics[] = { Actor::I_setActivity, // void Intrinsic131(6 bytes) Item::I_andStatus, // void Intrinsic132(6 bytes) Item::I_getQHi, // based on same coff set as 026 - WeaselGump::I_showWeaselGump, // void Intrinsic134(2 bytes) - Actor::I_setDead, - 0, // void UNUSEDInt136() - 0 // void UNUSEDInt137() + WeaselGump::I_showWeaselGump, // void Intrinsic134(2 bytes) + Actor::I_setDead, + 0, // void UNUSEDInt136() + 0 // void UNUSEDInt137() }; } // End of namespace Ultima8 diff --git a/engines/ultima/ultima8/usecode/uc_machine.cpp b/engines/ultima/ultima8/usecode/uc_machine.cpp index 66f84d3246c..6931ce3b120 100644 --- a/engines/ultima/ultima8/usecode/uc_machine.cpp +++ b/engines/ultima/ultima8/usecode/uc_machine.cpp @@ -2062,7 +2062,7 @@ const Std::string &UCMachine::getString(uint16 str) const { static Std::string emptystring(""); Std::map::const_iterator iter = - _stringHeap.find(str); + _stringHeap.find(str); if (iter != _stringHeap.end()) return iter->_value; diff --git a/engines/ultima/ultima8/usecode/uc_process.cpp b/engines/ultima/ultima8/usecode/uc_process.cpp index a1ad1217f7e..7f1d2b13aeb 100644 --- a/engines/ultima/ultima8/usecode/uc_process.cpp +++ b/engines/ultima/ultima8/usecode/uc_process.cpp @@ -36,7 +36,7 @@ UCProcess::UCProcess() : Process(), _classId(0xFFFF), _ip(0xFFFF), } UCProcess::UCProcess(uint16 classid, uint16 offset, uint32 this_ptr, - int thissize, const uint8 *args, int argsize) + int thissize, const uint8 *args, int argsize) : Process(), _classId(0xFFFF), _ip(0xFFFF), _bp(0x0000), _temp32(0) { _usecode = GameData::get_instance()->getMainUsecode(); @@ -47,7 +47,7 @@ UCProcess::~UCProcess() { } void UCProcess::load(uint16 classid, uint16 offset, uint32 this_ptr, - int thissize, const uint8 *args, int argsize) { + int thissize, const uint8 *args, int argsize) { if (_usecode->get_class_size(classid) == 0) perr << "Class is empty..." << Std::endl; diff --git a/engines/ultima/ultima8/world/actors/actor.cpp b/engines/ultima/ultima8/world/actors/actor.cpp index 4e7b65b8330..4a386580e3f 100644 --- a/engines/ultima/ultima8/world/actors/actor.cpp +++ b/engines/ultima/ultima8/world/actors/actor.cpp @@ -583,7 +583,7 @@ void Actor::setToStartOfAnim(Animation::Sequence anim) { } Animation::Result Actor::tryAnim(Animation::Sequence anim, Direction dir, - unsigned int steps, PathfindingState *state) { + unsigned int steps, PathfindingState *state) { if (dir < 0 || dir > 16) return Animation::FAILURE; if (dir == dir_current) diff --git a/engines/ultima/ultima8/world/actors/actor_anim_process.cpp b/engines/ultima/ultima8/world/actors/actor_anim_process.cpp index 3e0f89ea0fe..5aacd24527a 100644 --- a/engines/ultima/ultima8/world/actors/actor_anim_process.cpp +++ b/engines/ultima/ultima8/world/actors/actor_anim_process.cpp @@ -59,7 +59,7 @@ ActorAnimProcess::ActorAnimProcess() : Process(), _tracker(nullptr), } ActorAnimProcess::ActorAnimProcess(Actor *actor, Animation::Sequence action, - Direction dir, uint32 steps) : + Direction dir, uint32 steps) : _dir(dir), _action(action), _steps(steps), _tracker(nullptr), _firstFrame(true), _currentStep(0), _repeatCounter(0), _animAborted(false), _attackedSomething(false) { diff --git a/engines/ultima/ultima8/world/actors/anim_action.cpp b/engines/ultima/ultima8/world/actors/anim_action.cpp index 1532b5ff8d5..edcf3f7e4bc 100644 --- a/engines/ultima/ultima8/world/actors/anim_action.cpp +++ b/engines/ultima/ultima8/world/actors/anim_action.cpp @@ -28,8 +28,8 @@ namespace Ultima { namespace Ultima8 { void AnimAction::getAnimRange(unsigned int lastanim, Direction lastdir, - bool firststep, Direction dir, - unsigned int &startframe, unsigned int &endframe) const { + bool firststep, Direction dir, + unsigned int &startframe, unsigned int &endframe) const { startframe = 0; endframe = _size; @@ -62,8 +62,8 @@ void AnimAction::getAnimRange(unsigned int lastanim, Direction lastdir, } void AnimAction::getAnimRange(const Actor *actor, Direction dir, - unsigned int &startframe, - unsigned int &endframe) const { + unsigned int &startframe, + unsigned int &endframe) const { getAnimRange(actor->getLastAnim(), actor->getDir(), actor->hasActorFlags(Actor::ACT_FIRSTSTEP), dir, startframe, endframe); diff --git a/engines/ultima/ultima8/world/actors/animation.cpp b/engines/ultima/ultima8/world/actors/animation.cpp index 1fa1d90f79d..9471ad8fded 100644 --- a/engines/ultima/ultima8/world/actors/animation.cpp +++ b/engines/ultima/ultima8/world/actors/animation.cpp @@ -81,7 +81,7 @@ bool isCombatAnimCru(const Sequence anim) { /** determines if we need to ready or unready our weapon */ Sequence checkWeapon(const Sequence nextanim, - const Sequence lastanim) { + const Sequence lastanim) { Sequence anim = nextanim; if (isCombatAnim(nextanim) && !isCombatAnim(lastanim)) { anim = readyWeapon; diff --git a/engines/ultima/ultima8/world/actors/animation_tracker.cpp b/engines/ultima/ultima8/world/actors/animation_tracker.cpp index 08a64cc5bad..2e899dc78eb 100644 --- a/engines/ultima/ultima8/world/actors/animation_tracker.cpp +++ b/engines/ultima/ultima8/world/actors/animation_tracker.cpp @@ -57,7 +57,7 @@ AnimationTracker::~AnimationTracker() { bool AnimationTracker::init(const Actor *actor, Animation::Sequence action, - Direction dir, const PathfindingState *state) { + Direction dir, const PathfindingState *state) { assert(actor); _actor = actor->getObjId(); uint32 shape = actor->getShape(); @@ -569,7 +569,7 @@ void AnimationTracker::updateActorFlags() { } void AnimationTracker::getInterpolatedPosition(int32 &x, int32 &y, - int32 &z, int fc) const { + int32 &z, int fc) const { int32 dx = _x - _prevX; int32 dy = _y - _prevY; int32 dz = _z - _prevZ; diff --git a/engines/ultima/ultima8/world/actors/animation_tracker.h b/engines/ultima/ultima8/world/actors/animation_tracker.h index 1a6acad0ab0..dc3e43ead6b 100644 --- a/engines/ultima/ultima8/world/actors/animation_tracker.h +++ b/engines/ultima/ultima8/world/actors/animation_tracker.h @@ -72,7 +72,7 @@ public: } void getInterpolatedPosition(int32 &x, int32 &y, int32 &z, int fc) - const; + const; //! get the difference between current position and previous position void getSpeed(int32 &dx, int32 &dy, int32 &dz) const; diff --git a/engines/ultima/ultima8/world/actors/battery_charger_process.cpp b/engines/ultima/ultima8/world/actors/battery_charger_process.cpp index f91f1f85b34..05c9f704da4 100644 --- a/engines/ultima/ultima8/world/actors/battery_charger_process.cpp +++ b/engines/ultima/ultima8/world/actors/battery_charger_process.cpp @@ -65,7 +65,7 @@ void BatteryChargerProcess::run() { return; } - if (!audio->isSFXPlayingForObject(CHARGE_GOING_SFX, _itemNum)) + if (!audio->isSFXPlayingForObject(CHARGE_GOING_SFX, _itemNum)) audio->playSFX(CHARGE_GOING_SFX, 0x80, _itemNum, 1); uint16 newEnergy = avatar->getMana() + 25; diff --git a/engines/ultima/ultima8/world/actors/combat_dat.h b/engines/ultima/ultima8/world/actors/combat_dat.h index 51363852a27..06ef607f262 100644 --- a/engines/ultima/ultima8/world/actors/combat_dat.h +++ b/engines/ultima/ultima8/world/actors/combat_dat.h @@ -43,7 +43,7 @@ class CombatDat { public: CombatDat(Common::SeekableReadStream &rs); - ~CombatDat(); + ~CombatDat(); const Std::string &getName() const { return _name; diff --git a/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.cpp b/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.cpp index ba4a23172bb..d6d11eaa5cf 100644 --- a/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.cpp +++ b/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.cpp @@ -347,7 +347,7 @@ void CruAvatarMoverProcess::handleNormalMode() { } void CruAvatarMoverProcess::step(Animation::Sequence action, Direction direction, - bool adjusted) { + bool adjusted) { Actor *avatar = getControlledActor(); // For "start run" animations, don't call it a success unless we can actually run diff --git a/engines/ultima/ultima8/world/actors/cru_healer_process.cpp b/engines/ultima/ultima8/world/actors/cru_healer_process.cpp index 4783dcdaf8e..454525d81f0 100644 --- a/engines/ultima/ultima8/world/actors/cru_healer_process.cpp +++ b/engines/ultima/ultima8/world/actors/cru_healer_process.cpp @@ -72,7 +72,7 @@ void CruHealerProcess::run() { return; } - if (audio && !audio->isSFXPlayingForObject(HEAL_GOING_SFX, _itemNum)) + if (audio && !audio->isSFXPlayingForObject(HEAL_GOING_SFX, _itemNum)) audio->playSFX(HEAL_GOING_SFX, 0x80, _itemNum, 1); uint16 newHP = avatar->getHP() + 1; diff --git a/engines/ultima/ultima8/world/actors/grant_peace_process.cpp b/engines/ultima/ultima8/world/actors/grant_peace_process.cpp index 64cb1a19973..9a811cd9bad 100644 --- a/engines/ultima/ultima8/world/actors/grant_peace_process.cpp +++ b/engines/ultima/ultima8/world/actors/grant_peace_process.cpp @@ -187,7 +187,7 @@ void GrantPeaceProcess::run() { } uint32 GrantPeaceProcess::I_castGrantPeace(const uint8 *args, - unsigned int /*argsize*/) { + unsigned int /*argsize*/) { MainActor *avatar = getMainActor(); GrantPeaceProcess *gpp = new GrantPeaceProcess(avatar); diff --git a/engines/ultima/ultima8/world/actors/main_actor.cpp b/engines/ultima/ultima8/world/actors/main_actor.cpp index 681ec6179e3..9e4ef2862d4 100644 --- a/engines/ultima/ultima8/world/actors/main_actor.cpp +++ b/engines/ultima/ultima8/world/actors/main_actor.cpp @@ -761,7 +761,7 @@ uint32 MainActor::I_teleportToEgg(const uint8 *args, unsigned int argsize) { } uint32 MainActor::I_accumulateStrength(const uint8 *args, - unsigned int /*argsize*/) { + unsigned int /*argsize*/) { ARG_SINT16(n); MainActor *av = getMainActor(); av->accumulateStr(n); @@ -770,7 +770,7 @@ uint32 MainActor::I_accumulateStrength(const uint8 *args, } uint32 MainActor::I_accumulateDexterity(const uint8 *args, - unsigned int /*argsize*/) { + unsigned int /*argsize*/) { ARG_SINT16(n); MainActor *av = getMainActor(); av->accumulateDex(n); @@ -779,7 +779,7 @@ uint32 MainActor::I_accumulateDexterity(const uint8 *args, } uint32 MainActor::I_accumulateIntelligence(const uint8 *args, - unsigned int /*argsize*/) { + unsigned int /*argsize*/) { ARG_SINT16(n); MainActor *av = getMainActor(); av->accumulateInt(n); @@ -788,7 +788,7 @@ uint32 MainActor::I_accumulateIntelligence(const uint8 *args, } uint32 MainActor::I_clrAvatarInCombat(const uint8 * /*args*/, - unsigned int /*argsize*/) { + unsigned int /*argsize*/) { MainActor *av = getMainActor(); av->clearInCombat(); @@ -796,7 +796,7 @@ uint32 MainActor::I_clrAvatarInCombat(const uint8 * /*args*/, } uint32 MainActor::I_setAvatarInCombat(const uint8 * /*args*/, - unsigned int /*argsize*/) { + unsigned int /*argsize*/) { MainActor *av = getMainActor(); // Note: only happens in U8, so activity num is not important. av->setInCombat(0); @@ -805,7 +805,7 @@ uint32 MainActor::I_setAvatarInCombat(const uint8 * /*args*/, } uint32 MainActor::I_isAvatarInCombat(const uint8 * /*args*/, - unsigned int /*argsize*/) { + unsigned int /*argsize*/) { MainActor *av = getMainActor(); if (av->isInCombat()) return 1; diff --git a/engines/ultima/ultima8/world/actors/npc_dat.h b/engines/ultima/ultima8/world/actors/npc_dat.h index 1b89ffdc62c..8beeb786410 100644 --- a/engines/ultima/ultima8/world/actors/npc_dat.h +++ b/engines/ultima/ultima8/world/actors/npc_dat.h @@ -67,7 +67,7 @@ public: static uint16 randomlyGetStrongerWeaponTypes(uint shapeno); private: - NPCDat(Common::SeekableReadStream &datars, Common::SeekableReadStream &namers); + NPCDat(Common::SeekableReadStream &datars, Common::SeekableReadStream &namers); Std::string _name; uint16 _minHp; diff --git a/engines/ultima/ultima8/world/actors/pathfinder.cpp b/engines/ultima/ultima8/world/actors/pathfinder.cpp index 56d4c34ae1a..611270abd90 100644 --- a/engines/ultima/ultima8/world/actors/pathfinder.cpp +++ b/engines/ultima/ultima8/world/actors/pathfinder.cpp @@ -60,7 +60,7 @@ void PathfindingState::load(const Actor *_actor) { } bool PathfindingState::checkPoint(int32 x, int32 y, int32 z, - int sqr_range) const { + int sqr_range) const { int distance = (_x - x) * (_x - x) + (_y - y) * (_y - y) + (_z - z) * (_z - z); return distance < sqr_range; } @@ -362,7 +362,7 @@ static void drawpath(PathNode *to, uint32 rgb, bool done) { #endif void Pathfinder::newNode(PathNode *oldnode, PathfindingState &state, - unsigned int steps) { + unsigned int steps) { PathNode *newnode = new PathNode(); newnode->state = state; newnode->parent = oldnode; diff --git a/engines/ultima/ultima8/world/actors/u8_avatar_mover_process.cpp b/engines/ultima/ultima8/world/actors/u8_avatar_mover_process.cpp index eaab2bb8bf8..9d15308ba2c 100644 --- a/engines/ultima/ultima8/world/actors/u8_avatar_mover_process.cpp +++ b/engines/ultima/ultima8/world/actors/u8_avatar_mover_process.cpp @@ -623,7 +623,7 @@ void U8AvatarMoverProcess::handleNormalMode() { } void U8AvatarMoverProcess::step(Animation::Sequence action, Direction direction, - bool adjusted) { + bool adjusted) { assert(action == Animation::step || action == Animation::walk || action == Animation::run); diff --git a/engines/ultima/ultima8/world/container.cpp b/engines/ultima/ultima8/world/container.cpp index 0f263867ecb..7a65f93b356 100644 --- a/engines/ultima/ultima8/world/container.cpp +++ b/engines/ultima/ultima8/world/container.cpp @@ -268,7 +268,7 @@ uint32 Container::getContentVolume() const { } void Container::containerSearch(UCList *itemlist, const uint8 *loopscript, - uint32 scriptsize, bool recurse) const { + uint32 scriptsize, bool recurse) const { Std::list::const_iterator iter; for (iter = _contents.begin(); iter != _contents.end(); ++iter) { // check item against loopscript diff --git a/engines/ultima/ultima8/world/create_item_process.cpp b/engines/ultima/ultima8/world/create_item_process.cpp index 41ff0d5187c..274985e42e9 100644 --- a/engines/ultima/ultima8/world/create_item_process.cpp +++ b/engines/ultima/ultima8/world/create_item_process.cpp @@ -38,10 +38,10 @@ CreateItemProcess::CreateItemProcess() } CreateItemProcess::CreateItemProcess(uint32 shape, uint32 frame, - uint16 quality, uint16 flags, - uint16 npcnum, uint16 mapnum, - uint32 extendedflags, - int32 x, int32 y, int32 z) + uint16 quality, uint16 flags, + uint16 npcnum, uint16 mapnum, + uint32 extendedflags, + int32 x, int32 y, int32 z) : _shape(shape), _frame(frame), _quality(quality), _flags(flags), _npcNum(npcnum), _mapNum(mapnum), _extendedFlags(extendedflags), _x(x), _y(y), _z(z) { diff --git a/engines/ultima/ultima8/world/current_map.cpp b/engines/ultima/ultima8/world/current_map.cpp index 3252004122b..ebe7ca3a619 100644 --- a/engines/ultima/ultima8/world/current_map.cpp +++ b/engines/ultima/ultima8/world/current_map.cpp @@ -434,9 +434,9 @@ static inline bool ChunkOnScreen(int32 cx, int32 cy, int32 sleft, int32 stop, in } static inline void CalcFastAreaLimits(int32 &sx_limit, - int32 &sy_limit, - int32 &xy_limit, - const Rect &dims, + int32 &sy_limit, + int32 &xy_limit, + const Rect &dims, int mapChunkSize) { // By default the fastArea is the screensize rounded down to the nearest // map chunk, plus 3 wide and 7 high. @@ -551,8 +551,8 @@ inline void CurrentMap::clipMapChunks(int &minx, int &maxx, int &miny, int &maxy } void CurrentMap::areaSearch(UCList *itemlist, const uint8 *loopscript, - uint32 scriptsize, const Item *check, uint16 range, - bool recurse, int32 x, int32 y) const { + uint32 scriptsize, const Item *check, uint16 range, + bool recurse, int32 x, int32 y) const { int32 xd = 0, yd = 0; // if item != 0, search an area around item. Otherwise, search an area @@ -617,7 +617,7 @@ void CurrentMap::areaSearch(UCList *itemlist, const uint8 *loopscript, } void CurrentMap::surfaceSearch(UCList *itemlist, const uint8 *loopscript, - uint32 scriptsize, const Item *check, + uint32 scriptsize, const Item *check, bool above, bool below, bool recurse) const { int32 origin[3]; int32 dims[3]; @@ -628,9 +628,9 @@ void CurrentMap::surfaceSearch(UCList *itemlist, const uint8 *loopscript, } void CurrentMap::surfaceSearch(UCList *itemlist, const uint8 *loopscript, - uint32 scriptsize, ObjId check, - int32 origin[3], int32 dims[3], - bool above, bool below, bool recurse) const { + uint32 scriptsize, ObjId check, + int32 origin[3], int32 dims[3], + bool above, bool below, bool recurse) const { const Rect searchrange(origin[0] - dims[0], origin[1] - dims[1], origin[0], origin[1]); @@ -722,9 +722,9 @@ const Std::list *CurrentMap::getItemList(int32 gx, int32 gy) const { bool CurrentMap::isValidPosition(int32 x, int32 y, int32 z, - uint32 shape, - ObjId item, const Item **support, - ObjId *roof, const Item **blocker) const { + uint32 shape, + ObjId item, const Item **support, + ObjId *roof, const Item **blocker) const { const ShapeInfo *si = GameData::get_instance()-> getMainShapes()->getShapeInfo(shape); int32 xd, yd, zd; @@ -738,10 +738,10 @@ bool CurrentMap::isValidPosition(int32 x, int32 y, int32 z, } bool CurrentMap::isValidPosition(int32 x, int32 y, int32 z, - int xd, int yd, int zd, - uint32 shapeflags, - ObjId item, const Item **support, - ObjId *roof, const Item **blocker) const { + int xd, int yd, int zd, + uint32 shapeflags, + ObjId item, const Item **support, + ObjId *roof, const Item **blocker) const { return isValidPosition(x, y, z, INT_MAX_VALUE / 2, INT_MAX_VALUE / 2, INT_MAX_VALUE / 2, xd, yd, zd, @@ -750,11 +750,11 @@ bool CurrentMap::isValidPosition(int32 x, int32 y, int32 z, bool CurrentMap::isValidPosition(int32 x, int32 y, int32 z, - int32 startx, int32 starty, int32 startz, - int xd, int yd, int zd, - uint32 shapeflags, - ObjId item_, const Item **support_, - ObjId *roof_, const Item **blocker_) const { + int32 startx, int32 starty, int32 startz, + int xd, int yd, int zd, + uint32 shapeflags, + ObjId item_, const Item **support_, + ObjId *roof_, const Item **blocker_) const { static const uint32 flagmask = (ShapeInfo::SI_SOLID | ShapeInfo::SI_DAMAGING | ShapeInfo::SI_ROOF); static const uint32 blockflagmask = (ShapeInfo::SI_SOLID | ShapeInfo::SI_DAMAGING); @@ -850,8 +850,8 @@ bool CurrentMap::isValidPosition(int32 x, int32 y, int32 z, } bool CurrentMap::scanForValidPosition(int32 x, int32 y, int32 z, const Item *item, - Direction movedir, bool wantsupport, - int32 &tx, int32 &ty, int32 &tz) { + Direction movedir, bool wantsupport, + int32 &tx, int32 &ty, int32 &tz) { // TODO: clean this up. Currently the mask arrays are filled with more // data than is actually used. const uint32 blockflagmask = (ShapeInfo::SI_SOLID | ShapeInfo::SI_DAMAGING) & item->getShapeInfo()->_flags; @@ -1014,9 +1014,9 @@ bool CurrentMap::scanForValidPosition(int32 x, int32 y, int32 z, const Item *ite // Returns item hit or 0 if no hit. // end is set to the colision point bool CurrentMap::sweepTest(const int32 start[3], const int32 end[3], - const int32 dims[3], uint32 shapeflags, - ObjId item, bool blocking_only, - Std::list *hit) const { + const int32 dims[3], uint32 shapeflags, + ObjId item, bool blocking_only, + Std::list *hit) const { const uint32 blockflagmask = (ShapeInfo::SI_SOLID | ShapeInfo::SI_DAMAGING | ShapeInfo::SI_LAND); int minx = ((start[0] - dims[0]) / _mapChunkSize) - 1; diff --git a/engines/ultima/ultima8/world/current_map.h b/engines/ultima/ultima8/world/current_map.h index 1c1a11c64bc..6bb11dd23b0 100644 --- a/engines/ultima/ultima8/world/current_map.h +++ b/engines/ultima/ultima8/world/current_map.h @@ -134,7 +134,7 @@ public: // into account! bool isValidPosition(int32 x, int32 y, int32 z, uint32 shape, ObjId item, const Item **support = 0, - ObjId *roof = 0, const Item **blocker = 0) const; + ObjId *roof = 0, const Item **blocker = 0) const; //! Scan for a valid position for item in directions orthogonal to movedir bool scanForValidPosition(int32 x, int32 y, int32 z, const Item *item, diff --git a/engines/ultima/ultima8/world/fireball_process.cpp b/engines/ultima/ultima8/world/fireball_process.cpp index c7de076a653..93ffe696832 100644 --- a/engines/ultima/ultima8/world/fireball_process.cpp +++ b/engines/ultima/ultima8/world/fireball_process.cpp @@ -168,7 +168,7 @@ void FireballProcess::explode() { } uint32 FireballProcess::I_TonysBalls(const uint8 *args, - unsigned int /*argsize*/) { + unsigned int /*argsize*/) { ARG_NULL16(); // unknown ARG_NULL16(); // unknown ARG_SINT16(x); diff --git a/engines/ultima/ultima8/world/item.cpp b/engines/ultima/ultima8/world/item.cpp index 93563478442..c99907ce7b7 100644 --- a/engines/ultima/ultima8/world/item.cpp +++ b/engines/ultima/ultima8/world/item.cpp @@ -2283,8 +2283,8 @@ int Item::getThrowRange() { } static bool checkLineOfSightCollisions( - const Std::list &collisions, - bool usingAlternatePos, ObjId item, ObjId other) { + const Std::list &collisions, + bool usingAlternatePos, ObjId item, ObjId other) { Std::list::const_iterator it; int32 other_hit_time = 0x4000; int32 blocked_time = 0x4000; @@ -2310,7 +2310,7 @@ static bool checkLineOfSightCollisions( } bool Item::canReach(Item *other, int range, - int32 otherX, int32 otherY, int32 otherZ) { + int32 otherX, int32 otherY, int32 otherZ) { // get location and dimensions of self and other (or their root containers) int32 thisX, thisY, thisZ; int32 thisXd, thisYd, thisZd; @@ -2941,7 +2941,7 @@ uint32 Item::I_getWeight(const uint8 *args, unsigned int /*argsize*/) { } uint32 Item::I_getWeightIncludingContents(const uint8 *args, - unsigned int /*argsize*/) { + unsigned int /*argsize*/) { ARG_ITEM_FROM_PTR(item); if (!item) return 0; diff --git a/engines/ultima/ultima8/world/item_factory.cpp b/engines/ultima/ultima8/world/item_factory.cpp index f33420d7352..d68fa947b7d 100644 --- a/engines/ultima/ultima8/world/item_factory.cpp +++ b/engines/ultima/ultima8/world/item_factory.cpp @@ -72,8 +72,8 @@ static Item *getItemForFamily(uint32 family) { } Item *ItemFactory::createItem(uint32 shape, uint32 frame, uint16 quality, - uint16 flags, uint16 npcnum, uint16 mapnum, - uint32 extendedflags, bool objId) { + uint16 flags, uint16 npcnum, uint16 mapnum, + uint32 extendedflags, bool objId) { // check what class to create const ShapeInfo *info = GameData::get_instance()->getMainShapes()-> getShapeInfo(shape); @@ -124,8 +124,8 @@ static Actor *getActorForNpcNum(uint32 npcnum) { } Actor *ItemFactory::createActor(uint32 shape, uint32 frame, uint16 quality, - uint16 flags, uint16 npcnum, uint16 mapnum, - uint32 extendedflags, bool objId) { + uint16 flags, uint16 npcnum, uint16 mapnum, + uint32 extendedflags, bool objId) { /* // This makes it rather hard to create new NPCs... if (npcnum == 0) // or do monsters have npcnum 0? we'll see... diff --git a/engines/ultima/ultima8/world/item_selection_process.h b/engines/ultima/ultima8/world/item_selection_process.h index 22aaf2e298b..f5448047076 100644 --- a/engines/ultima/ultima8/world/item_selection_process.h +++ b/engines/ultima/ultima8/world/item_selection_process.h @@ -61,9 +61,9 @@ public: return _instance; } - uint16 getSelectedItem() const { - return _selectedItem; - } + uint16 getSelectedItem() const { + return _selectedItem; + } private: void putItemSelectionOnItem(Item *item); diff --git a/engines/ultima/ultima8/world/item_sorter.cpp b/engines/ultima/ultima8/world/item_sorter.cpp index e6b0d54625d..9995642ab6c 100644 --- a/engines/ultima/ultima8/world/item_sorter.cpp +++ b/engines/ultima/ultima8/world/item_sorter.cpp @@ -598,7 +598,7 @@ ItemSorter::~ItemSorter() { } void ItemSorter::BeginDisplayList(RenderSurface *rs, - int32 camx, int32 camy, int32 camz) { + int32 camx, int32 camy, int32 camz) { // Get the _shapes, if required if (!_shapes) _shapes = GameData::get_instance()->getMainShapes(); diff --git a/engines/ultima/ultima8/world/map.cpp b/engines/ultima/ultima8/world/map.cpp index 789900116c6..d9e4bfd41b7 100644 --- a/engines/ultima/ultima8/world/map.cpp +++ b/engines/ultima/ultima8/world/map.cpp @@ -204,7 +204,7 @@ void Map::unloadFixed() { void Map::loadFixedFormatObjects(Std::list &itemlist, Common::SeekableReadStream *rs, - uint32 extendedflags) { + uint32 extendedflags) { if (!rs) return; uint32 size = rs->size(); if (size == 0) return; diff --git a/engines/ultima/ultima8/world/missile_tracker.cpp b/engines/ultima/ultima8/world/missile_tracker.cpp index f38a48c54d8..f47e87c2749 100644 --- a/engines/ultima/ultima8/world/missile_tracker.cpp +++ b/engines/ultima/ultima8/world/missile_tracker.cpp @@ -33,8 +33,8 @@ namespace Ultima { namespace Ultima8 { MissileTracker::MissileTracker(const Item *item, int32 sx, int32 sy, int32 sz, - int32 tx, int32 ty, int32 tz, - int32 speed, int32 gravity) : + int32 tx, int32 ty, int32 tz, + int32 speed, int32 gravity) : _destX(tx), _destY(ty), _destZ(tz), _gravity(gravity) { _objId = item->getObjId(); @@ -42,7 +42,7 @@ MissileTracker::MissileTracker(const Item *item, int32 sx, int32 sy, int32 sz, } MissileTracker::MissileTracker(const Item *item, int32 tx, int32 ty, int32 tz, - int32 speed, int32 gravity) : + int32 speed, int32 gravity) : _destX(tx), _destY(ty), _destZ(tz), _gravity(gravity) { assert(item->getParent() == 0); diff --git a/engines/ultima/ultima8/world/sprite_process.cpp b/engines/ultima/ultima8/world/sprite_process.cpp index 6393152a86c..7d06fcbc50a 100644 --- a/engines/ultima/ultima8/world/sprite_process.cpp +++ b/engines/ultima/ultima8/world/sprite_process.cpp @@ -40,8 +40,8 @@ SpriteProcess::SpriteProcess() } SpriteProcess::SpriteProcess(int shape, int frame, int lastFrame, - int repeats, int delay, int x, int y, int z, - bool delayed_init) : + int repeats, int delay, int x, int y, int z, + bool delayed_init) : _shape(shape), _frame(frame), _firstFrame(frame), _lastFrame(lastFrame), _repeats(repeats), _delay(delay * 2), _x(x), _y(y), _z(z), _delayCounter(0), _initialized(false) { diff --git a/engines/ultima/ultima8/world/target_reticle_process.h b/engines/ultima/ultima8/world/target_reticle_process.h index 49446afc3a4..7f5ce8258b0 100644 --- a/engines/ultima/ultima8/world/target_reticle_process.h +++ b/engines/ultima/ultima8/world/target_reticle_process.h @@ -70,7 +70,7 @@ private: void putTargetReticleOnItem(Item *, bool last_frame); void clearSprite(); - bool _reticleEnabled; + bool _reticleEnabled; int32 _lastUpdate; uint16 _reticleSpriteProcess; Direction _lastTargetDir; diff --git a/engines/ultima/ultima8/world/world.cpp b/engines/ultima/ultima8/world/world.cpp index 28e9745e32d..d72777de481 100644 --- a/engines/ultima/ultima8/world/world.cpp +++ b/engines/ultima/ultima8/world/world.cpp @@ -402,7 +402,7 @@ bool World::loadMaps(Common::ReadStream *rs, uint32 version) { void World::setAlertActive(bool active) { assert(GAME_IS_CRUSADER); - _alertActive = active; + _alertActive = active; // Replicate the behavior of the original game. LOOPSCRIPT(script, diff --git a/engines/voyeur/detection_tables.h b/engines/voyeur/detection_tables.h index debc67cbb76..8154043a89e 100644 --- a/engines/voyeur/detection_tables.h +++ b/engines/voyeur/detection_tables.h @@ -28,7 +28,7 @@ static const VoyeurGameDescription gameDescriptions[] = { { "voyeur", 0, - AD_ENTRY1s("bvoy.blt", "12e9e10654171501cf8be3a7aa7198e1", 13036269), + AD_ENTRY1s("bvoy.blt", "12e9e10654171501cf8be3a7aa7198e1", 13036269), Common::EN_ANY, Common::kPlatformDOS, ADGF_NO_FLAGS, @@ -37,17 +37,17 @@ static const VoyeurGameDescription gameDescriptions[] = { }, { - // Voyeur DOS English - { - "voyeur", - "Demo", - AD_ENTRY1s("bvoy.blt", "abd10f241b845ebc2a76d27a43770709", 13015827), - Common::EN_ANY, - Common::kPlatformDOS, - ADGF_DEMO, - GUIO1(GUIO_NOMIDI) + // Voyeur DOS English + { + "voyeur", + "Demo", + AD_ENTRY1s("bvoy.blt", "abd10f241b845ebc2a76d27a43770709", 13015827), + Common::EN_ANY, + Common::kPlatformDOS, + ADGF_DEMO, + GUIO1(GUIO_NOMIDI) } - }, + }, { AD_TABLE_END_MARKER } }; diff --git a/engines/voyeur/metaengine.cpp b/engines/voyeur/metaengine.cpp index 5c4d4923a50..85cbaa0f4f4 100644 --- a/engines/voyeur/metaengine.cpp +++ b/engines/voyeur/metaengine.cpp @@ -59,7 +59,7 @@ public: return "voyeur"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; SaveStateList listSaves(const char *target) const override; int getMaximumSaveSlot() const override; diff --git a/engines/wage/design.h b/engines/wage/design.h index 7b11f3b2c65..7ed70ff9de1 100644 --- a/engines/wage/design.h +++ b/engines/wage/design.h @@ -73,7 +73,7 @@ public: return _bounds; } - void paint(Graphics::ManagedSurface *canvas, Graphics::MacPatterns &patterns, int x, int y); + void paint(Graphics::ManagedSurface *canvas, Graphics::MacPatterns &patterns, int x, int y); bool isPointOpaque(int x, int y); static void drawRect(Graphics::ManagedSurface *surface, Common::Rect &rect, int thickness, int color, Graphics::MacPatterns &patterns, byte fillType); static void drawRect(Graphics::ManagedSurface *surface, int x1, int y1, int x2, int y2, int thickness, int color, Graphics::MacPatterns &patterns, byte fillType); diff --git a/engines/wage/metaengine.cpp b/engines/wage/metaengine.cpp index b9dda6af5b3..84174a87264 100644 --- a/engines/wage/metaengine.cpp +++ b/engines/wage/metaengine.cpp @@ -39,7 +39,7 @@ const char *WageEngine::getGameFile() const { class WageMetaEngine : public AdvancedMetaEngine { public: - const char *getName() const override { + const char *getName() const override { return "wage"; } diff --git a/engines/wintermute/ad/ad_actor_3dx.cpp b/engines/wintermute/ad/ad_actor_3dx.cpp index 1ecf07fa171..13382030fdd 100644 --- a/engines/wintermute/ad/ad_actor_3dx.cpp +++ b/engines/wintermute/ad/ad_actor_3dx.cpp @@ -62,27 +62,27 @@ IMPLEMENT_PERSISTENT(AdActor3DX, false) ////////////////////////////////////////////////////////////////////////// AdActor3DX::AdActor3DX(BaseGame *inGame) : AdObject3D(inGame), - _partOffset(0.0f, 0.0f, 0.0f), - _stateAnimChannel(-1), - _defaultTransTime(200), - _defaultStopTransTime(200), - _afterWalkAngle(-1.0f), - _talkAnimName("talk"), - _idleAnimName("idle"), - _walkAnimName("walk"), - _turnLeftAnimName("turnleft"), - _turnRightAnimName("turnright"), - _talkAnimChannel(0), - _directWalkMode(DIRECT_WALK_NONE), - _directTurnMode(DIRECT_TURN_NONE), - _directWalkVelocity(0.0f), - _directTurnVelocity(0.0f), - _goToTolerance(2), - _targetPoint3D(0.0f, 0.0f, 0.0f), - _targetPoint2D(new BasePoint), - _targetAngle(0.0f), - _path3D(new AdPath3D(inGame)), - _path2D(new AdPath(inGame)) { + _partOffset(0.0f, 0.0f, 0.0f), + _stateAnimChannel(-1), + _defaultTransTime(200), + _defaultStopTransTime(200), + _afterWalkAngle(-1.0f), + _talkAnimName("talk"), + _idleAnimName("idle"), + _walkAnimName("walk"), + _turnLeftAnimName("turnleft"), + _turnRightAnimName("turnright"), + _talkAnimChannel(0), + _directWalkMode(DIRECT_WALK_NONE), + _directTurnMode(DIRECT_TURN_NONE), + _directWalkVelocity(0.0f), + _directTurnVelocity(0.0f), + _goToTolerance(2), + _targetPoint3D(0.0f, 0.0f, 0.0f), + _targetPoint2D(new BasePoint), + _targetAngle(0.0f), + _path3D(new AdPath3D(inGame)), + _path2D(new AdPath(inGame)) { _gameRef->_renderer3D->enableShadows(); } diff --git a/engines/wintermute/ad/ad_block.cpp b/engines/wintermute/ad/ad_block.cpp index b58dc521054..9b130214d7f 100644 --- a/engines/wintermute/ad/ad_block.cpp +++ b/engines/wintermute/ad/ad_block.cpp @@ -34,8 +34,8 @@ namespace Wintermute { ////////////////////////////////////////////////////////////////////////// AdBlock::AdBlock(BaseGame *inGame) : BaseScriptable(inGame, false, false), - _receiveShadows(false), _active(true), - _mesh(nullptr) { + _receiveShadows(false), _active(true), + _mesh(nullptr) { } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp index c802befbd49..24ecb6bb93a 100644 --- a/engines/wintermute/ad/ad_entity.cpp +++ b/engines/wintermute/ad/ad_entity.cpp @@ -1265,7 +1265,7 @@ bool AdEntity::persist(BasePersistenceManager *persistMgr) { persistMgr->transferPtr(TMEMBER_PTR(_theora)); #ifdef ENABLE_FOXTAIL - if (BaseEngine::instance().isFoxTail(FOXTAIL_1_2_527, FOXTAIL_LATEST_VERSION)) { + if (BaseEngine::instance().isFoxTail(FOXTAIL_1_2_527, FOXTAIL_LATEST_VERSION)) { persistMgr->transferSint32(TMEMBER(_hintX)); persistMgr->transferSint32(TMEMBER(_hintY)); } diff --git a/engines/wintermute/ad/ad_generic.cpp b/engines/wintermute/ad/ad_generic.cpp index b36f10b3855..3b134457dad 100644 --- a/engines/wintermute/ad/ad_generic.cpp +++ b/engines/wintermute/ad/ad_generic.cpp @@ -34,7 +34,7 @@ namespace Wintermute { ////////////////////////////////////////////////////////////////////////// AdGeneric::AdGeneric(BaseGame *inGame) : BaseScriptable(inGame, false, false), - _receiveShadows(false), _active(true), _mesh(nullptr) { + _receiveShadows(false), _active(true), _mesh(nullptr) { } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/ad/ad_geom_ext_node.cpp b/engines/wintermute/ad/ad_geom_ext_node.cpp index 7b90fe96645..980c545d00f 100644 --- a/engines/wintermute/ad/ad_geom_ext_node.cpp +++ b/engines/wintermute/ad/ad_geom_ext_node.cpp @@ -36,7 +36,7 @@ namespace Wintermute { ////////////////////////////////////////////////////////////////////////// AdGeomExtNode::AdGeomExtNode(BaseGame *inGame) : BaseClass(inGame), - _receiveShadows(false), _type(GEOM_GENERIC), _namePattern(nullptr) { + _receiveShadows(false), _type(GEOM_GENERIC), _namePattern(nullptr) { } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/ad/ad_object_3d.cpp b/engines/wintermute/ad/ad_object_3d.cpp index 9423548ab0c..91f87638eed 100644 --- a/engines/wintermute/ad/ad_object_3d.cpp +++ b/engines/wintermute/ad/ad_object_3d.cpp @@ -45,14 +45,14 @@ IMPLEMENT_PERSISTENT(AdObject3D, false) ////////////////////////////////////////////////////////////////////////// AdObject3D::AdObject3D(BaseGame *inGame) : AdObject(inGame), - _tempSkelAnim(nullptr), - _lastPosVector(0.0f, 0.0f, 0.0f), - _dropToFloor(true), - _velocity(1.0f), - _angVelocity(1.0f), - _ambientLightColor(0x00000000), - _hasAmbientLightColor(false), - _shadowVolume(nullptr) { + _tempSkelAnim(nullptr), + _lastPosVector(0.0f, 0.0f, 0.0f), + _dropToFloor(true), + _velocity(1.0f), + _angVelocity(1.0f), + _ambientLightColor(0x00000000), + _hasAmbientLightColor(false), + _shadowVolume(nullptr) { _is3D = true; _state = _nextState = STATE_READY; _shadowType = SHADOW_STENCIL; diff --git a/engines/wintermute/ad/ad_path_point3d.cpp b/engines/wintermute/ad/ad_path_point3d.cpp index 32d0a56057f..12703902481 100644 --- a/engines/wintermute/ad/ad_path_point3d.cpp +++ b/engines/wintermute/ad/ad_path_point3d.cpp @@ -35,8 +35,8 @@ IMPLEMENT_PERSISTENT(AdPathPoint3D, false) ////////////////////////////////////////////////////////////////////////// AdPathPoint3D::AdPathPoint3D() : BaseClass(), - _origin(nullptr), _marked(false), - _distance(0.0f), _pos(0.0f, 0.0f, 0.0f) { + _origin(nullptr), _marked(false), + _distance(0.0f), _pos(0.0f, 0.0f, 0.0f) { } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/ad/ad_walkplane.cpp b/engines/wintermute/ad/ad_walkplane.cpp index bfa4bf1c4e6..d7177385c73 100644 --- a/engines/wintermute/ad/ad_walkplane.cpp +++ b/engines/wintermute/ad/ad_walkplane.cpp @@ -34,7 +34,7 @@ namespace Wintermute { ////////////////////////////////////////////////////////////////////////// AdWalkplane::AdWalkplane(BaseGame *inGame) : BaseScriptable(inGame, false, false), - _receiveShadows(false), _active(true), _mesh(nullptr) { + _receiveShadows(false), _active(true), _mesh(nullptr) { } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index bfa514ac1a1..698ea255a24 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -335,7 +335,7 @@ bool BaseKeyboardState::scCallMethod(ScScript *script, ScStack *stack, ScStack * } } - if (vKeyCode == Common::KEYCODE_INVALID) { + if (vKeyCode == Common::KEYCODE_INVALID) { warning("Unknown VKEY: %d", temp); } diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index a2dedf66a31..ee6c3c91e65 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -158,13 +158,13 @@ bool BaseSurfaceStorage::restoreAll() { bool BaseSurfaceStorage::persist(BasePersistenceManager *persistMgr) { - if (!persistMgr->getIsSaving()) cleanup(false); + if (!persistMgr->getIsSaving()) cleanup(false); - persistMgr->transfer(TMEMBER(_gameRef)); + persistMgr->transfer(TMEMBER(_gameRef)); - //_surfaces.persist(persistMgr); + //_surfaces.persist(persistMgr); - return STATUS_OK; + return STATUS_OK; } */ diff --git a/engines/wintermute/base/file/dcpackage.h b/engines/wintermute/base/file/dcpackage.h index 5f21ce94ea7..87ae80adc24 100644 --- a/engines/wintermute/base/file/dcpackage.h +++ b/engines/wintermute/base/file/dcpackage.h @@ -59,19 +59,19 @@ v2: uint32 DirOffset Dir: byte NameLength - char Name [NameLength] - byte CD; - uint32 NumEntries + char Name [NameLength] + byte CD; + uint32 NumEntries Entry: byte NameLength - char Name [NameLength] - uint32 Offset - uint32 Length - uint32 CompLength - uint32 Flags + char Name [NameLength] + uint32 Offset + uint32 Length + uint32 CompLength + uint32 Flags v2: uint32 TimeDate1 - uint32 TimeDate2 // not used + uint32 TimeDate2 // not used */ diff --git a/engines/wintermute/base/gfx/3ds/camera3d.cpp b/engines/wintermute/base/gfx/3ds/camera3d.cpp index 94930996d18..3a8aee37bfc 100644 --- a/engines/wintermute/base/gfx/3ds/camera3d.cpp +++ b/engines/wintermute/base/gfx/3ds/camera3d.cpp @@ -41,9 +41,9 @@ namespace Wintermute { ////////////////////////////////////////////////////////////////////////// Camera3D::Camera3D(BaseGame *inGame) : BaseNamedObject(inGame), - _position(0.0f, 0.0f, 0.0f), _target(0.0f, 0.0f, 0.0f), _bank(0.0f), - _fov(Math::Angle(45.0f).getRadians()), _originalFOV(Math::Angle(45.0f).getRadians()), - _nearClipPlane(-1.0f), _farClipPlane(-1.0f) { + _position(0.0f, 0.0f, 0.0f), _target(0.0f, 0.0f, 0.0f), _bank(0.0f), + _fov(Math::Angle(45.0f).getRadians()), _originalFOV(Math::Angle(45.0f).getRadians()), + _nearClipPlane(-1.0f), _farClipPlane(-1.0f) { } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/gfx/3ds/light3d.cpp b/engines/wintermute/base/gfx/3ds/light3d.cpp index 46245361d93..12d4a20f905 100644 --- a/engines/wintermute/base/gfx/3ds/light3d.cpp +++ b/engines/wintermute/base/gfx/3ds/light3d.cpp @@ -39,9 +39,9 @@ namespace Wintermute { ////////////////////////////////////////////////////////////////////////// Light3D::Light3D(BaseGame *inGame) : BaseScriptable(inGame, false, false), - _diffuseColor(BYTETORGBA(255, 255, 255, 255)), - _position(0, 0, 0), _target(0, 0, 0), _isSpotlight(false), - _active(true), _falloff(0), _distance(0.0f), _isAvailable(false) { + _diffuseColor(BYTETORGBA(255, 255, 255, 255)), + _position(0, 0, 0), _target(0, 0, 0), _isSpotlight(false), + _active(true), _falloff(0), _distance(0.0f), _isAvailable(false) { } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/gfx/3ds/loader3ds.cpp b/engines/wintermute/base/gfx/3ds/loader3ds.cpp index f9750100ef6..eefa96de4b0 100644 --- a/engines/wintermute/base/gfx/3ds/loader3ds.cpp +++ b/engines/wintermute/base/gfx/3ds/loader3ds.cpp @@ -32,7 +32,7 @@ namespace Wintermute { bool load3DSObject(Common::MemoryReadStream &fileStream, BaseArray &meshes, BaseArray &meshNames, - BaseArray &lights, BaseArray &cameras, BaseGame *gameRef) { + BaseArray &lights, BaseArray &cameras, BaseGame *gameRef) { uint32 wholeChunkSize = fileStream.readUint32LE(); int32 end = fileStream.pos() + wholeChunkSize - 6; @@ -88,7 +88,7 @@ bool load3DSObject(Common::MemoryReadStream &fileStream, BaseArray &meshes, BaseArray &meshNames, - BaseArray &lights, BaseArray &cameras, BaseGame *gameRef) { + BaseArray &lights, BaseArray &cameras, BaseGame *gameRef) { uint32 fileSize = 0; byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename, &fileSize); diff --git a/engines/wintermute/base/gfx/3ds/loader3ds.h b/engines/wintermute/base/gfx/3ds/loader3ds.h index a7b0f659ce8..09e48081497 100644 --- a/engines/wintermute/base/gfx/3ds/loader3ds.h +++ b/engines/wintermute/base/gfx/3ds/loader3ds.h @@ -33,7 +33,7 @@ class Camera3D; class Mesh3DS; bool load3DSFile(const char *filename, BaseArray &meshes, BaseArray &meshNames, - BaseArray &lights, BaseArray &cameras, BaseGame *gameRef); + BaseArray &lights, BaseArray &cameras, BaseGame *gameRef); enum Chunks3DS { RGB_FLOAT = 0x0010, diff --git a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp index 1f737aade1a..d911a4214c2 100644 --- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp +++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp @@ -614,9 +614,9 @@ struct SpriteVertex { #include "common/pack-end.h" bool BaseRenderOpenGL3D::drawSpriteEx(BaseSurfaceOpenGL3D &tex, const Wintermute::Rect32 &rect, - const Wintermute::Vector2 &pos, const Wintermute::Vector2 &rot, const Wintermute::Vector2 &scale, - float angle, uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode, - bool mirrorX, bool mirrorY) { + const Wintermute::Vector2 &pos, const Wintermute::Vector2 &rot, const Wintermute::Vector2 &scale, + float angle, uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode, + bool mirrorX, bool mirrorY) { // original wme has a batch mode for sprites, we ignore this for the moment if (_forceAlphaColor != 0) { @@ -737,7 +737,7 @@ bool BaseRenderOpenGL3D::drawSpriteEx(BaseSurfaceOpenGL3D &tex, const Wintermute } void BaseRenderOpenGL3D::renderSceneGeometry(const BaseArray &planes, const BaseArray &blocks, - const BaseArray &generics, const BaseArray &lights, Camera3D *camera) { + const BaseArray &generics, const BaseArray &lights, Camera3D *camera) { glMatrixMode(GL_MODELVIEW); glLoadIdentity(); _gameRef->_renderer3D->setup3D(camera, true); diff --git a/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp b/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp index e48c1fdc646..aebdc3aa740 100644 --- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp +++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp @@ -58,7 +58,7 @@ struct SpriteVertexShader { BaseRenderOpenGL3DShader::BaseRenderOpenGL3DShader(BaseGame *inGame) : BaseRenderer3D(inGame), _spriteBatchMode(false), _flatShadowMaskShader(nullptr) { - (void)_spriteBatchMode; // silence warning + (void)_spriteBatchMode; // silence warning } BaseRenderOpenGL3DShader::~BaseRenderOpenGL3DShader() { @@ -687,9 +687,9 @@ BaseSurface *Wintermute::BaseRenderOpenGL3DShader::createSurface() { } bool BaseRenderOpenGL3DShader::drawSpriteEx(BaseSurfaceOpenGL3D &tex, const Wintermute::Rect32 &rect, - const Wintermute::Vector2 &pos, const Wintermute::Vector2 &rot, const Wintermute::Vector2 &scale, - float angle, uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode, - bool mirrorX, bool mirrorY) { + const Wintermute::Vector2 &pos, const Wintermute::Vector2 &rot, const Wintermute::Vector2 &scale, + float angle, uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode, + bool mirrorX, bool mirrorY) { // original wme has a batch mode for sprites, we ignore this for the moment if (_forceAlphaColor != 0) { @@ -791,7 +791,7 @@ bool BaseRenderOpenGL3DShader::drawSpriteEx(BaseSurfaceOpenGL3D &tex, const Wint } void BaseRenderOpenGL3DShader::renderSceneGeometry(const BaseArray &planes, const BaseArray &blocks, - const BaseArray &generics, const BaseArray &lights, Camera3D *camera) { + const BaseArray &generics, const BaseArray &lights, Camera3D *camera) { // don't render scene geometry, as OpenGL ES 2 has no wireframe rendering and we don't have a shader alternative yet } diff --git a/engines/wintermute/base/gfx/x/material.cpp b/engines/wintermute/base/gfx/x/material.cpp index 6a2357a17ce..6c5fd1d98c6 100644 --- a/engines/wintermute/base/gfx/x/material.cpp +++ b/engines/wintermute/base/gfx/x/material.cpp @@ -44,8 +44,8 @@ namespace Wintermute { ////////////////////////////////////////////////////////////////////////// Material::Material(BaseGame *inGame) : BaseNamedObject(inGame), - _surface(nullptr), _ownedSurface(false), - _sprite(nullptr), _theora(nullptr) { + _surface(nullptr), _ownedSurface(false), + _sprite(nullptr), _theora(nullptr) { } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/gfx/x/modelx.cpp b/engines/wintermute/base/gfx/x/modelx.cpp index 9e9ffa2d05f..ce611f5d5f0 100644 --- a/engines/wintermute/base/gfx/x/modelx.cpp +++ b/engines/wintermute/base/gfx/x/modelx.cpp @@ -150,9 +150,9 @@ IMPLEMENT_PERSISTENT(ModelX, false) ////////////////////////////////////////////////////////////////////////// ModelX::ModelX(BaseGame *inGame, BaseObject *owner) : BaseObject(inGame), - _owner(owner), _lastOffsetX(0), _lastOffsetY(0), - _BBoxStart(0.0f, 0.0f, 0.0f), _BBoxEnd(0.0f, 0.0f, 0.0f), - _rootFrame(nullptr) { + _owner(owner), _lastOffsetX(0), _lastOffsetY(0), + _BBoxStart(0.0f, 0.0f, 0.0f), _BBoxEnd(0.0f, 0.0f, 0.0f), + _rootFrame(nullptr) { _drawingViewport.setEmpty(); _lastWorldMat.setToIdentity(); _lastViewMat.setToIdentity(); diff --git a/engines/wintermute/math/math_util.cpp b/engines/wintermute/math/math_util.cpp index 64c82d7eddd..9a14da5a777 100644 --- a/engines/wintermute/math/math_util.cpp +++ b/engines/wintermute/math/math_util.cpp @@ -55,8 +55,8 @@ float MathUtil::roundUp(float val) { #ifdef ENABLE_WME3D bool lineIntersectsTriangle(const Math::Vector3d &origin, const Math::Vector3d &direction, - const Math::Vector3d &v0, const Math::Vector3d &v1, const Math::Vector3d &v2, - float &t, float &u, float &v) { + const Math::Vector3d &v0, const Math::Vector3d &v1, const Math::Vector3d &v2, + float &t, float &u, float &v) { const float epsilon = 0.0001f; Math::Vector3d edge1 = v1 - v0; @@ -94,8 +94,8 @@ bool lineIntersectsTriangle(const Math::Vector3d &origin, const Math::Vector3d & } bool lineSegmentIntersectsTriangle(const Math::Vector3d &lineStart, const Math::Vector3d &lineEnd, - const Math::Vector3d &v0, const Math::Vector3d &v1, const Math::Vector3d &v2, - Math::Vector3d &intersection, float &distance) { + const Math::Vector3d &v0, const Math::Vector3d &v1, const Math::Vector3d &v2, + Math::Vector3d &intersection, float &distance) { const float epsilon = 0.0001f; Math::Vector3d edge1 = v1 - v0; diff --git a/engines/wintermute/math/math_util.h b/engines/wintermute/math/math_util.h index bc455aa4b4e..5d32ae9c363 100644 --- a/engines/wintermute/math/math_util.h +++ b/engines/wintermute/math/math_util.h @@ -43,11 +43,11 @@ public: #ifdef ENABLE_WME3D bool lineIntersectsTriangle(const Math::Vector3d &origin, const Math::Vector3d &direction, - const Math::Vector3d &v0, const Math::Vector3d &v1, const Math::Vector3d &v2, - float &t, float &u, float &v); + const Math::Vector3d &v0, const Math::Vector3d &v1, const Math::Vector3d &v2, + float &t, float &u, float &v); bool lineSegmentIntersectsTriangle(const Math::Vector3d &lineStart, const Math::Vector3d &lineEnd, - const Math::Vector3d &v0, const Math::Vector3d &v1, const Math::Vector3d &v2, + const Math::Vector3d &v0, const Math::Vector3d &v1, const Math::Vector3d &v2, Math::Vector3d &intersection, float &distance); #endif diff --git a/engines/wintermute/metaengine.cpp b/engines/wintermute/metaengine.cpp index f283dbe0170..b4390265d75 100644 --- a/engines/wintermute/metaengine.cpp +++ b/engines/wintermute/metaengine.cpp @@ -53,11 +53,11 @@ static char s_fallbackExtraBuf[256]; class WintermuteMetaEngine : public AdvancedMetaEngine { public: - const char *getName() const override { + const char *getName() const override { return "wintermute"; } - Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override { + Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override { const WMEGameDescription *gd = (const WMEGameDescription *)desc; #ifndef ENABLE_FOXTAIL @@ -131,7 +131,7 @@ public: return retVal; } - const Common::AchievementsInfo getAchievementsInfo(const Common::String &target) const override { + const Common::AchievementsInfo getAchievementsInfo(const Common::String &target) const override { Common::String gameId = ConfMan.get("gameid", target); // HACK: "juliauntold" is a DLC of "juliastars", they share the same achievements list diff --git a/engines/wintermute/utils/convert_utf.cpp b/engines/wintermute/utils/convert_utf.cpp index 2e227e40641..0ae63d63a94 100644 --- a/engines/wintermute/utils/convert_utf.cpp +++ b/engines/wintermute/utils/convert_utf.cpp @@ -22,19 +22,19 @@ /* --------------------------------------------------------------------- - Conversions between UTF32, UTF-16, and UTF-8. Source code file. - Author: Mark E. Davis, 1994. - Rev History: Rick McGowan, fixes & updates May 2001. - Sept 2001: fixed const & error conditions per - mods suggested by S. Parent & A. Lillich. - June 2002: Tim Dodd added detection and handling of incomplete - source sequences, enhanced error detection, added casts - to eliminate compiler warnings. - July 2003: slight mods to back out aggressive FFFE detection. - Jan 2004: updated switches in from-UTF8 conversions. - Oct 2004: updated to use UNI_MAX_LEGAL_UTF32 in UTF-32 conversions. + Conversions between UTF32, UTF-16, and UTF-8. Source code file. + Author: Mark E. Davis, 1994. + Rev History: Rick McGowan, fixes & updates May 2001. + Sept 2001: fixed const & error conditions per + mods suggested by S. Parent & A. Lillich. + June 2002: Tim Dodd added detection and handling of incomplete + source sequences, enhanced error detection, added casts + to eliminate compiler warnings. + July 2003: slight mods to back out aggressive FFFE detection. + Jan 2004: updated switches in from-UTF8 conversions. + Oct 2004: updated to use UNI_MAX_LEGAL_UTF32 in UTF-32 conversions. - See the header file "ConvertUTF.h" for complete documentation. + See the header file "ConvertUTF.h" for complete documentation. ------------------------------------------------------------------------ */ @@ -59,8 +59,8 @@ static const UTF32 halfMask = 0x3FFUL; /* --------------------------------------------------------------------- */ ConversionResult ConvertUTF32toUTF16( - const UTF32 **sourceStart, const UTF32 *sourceEnd, - UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags) { + const UTF32 **sourceStart, const UTF32 *sourceEnd, + UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags) { ConversionResult result = conversionOK; const UTF32 *source = *sourceStart; UTF16 *target = *targetStart; @@ -110,8 +110,8 @@ ConversionResult ConvertUTF32toUTF16( /* --------------------------------------------------------------------- */ ConversionResult ConvertUTF16toUTF32( - const UTF16 **sourceStart, const UTF16 *sourceEnd, - UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags) { + const UTF16 **sourceStart, const UTF16 *sourceEnd, + UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags) { ConversionResult result = conversionOK; const UTF16 *source = *sourceStart; UTF32 *target = *targetStart; @@ -190,8 +190,8 @@ static const char trailingBytesForUTF8[256] = { * in a UTF-8 sequence. */ static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, - 0x03C82080UL, 0xFA082080UL, 0x82082080UL - }; + 0x03C82080UL, 0xFA082080UL, 0x82082080UL + }; /* * Once the bits are split out into bytes of UTF-8, this is a mask OR-ed @@ -215,8 +215,8 @@ static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC /* --------------------------------------------------------------------- */ ConversionResult ConvertUTF16toUTF8( - const UTF16 **sourceStart, const UTF16 *sourceEnd, - UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags) { + const UTF16 **sourceStart, const UTF16 *sourceEnd, + UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags) { ConversionResult result = conversionOK; const UTF16 *source = *sourceStart; UTF8 *target = *targetStart; @@ -374,8 +374,8 @@ bool isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) { /* --------------------------------------------------------------------- */ ConversionResult ConvertUTF8toUTF16( - const UTF8 **sourceStart, const UTF8 *sourceEnd, - UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags) { + const UTF8 **sourceStart, const UTF8 *sourceEnd, + UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags) { ConversionResult result = conversionOK; const UTF8 *source = *sourceStart; UTF16 *target = *targetStart; @@ -469,8 +469,8 @@ ConversionResult ConvertUTF8toUTF16( /* --------------------------------------------------------------------- */ ConversionResult ConvertUTF32toUTF8( - const UTF32 **sourceStart, const UTF32 *sourceEnd, - UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags) { + const UTF32 **sourceStart, const UTF32 *sourceEnd, + UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags) { ConversionResult result = conversionOK; const UTF32 *source = *sourceStart; UTF8 *target = *targetStart; @@ -542,8 +542,8 @@ ConversionResult ConvertUTF32toUTF8( /* --------------------------------------------------------------------- */ ConversionResult ConvertUTF8toUTF32( - const UTF8 **sourceStart, const UTF8 *sourceEnd, - UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags) { + const UTF8 **sourceStart, const UTF8 *sourceEnd, + UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags) { ConversionResult result = conversionOK; const UTF8 *source = *sourceStart; UTF32 *target = *targetStart; @@ -624,20 +624,20 @@ ConversionResult ConvertUTF8toUTF32( /* --------------------------------------------------------------------- - Note A. - The fall-through switches in UTF-8 reading code save a - temp variable, some decrements & conditionals. The switches - are equivalent to the following loop: - { - int tmpBytesToRead = extraBytesToRead+1; - do { - ch += *source++; - --tmpBytesToRead; - if (tmpBytesToRead) ch <<= 6; - } while (tmpBytesToRead > 0); - } - In UTF-8 writing code, the switches on "bytesToWrite" are - similarly unrolled loops. + Note A. + The fall-through switches in UTF-8 reading code save a + temp variable, some decrements & conditionals. The switches + are equivalent to the following loop: + { + int tmpBytesToRead = extraBytesToRead+1; + do { + ch += *source++; + --tmpBytesToRead; + if (tmpBytesToRead) ch <<= 6; + } while (tmpBytesToRead > 0); + } + In UTF-8 writing code, the switches on "bytesToWrite" are + similarly unrolled loops. --------------------------------------------------------------------- */ diff --git a/engines/wintermute/utils/string_util.cpp b/engines/wintermute/utils/string_util.cpp index ad1313a20f5..abf4dee2c85 100644 --- a/engines/wintermute/utils/string_util.cpp +++ b/engines/wintermute/utils/string_util.cpp @@ -41,13 +41,13 @@ bool StringUtil::compareNoCase(const AnsiString &str1, const AnsiString &str2) { ////////////////////////////////////////////////////////////////////////// /*bool StringUtil::CompareNoCase(const WideString &str1, const WideString &str2) { - WideString str1lc = str1; - WideString str2lc = str2; + WideString str1lc = str1; + WideString str2lc = str2; - ToLowerCase(str1lc); - ToLowerCase(str2lc); + ToLowerCase(str1lc); + ToLowerCase(str2lc); - return (str1lc == str2lc); + return (str1lc == str2lc); }*/ ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/video/subtitle_card.cpp b/engines/wintermute/video/subtitle_card.cpp index 4199817f49c..e20a68063e2 100644 --- a/engines/wintermute/video/subtitle_card.cpp +++ b/engines/wintermute/video/subtitle_card.cpp @@ -32,9 +32,9 @@ namespace Wintermute { SubtitleCard::SubtitleCard(BaseGame *inGame, - const Common::String &text, - const uint &startFrame, - const uint &endFrame) : _gameRef(inGame), + const Common::String &text, + const uint &startFrame, + const uint &endFrame) : _gameRef(inGame), _startFrame(startFrame), _endFrame(endFrame) { _text = text; diff --git a/engines/zvision/graphics/cursors/cursor_manager.cpp b/engines/zvision/graphics/cursors/cursor_manager.cpp index 6e8293db265..14109f17059 100644 --- a/engines/zvision/graphics/cursors/cursor_manager.cpp +++ b/engines/zvision/graphics/cursors/cursor_manager.cpp @@ -34,16 +34,16 @@ namespace ZVision { const char *CursorManager::_cursorNames[NUM_CURSORS] = { "active", "arrow", "backward", "downarrow", "forward", "handpt", "handpu", "hdown", "hleft", - "hright", "hup", "idle", "leftarrow", "rightarrow", "suggest_surround", "suggest_tilt", "turnaround", "zuparrow" - }; + "hright", "hup", "idle", "leftarrow", "rightarrow", "suggest_surround", "suggest_tilt", "turnaround", "zuparrow" + }; const char *CursorManager::_zgiCursorFileNames[NUM_CURSORS] = { "g0gbc011.zcr", "g0gac011.zcr", "g0gac021.zcr", "g0gac031.zcr", "g0gac041.zcr", "g0gac051.zcr", "g0gac061.zcr", "g0gac071.zcr", "g0gac081.zcr", - "g0gac091.zcr", "g0gac101.zcr", "g0gac011.zcr", "g0gac111.zcr", "g0gac121.zcr", "g0gac131.zcr", "g0gac141.zcr", "g0gac151.zcr", "g0gac161.zcr" - }; + "g0gac091.zcr", "g0gac101.zcr", "g0gac011.zcr", "g0gac111.zcr", "g0gac121.zcr", "g0gac131.zcr", "g0gac141.zcr", "g0gac151.zcr", "g0gac161.zcr" + }; const char *CursorManager::_zNemCursorFileNames[NUM_CURSORS] = { "00act", "arrow", "back", "down", "forw", "handpt", "handpu", "hdown", "hleft", - "hright", "hup", "00idle", "left", "right", "ssurr", "stilt", "turn", "up" - }; + "hright", "hup", "00idle", "left", "right", "ssurr", "stilt", "turn", "up" + }; CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat pixelFormat) : _engine(engine), diff --git a/engines/zvision/metaengine.cpp b/engines/zvision/metaengine.cpp index 69e6370c65a..dd6cbf494a9 100644 --- a/engines/zvision/metaengine.cpp +++ b/engines/zvision/metaengine.cpp @@ -57,7 +57,7 @@ public: return "zvision"; } - bool hasFeature(MetaEngineFeature f) const override; + bool hasFeature(MetaEngineFeature f) const override; Common::KeymapArray initKeymaps(const char *target) const override; Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override; diff --git a/engines/zvision/sound/zork_raw.cpp b/engines/zvision/sound/zork_raw.cpp index e9439321f5e..5130359f589 100644 --- a/engines/zvision/sound/zork_raw.cpp +++ b/engines/zvision/sound/zork_raw.cpp @@ -39,17 +39,17 @@ namespace ZVision { const int16 RawChunkStream::_stepAdjustmentTable[8] = { -1, -1, -1, 1, 4, 7, 10, 12}; const int32 RawChunkStream::_amplitudeLookupTable[89] = {0x0007, 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, - 0x0010, 0x0011, 0x0013, 0x0015, 0x0017, 0x0019, 0x001C, 0x001F, - 0x0022, 0x0025, 0x0029, 0x002D, 0x0032, 0x0037, 0x003C, 0x0042, - 0x0049, 0x0050, 0x0058, 0x0061, 0x006B, 0x0076, 0x0082, 0x008F, - 0x009D, 0x00AD, 0x00BE, 0x00D1, 0x00E6, 0x00FD, 0x0117, 0x0133, - 0x0151, 0x0173, 0x0198, 0x01C1, 0x01EE, 0x0220, 0x0256, 0x0292, - 0x02D4, 0x031C, 0x036C, 0x03C3, 0x0424, 0x048E, 0x0502, 0x0583, - 0x0610, 0x06AB, 0x0756, 0x0812, 0x08E0, 0x09C3, 0x0ABD, 0x0BD0, - 0x0CFF, 0x0E4C, 0x0FBA, 0x114C, 0x1307, 0x14EE, 0x1706, 0x1954, - 0x1BDC, 0x1EA5, 0x21B6, 0x2515, 0x28CA, 0x2CDF, 0x315B, 0x364B, - 0x3BB9, 0x41B2, 0x4844, 0x4F7E, 0x5771, 0x602F, 0x69CE, 0x7462, 0x7FFF - }; + 0x0010, 0x0011, 0x0013, 0x0015, 0x0017, 0x0019, 0x001C, 0x001F, + 0x0022, 0x0025, 0x0029, 0x002D, 0x0032, 0x0037, 0x003C, 0x0042, + 0x0049, 0x0050, 0x0058, 0x0061, 0x006B, 0x0076, 0x0082, 0x008F, + 0x009D, 0x00AD, 0x00BE, 0x00D1, 0x00E6, 0x00FD, 0x0117, 0x0133, + 0x0151, 0x0173, 0x0198, 0x01C1, 0x01EE, 0x0220, 0x0256, 0x0292, + 0x02D4, 0x031C, 0x036C, 0x03C3, 0x0424, 0x048E, 0x0502, 0x0583, + 0x0610, 0x06AB, 0x0756, 0x0812, 0x08E0, 0x09C3, 0x0ABD, 0x0BD0, + 0x0CFF, 0x0E4C, 0x0FBA, 0x114C, 0x1307, 0x14EE, 0x1706, 0x1954, + 0x1BDC, 0x1EA5, 0x21B6, 0x2515, 0x28CA, 0x2CDF, 0x315B, 0x364B, + 0x3BB9, 0x41B2, 0x4844, 0x4F7E, 0x5771, 0x602F, 0x69CE, 0x7462, 0x7FFF + }; RawChunkStream::RawChunkStream(bool stereo) { if (stereo) @@ -232,9 +232,9 @@ bool RawZorkStream::rewind() { } Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream, - int rate, - bool stereo, - DisposeAfterUse::Flag disposeAfterUse) { + int rate, + bool stereo, + DisposeAfterUse::Flag disposeAfterUse) { if (stereo) assert(stream->size() % 2 == 0); diff --git a/engines/zvision/sound/zork_raw.h b/engines/zvision/sound/zork_raw.h index 4e5b36b8e75..b5aa239ef8c 100644 --- a/engines/zvision/sound/zork_raw.h +++ b/engines/zvision/sound/zork_raw.h @@ -131,9 +131,9 @@ public: * @return The new SeekableAudioStream (or 0 on failure). */ Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream, - int rate, - bool stereo, - DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); + int rate, + bool stereo, + DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine); diff --git a/graphics/conversion.cpp b/graphics/conversion.cpp index 5dcf005459d..0ff2c6e6749 100644 --- a/graphics/conversion.cpp +++ b/graphics/conversion.cpp @@ -31,9 +31,9 @@ namespace Graphics { // Function to blit a rect void copyBlit(byte *dst, const byte *src, - const uint dstPitch, const uint srcPitch, - const uint w, const uint h, - const uint bytesPerPixel) { + const uint dstPitch, const uint srcPitch, + const uint w, const uint h, + const uint bytesPerPixel) { if (dst == src) return; @@ -52,8 +52,8 @@ namespace { template inline void crossBlitLogic(byte *dst, const byte *src, const uint w, const uint h, - const PixelFormat &srcFmt, const PixelFormat &dstFmt, - const uint srcDelta, const uint dstDelta) { + const PixelFormat &srcFmt, const PixelFormat &dstFmt, + const uint srcDelta, const uint dstDelta) { for (uint y = 0; y < h; ++y) { for (uint x = 0; x < w; ++x) { const uint32 color = *(const SrcColor *)src; @@ -82,8 +82,8 @@ inline void crossBlitLogic(byte *dst, const byte *src, const uint w, const uint template inline void crossBlitLogic3BppSource(byte *dst, const byte *src, const uint w, const uint h, - const PixelFormat &srcFmt, const PixelFormat &dstFmt, - const uint srcDelta, const uint dstDelta) { + const PixelFormat &srcFmt, const PixelFormat &dstFmt, + const uint srcDelta, const uint dstDelta) { uint32 color; byte r, g, b, a; uint8 *col = (uint8 *)&color; @@ -119,9 +119,9 @@ inline void crossBlitLogic3BppSource(byte *dst, const byte *src, const uint w, c // Function to blit a rect from one color format to another bool crossBlit(byte *dst, const byte *src, - const uint dstPitch, const uint srcPitch, - const uint w, const uint h, - const Graphics::PixelFormat &dstFmt, const Graphics::PixelFormat &srcFmt) { + const uint dstPitch, const uint srcPitch, + const uint w, const uint h, + const Graphics::PixelFormat &dstFmt, const Graphics::PixelFormat &srcFmt) { // Error out if conversion is impossible if ((srcFmt.bytesPerPixel == 1) || (dstFmt.bytesPerPixel == 1) || (dstFmt.bytesPerPixel == 3) @@ -179,10 +179,10 @@ namespace { template void scaleNN(byte *dst, const byte *src, - const uint dstPitch, const uint srcPitch, - const uint dstW, const uint dstH, - const uint srcW, const uint srcH, - int *scaleCacheX) { + const uint dstPitch, const uint srcPitch, + const uint dstW, const uint dstH, + const uint srcW, const uint srcH, + int *scaleCacheX) { const uint dstDelta = (dstPitch - dstW * sizeof(Size)); @@ -200,10 +200,10 @@ void scaleNN(byte *dst, const byte *src, } // End of anonymous namespace bool scaleBlit(byte *dst, const byte *src, - const uint dstPitch, const uint srcPitch, - const uint dstW, const uint dstH, - const uint srcW, const uint srcH, - const Graphics::PixelFormat &fmt) { + const uint dstPitch, const uint srcPitch, + const uint dstW, const uint dstH, + const uint srcW, const uint srcH, + const Graphics::PixelFormat &fmt) { int *scaleCacheX = new int[dstW]; for (uint x = 0; x < dstW; x++) { @@ -280,7 +280,7 @@ inline byte scaleBlitBilinearInterpolate(byte c01, byte c00, byte c11, byte c10, template Size scaleBlitBilinearInterpolate(Size c01, Size c00, Size c11, Size c10, int ex, int ey, - const Graphics::PixelFormat &fmt) { + const Graphics::PixelFormat &fmt) { byte c01_a, c01_r, c01_g, c01_b; fmt.colorToARGB(c01, c01_a, c01_r, c01_g, c01_b); @@ -302,11 +302,11 @@ Size scaleBlitBilinearInterpolate(Size c01, Size c00, Size c11, Size c10, int ex template // TODO: See mirroring comment in RenderTicket ctor void scaleBlitBilinearLogic(byte *dst, const byte *src, - const uint dstPitch, const uint srcPitch, - const uint dstW, const uint dstH, + const uint dstPitch, const uint srcPitch, + const uint dstW, const uint dstH, const uint srcW, const uint srcH, - const Graphics::PixelFormat &fmt, - int *sax, int *say) { + const Graphics::PixelFormat &fmt, + int *sax, int *say) { int spixelw = (srcW - 1); int spixelh = (srcH - 1); @@ -393,10 +393,10 @@ void scaleBlitBilinearLogic(byte *dst, const byte *src, } // End of anonymous namespace bool scaleBlitBilinear(byte *dst, const byte *src, - const uint dstPitch, const uint srcPitch, - const uint dstW, const uint dstH, - const uint srcW, const uint srcH, - const Graphics::PixelFormat &fmt) { + const uint dstPitch, const uint srcPitch, + const uint dstW, const uint dstH, + const uint srcW, const uint srcH, + const Graphics::PixelFormat &fmt) { if (fmt.bytesPerPixel != 2 && fmt.bytesPerPixel != 4) return false; diff --git a/graphics/conversion.h b/graphics/conversion.h index 597fb22988f..4729bc2e728 100644 --- a/graphics/conversion.h +++ b/graphics/conversion.h @@ -66,9 +66,9 @@ inline static void RGB2YUV(byte r, byte g, byte b, byte &y, byte &u, byte &v) { * @param bytesPerPixel the number of bytes per pixel */ void copyBlit(byte *dst, const byte *src, - const uint dstPitch, const uint srcPitch, - const uint w, const uint h, - const uint bytesPerPixel); + const uint dstPitch, const uint srcPitch, + const uint w, const uint h, + const uint bytesPerPixel); /** * Blits a rectangle from one graphical format to another. @@ -93,21 +93,21 @@ void copyBlit(byte *dst, const byte *src, * dstPitch < srcPitch though. */ bool crossBlit(byte *dst, const byte *src, - const uint dstPitch, const uint srcPitch, - const uint w, const uint h, - const Graphics::PixelFormat &dstFmt, const Graphics::PixelFormat &srcFmt); + const uint dstPitch, const uint srcPitch, + const uint w, const uint h, + const Graphics::PixelFormat &dstFmt, const Graphics::PixelFormat &srcFmt); bool scaleBlit(byte *dst, const byte *src, - const uint dstPitch, const uint srcPitch, - const uint dstW, const uint dstH, - const uint srcW, const uint srcH, - const Graphics::PixelFormat &fmt); + const uint dstPitch, const uint srcPitch, + const uint dstW, const uint dstH, + const uint srcW, const uint srcH, + const Graphics::PixelFormat &fmt); bool scaleBlitBilinear(byte *dst, const byte *src, - const uint dstPitch, const uint srcPitch, - const uint dstW, const uint dstH, - const uint srcW, const uint srcH, - const Graphics::PixelFormat &fmt); + const uint dstPitch, const uint srcPitch, + const uint dstW, const uint dstH, + const uint srcW, const uint srcH, + const Graphics::PixelFormat &fmt); /** @} */ } // End of namespace Graphics diff --git a/graphics/fonts/ttf.cpp b/graphics/fonts/ttf.cpp index 02a72343a31..8d7636767d8 100644 --- a/graphics/fonts/ttf.cpp +++ b/graphics/fonts/ttf.cpp @@ -52,19 +52,19 @@ #include FT_TRUETYPE_TAGS_H #if (FREETYPE_MAJOR > 2 || \ - (FREETYPE_MAJOR == 2 && (FREETYPE_MINOR > 3 || \ - (FREETYPE_MINOR == 3 && FREETYPE_PATCH >= 8)))) + (FREETYPE_MAJOR == 2 && (FREETYPE_MINOR > 3 || \ + (FREETYPE_MINOR == 3 && FREETYPE_PATCH >= 8)))) // FT2.3.8+, nothing to do, FT_GlyphSlot_Own_Bitmap is in FT_BITMAP_H #define FAKE_BOLD 2 #elif (FREETYPE_MAJOR > 2 || \ - (FREETYPE_MAJOR == 2 && (FREETYPE_MINOR > 2 || \ - (FREETYPE_MINOR == 2 && FREETYPE_PATCH >= 0)))) + (FREETYPE_MAJOR == 2 && (FREETYPE_MINOR > 2 || \ + (FREETYPE_MINOR == 2 && FREETYPE_PATCH >= 0)))) // FT2.2.0+ have FT_GlyphSlot_Own_Bitmap in FT_SYNTHESIS_H #include FT_SYNTHESIS_H #define FAKE_BOLD 2 #elif (FREETYPE_MAJOR > 2 || \ - (FREETYPE_MAJOR == 2 && (FREETYPE_MINOR > 1 || \ - (FREETYPE_MINOR == 1 && FREETYPE_PATCH >= 10)))) + (FREETYPE_MAJOR == 2 && (FREETYPE_MINOR > 1 || \ + (FREETYPE_MINOR == 1 && FREETYPE_PATCH >= 10)))) // FT2.1.10+ don't have FT_GlyphSlot_Own_Bitmap but they have FT_Bitmap_Embolden, do workaround #define FAKE_BOLD 1 #else @@ -202,9 +202,9 @@ private: }; TTFFont::TTFFont() - : _initialized(false), _face(), _ttfFile(0), _size(0), _width(0), _height(0), _ascent(0), - _descent(0), _glyphs(), _loadFlags(FT_LOAD_TARGET_NORMAL), _renderMode(FT_RENDER_MODE_NORMAL), - _hasKerning(false), _allowLateCaching(false), _fakeBold(false), _fakeItalic(false) { + : _initialized(false), _face(), _ttfFile(0), _size(0), _width(0), _height(0), _ascent(0), + _descent(0), _glyphs(), _loadFlags(FT_LOAD_TARGET_NORMAL), _renderMode(FT_RENDER_MODE_NORMAL), + _hasKerning(false), _allowLateCaching(false), _fakeBold(false), _fakeItalic(false) { } TTFFont::~TTFFont() { @@ -222,7 +222,7 @@ TTFFont::~TTFFont() { } bool TTFFont::load(Common::SeekableReadStream &stream, int size, TTFSizeMode sizeMode, - uint dpi, TTFRenderMode renderMode, const uint32 *mapping, bool stemDarkening) { + uint dpi, TTFRenderMode renderMode, const uint32 *mapping, bool stemDarkening) { if (!g_ttf.isInitialized()) return false; @@ -248,7 +248,7 @@ bool TTFFont::load(Common::SeekableReadStream &stream, int size, TTFSizeMode siz } bool TTFFont::load(uint8 *ttfFile, uint32 sizeFile, int32 faceIndex, bool bold, bool italic, - int size, TTFSizeMode sizeMode, uint dpi, TTFRenderMode renderMode, const uint32 *mapping, bool stemDarkening) { + int size, TTFSizeMode sizeMode, uint dpi, TTFRenderMode renderMode, const uint32 *mapping, bool stemDarkening) { _initialized = false; if (!g_ttf.isInitialized()) @@ -947,7 +947,7 @@ static bool matchFaceName(const Common::U32String &faceName, const FT_Face &face } Font *findTTFace(const Common::Array &files, const Common::U32String &faceName, - bool bold, bool italic, int size, uint dpi, TTFRenderMode renderMode, const uint32 *mapping) { + bool bold, bool italic, int size, uint dpi, TTFRenderMode renderMode, const uint32 *mapping) { if (!g_ttf.isInitialized()) return nullptr; diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp index b0318a103e2..e03bffd8118 100644 --- a/graphics/macgui/mactext.cpp +++ b/graphics/macgui/mactext.cpp @@ -540,7 +540,7 @@ void MacText::splitString(const Common::U32String &str, int curLine) { _textLines[curLine].lastChunk().text = Common::U32String(); tmp_width = 0; cur_width = 0; - } + } tmp_width += char_width; _textLines[curLine].lastChunk().text += c; } diff --git a/graphics/nanosvg/nanosvg.h b/graphics/nanosvg/nanosvg.h index 79b4fc331a6..9891fc627c4 100644 --- a/graphics/nanosvg/nanosvg.h +++ b/graphics/nanosvg/nanosvg.h @@ -2971,32 +2971,32 @@ error: NSVGpath* nsvgDuplicatePath(NSVGpath* p) { - NSVGpath* res = NULL; + NSVGpath* res = NULL; - if (p == NULL) - return NULL; + if (p == NULL) + return NULL; - res = (NSVGpath*)malloc(sizeof(NSVGpath)); - if (res == NULL) goto error; - memset(res, 0, sizeof(NSVGpath)); + res = (NSVGpath*)malloc(sizeof(NSVGpath)); + if (res == NULL) goto error; + memset(res, 0, sizeof(NSVGpath)); - res->pts = (float*)malloc(p->npts*2*sizeof(float)); - if (res->pts == NULL) goto error; - memcpy(res->pts, p->pts, p->npts * sizeof(float) * 2); - res->npts = p->npts; + res->pts = (float*)malloc(p->npts*2*sizeof(float)); + if (res->pts == NULL) goto error; + memcpy(res->pts, p->pts, p->npts * sizeof(float) * 2); + res->npts = p->npts; - memcpy(res->bounds, p->bounds, sizeof(p->bounds)); + memcpy(res->bounds, p->bounds, sizeof(p->bounds)); - res->closed = p->closed; + res->closed = p->closed; - return res; + return res; error: - if (res != NULL) { - free(res->pts); - free(res); - } - return NULL; + if (res != NULL) { + free(res->pts); + free(res); + } + return NULL; } void nsvgDelete(NSVGimage* image) diff --git a/graphics/nanosvg/nanosvgrast.h b/graphics/nanosvg/nanosvgrast.h index b740c316ca2..f2064aeea9f 100644 --- a/graphics/nanosvg/nanosvgrast.h +++ b/graphics/nanosvg/nanosvgrast.h @@ -981,7 +981,7 @@ static unsigned int nsvg__applyOpacity(unsigned int c, float u) static inline int nsvg__div255(int x) { - return ((x+1) * 257) >> 16; + return ((x+1) * 257) >> 16; } static void nsvg__scanlineSolid(unsigned char* dst, int count, unsigned char* cover, int x, int y, diff --git a/graphics/scaler/aspect.h b/graphics/scaler/aspect.h index 05ed7c1af5e..0efe8738e95 100644 --- a/graphics/scaler/aspect.h +++ b/graphics/scaler/aspect.h @@ -48,16 +48,16 @@ void makeRectStretchable(int &x, int &y, int &w, int &h, bool interpolate); /** * TODO: explain */ - + int stretch200To240(uint8 *buf, - uint32 pitch, - int width, - int height, - int srcX, - int srcY, - int origSrcY, - bool interpolate, - const Graphics::PixelFormat &format); + uint32 pitch, + int width, + int height, + int srcX, + int srcY, + int origSrcY, + bool interpolate, + const Graphics::PixelFormat &format); int stretch200To240Nearest(uint8 *buf, uint32 pitch, int width, int height, int srcX, int srcY, int origSrcY, const Graphics::PixelFormat &format); diff --git a/graphics/scaler/downscaler.h b/graphics/scaler/downscaler.h index 2120a1f7b77..1ef62271ad9 100644 --- a/graphics/scaler/downscaler.h +++ b/graphics/scaler/downscaler.h @@ -30,6 +30,6 @@ * For example, a 320x200 image is scaled to 160x100. */ extern void DownscaleAllByHalf(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, - uint32 dstPitch, int width, int height); + uint32 dstPitch, int width, int height); #endif diff --git a/graphics/scaler/edge.cpp b/graphics/scaler/edge.cpp index 28851816ffb..4447ac00ecb 100644 --- a/graphics/scaler/edge.cpp +++ b/graphics/scaler/edge.cpp @@ -452,8 +452,8 @@ int32 EdgePlugin::calcPixelDiffNosqrt(typename ColorMask::PixelType pixel1, type int EdgePlugin::findPrincipleAxis(int16 *diffs, int16 *bplane, - int8 *sim, - int32 *return_angle) { + int8 *sim, + int32 *return_angle) { struct xy_point { int16 x, y; }; @@ -784,7 +784,7 @@ int EdgePlugin::checkArrows(int best_dir, Pixel *pixels, int8 *sim, int half_fla template int EdgePlugin::refineDirection(char edge_type, Pixel *pixels, int16 *bptr, - int8 *sim, double angle) { + int8 *sim, double angle) { int32 sums_dir[9] = { 0 }; int32 sum; int32 best_sum; @@ -1772,7 +1772,7 @@ int EdgePlugin::fixKnights(int sub_type, Pixel *pixels, int8 *sim) { template void EdgePlugin::antiAliasGridClean3x(uint8 *dptr, int dstPitch, - typename ColorMask::PixelType *pixels, int sub_type, int16 *bptr) { + typename ColorMask::PixelType *pixels, int sub_type, int16 *bptr) { typedef typename ColorMask::PixelType Pixel; Pixel *dptr2; @@ -2373,9 +2373,9 @@ void EdgePlugin::antiAliasGridClean3x(uint8 *dptr, int dstPitch, template void EdgePlugin::antiAliasGrid2x(uint8 *dptr, int dstPitch, - typename ColorMask::PixelType *pixels, int sub_type, int16 *bptr, - int8 *sim, - int interpolate_2x) { + typename ColorMask::PixelType *pixels, int sub_type, int16 *bptr, + int8 *sim, + int interpolate_2x) { typedef typename ColorMask::PixelType Pixel; Pixel *dptr2; @@ -3263,7 +3263,7 @@ int checkUnchangedPixels(const Pixel *old_src_ptr, const Pixel *pixels, int w) { /* old_dptr starts in top left of grid, dptr in center */ template void drawUnchangedGrid3x(byte *dptr, int dstPitch, - const byte *old_dptr, int old_dst_inc) { + const byte *old_dptr, int old_dst_inc) { const Pixel *sp; Pixel *dp; @@ -3291,7 +3291,7 @@ void drawUnchangedGrid3x(byte *dptr, int dstPitch, /* Draw unchanged pixel grid, 2x */ template void drawUnchangedGrid2x(byte *dptr, int dstPitch, - const byte *old_dptr, int old_dst_inc) { + const byte *old_dptr, int old_dst_inc) { const Pixel *sp; Pixel *dp; @@ -3309,11 +3309,11 @@ void drawUnchangedGrid2x(byte *dptr, int dstPitch, template void EdgePlugin::antiAliasPass3x(const uint8 *src, uint8 *dst, - int w, int h, - int srcPitch, int dstPitch, - bool haveOldSrc, - const uint8* oldSrc, int oldPitch, - const uint8 *buffer, int bufferPitch) { + int w, int h, + int srcPitch, int dstPitch, + bool haveOldSrc, + const uint8* oldSrc, int oldPitch, + const uint8 *buffer, int bufferPitch) { typedef typename ColorMask::PixelType Pixel; int x, y; @@ -3393,12 +3393,12 @@ void EdgePlugin::antiAliasPass3x(const uint8 *src, uint8 *dst, template void EdgePlugin::antiAliasPass2x(const uint8 *src, uint8 *dst, - int w, int h, - int srcPitch, int dstPitch, - int interpolate_2x, - bool haveOldSrc, - const uint8 *oldSrc, int oldSrcPitch, - const uint8 *buffer, int bufferPitch) { + int w, int h, + int srcPitch, int dstPitch, + int interpolate_2x, + bool haveOldSrc, + const uint8 *oldSrc, int oldSrcPitch, + const uint8 *buffer, int bufferPitch) { typedef typename ColorMask::PixelType Pixel; int x, y; @@ -3478,7 +3478,7 @@ void EdgePlugin::antiAliasPass2x(const uint8 *src, uint8 *dst, void EdgePlugin::initTables(const uint8 *srcPtr, uint32 srcPitch, - int width, int height) { + int width, int height) { double r_float, g_float, b_float; int r, g, b; uint16 i; @@ -3543,7 +3543,7 @@ void EdgePlugin::initialize(const Graphics::PixelFormat &format) { #if 0 void EdgePlugin::scale(const uint8 *srcPtr, uint32 srcPitch, - uint8 *dstPtr, uint32 dstPitch, int width, int height, int x, int y) { + uint8 *dstPtr, uint32 dstPitch, int width, int height, int x, int y) { if (_format.bytesPerPixel == 2) { if (_factor == 2) { if (_format.gLoss == 2) @@ -3573,7 +3573,7 @@ void EdgePlugin::scale(const uint8 *srcPtr, uint32 srcPitch, #endif void EdgePlugin::internScale(const uint8 *srcPtr, uint32 srcPitch, - uint8 *dstPtr, uint32 dstPitch, const uint8 *oldSrcPtr, uint32 oldSrcPitch, int width, int height, const uint8 *buffer, uint32 bufferPitch) { + uint8 *dstPtr, uint32 dstPitch, const uint8 *oldSrcPtr, uint32 oldSrcPitch, int width, int height, const uint8 *buffer, uint32 bufferPitch) { bool enable = oldSrcPtr != NULL; if (_format.bytesPerPixel == 2) { if (_factor == 2) { diff --git a/graphics/scaler/normal.cpp b/graphics/scaler/normal.cpp index a627a819be3..a007d6a0b30 100644 --- a/graphics/scaler/normal.cpp +++ b/graphics/scaler/normal.cpp @@ -61,11 +61,11 @@ void Normal2x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPit #ifdef USE_ARM_SCALER_ASM extern "C" void Normal2xARM(const uint8 *srcPtr, - uint32 srcPitch, - uint8 *dstPtr, - uint32 dstPitch, - int width, - int height); + uint32 srcPitch, + uint8 *dstPtr, + uint32 dstPitch, + int width, + int height); #else /** diff --git a/graphics/scalerplugin.cpp b/graphics/scalerplugin.cpp index a5b7c692350..b2904de60da 100644 --- a/graphics/scalerplugin.cpp +++ b/graphics/scalerplugin.cpp @@ -101,7 +101,7 @@ uint SourceScaler::setFactor(uint factor) { } void SourceScaler::scaleIntern(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, - uint32 dstPitch, int width, int height, int x, int y) { + uint32 dstPitch, int width, int height, int x, int y) { if (!_enable) { // Do not pass _oldSrc, do not update _oldSrc internScale(srcPtr, srcPitch, diff --git a/graphics/tinygl/zline.cpp b/graphics/tinygl/zline.cpp index ed623ea1133..f795e8127d7 100644 --- a/graphics/tinygl/zline.cpp +++ b/graphics/tinygl/zline.cpp @@ -105,7 +105,7 @@ void FrameBuffer::drawLine(const ZBufferPoint *p1, const ZBufferPoint *p2) { int color = RGB_TO_PIXEL(r, g, b); int sr, sg, sb; - if (kInterpZ) { + if (kInterpZ) { sz = (p2->z - p1->z) / n; z = p1->z; } diff --git a/graphics/tinygl/ztriangle.cpp b/graphics/tinygl/ztriangle.cpp index 620f3d25105..9072a93ecd4 100644 --- a/graphics/tinygl/ztriangle.cpp +++ b/graphics/tinygl/ztriangle.cpp @@ -37,7 +37,7 @@ static const int NB_INTERP = 8; template FORCEINLINE static void putPixelFlat(FrameBuffer *buffer, int buf, unsigned int *pz, int _a, - int x, int y, unsigned int &z, unsigned int &r, unsigned int &g, unsigned int &b, unsigned int &a, int &dzdx) { + int x, int y, unsigned int &z, unsigned int &r, unsigned int &g, unsigned int &b, unsigned int &a, int &dzdx) { if ((!kEnableScissor || !buffer->scissorPixel(x + _a, y)) && buffer->compareDepth(z, pz[_a])) { buffer->writePixel(buf + _a, a >> (ZB_POINT_ALPHA_BITS - 8), r >> (ZB_POINT_RED_BITS - 8), g >> (ZB_POINT_GREEN_BITS - 8), b >> (ZB_POINT_BLUE_BITS - 8), z); } @@ -46,8 +46,8 @@ FORCEINLINE static void putPixelFlat(FrameBuffer *buffer, int buf, unsigned int template FORCEINLINE static void putPixelSmooth(FrameBuffer *buffer, int buf, unsigned int *pz, int _a, - int x, int y, unsigned int &z, unsigned int &r, unsigned int &g, unsigned int &b, unsigned int &a, - int &dzdx, int &drdx, int &dgdx, int &dbdx, unsigned int dadx) { + int x, int y, unsigned int &z, unsigned int &r, unsigned int &g, unsigned int &b, unsigned int &a, + int &dzdx, int &drdx, int &dgdx, int &dbdx, unsigned int dadx) { if ((!kEnableScissor || !buffer->scissorPixel(x + _a, y)) && buffer->compareDepth(z, pz[_a])) { buffer->writePixel(buf + _a, a >> (ZB_POINT_ALPHA_BITS - 8), r >> (ZB_POINT_RED_BITS - 8), g >> (ZB_POINT_GREEN_BITS - 8), b >> (ZB_POINT_BLUE_BITS - 8), z); } @@ -78,9 +78,9 @@ FORCEINLINE static void putPixelShadow(FrameBuffer *buffer, int buf, unsigned in template FORCEINLINE static void putPixelTextureMappingPerspective(FrameBuffer *buffer, int buf, - const Graphics::TexelBuffer *texture, unsigned int wrap_s, unsigned int wrap_t, unsigned int *pz, int _a, - int x, int y, unsigned int &z, int &t, int &s, unsigned int &r, unsigned int &g, unsigned int &b, unsigned int &a, - int &dzdx, int &dsdx, int &dtdx, int &drdx, int &dgdx, int &dbdx, unsigned int dadx) { + const Graphics::TexelBuffer *texture, unsigned int wrap_s, unsigned int wrap_t, unsigned int *pz, int _a, + int x, int y, unsigned int &z, int &t, int &s, unsigned int &r, unsigned int &g, unsigned int &b, unsigned int &a, + int &dzdx, int &dsdx, int &dtdx, int &drdx, int &dgdx, int &dbdx, unsigned int dadx) { if ((!kEnableScissor || !buffer->scissorPixel(x + _a, y)) && buffer->compareDepth(z, pz[_a])) { uint8 c_a, c_r, c_g, c_b; texture->getARGBAt(wrap_s, wrap_t, s, t, c_a, c_r, c_g, c_b); diff --git a/graphics/transparent_surface.h b/graphics/transparent_surface.h index 6164b17f4ea..8277eefd73a 100644 --- a/graphics/transparent_surface.h +++ b/graphics/transparent_surface.h @@ -189,10 +189,10 @@ private: * This deleter assures Surface::free is called on deletion. */ /*struct SharedPtrTransparentSurfaceDeleter { - void operator()(TransparentSurface *ptr) { - ptr->free(); - delete ptr; - } + void operator()(TransparentSurface *ptr) { + ptr->free(); + delete ptr; + } };*/ /** @} */ } // End of namespace Graphics diff --git a/gui/EventRecorder.cpp b/gui/EventRecorder.cpp index 6f4fa88d439..a6a3f213a79 100644 --- a/gui/EventRecorder.cpp +++ b/gui/EventRecorder.cpp @@ -569,7 +569,7 @@ void EventRecorder::preDrawOverlayGui() { } void EventRecorder::postDrawOverlayGui() { - if ((_initialized) || (_needRedraw)) { + if ((_initialized) || (_needRedraw)) { RecordMode oldMode = _recordMode; _recordMode = kPassthrough; g_system->hideOverlay(); diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index d3fdb35092c..600379b14f6 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -1037,7 +1037,7 @@ void ThemeEngine::drawButton(const Common::Rect &r, const Common::U32String &str } void ThemeEngine::drawDropDownButton(const Common::Rect &r, uint32 dropdownWidth, const Common::U32String &str, - ThemeEngine::WidgetStateInfo buttonState, bool inButton, bool inDropdown, bool rtl) { + ThemeEngine::WidgetStateInfo buttonState, bool inButton, bool inDropdown, bool rtl) { if (!ready()) return; @@ -1298,7 +1298,7 @@ void ThemeEngine::drawWidgetBackground(const Common::Rect &r, WidgetBackground b } void ThemeEngine::drawTab(const Common::Rect &r, int tabHeight, const Common::Array &tabWidths, - const Common::Array &tabs, int active, bool rtl) { + const Common::Array &tabs, int active, bool rtl) { if (!ready()) return; @@ -1350,8 +1350,8 @@ void ThemeEngine::drawTab(const Common::Rect &r, int tabHeight, const Common::Ar } void ThemeEngine::drawText(const Common::Rect &r, const Common::U32String &str, WidgetStateInfo state, - Graphics::TextAlign align, TextInversionState inverted, int deltax, bool useEllipsis, - FontStyle font, FontColor color, bool restore, const Common::Rect &drawableTextArea) { + Graphics::TextAlign align, TextInversionState inverted, int deltax, bool useEllipsis, + FontStyle font, FontColor color, bool restore, const Common::Rect &drawableTextArea) { if (!ready()) return; diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp index 7bf71c2d9fa..67f301c06d1 100644 --- a/gui/gui-manager.cpp +++ b/gui/gui-manager.cpp @@ -58,7 +58,7 @@ enum { // Constructor GuiManager::GuiManager() : _redrawStatus(kRedrawDisabled), _stateIsSaved(false), - _cursorAnimateCounter(0), _cursorAnimateTimer(0) { + _cursorAnimateCounter(0), _cursorAnimateTimer(0) { _theme = nullptr; _useStdCursor = false; diff --git a/gui/widget.cpp b/gui/widget.cpp index 4291fa913fa..87ac63f5b12 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -973,7 +973,7 @@ void ContainerWidget::drawWidget() { #pragma mark - OptionsContainerWidget::OptionsContainerWidget(GuiObject *boss, const Common::String &name, const Common::String &dialogLayout, - bool scrollable, const Common::String &domain) : + bool scrollable, const Common::String &domain) : Widget(boss, name), _domain(domain), _dialogLayout(dialogLayout), diff --git a/image/codecs/msvideo1.cpp b/image/codecs/msvideo1.cpp index 439f219fc50..caa761d9c1f 100644 --- a/image/codecs/msvideo1.cpp +++ b/image/codecs/msvideo1.cpp @@ -31,13 +31,13 @@ namespace Image { #define CHECK_STREAM_PTR(n) \ if ((stream.pos() + n) > stream.size() ) { \ warning ("MS Video-1: Stream out of bounds (%d >= %d) d%d", stream.pos() + n, stream.size(), n); \ - return; \ + return; \ } MSVideo1Decoder::MSVideo1Decoder(uint16 width, uint16 height, byte bitsPerPixel) : Codec() { _surface = new Graphics::Surface(); _surface->create(width, height, (bitsPerPixel == 8) ? Graphics::PixelFormat::createFormatCLUT8() : - Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0)); + Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0)); _bitsPerPixel = bitsPerPixel; } @@ -48,178 +48,178 @@ MSVideo1Decoder::~MSVideo1Decoder() { } void MSVideo1Decoder::decode8(Common::SeekableReadStream &stream) { - byte colors[8]; - byte *pixels = (byte *)_surface->getPixels(); - uint16 stride = _surface->w; + byte colors[8]; + byte *pixels = (byte *)_surface->getPixels(); + uint16 stride = _surface->w; - int skipBlocks = 0; - uint16 blocks_wide = _surface->w / 4; - uint16 blocks_high = _surface->h / 4; - uint32 totalBlocks = blocks_wide * blocks_high; - uint32 blockInc = 4; - uint16 rowDec = stride + 4; + int skipBlocks = 0; + uint16 blocks_wide = _surface->w / 4; + uint16 blocks_high = _surface->h / 4; + uint32 totalBlocks = blocks_wide * blocks_high; + uint32 blockInc = 4; + uint16 rowDec = stride + 4; - for (uint16 block_y = blocks_high; block_y > 0; block_y--) { - uint32 blockPtr = (block_y * 4 - 1) * stride; - for (uint16 block_x = blocks_wide; block_x > 0; block_x--) { - // check if this block should be skipped - if (skipBlocks > 0) { - blockPtr += blockInc; - skipBlocks--; - totalBlocks--; - continue; - } + for (uint16 block_y = blocks_high; block_y > 0; block_y--) { + uint32 blockPtr = (block_y * 4 - 1) * stride; + for (uint16 block_x = blocks_wide; block_x > 0; block_x--) { + // check if this block should be skipped + if (skipBlocks > 0) { + blockPtr += blockInc; + skipBlocks--; + totalBlocks--; + continue; + } - uint32 pixelPtr = blockPtr; + uint32 pixelPtr = blockPtr; - /* get the next two bytes in the encoded data stream */ - CHECK_STREAM_PTR(2); - byte byte_a = stream.readByte(); - byte byte_b = stream.readByte(); + /* get the next two bytes in the encoded data stream */ + CHECK_STREAM_PTR(2); + byte byte_a = stream.readByte(); + byte byte_b = stream.readByte(); - /* check if the decode is finished */ - if (byte_a == 0 && byte_b == 0 && totalBlocks == 0) { - return; - } else if ((byte_b & 0xFC) == 0x84) { - // skip code, but don't count the current block - skipBlocks = ((byte_b - 0x84) << 8) + byte_a - 1; - } else if (byte_b < 0x80) { - // 2-color encoding - uint16 flags = (byte_b << 8) | byte_a; + /* check if the decode is finished */ + if (byte_a == 0 && byte_b == 0 && totalBlocks == 0) { + return; + } else if ((byte_b & 0xFC) == 0x84) { + // skip code, but don't count the current block + skipBlocks = ((byte_b - 0x84) << 8) + byte_a - 1; + } else if (byte_b < 0x80) { + // 2-color encoding + uint16 flags = (byte_b << 8) | byte_a; - CHECK_STREAM_PTR(2); - colors[0] = stream.readByte(); - colors[1] = stream.readByte(); + CHECK_STREAM_PTR(2); + colors[0] = stream.readByte(); + colors[1] = stream.readByte(); - for (byte pixel_y = 0; pixel_y < 4; pixel_y++) { - for (byte pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1) - pixels[pixelPtr++] = colors[(flags & 0x1) ^ 1]; - pixelPtr -= rowDec; - } - } else if (byte_b >= 0x90) { - // 8-color encoding - uint16 flags = (byte_b << 8) | byte_a; + for (byte pixel_y = 0; pixel_y < 4; pixel_y++) { + for (byte pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1) + pixels[pixelPtr++] = colors[(flags & 0x1) ^ 1]; + pixelPtr -= rowDec; + } + } else if (byte_b >= 0x90) { + // 8-color encoding + uint16 flags = (byte_b << 8) | byte_a; - CHECK_STREAM_PTR(8); + CHECK_STREAM_PTR(8); for (byte i = 0; i < 8; i++) colors[i] = stream.readByte(); - for (byte pixel_y = 0; pixel_y < 4; pixel_y++) { - for (byte pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1) - pixels[pixelPtr++] = colors[((pixel_y & 0x2) << 1) + (pixel_x & 0x2) + ((flags & 0x1) ^ 1)]; - pixelPtr -= rowDec; - } - } else { - // 1-color encoding - colors[0] = byte_a; + for (byte pixel_y = 0; pixel_y < 4; pixel_y++) { + for (byte pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1) + pixels[pixelPtr++] = colors[((pixel_y & 0x2) << 1) + (pixel_x & 0x2) + ((flags & 0x1) ^ 1)]; + pixelPtr -= rowDec; + } + } else { + // 1-color encoding + colors[0] = byte_a; - for (byte pixel_y = 0; pixel_y < 4; pixel_y++) { - for (byte pixel_x = 0; pixel_x < 4; pixel_x++) - pixels[pixelPtr++] = colors[0]; - pixelPtr -= rowDec; - } - } + for (byte pixel_y = 0; pixel_y < 4; pixel_y++) { + for (byte pixel_x = 0; pixel_x < 4; pixel_x++) + pixels[pixelPtr++] = colors[0]; + pixelPtr -= rowDec; + } + } - blockPtr += blockInc; - totalBlocks--; - } - } + blockPtr += blockInc; + totalBlocks--; + } + } } void MSVideo1Decoder::decode16(Common::SeekableReadStream &stream) { - /* decoding parameters */ - uint16 colors[8]; - uint16 *pixels = (uint16 *)_surface->getPixels(); - int32 stride = _surface->w; + /* decoding parameters */ + uint16 colors[8]; + uint16 *pixels = (uint16 *)_surface->getPixels(); + int32 stride = _surface->w; - int32 skip_blocks = 0; - int32 blocks_wide = _surface->w / 4; - int32 blocks_high = _surface->h / 4; - int32 total_blocks = blocks_wide * blocks_high; - int32 block_inc = 4; - int32 row_dec = stride + 4; + int32 skip_blocks = 0; + int32 blocks_wide = _surface->w / 4; + int32 blocks_high = _surface->h / 4; + int32 total_blocks = blocks_wide * blocks_high; + int32 block_inc = 4; + int32 row_dec = stride + 4; - for (int32 block_y = blocks_high; block_y > 0; block_y--) { - int32 block_ptr = ((block_y * 4) - 1) * stride; - for (int32 block_x = blocks_wide; block_x > 0; block_x--) { - /* check if this block should be skipped */ - if (skip_blocks) { - block_ptr += block_inc; - skip_blocks--; - total_blocks--; - continue; - } + for (int32 block_y = blocks_high; block_y > 0; block_y--) { + int32 block_ptr = ((block_y * 4) - 1) * stride; + for (int32 block_x = blocks_wide; block_x > 0; block_x--) { + /* check if this block should be skipped */ + if (skip_blocks) { + block_ptr += block_inc; + skip_blocks--; + total_blocks--; + continue; + } - int32 pixel_ptr = block_ptr; + int32 pixel_ptr = block_ptr; - /* get the next two bytes in the encoded data stream */ - CHECK_STREAM_PTR(2); - byte byte_a = stream.readByte(); - byte byte_b = stream.readByte(); + /* get the next two bytes in the encoded data stream */ + CHECK_STREAM_PTR(2); + byte byte_a = stream.readByte(); + byte byte_b = stream.readByte(); - /* check if the decode is finished */ - if ((byte_a == 0) && (byte_b == 0) && (total_blocks == 0)) { - return; - } else if ((byte_b & 0xFC) == 0x84) { - /* skip code, but don't count the current block */ - skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1; - } else if (byte_b < 0x80) { - /* 2- or 8-color encoding modes */ - uint16 flags = (byte_b << 8) | byte_a; + /* check if the decode is finished */ + if ((byte_a == 0) && (byte_b == 0) && (total_blocks == 0)) { + return; + } else if ((byte_b & 0xFC) == 0x84) { + /* skip code, but don't count the current block */ + skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1; + } else if (byte_b < 0x80) { + /* 2- or 8-color encoding modes */ + uint16 flags = (byte_b << 8) | byte_a; - CHECK_STREAM_PTR(4); - colors[0] = stream.readUint16LE(); - colors[1] = stream.readUint16LE(); + CHECK_STREAM_PTR(4); + colors[0] = stream.readUint16LE(); + colors[1] = stream.readUint16LE(); - if (colors[0] & 0x8000) { - /* 8-color encoding */ - CHECK_STREAM_PTR(12); - colors[2] = stream.readUint16LE(); - colors[3] = stream.readUint16LE(); - colors[4] = stream.readUint16LE(); - colors[5] = stream.readUint16LE(); - colors[6] = stream.readUint16LE(); - colors[7] = stream.readUint16LE(); + if (colors[0] & 0x8000) { + /* 8-color encoding */ + CHECK_STREAM_PTR(12); + colors[2] = stream.readUint16LE(); + colors[3] = stream.readUint16LE(); + colors[4] = stream.readUint16LE(); + colors[5] = stream.readUint16LE(); + colors[6] = stream.readUint16LE(); + colors[7] = stream.readUint16LE(); - for (int pixel_y = 0; pixel_y < 4; pixel_y++) { - for (int pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1) - pixels[pixel_ptr++] = - colors[((pixel_y & 0x2) << 1) + - (pixel_x & 0x2) + ((flags & 0x1) ^ 1)]; - pixel_ptr -= row_dec; - } - } else { - /* 2-color encoding */ - for (int pixel_y = 0; pixel_y < 4; pixel_y++) { - for (int pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1) - pixels[pixel_ptr++] = colors[(flags & 0x1) ^ 1]; - pixel_ptr -= row_dec; - } - } - } else { - /* otherwise, it's a 1-color block */ - colors[0] = (byte_b << 8) | byte_a; + for (int pixel_y = 0; pixel_y < 4; pixel_y++) { + for (int pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1) + pixels[pixel_ptr++] = + colors[((pixel_y & 0x2) << 1) + + (pixel_x & 0x2) + ((flags & 0x1) ^ 1)]; + pixel_ptr -= row_dec; + } + } else { + /* 2-color encoding */ + for (int pixel_y = 0; pixel_y < 4; pixel_y++) { + for (int pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1) + pixels[pixel_ptr++] = colors[(flags & 0x1) ^ 1]; + pixel_ptr -= row_dec; + } + } + } else { + /* otherwise, it's a 1-color block */ + colors[0] = (byte_b << 8) | byte_a; - for (int pixel_y = 0; pixel_y < 4; pixel_y++) { - for (int pixel_x = 0; pixel_x < 4; pixel_x++) - pixels[pixel_ptr++] = colors[0]; - pixel_ptr -= row_dec; - } - } + for (int pixel_y = 0; pixel_y < 4; pixel_y++) { + for (int pixel_x = 0; pixel_x < 4; pixel_x++) + pixels[pixel_ptr++] = colors[0]; + pixel_ptr -= row_dec; + } + } - block_ptr += block_inc; - total_blocks--; - } - } + block_ptr += block_inc; + total_blocks--; + } + } } const Graphics::Surface *MSVideo1Decoder::decodeFrame(Common::SeekableReadStream &stream) { if (_bitsPerPixel == 8) decode8(stream); else - decode16(stream); + decode16(stream); - return _surface; + return _surface; } } // End of namespace Image diff --git a/image/png.cpp b/image/png.cpp index d389908d002..fc4134b2e6c 100644 --- a/image/png.cpp +++ b/image/png.cpp @@ -41,10 +41,10 @@ namespace Image { PNGDecoder::PNGDecoder() : - _outputSurface(0), - _palette(0), - _paletteColorCount(0), - _skipSignature(false), + _outputSurface(0), + _palette(0), + _paletteColorCount(0), + _skipSignature(false), _keepTransparencyPaletted(false), _transparentColor(-1) { } diff --git a/math/matrix3.cpp b/math/matrix3.cpp index 16663f61cbe..2dce9ab7c11 100644 --- a/math/matrix3.cpp +++ b/math/matrix3.cpp @@ -47,7 +47,7 @@ void Matrix<3, 3>::transpose() { * http://clb.demon.fi/MathGeoLib/docs/float3x3_LookAt.php */ void Matrix<3, 3>::buildFromTargetDir(const Math::Vector3d &modelForward, const Math::Vector3d &targetDirection, - const Math::Vector3d &modelUp, const Math::Vector3d &worldUp) { + const Math::Vector3d &modelUp, const Math::Vector3d &worldUp) { Math::Vector3d modelRight = Math::Vector3d::crossProduct(modelUp, modelForward); modelRight.normalize(); Math::Vector3d worldRight = Math::Vector3d::crossProduct(worldUp, targetDirection); diff --git a/math/matrix3.h b/math/matrix3.h index f80c1740cb9..a4c7da9d807 100644 --- a/math/matrix3.h +++ b/math/matrix3.h @@ -51,7 +51,7 @@ public: * All the parameters MUST be normalized. */ void buildFromTargetDir(const Math::Vector3d &modelForward, const Math::Vector3d &targetDirection, - const Math::Vector3d &modelUp, const Math::Vector3d &worldUp); + const Math::Vector3d &modelUp, const Math::Vector3d &worldUp); inline Matrix<3, 3> operator*(const Matrix<3, 3> &m2) const { Matrix<3, 3> result; diff --git a/math/matrix4.cpp b/math/matrix4.cpp index 6f32dbc76fb..c7c12c9e847 100644 --- a/math/matrix4.cpp +++ b/math/matrix4.cpp @@ -111,7 +111,7 @@ void Matrix<4, 4>::translate(const Vector3d &vec) { * http://clb.demon.fi/MathGeoLib/docs/float3x3_LookAt.php */ void Matrix<4, 4>::buildFromTargetDir(const Math::Vector3d &modelForward, const Math::Vector3d &targetDirection, - const Math::Vector3d &modelUp, const Math::Vector3d &worldUp) + const Math::Vector3d &modelUp, const Math::Vector3d &worldUp) { Matrix3 rotation; rotation.buildFromTargetDir(modelForward, targetDirection, modelUp, worldUp); diff --git a/math/matrix4.h b/math/matrix4.h index cc67346696d..d1030d50749 100644 --- a/math/matrix4.h +++ b/math/matrix4.h @@ -64,7 +64,7 @@ public: * All the parameters MUST be normalized. */ void buildFromTargetDir(const Math::Vector3d &modelForward, const Math::Vector3d &targetDirection, - const Math::Vector3d &modelUp, const Math::Vector3d &worldUp); + const Math::Vector3d &modelUp, const Math::Vector3d &worldUp); /** * Inverts a matrix in place. diff --git a/math/rect2d.cpp b/math/rect2d.cpp index ebf6f445619..b664b7fd336 100644 --- a/math/rect2d.cpp +++ b/math/rect2d.cpp @@ -43,7 +43,7 @@ Rect2d::Rect2d(const Vector2d &topLeft, const Vector2d &bottomRight) { } Rect2d::Rect2d(const Vector2d &topLeft, const Vector2d &topRight, - const Vector2d &bottomLeft, const Vector2d &bottomRight) : + const Vector2d &bottomLeft, const Vector2d &bottomRight) : _topLeft(topLeft), _topRight(topRight), _bottomLeft(bottomLeft), _bottomRight(bottomRight) { diff --git a/test/common/hashmap.h b/test/common/hashmap.h index 8131322afd8..127dec83dd4 100644 --- a/test/common/hashmap.h +++ b/test/common/hashmap.h @@ -155,7 +155,7 @@ class HashMapTestSuite : public CxxTest::TestSuite TS_ASSERT_EQUALS(container2[323], 32); } - void test_collision() { + void test_collision() { // NB: The usefulness of this example depends strongly on the // specific hashmap implementation. // It is constructed to insert multiple colliding elements. @@ -195,7 +195,7 @@ class HashMapTestSuite : public CxxTest::TestSuite TS_ASSERT(h.contains(32+5)); h.erase(32+5); TS_ASSERT(h.empty()); - } + } void test_iterator() { Common::HashMap container; diff --git a/test/common/str.h b/test/common/str.h index 6f72a45d967..598051aea89 100644 --- a/test/common/str.h +++ b/test/common/str.h @@ -540,21 +540,21 @@ class StringTestSuite : public CxxTest::TestSuite testString.replace(5, 9, Common::String("Displaced ristretto string"), 10, 10); TS_ASSERT_EQUALS(testString, Common::String("Good ristretto coffee friends")); - // ----------------------- - // Deep copy compliance - // ----------------------- + // ----------------------- + // Deep copy compliance + // ----------------------- - // Makes a deep copy without changing the length of the original - Common::String s1 = "TestTestTestTestTestTestTestTestTestTestTest"; - Common::String s2(s1); - TS_ASSERT_EQUALS(s1, "TestTestTestTestTestTestTestTestTestTestTest"); - TS_ASSERT_EQUALS(s2, "TestTestTestTestTestTestTestTestTestTestTest"); - s1.replace(0, 4, "TEST"); - TS_ASSERT_EQUALS(s1, "TESTTestTestTestTestTestTestTestTestTestTest"); - TS_ASSERT_EQUALS(s2, "TestTestTestTestTestTestTestTestTestTestTest"); + // Makes a deep copy without changing the length of the original + Common::String s1 = "TestTestTestTestTestTestTestTestTestTestTest"; + Common::String s2(s1); + TS_ASSERT_EQUALS(s1, "TestTestTestTestTestTestTestTestTestTestTest"); + TS_ASSERT_EQUALS(s2, "TestTestTestTestTestTestTestTestTestTestTest"); + s1.replace(0, 4, "TEST"); + TS_ASSERT_EQUALS(s1, "TESTTestTestTestTestTestTestTestTestTestTest"); + TS_ASSERT_EQUALS(s2, "TestTestTestTestTestTestTestTestTestTestTest"); - // Makes a deep copy when we shorten the string - Common::String s3 = "TestTestTestTestTestTestTestTestTestTestTest"; + // Makes a deep copy when we shorten the string + Common::String s3 = "TestTestTestTestTestTestTestTestTestTestTest"; Common::String s4(s3); s3.replace(0, 32, ""); TS_ASSERT_EQUALS(s3, "TestTestTest"); diff --git a/video/bink_decoder.cpp b/video/bink_decoder.cpp index ed40e49bf95..56f58ed8855 100644 --- a/video/bink_decoder.cpp +++ b/video/bink_decoder.cpp @@ -1429,27 +1429,27 @@ void BinkDecoder::BinkVideoTrack::readResidue(VideoFrame &video, int16 *block, i #define A4 -5352 #define IDCT_TRANSFORM(dest,s0,s1,s2,s3,s4,s5,s6,s7,d0,d1,d2,d3,d4,d5,d6,d7,munge,src) {\ - const int a0 = (src)[s0] + (src)[s4]; \ - const int a1 = (src)[s0] - (src)[s4]; \ - const int a2 = (src)[s2] + (src)[s6]; \ - const int a3 = (A1*((src)[s2] - (src)[s6])) >> 11; \ - const int a4 = (src)[s5] + (src)[s3]; \ - const int a5 = (src)[s5] - (src)[s3]; \ - const int a6 = (src)[s1] + (src)[s7]; \ - const int a7 = (src)[s1] - (src)[s7]; \ - const int b0 = a4 + a6; \ - const int b1 = (A3*(a5 + a7)) >> 11; \ - const int b2 = ((A4*a5) >> 11) - b0 + b1; \ - const int b3 = (A1*(a6 - a4) >> 11) - b2; \ - const int b4 = ((A2*a7) >> 11) + b3 - b1; \ - (dest)[d0] = munge(a0+a2 +b0); \ - (dest)[d1] = munge(a1+a3-a2+b2); \ - (dest)[d2] = munge(a1-a3+a2+b3); \ - (dest)[d3] = munge(a0-a2 -b4); \ - (dest)[d4] = munge(a0-a2 +b4); \ - (dest)[d5] = munge(a1-a3+a2-b3); \ - (dest)[d6] = munge(a1+a3-a2-b2); \ - (dest)[d7] = munge(a0+a2 -b0); \ + const int a0 = (src)[s0] + (src)[s4]; \ + const int a1 = (src)[s0] - (src)[s4]; \ + const int a2 = (src)[s2] + (src)[s6]; \ + const int a3 = (A1*((src)[s2] - (src)[s6])) >> 11; \ + const int a4 = (src)[s5] + (src)[s3]; \ + const int a5 = (src)[s5] - (src)[s3]; \ + const int a6 = (src)[s1] + (src)[s7]; \ + const int a7 = (src)[s1] - (src)[s7]; \ + const int b0 = a4 + a6; \ + const int b1 = (A3*(a5 + a7)) >> 11; \ + const int b2 = ((A4*a5) >> 11) - b0 + b1; \ + const int b3 = (A1*(a6 - a4) >> 11) - b2; \ + const int b4 = ((A2*a7) >> 11) + b3 - b1; \ + (dest)[d0] = munge(a0+a2 +b0); \ + (dest)[d1] = munge(a1+a3-a2+b2); \ + (dest)[d2] = munge(a1-a3+a2+b3); \ + (dest)[d3] = munge(a0-a2 -b4); \ + (dest)[d4] = munge(a0-a2 +b4); \ + (dest)[d5] = munge(a1-a3+a2-b3); \ + (dest)[d6] = munge(a1+a3-a2-b2); \ + (dest)[d7] = munge(a0+a2 -b0); \ } /* end IDCT_TRANSFORM macro */