Beispiel #1
0
void
MMOModel::write (string file)
{
  MMOVisitor *writer;
  if (_type == WR_MMO)
    {
      writer = new MMOWriter (file);
    }
  else
    {
      writer = new BioRicaWriter (file);
    }
  _addConstantAlgebraics ();
  _reorder ();
  _importSec.accept (writer);
  _external_functions.accept (writer);
  _declarations.accept (writer);
  _initial_algorithm.accept (writer);
  _equation.accept (writer);
  _algorithm.accept (writer);
  delete writer;
}
Beispiel #2
0
void Compression13::decompressFork(SitFileItem* item, std::string destination, bool data)
{
    _init();

    int32_t N = 314;
    int32_t T = 2*N - 1;

    int32_t byte, i, i1, j, ch, offs, skip;

    item->sitFile()->stream()->seekg(data ? item->dataOffset() : item->resourceOffset(), std::ios_base::beg);
    uint32_t bytesLeft = data ? item->dataPackedSize() : item->resourcePackedSize();

    _bitsavail = 0;
    for(i = 0; i < 4036; i++)
    {
        _buffer[i] = ' ';
    }
    _bufferptr = 4036;

    while(bytesLeft != 0)
    {
        ch = _ForwTree[T - 1];
        while(ch < T)
        {
            _getbit(item);
            if(_bits & 0x80)
            {
                ch = ch + 1;
            }
            ch = _ForwTree[ch];
        }
        ch -= T;
        if(_Frequ[T - 1] >= 0x8000)
        {
            _reorder();
        }

        i = _BackTree[ch + T];
        do
        {
            j = ++_Frequ[i];
            i1 = i + 1;
            if(_Frequ[i1] < j)
            {
                while(_Frequ[++i1] < j);
                i1--;
                _Frequ[i] = _Frequ[i1];
                _Frequ[i1] = j;

                j = _ForwTree[i];
                _BackTree[j] = i1;
                if(j < T)
                {
                    _BackTree[j + 1] = i1;
                }
                _ForwTree[i] = _ForwTree[i1];
                _ForwTree[i1] = j;
                j = _ForwTree[i];
                _BackTree[j] = i;
                if(j < T)
                {
                    _BackTree[j + 1] = i;
                }
                i = i1;
            }
            i = _BackTree[i];
        }
        while(i != 0);

        if(ch < 256)
        {
            _outchar((char)ch);
            bytesLeft--;
        }
        else
        {
            if(_bitsavail != 0)
            {
                byte = (_bits << 1) & 0xff;
                _bits = _getbyte(item);
                byte |= (_bits >> _bitsavail);
                _bits = _bits << (7 - _bitsavail);
            }
            else
            {
                byte = _getbyte(item);
            }
            offs = _huffmanCode[byte];
            skip = _huffmanLength[byte] - 2;
            while(skip-- != 0)
            {
                byte = byte + byte;
                _getbit(item);
                if(_bits & 0x80)
                {
                    byte++;
                }
            }
            offs |= (byte & 0x3f);
            offs = ((_bufferptr - offs - 1) & 0xfff);
            ch = ch - 253;
            while(ch-- > 0)
            {
                _outchar(_buffer[offs++ & 0xfff]);
                bytesLeft--;
                if(bytesLeft == 0)
                {
                    break;
                }
            }
        }