Example #1
0
void cProtocol125::WriteItem(const cItem & a_Item)
{
	short ItemType = a_Item.m_ItemType;
	ASSERT(ItemType >= -1);  // Check validity of packets in debug runtime
	if (ItemType <= 0)
	{
		// Fix, to make sure no invalid values are sent.
		ItemType = -1;
	}
	
	WriteShort(ItemType);
	if (a_Item.IsEmpty())
	{
		return;
	}
	
	WriteChar (a_Item.m_ItemCount);
	WriteShort(a_Item.m_ItemDamage);
	
	if (cItem::IsEnchantable(a_Item.m_ItemType))
	{
		// TODO: Implement enchantments
		WriteShort(-1);
	}
}
Example #2
0
void cProtocol146::SendPickupSpawn(const cPickup & a_Pickup)
{
	ASSERT(!a_Pickup.GetItem().IsEmpty());
	
	cCSLock Lock(m_CSPacket);

	// Send a SPAWN_OBJECT packet for the base entity:
	WriteByte(PACKET_SPAWN_OBJECT);
	WriteInt (a_Pickup.GetUniqueID());
	WriteByte(0x02);
	WriteInt ((int)(a_Pickup.GetPosX() * 32));
	WriteInt ((int)(a_Pickup.GetPosY() * 32));
	WriteInt ((int)(a_Pickup.GetPosZ() * 32));
	WriteInt (1);
	WriteShort((short)(a_Pickup.GetSpeed().x * 32));
	WriteShort((short)(a_Pickup.GetSpeed().y * 32));
	WriteShort((short)(a_Pickup.GetSpeed().z * 32));
	WriteByte(0);
	WriteByte(0);
	
	// Send a ENTITY_METADATA packet with the slot info:
	WriteByte(PACKET_ENTITY_METADATA);
	WriteInt(a_Pickup.GetUniqueID());
	WriteByte(0xaa);  // a slot value at index 10
	WriteItem(a_Pickup.GetItem());
	WriteByte(0x7f);  // End of metadata
	Flush();
}
Example #3
0
// Polygon list
bool CLwoWriter::WritePolygons()
{
	MSG_DEBUG("POLS | FACE");

	// "POLS" + size
	WriteChunk(CLwoFile::CHUNK_POLS);

	// type : "FACE"
	WriteTag(CLwoFile::CHUNK_FACE);

	CLwoFile::CLayer::FaceVector& faces = m_curLayer.GetFaceVector();
	CLwoFile::CLayer::FaceVector::iterator faceIt, faceBegin, faceEnd;
	faceBegin = faces.begin();
	faceEnd = faces.end();

	for(faceIt = faceBegin; faceIt != faceEnd; ++faceIt) // For each LWO face
	{
		ushort vertexCount = faceIt->VertexCount();
		WriteShort(vertexCount);

		for(ushort v=0; v<vertexCount; ++v) // For each vertex in LWO face
		{
			ushort vertexIndex = faceIt->GetVertexIndexVector()[v]; // Retreive vertex index
			WriteShort(vertexIndex);
		}
	}

	return true;
}
Example #4
0
// Layer
bool CLwoWriter::WriteLayer()
{
	MSG_DEBUG("LAYR");

	// "LAYR" + size
	WriteChunk(CLwoFile::CHUNK_LAYR);

	// layer ID
	ushort layerID = 0; // hack, only support first layer
	WriteShort(layerID);

	// layer Flag
	ushort layerFlag = 0; // hack
	WriteShort(layerFlag);

	// layer Pivot
	Vector3D pivot(3); // Pivot
	pivot[0] = 0.0f;
	pivot[1] = 0.0f;
	pivot[2] = 0.0f;
	WriteVector3D(pivot);

	// layer Name
	WriteString(""); // Layer Name

	// no parent

	return true;
}
Example #5
0
void CMidiFile::WriteHeader(short Tracks, short PPQ, double Tempo, const TIME_SIGNATURE* TimeSig, const KEY_SIGNATURE* KeySig)
{
	// write file header
	UINT	ChunkID = MAKEFOURCC('M', 'T', 'h', 'd');	// header chunk ID
	Write(&ChunkID, sizeof(ChunkID));	// write chunk ID
	WriteInt(FILE_HEADER_LEN);	// write chunk size
	WriteShort(MF_MULTI);	// write MIDI file format
	WriteShort(Tracks + 1);	// write track count; one extra for song track
	WriteShort(PPQ);	// write pulses per quarter note
	// write song track
	FILE_POS	StartPos = BeginTrack();	// write track header
	if (Tempo > 0) {	// if tempo specified
		WriteMeta(ME_SET_TEMPO, TEMPO_LEN);	// write meta header
		int	mspq = round(60000000 / Tempo);	 // microseconds per quarter note
		BYTE	TempoBuf[TEMPO_LEN];
		Reverse(TempoBuf, &mspq, TEMPO_LEN);	// convert tempo to big endian
		Write(TempoBuf, TEMPO_LEN);	// write tempo
	}
	if (TimeSig != NULL) {	// if time signature specified
		WriteMeta(ME_TIME_SIGNATURE, TIME_SIG_LEN);	// write meta header
		Write(TimeSig, TIME_SIG_LEN);	// write time signature
	}
	if (KeySig != NULL) {	// if key signature specified
		WriteMeta(ME_KEY_SIGNATURE, KEY_SIG_LEN);	// write meta header
		Write(KeySig, KEY_SIG_LEN);	// write key signature
	}
	EndTrack(StartPos);	// finish track and fix header
}
Example #6
0
void NifStream( short const & val, ostream& out, const NifInfo & info ) {
	if ( info.endian == sys_endian ) {
		WriteShort( val, out );
	} else {
		WriteShort( SwapEndian(val), out );
	}
}
BOOL CObjectSerialiser::WriteDependent(CEmbeddedObject* pcDependent)
{
	BOOL				bResult;
	CBaseObject*		pcContainer;
	unsigned short int	iEmbeddedIndex;
	unsigned short int	iNumEmbedded;

	if (pcDependent)
	{
		pcContainer = pcDependent->GetEmbeddingContainer();
		iEmbeddedIndex = pcContainer->GetEmbeddedIndex(pcDependent);
		iNumEmbedded = pcContainer->GetNumEmbedded();

		bResult = WriteIdentifier(pcContainer);
		bResult &= WriteShort(iNumEmbedded);
		bResult &= WriteShort(iEmbeddedIndex);

		if (bResult)
		{
			if (mpcSerialiser)
			{
				mpcSerialiser->AddDependent(pcContainer);
			}
		}
		return bResult;
	}
	else
	{
		bResult = WriteIdentifier(NULL);
		return bResult;
	}
}
Example #8
0
/*----------------------------------------------------------------------
   WriteSignedShort  ecrit l'entier signe' n			
  ----------------------------------------------------------------------*/
void                WriteSignedShort (int n)
{
   if (n >= 0)
      WriteShort (n);
   else
      WriteShort (n + 65536);
}
Example #9
0
void SaveCPU(SAVESTATE_t* save, CPU_t* cpu) {
	int i;
	if (!cpu) return;
	CHUNK_t* chunk = NewChunk(save,CPU_tag);
	
	WriteChar(chunk, cpu->a);
	WriteChar(chunk, cpu->f);
	WriteChar(chunk, cpu->b);
	WriteChar(chunk, cpu->c);
	WriteChar(chunk, cpu->d);
	WriteChar(chunk, cpu->e);
	WriteChar(chunk, cpu->h);
	WriteChar(chunk, cpu->l);
	
	WriteChar(chunk, cpu->ap);
	WriteChar(chunk, cpu->fp);
	WriteChar(chunk, cpu->bp);
	WriteChar(chunk, cpu->cp);
	WriteChar(chunk, cpu->dp);
	WriteChar(chunk, cpu->ep);
	WriteChar(chunk, cpu->hp);
	WriteChar(chunk, cpu->lp);
	
	WriteChar(chunk, cpu->ixl);
	WriteChar(chunk, cpu->ixh);
	WriteChar(chunk, cpu->iyl);
	WriteChar(chunk, cpu->iyh);

	WriteShort(chunk, cpu->pc);
	WriteShort(chunk, cpu->sp);

	WriteChar(chunk, cpu->i);
	WriteChar(chunk, cpu->r);
	WriteChar(chunk, cpu->bus);
	
	WriteInt(chunk, cpu->imode);

	WriteInt(chunk, cpu->interrupt);
	WriteInt(chunk, cpu->ei_block);
	WriteInt(chunk, cpu->iff1);
	WriteInt(chunk, cpu->iff2);
	WriteInt(chunk, cpu->halt);
	
	WriteInt(chunk, cpu->read);
	WriteInt(chunk, cpu->write);
	WriteInt(chunk, cpu->output);
	WriteInt(chunk, cpu->input);
	WriteInt(chunk, cpu->prefix);

	
	/* pio */
	for(i = 0; i < 256; i++) {
		interrupt_t *val = &cpu->pio.interrupt[i];
		WriteInt(chunk, val->interrupt_val);
		WriteInt(chunk, val->skip_factor);
		WriteInt(chunk, val->skip_count);
	}
}
Example #10
0
void cProtocol125::SendWindowProperty(const cWindow & a_Window, int a_Property, int a_Value)
{
	cCSLock Lock(m_CSPacket);
	WriteByte (PACKET_WINDOW_PROPERTY);
	WriteChar (a_Window.GetWindowID());
	WriteShort(a_Property);
	WriteShort(a_Value);
	Flush();
}
Example #11
0
void cProtocol125::SendHealth(void)
{
	cCSLock Lock(m_CSPacket);
	WriteByte (PACKET_UPDATE_HEALTH);
	WriteShort((short)m_Client->GetPlayer()->GetHealth());
	WriteShort(m_Client->GetPlayer()->GetFoodLevel());
	WriteFloat((float)m_Client->GetPlayer()->GetFoodSaturationLevel());
	Flush();
}
Example #12
0
void cProtocol125::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item)
{
	cCSLock Lock(m_CSPacket);
	WriteByte (PACKET_ENTITY_EQUIPMENT);
	WriteInt  (a_Entity.GetUniqueID());
	WriteShort(a_SlotNum);
	WriteShort(a_Item.m_ItemType);
	WriteShort(a_Item.m_ItemDamage);
	Flush();
}
Example #13
0
void cProtocol125::SendExperience(void)
{
	cCSLock Lock(m_CSPacket);
	cPlayer * Player = m_Client->GetPlayer();
	WriteByte  (PACKET_EXPERIENCE);
	WriteFloat (Player->GetXpPercentage());
	WriteShort (Player->GetXpLevel());
	WriteShort (Player->GetCurrentXp());
	Flush();
}
Example #14
0
void cProtocol132::SendEncryptionKeyRequest(void)
{
	cCSLock Lock(m_CSPacket);
	WriteByte(0xfd);
	WriteString(cRoot::Get()->GetServer()->GetServerID());
	WriteShort((short)(cRoot::Get()->GetServer()->GetPublicKeyDER().size()));
	SendData(cRoot::Get()->GetServer()->GetPublicKeyDER().data(), cRoot::Get()->GetServer()->GetPublicKeyDER().size());
	WriteShort(4);
	WriteInt((int)(intptr_t)this);  // Using 'this' as the cryptographic nonce, so that we don't have to generate one each time :)
	Flush();
}
Example #15
0
void cProtocol132::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType)
{
	cCSLock Lock(m_CSPacket);
	WriteByte (PACKET_BLOCK_ACTION);
	WriteInt  (a_BlockX);
	WriteShort((short)a_BlockY);
	WriteInt  (a_BlockZ);
	WriteChar (a_Byte1);
	WriteChar (a_Byte2);
	WriteShort(a_BlockType);
	Flush();
}
Example #16
0
void cProtocol125::SendEntityVelocity(const cEntity & a_Entity)
{
	ASSERT(a_Entity.GetUniqueID() != m_Client->GetPlayer()->GetUniqueID());  // Must not send for self
	
	cCSLock Lock(m_CSPacket);
	WriteByte(PACKET_ENTITY_VELOCITY);
	WriteInt (a_Entity.GetUniqueID());
	WriteShort((short) (a_Entity.GetSpeedX() * 400)); //400 = 8000 / 20 
	WriteShort((short) (a_Entity.GetSpeedY() * 400));
	WriteShort((short) (a_Entity.GetSpeedZ() * 400));
	Flush();
}
Example #17
0
// Discontinuous Vertex Mapping
bool CLwoWriter::WriteDiscVertexMapping()
{
	CLwoFile::CLayer::TexCoordMap& texCoords = m_curLayer.GetTexCoordMap();
	if(texCoords.size() == 0)
		return true;

	MSG_DEBUG("VMAD | TXUV");

	// "VMAD" + size
	WriteChunk(CLwoFile::CHUNK_VMAD);

	// type : "TXUV"
	WriteTag(CLwoFile::CHUNK_TXUV);

	ushort dimension = 2; // UVs are 2D
	WriteShort(dimension);

	std::string name("txuv00");
	WriteString(name);

	CLwoFile::CLayer::TexCoordMap::iterator texCoordIt, texCoordEnd;
	texCoordEnd = texCoords.end();

	std::vector< CLwoFile::CLayer::CTexCoord > uvVector;
	ushort pointIndex = 0;
	ushort polyIndex = 0;
	Vector3D uv(3);

	for(texCoordIt = texCoords.begin(); texCoordIt != texCoordEnd; ++texCoordIt) // For each LWO texCoord
	{
		uvVector = texCoordIt->second;
		std::vector< CLwoFile::CLayer::CTexCoord >::iterator uvVectorIt, uvVectorEnd;
		uvVectorEnd = uvVector.end();

		for(uvVectorIt = uvVector.begin(); uvVectorIt != uvVectorEnd; ++uvVectorIt) // For each LWO face
		{
			if(uvVectorIt == uvVector.begin()) // skip the first one since it was written in the VMAP
				continue;

			pointIndex = texCoordIt->first;
			WriteShort(pointIndex); // vertex position index

			ushort polyIndex = uvVectorIt->m_faceIndex;
			WriteShort(polyIndex); // face index

			uv = uvVectorIt->m_texCoord;
			WriteVector2D(uv); // Write UV
		}
	}

	return true;
}
Example #18
0
/*
===================
idSaveGame::WriteUsercmd
===================
*/
void idSaveGame::WriteUsercmd( const usercmd_t& usercmd )
{
	WriteByte( usercmd.buttons );
	WriteSignedChar( usercmd.forwardmove );
	WriteSignedChar( usercmd.rightmove );
	WriteShort( usercmd.angles[0] );
	WriteShort( usercmd.angles[1] );
	WriteShort( usercmd.angles[2] );
	WriteShort( usercmd.mx );
	WriteShort( usercmd.my );
	WriteByte( usercmd.impulse );
	WriteByte( usercmd.impulseSequence );
}
Example #19
0
void WriteString(char *str)
{
	int     len;

	if(!str)
	{
		WriteShort(0);
		return;
	}
	len = strlen(str);
	WriteShort(len);
	Write(str, len);
}
Example #20
0
void FollowSegment()
{
  int steering;

  T("enter FollowSegment");

  ClearTimer(T1);
  long lastTime = time1[T1];

  while (true) {
    int timeNow = time1[T1];
    int elapsedTime = timeNow - lastTime;
    lastTime = timeNow;

    int llAvg = LLreadAverage(LINELEADER);
    unsigned byte llResult = LLreadResult(LINELEADER);

    if (llAvg != 0)
    {
      steering = DoPID(llAvg, 45, Kp, Ki, Kd, elapsedTime); // 45 is our goal, set point
      //steering = llAvg;
      motor[LEFT] = clip((basePower + steering), Min, Max);
      motor[RIGHT] = clip((basePower - steering), Min, Max);

      // data logging
      int heading = HTMCreadHeading(COMPASS);
      WriteShort(hFileHandle, nIoResult, timeNow);
      WriteShort(hFileHandle, nIoResult, llAvg);
      WriteShort(hFileHandle, nIoResult, steering);
      WriteFloat(hFileHandle, nIoResult, integral);
      WriteFloat(hFileHandle, nIoResult, derivative);
      WriteShort(hFileHandle, nIoResult, elapsedTime);
      WriteShort(hFileHandle, nIoResult, heading);
      WriteByte(hFileHandle, nIoResult, llResult);
    }
    else
    {
      // stuff gone wrong, we lost the line
      // this may be where we check result for an intersection
      PlaySound(soundException);
    }

    if (TSreadState(BUMPER))
      break;

    lastTime = timeNow; // using the variable, not the actual clock
    //wait1Msec(10);    // some throttling
  }

  T("leave FollowSegment");
}
Example #21
0
void cProtocol132::SendUnloadChunk(int a_ChunkX, int a_ChunkZ)
{
	// Unloading the chunk is done by sending a "map chunk" packet
	// with IncludeInitialize set to true and primary bitmap set to 0:
	cCSLock Lock(m_CSPacket);
	WriteByte(PACKET_CHUNK_DATA);
	WriteInt (a_ChunkX);
	WriteInt (a_ChunkZ);
	WriteBool(true);      // IncludeInitialize
	WriteShort(0);        // Primary bitmap
	WriteShort(0);        // Add bitmap
	WriteInt(0);
	Flush();
}
Example #22
0
void cProtocol125::SendPickupSpawn(const cPickup & a_Pickup)
{
	cCSLock Lock(m_CSPacket);
	WriteByte   (PACKET_PICKUP_SPAWN);
	WriteInt    (a_Pickup.GetUniqueID());
	WriteShort  (a_Pickup.GetItem().m_ItemType);
	WriteByte   (a_Pickup.GetItem().m_ItemCount);
	WriteShort  (a_Pickup.GetItem().m_ItemDamage);
	WriteVectorI((Vector3i)(a_Pickup.GetPosition() * 32));
	WriteByte   ((char)(a_Pickup.GetSpeed().x * 8));
	WriteByte   ((char)(a_Pickup.GetSpeed().y * 8));
	WriteByte   ((char)(a_Pickup.GetSpeed().z * 8));
	Flush();
}
Example #23
0
void cProtocol132::HandleEncryptionKeyResponse(const AString & a_EncKey, const AString & a_EncNonce)
{
	// Decrypt EncNonce using privkey
	cRsaPrivateKey & rsaDecryptor = cRoot::Get()->GetServer()->GetPrivateKey();

	Int32 DecryptedNonce[MAX_ENC_LEN / sizeof(Int32)];
	int res = rsaDecryptor.Decrypt((const Byte *)a_EncNonce.data(), a_EncNonce.size(), (Byte *)DecryptedNonce, sizeof(DecryptedNonce));
	if (res != 4)
	{
		LOGD("Bad nonce length");
		m_Client->Kick("Hacked client");
		return;
	}
	if (ntohl(DecryptedNonce[0]) != (unsigned)(uintptr_t)this)
	{
		LOGD("Bad nonce value");
		m_Client->Kick("Hacked client");
		return;
	}
	
	// Decrypt the symmetric encryption key using privkey:
	Byte DecryptedKey[MAX_ENC_LEN];
	res = rsaDecryptor.Decrypt((const Byte *)a_EncKey.data(), a_EncKey.size(), DecryptedKey, sizeof(DecryptedKey));
	if (res != 16)
	{
		LOGD("Bad key length");
		m_Client->Kick("Hacked client");
		return;
	}
	
	{
		// Send encryption key response:
		cCSLock Lock(m_CSPacket);
		WriteByte(0xfc);
		WriteShort(0);
		WriteShort(0);
		Flush();
	}
	
	#ifdef _DEBUG
	AString DecryptedKeyHex;
	CreateHexDump(DecryptedKeyHex, DecryptedKey, res, 16);
	LOGD("Received encryption key, %d bytes:\n%s", res, DecryptedKeyHex.c_str());
	#endif
	
	StartEncryption(DecryptedKey);
	return;
}
Example #24
0
void CSave::WriteString( const char *pname, const int *stringId, int count )
{
	int i, size;

#ifdef TOKENIZE
	short	token = ( short ) TokenHash( STRING( *stringId ) );
	WriteShort( pname, &token, 1 );
#else
#if 0
	if( count != 1 )
		ALERT( at_error, "No string arrays!\n" );
	WriteString( pname, ( char * ) STRING( *stringId ) );
#endif

	size = 0;
	for( i = 0; i < count; i++ )
		size += strlen( STRING( stringId[ i ] ) ) + 1;

	BufferHeader( pname, size );
	for( i = 0; i < count; i++ )
	{
		const char *pString = STRING( stringId[ i ] );
		BufferData( pString, strlen( pString ) + 1 );
	}
#endif
}
Example #25
0
// Image definition
bool CLwoWriter::WriteImageDefinitions()
{
	CLwoFile::CLayer::ImageVector& images = m_curLayer.GetImageVector();
	CLwoFile::CLayer::ImageVector::iterator imageBegin, imageIt, imageEnd;
	imageBegin = images.begin();
	imageEnd = images.end();

	for(imageIt = imageBegin; imageIt != imageEnd; ++imageIt) // For each LWO face
	{
		std::string imagePath(*imageIt);
		ushort still_size = (ushort)GetStringSize(imagePath);

		MSG_DEBUG("CLIP | STIL: '" << imagePath << "'");

		// "CLIP" + size
		WriteTag(CLwoFile::CHUNK_CLIP);
		WriteLong(4 + 4 + 2 + still_size); // imageIndex + "STIL" + stilSize + pathString 

		ulong imageIndex = (imageIt - imageBegin);
		WriteLong(imageIndex); // image index : 0-based index

		WriteTag(CLwoFile::CHUNK_STIL); // STIL
		WriteShort(still_size);

		// Write the image path
		WriteString(imagePath);
	}

	return true;
}
Example #26
0
void 
MovieWriter::MakeIODS(Atom* pmoov)
{
    smart_ptr<Atom> piods = pmoov->CreateAtom('iods');

    Descriptor iod(Descriptor::MP4_IOD);
    BYTE b[16];
    WriteShort(0x004f, b);      // object id 1, no url, no inline profile + reserved bits
    b[2] = 0xff;        // no od capability required
    b[3] = 0xff;        // no scene graph capability required
    b[4] = 0x0f;        // audio profile
    b[5] = 0x03;        // video profile
    b[6] = 0xff;        // no graphics capability required
    iod.Append(b, 7);

    // append the id of each media track
    for (UINT i = 0; i < m_Tracks.size(); i++)
    {
        if (m_Tracks[i]->IsVideo() || m_Tracks[i]->IsAudio())
        {
            // use 32-bit track id in IODS
            Descriptor es(Descriptor::ES_ID_Inc);
            WriteLong(m_Tracks[i]->ID(), b);
            es.Append(b, 4);
            iod.Append(&es);
        }
    }
    WriteLong(0, b);
    piods->Append(b, 4);       // ver/flags
    iod.Write(piods);
    piods->Close();
}
Example #27
0
/*
===================
idSaveGame::WriteUsercmd
===================
*/
void idSaveGame::WriteUsercmd( const usercmd_t &usercmd ) {
	WriteInt( usercmd.gameFrame );
	WriteInt( usercmd.gameTime );
	WriteInt( usercmd.duplicateCount );
	WriteByte( usercmd.buttons );
	WriteSignedChar( usercmd.forwardmove );
	WriteSignedChar( usercmd.rightmove );
	WriteSignedChar( usercmd.upmove );
	WriteShort( usercmd.angles[0] );
	WriteShort( usercmd.angles[1] );
	WriteShort( usercmd.angles[2] );
	WriteShort( usercmd.mx );
	WriteShort( usercmd.my );
	WriteSignedChar( usercmd.impulse );
	WriteByte( usercmd.flags );
	WriteInt( usercmd.sequence );
}
Example #28
0
void cProtocol125::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType)
{
	cCSLock Lock(m_CSPacket);
	WriteByte (PACKET_SPAWN_OBJECT);
	WriteInt  (a_Vehicle.GetUniqueID());
	WriteByte (a_VehicleType);
	WriteInt  ((int)(a_Vehicle.GetPosX() * 32));
	WriteInt  ((int)(a_Vehicle.GetPosY() * 32));
	WriteInt  ((int)(a_Vehicle.GetPosZ() * 32));
	WriteByte ((Byte)((a_Vehicle.GetPitch() / 360.f) * 256));
	WriteByte ((Byte)((a_Vehicle.GetRotation() / 360.f) * 256));
	WriteInt  (1);
	WriteShort((short)(a_Vehicle.GetSpeedX() * 400));
	WriteShort((short)(a_Vehicle.GetSpeedY() * 400));
	WriteShort((short)(a_Vehicle.GetSpeedZ() * 400));
	Flush();
}
Example #29
0
/* 
* 往流中写入utf8字符串,写入格式:DataLen 和 pData
*
*	DataLen:长度,short类型
*	pData:字符串指针
*/
void CByteOutputStream::WriteUtf8(const char* pUtf8)
{
	unsigned short iLen = strlen(pUtf8);
	if (iLen<=0)
		return;
	WriteShort(iLen);
	Write((unsigned char*)pUtf8, iLen, 0, iLen);
}
Example #30
0
void cProtocol125::SendMapColumn(int a_ID, int a_X, int a_Y, const Byte * a_Colors, unsigned int a_Length)
{
	cCSLock Lock(m_CSPacket);

	WriteByte (PACKET_ITEM_DATA);
	WriteShort(E_ITEM_MAP);
	WriteShort((short)a_ID);
	WriteShort((short)(3 + a_Length));

	WriteByte(0);
	WriteChar((char)a_X);
	WriteChar((char)a_Y);
	
	SendData((const char *)a_Colors, a_Length);

	Flush();
}