Exemplo n.º 1
0
void CBaseEntity::StopFollowingEntity(int edictptr) {
	int newentptr = Instance(edictptr);
	if ( newentptr == 0) return;
	newentptr = ReadInt32(newentptr + 0x4);
	WriteInt32((newentptr + 0x108), MOVETYPE_NONE ); //set the entity's movetype
	WriteInt32((newentptr + 0x10C), NULL); //solid flags
	WriteInt32((newentptr + 0x194), NULL); //aiment Follow
	WriteInt32((newentptr + 0x198), NULL); //Owner
}
size_t AttachEntity::serialize(Buffer& _dst, size_t _offset)
{
	_pm_checkInit();
	if(_offset == 0) _dst.clear();

	_offset = WriteInt8(_dst, _offset, _pf_packetId);
	_offset = WriteInt32(_dst, _offset, _pf_entityId);
	_offset = WriteInt32(_dst, _offset, _pf_vehicleId);


	return _offset;
}
Exemplo n.º 3
0
static void WriteWaveFormatEx( FILE * file, hb_wave_formatex_t * format )
{
    WriteInt32( file, format->FourCC );
    WriteInt32( file, format->BytesCount );
    WriteInt16( file, format->FormatTag );
    WriteInt16( file, format->Channels );
    WriteInt32( file, format->SamplesPerSec );
    WriteInt32( file, format->AvgBytesPerSec );
    WriteInt16( file, format->BlockAlign );
    WriteInt16( file, format->BitsPerSample );
    WriteInt16( file, format->Size );
}
Exemplo n.º 4
0
size_t CollectItem::serialize(Buffer& _dst, size_t _offset)
{
	_pm_checkInit();
	if(_offset == 0) _dst.clear();

	_offset = WriteInt8(_dst, _offset, _pf_packetId);
	_offset = WriteInt32(_dst, _offset, _pf_collectedEID);
	_offset = WriteInt32(_dst, _offset, _pf_collectorEID);


	return _offset;
}
size_t RemoveEntityEffect::serialize(Buffer& _dst, size_t _offset)
{
	_pm_checkInit();
	if(_offset == 0) _dst.clear();

	_offset = WriteInt8(_dst, _offset, _pf_packetId);
	_offset = WriteInt32(_dst, _offset, _pf_entityId);
	_offset = WriteInt32(_dst, _offset, _pf_effectId);


	return _offset;
}
Exemplo n.º 6
0
static HRESULT
FixWavHeader(FILE *fpw, DWORD writeDataTotalBytes)
{
    HRESULT hr = E_FAIL;

    fseek(fpw, 4, SEEK_SET);
    HRG(WriteInt32(fpw, writeDataTotalBytes + 0x24));

    fseek(fpw, 0x28, SEEK_SET);
    HRG(WriteInt32(fpw, writeDataTotalBytes));

end:
    return hr;
}
Exemplo n.º 7
0
ECode RILParcel::WriteInt32Array(
    /* [in] */ ArrayOf<Int32>* val)
{
    if (val != NULL) {
        Int32 N = val->GetLength();
        WriteInt32(N);
        for (Int32 i=0; i<N; i++) {
            WriteInt32((*val)[i]);
        }
    } else {
        WriteInt32(-1);
    }
    return NOERROR;
}
Exemplo n.º 8
0
ECode RILParcel::WriteStringArray(
    /* [in] */ ArrayOf<String>* array)
{
    if (array != NULL) {
        Int32 N = array->GetLength();
        WriteInt32(N);
        for (Int32 i = 0; i < N; i++) {
            WriteString((*array)[i]);
        }
    }
    else {
        WriteInt32(-1);
    }
    return NOERROR;
}
size_t SpawnGlobalEntity::serialize(Buffer& _dst, size_t _offset)
{
	_pm_checkInit();
	if(_offset == 0) _dst.clear();

	_offset = WriteInt8(_dst, _offset, _pf_packetId);
	_offset = WriteInt32(_dst, _offset, _pf_entityId);
	_offset = WriteInt8(_dst, _offset, _pf_type);
	_offset = WriteInt32(_dst, _offset, _pf_x);
	_offset = WriteInt32(_dst, _offset, _pf_y);
	_offset = WriteInt32(_dst, _offset, _pf_z);


	return _offset;
}
Exemplo n.º 10
0
/**********************************************************************
 *                   TABMAPToolBlock::InitNewBlock()
 *
 * Initialize a newly created block so that it knows to which file it
 * is attached, its block size, etc . and then perform any specific
 * initialization for this block type, including writing a default
 * block header, etc. and leave the block ready to receive data.
 *
 * This is an alternative to calling ReadFromFile() or InitBlockFromData()
 * that puts the block in a stable state without loading any initial
 * data in it.
 *
 * Returns 0 if successful or -1 if an error happened, in which case
 * CPLError() will have been called.
 **********************************************************************/
int     TABMAPToolBlock::InitNewBlock(VSILFILE *fpSrc, int nBlockSize,
                                        int nFileOffset /* = 0*/)
{
#ifdef DEBUG_VERBOSE
    CPLDebug( "MITAB",
              "Instantiating new TOOL block at offset %d", nFileOffset);
#endif

    /*-----------------------------------------------------------------
     * Start with the default initialization
     *----------------------------------------------------------------*/
    if ( TABRawBinBlock::InitNewBlock(fpSrc, nBlockSize, nFileOffset) != 0)
        return -1;

    /*-----------------------------------------------------------------
     * And then set default values for the block header.
     *----------------------------------------------------------------*/
    m_nNextToolBlock = 0;

    m_numDataBytes = 0;

    GotoByteInBlock(0x000);

    if (m_eAccess != TABRead)
    {
        WriteInt16(TABMAP_TOOL_BLOCK); // Block type code
        WriteInt16(0);                 // num. bytes used, excluding header
        WriteInt32(0);                 // Pointer to next tool block
    }

    if (CPLGetLastErrorNo() != 0)
        return -1;

    return 0;
}
Exemplo n.º 11
0
void BinaryWriter::WriteString(const wchar_t* src)
{
    unsigned srcLen = 0;

    //handle empty string
    if (src == NULL || (srcLen = (unsigned)wcslen(src)) == 0 )
    {
        WriteInt32(0);
        return;
    }

    unsigned maxmbslen = srcLen * 4 + 1;

    if (m_strCacheLen < maxmbslen)
    {
        delete [] m_strCache;
        m_strCacheLen = maxmbslen;
        m_strCache = new char[maxmbslen];
    }

    int actualLen = ut_utf8_from_unicode(src, srcLen, m_strCache, m_strCacheLen);

    _ASSERT(actualLen >= 0);

    actualLen += 1; //add 1 for null character

    CheckResize(actualLen + sizeof(unsigned));

    //write string length (number of bytes, not characters!!!)
    WriteUInt32(actualLen);

    //write actual string content to the output
    memcpy(m_data + m_pos, m_strCache, actualLen);
    m_pos += actualLen;
}
Exemplo n.º 12
0
/**********************************************************************
 *                   TABMAPIndexBlock::WriteNextEntry()
 *
 * Write the sEntry index entry at current position in the block.
 *
 * Returns 0 if succesful or -1 if we reached the end of the block.
 **********************************************************************/
int     TABMAPIndexBlock::WriteNextEntry(TABMAPIndexEntry *psEntry)
{
    if (m_nCurPos < 4)
        GotoByteInBlock( 0x004 );

    WriteInt32(psEntry->XMin);
    WriteInt32(psEntry->YMin);
    WriteInt32(psEntry->XMax);
    WriteInt32(psEntry->YMax);
    WriteInt32(psEntry->nBlockPtr);

    if (CPLGetLastErrorNo() != 0)
        return -1;

    return 0;
}
Exemplo n.º 13
0
/**********************************************************************
 *                   TABRawBinBlock::CommitAsDeleted()
 *
 * Commit current block to file using block type 4 (garbage block)
 *
 * Returns 0 if successful or -1 if an error happened, in which case
 * CPLError() will have been called.
 **********************************************************************/
int     TABRawBinBlock::CommitAsDeleted(GInt32 nNextBlockPtr)
{
    CPLErrorReset();

    if ( m_pabyBuf == nullptr )
    {
        CPLError(CE_Failure, CPLE_AssertionFailed,
                 "CommitAsDeleted(): Block has not been initialized yet!");
        return -1;
    }

    /*-----------------------------------------------------------------
     * Create deleted block header
     *----------------------------------------------------------------*/
    GotoByteInBlock(0x000);
    WriteInt16(TABMAP_GARB_BLOCK);    // Block type code
    WriteInt32(nNextBlockPtr);

    int nStatus = CPLGetLastErrorType() == CE_Failure ? -1 : 0;

    /*-----------------------------------------------------------------
     * OK, call the base class to write the block to disk.
     *----------------------------------------------------------------*/
    if (nStatus == 0)
    {
#ifdef DEBUG_VERBOSE
        CPLDebug("MITAB", "Committing GARBAGE block to offset %d", m_nFileOffset);
#endif
        nStatus = TABRawBinBlock::CommitToFile();
        m_nSizeUsed = 0;
    }

    return nStatus;
}
Exemplo n.º 14
0
ECode RILParcel::WriteByteArray(
    /* [in] */ ArrayOf<Byte>* array)
{
    if (array == NULL) {
        WriteInt32(-1);
        return NOERROR;
    }
    Int32 offset = 0;
    Int32 length = array->GetLength();

    const android::status_t err = parcel->writeInt32(length);
    if (err != NO_ERROR) {
        Logger::E("RILParcel", "TODO RILParcel::WriteByteArray error happen");
        return E_RUNTIME_EXCEPTION;
    }

    void* dest = parcel->writeInplace(length);
    if (dest == NULL) {
        //signalExceptionForError(env, clazz, NO_MEMORY);
        Logger::E("RILParcel", "TODO RILParcel::WriteByteArray 2 error happen");
        return E_RUNTIME_EXCEPTION;
    }

    Byte* ar = array->GetPayload();
    if (ar) {
        memcpy(dest, ar + offset, length);
    }
    return NOERROR;
}
Exemplo n.º 15
0
/**********************************************************************
 *                   TABRawBinBlock::CommitAsDeleted()
 *
 * Commit current block to file using block type 4 (garbage block)
 *
 * Returns 0 if succesful or -1 if an error happened, in which case 
 * CPLError() will have been called.
 **********************************************************************/
int     TABRawBinBlock::CommitAsDeleted(GInt32 nNextBlockPtr)
{
    int nStatus = 0;

    CPLErrorReset();

    if ( m_pabyBuf == NULL )
    {
        CPLError(CE_Failure, CPLE_AssertionFailed, 
                 "CommitAsDeleted(): Block has not been initialized yet!");
        return -1;
    }

    /*-----------------------------------------------------------------
     * Create deleted block header
     *----------------------------------------------------------------*/
    GotoByteInBlock(0x000);
    WriteInt32(nNextBlockPtr);

    if( CPLGetLastErrorType() == CE_Failure )
        nStatus = CPLGetLastErrorNo();

    /*-----------------------------------------------------------------
     * OK, call the base class to write the block to disk.
     *----------------------------------------------------------------*/
    if (nStatus == 0)
        nStatus = TABRawBinBlock::CommitToFile();

    return nStatus;
}
Exemplo n.º 16
0
            void InteropOutputStream::WriteFloat(const float val)
            {
                BinaryFloatInt32 u;

                u.f = val;

                WriteInt32(u.i);
            }
Exemplo n.º 17
0
int32 USBHost::rh_port_status(memptr rh)
{
	for (int i = 0; i < NUMBER_OF_PORTS; i++) {
		WriteInt32(rh + 4 * i, port_status[i]);
	}

	return 0;
}
Exemplo n.º 18
0
static void WriteWaveMp3( FILE * file, hb_wave_mp3_t * mp3 )
{
    WriteInt16( file, mp3->Id );
    WriteInt32( file, mp3->Flags );
    WriteInt16( file, mp3->BlockSize );
    WriteInt16( file, mp3->FramesPerBlock );
    WriteInt16( file, mp3->CodecDelay );
}
Exemplo n.º 19
0
static HRESULT
WriteWavHeader(FILE *fpw, WWMFPcmFormat &format, DWORD dataBytes)
{
    HRESULT hr = E_FAIL;
    int dataChunkSize = ((dataBytes+1)&(~1)) + 4;

    HRG(WriteBytes(fpw, "RIFF", 4U));
    HRG(WriteInt32(fpw, dataChunkSize + 0x24));
    HRG(WriteBytes(fpw, "WAVE", 4U));

    HRG(WriteBytes(fpw, "fmt ", 4U));
    HRG(WriteInt32(fpw, 16));

    // fmt audioFormat size==2 1==int 3==float
    switch (format.sampleFormat) {
    case WWMFBitFormatInt:
        HRG(WriteInt16(fpw, 1));
        break;
    case WWMFBitFormatFloat:
        HRG(WriteInt16(fpw, 3));
        break;
    default:
        goto end;
    }

    // fmt numChannels size==2
    HRG(WriteInt16(fpw, format.nChannels));

    // fmt sampleRate size==4
    HRG(WriteInt32(fpw, format.sampleRate));

    // fmt byteRate size==4
    HRG(WriteInt32(fpw, format.BytesPerSec()));

    // fmt blockAlign size==2
    HRG(WriteInt16(fpw, format.FrameBytes()));

    // fmt bitspersample size==2
    HRG(WriteInt16(fpw, format.bits));

    HRG(WriteBytes(fpw, "data", 4U));
    HRG(WriteInt32(fpw, dataChunkSize));

end:
    return hr;
}
Exemplo n.º 20
0
size_t SpawnObject::serialize(Buffer& _dst, size_t _offset)
{
	_pm_checkInit();
	if(_offset == 0) _dst.clear();

	_offset = WriteInt8(_dst, _offset, _pf_packetId);
	_offset = WriteInt32(_dst, _offset, _pf_entityId);
	_offset = WriteInt8(_dst, _offset, _pf_type);
	_offset = WriteInt32(_dst, _offset, _pf_x);
	_offset = WriteInt32(_dst, _offset, _pf_y);
	_offset = WriteInt32(_dst, _offset, _pf_z);
	_offset = WriteInt8(_dst, _offset, _pf_pitch);
	_offset = WriteInt8(_dst, _offset, _pf_yaw);
	// —делать запись Object data


	return _offset;
}
Exemplo n.º 21
0
static void AddIndex( hb_mux_object_t * m )
{
    fseek( m->file, 0, SEEK_END );

    /* Write the index at the end of the file */
    WriteInt32( m->file, FOURCC( "idx1" ) );
    WriteInt32( m->file, m->index->size );
    WriteBuffer( m->file, m->index );

    /* Update file size */
    m->size += 8 + m->index->size;
    fseek( m->file, 4, SEEK_SET );
    WriteInt32( m->file, 2040 + m->size );

    /* Update HASINDEX flag */
    m->main_header.Flags |= AVIF_HASINDEX;
    fseek( m->file, 24, SEEK_SET );
    WriteMainHeader( m->file, &m->main_header );
}
Exemplo n.º 22
0
void Serializer::WriteRepeatedMessageField(google::protobuf::Message const& value, google::protobuf::FieldDescriptor const* field)
{
    google::protobuf::Reflection const* reflection = value.GetReflection();
    for (int32 i = 0; i < reflection->FieldSize(value, field); ++i)
    {
        switch (field->cpp_type())
        {
            case google::protobuf::FieldDescriptor::CPPTYPE_INT32:
                WriteInt32(reflection->GetRepeatedInt32(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_INT64:
                WriteInt64(reflection->GetRepeatedInt64(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_UINT32:
                WriteUInt32(reflection->GetRepeatedUInt32(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_UINT64:
                WriteUInt64(reflection->GetRepeatedUInt64(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE:
                WriteDouble(reflection->GetRepeatedDouble(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT:
                WriteFloat(reflection->GetRepeatedFloat(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_BOOL:
                WriteBool(reflection->GetRepeatedBool(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_ENUM:
                WriteEnum(reflection->GetRepeatedEnum(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_STRING:
            {
                std::string strValue = reflection->GetRepeatedString(value, field, i);
                if (field->type() == google::protobuf::FieldDescriptor::TYPE_STRING)
                    WriteString(strValue);
                else
                {
                    _writer.StartArray();
                    for (std::size_t j = 0; j < strValue.length(); ++j)
                        WriteUInt32(uint32(strValue[j]));
                    _writer.EndArray();
                }
                break;
            }
            case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE:
                WriteMessage(reflection->GetRepeatedMessage(value, field, i));
                break;
            default:
                break;
        }
    }
}
Exemplo n.º 23
0
size_t DestroyEntity::serialize(Buffer& _dst, size_t _offset)
{
	_pm_checkInit();
	if(_offset == 0) _dst.clear();

	_offset = WriteInt8(_dst, _offset, _pf_packetId);
	_offset = WriteInt8(_dst, _offset, _pf_entityCount);

	for(int i = 0; i < _pf_entityCount; ++i)
		_offset = WriteInt32(_dst, _offset, _pf_entityIds[i]);
	
	return _offset;
}
Exemplo n.º 24
0
int32 XHDIDriver::XHInqTarget2(uint16 major, uint16 minor, lmemptr blocksize,
					lmemptr device_flags, memptr product_name, uint16 stringlen)
{
	D(bug("ARAnyM XHInqTarget2(%u.%u, product_name_len=%u)", major, minor, stringlen));

	disk_t *disk = dev2disk(major, minor);
	if (disk == NULL)
		return EUNDEV;

	if (blocksize) {
		WriteInt32(blocksize, XHDI_BLOCK_SIZE);
	}

	if (device_flags) {
		WriteInt32(device_flags, 0);
	}

	if (product_name && stringlen) {
		Host2AtariSafeStrncpy(product_name, disk->name, stringlen);
	}

	return E_OK;
}
Exemplo n.º 25
0
size_t Handshake::serialize(Buffer& _dst, size_t _offset)
{
	_pm_checkInit();
	if(_offset == 0) _dst.clear();

	_offset = WriteInt8(_dst, _offset, _pf_packetId);
	_offset = WriteInt8(_dst, _offset, _pf_protVer);
	_offset = WriteString16(_dst, _offset, _pf_username);
	_offset = WriteString16(_dst, _offset, _pf_host);
	_offset = WriteInt32(_dst, _offset, _pf_port);


	return _offset;
}
Exemplo n.º 26
0
Arquivo: Simple.hpp Projeto: ifzz/FDK
    bool Factorial(const __int32& value, __int32& result)
    {
        MemoryBuffer buffer;
        m_channel->Initialize(buffer);

        WriteInt32(value, buffer);

        const HRESULT _status = m_channel->Invoke(0, 2, buffer);
        Throw(_status, buffer);

        result = ReadInt32(buffer);
        auto _result = ReadBoolean(buffer);
        return _result;
    }
Exemplo n.º 27
0
size_t MapChunkBulk::serialize(Buffer& _dst, size_t _offset)
{
	_pm_checkInit();
	if(_offset == 0) _dst.clear();

	_offset = WriteInt8(_dst, _offset, _pf_packetId);
	_offset = WriteInt16(_dst, _offset, _pf_chunkColumnCount);
	_offset = WriteInt32(_dst, _offset, _pf_dataLength);
	_offset = WriteBool(_dst, _offset, _pf_skyLightSent);
	_offset = WriteByteArray(_dst, _offset, _pf_chunkData);
	_offset = WriteByteArray(_dst, _offset, _pf_metaInfo);


	return _offset;
}
Exemplo n.º 28
0
	/*
	 * Saver for AAA files
	 */
	int SaveAAA(string filename, KeyframeAnimation& anim)
	{
		ofstream file(filename.c_str(), ios::out | ios::binary);
		if(!file)
			return 1;

		// write animation name
		unsigned char anim_name_len = anim.name.length();
		WriteByte(anim_name_len, file);
		for(unsigned int i = 0; i < anim_name_len; ++i)
			WriteByte(anim.name[i], file);

		// write frames
		unsigned int frame_count = anim.frames.size();
		WriteUInt32(frame_count, file);
		for(vector<Keyframe>::iterator iter =anim.frames.begin(); iter != anim.frames.end(); ++iter)
		{
			Keyframe& frame = *iter;

			WriteInt32(frame.next, file);
			WriteSingle(frame.duration, file);

			// write each bone of the frame
			unsigned int values_count = frame.values.size();
			WriteUInt32(values_count, file);
			for(unordered_map<unsigned int, BoneInfluence>::iterator jter = frame.values.begin(); jter != frame.values.end(); ++jter)
			{
				// name of the bone
				string bone_name = Bone::string_table[jter->first];

				unsigned char bone_name_len = bone_name.length();
				WriteByte(bone_name_len, file);
				for(unsigned int i = 0; i < bone_name_len; ++i)
					WriteByte(bone_name[i], file);

				// bone influence
				BoneInfluence& inf = jter->second;
				WriteSingle(inf.ori.x, file);			// orientation...
				WriteSingle(inf.ori.y, file);
				WriteSingle(inf.ori.z, file);
				WriteSingle(inf.pos.x, file);			// position...
				WriteSingle(inf.pos.y, file);
				WriteSingle(inf.pos.z, file);
			}
		}

		return 0;
	}
Exemplo n.º 29
0
static int AVIMux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
                   hb_buffer_t * buf )
{
    hb_job_t   * job   = m->job;
    hb_title_t * title = job->title;

    hb_audio_t * audio;
    int i;

    /* Update index */
    IndexAddInt32( m->index, mux_data->fourcc );
    IndexAddInt32( m->index, (buf->frametype & HB_FRAME_KEY) ? AVIIF_KEYFRAME : 0 );
    IndexAddInt32( m->index, 4 + m->size );
    IndexAddInt32( m->index, buf->size );

    /* Write the chunk to the file */
    fseek( m->file, 0, SEEK_END );
    WriteInt32( m->file, mux_data->fourcc );
    WriteInt32( m->file, buf->size );
    WriteBuffer( m->file, buf );

    /* Chunks must be 2-bytes aligned */
    if( buf->size & 1 )
    {
        WriteInt8( m->file, 0 );
    }

    /* Update headers */
    m->size += 8 + EVEN( buf->size );
    mux_data->header.Length++;

    /* RIFF size */
    fseek( m->file, 4, SEEK_SET );
    WriteInt32( m->file, 2052 + m->size );

    /* Mmmmh that's not nice */
    fseek( m->file, 140, SEEK_SET );
    WriteInt32( m->file, job->mux_data->header.Length );
    for( i = 0; i < hb_list_count( title->list_audio ); i++ )
    {
        int is_passthru;
        audio = hb_list_item( title->list_audio, i );
        is_passthru = (audio->config.out.codec == HB_ACODEC_AC3) ||
                      (audio->config.out.codec == HB_ACODEC_DCA);
        fseek( m->file, 264 + i *
               ( 102 + ( is_passthru ? 0 :
                 sizeof( hb_wave_mp3_t ) ) ), SEEK_SET );
        WriteInt32( m->file, audio->priv.mux_data->header.Length );
    }

    /* movi size */
    fseek( m->file, 2052, SEEK_SET );
    WriteInt32( m->file, 4 + m->size );
    return 0;
}
Exemplo n.º 30
0
bool CStChannelImpl::Send()
{
	m_buffer.SetPosition(0);
	WriteInt32(static_cast<int32>(m_buffer.GetSize() - 4), m_buffer);
	const char* buffer = reinterpret_cast<const char*>(m_buffer.GetData());
	int length = static_cast<int>(m_buffer.GetSize());
	for (; length > 0; )
	{
		const int status = m_socket.Send(buffer, length);
		if (status <= 0)
		{
			return false;
		}
		buffer += status;
		length -= status;
	}
	return true;
}