Exemplo n.º 1
0
bool L2Login_PlayFail::create( L2_VERSION ver /*= L2_VERSION_T1*/ )
{
	UNREFERENCED_PARAMETER(ver);
	setPacketType( 0x06 );
	writeUChar( p_reasonCode );
	return true;
}
bool L2Game_RequestUserCommand::create( unsigned int commandID )
{
	writeReset();
	writeUChar( 0xB3 );
	writeUInt( commandID );
	return true;
}
Exemplo n.º 3
0
void writeByteList( TAThread thread, int size, unsigned char * list, int needDealloc ) {
    writeInt( thread, size );
    if ( size >= 0 ) {
        int i;
        for ( i = 0; i < size; i++ ) { writeUChar( thread, list[ i ] ); }
        if ( needDealloc != 0 ) { ta_dealloc_memory( list ); }
    }
}
Exemplo n.º 4
0
bool Packet::appendChecksum( bool append4bytes )
{
	unsigned char *raw = b.getBytesPtr();
	int size = (int)this->real_size;
	unsigned int chksum = 0;
	int count = size;
	unsigned int ecx = 0;
	int i = 0;
	int offset = 2;
	for( i = offset; i<count; i+=4 )
	{
		ecx  = (raw[i])           & 0x000000ff;
		ecx |= (raw[i+1] << 0x08) & 0x0000ff00;
		ecx |= (raw[i+2] << 0x10) & 0x00ff0000;
		ecx |= (raw[i+3] << 0x18) & 0xff000000;

		chksum ^= ecx;
	}

	ecx  = raw[i]           & 0x000000ff;
	ecx |= raw[i+1] << 0x08 & 0x0000ff00;
	ecx |= raw[i+2] << 0x10 & 0x00ff0000;
	ecx |= raw[i+3] << 0x18 & 0xff000000;

	writeUChar( (unsigned char)((chksum)         & 0xff) );
	writeUChar( (unsigned char)((chksum >> 0x08) & 0xff) );
	writeUChar( (unsigned char)((chksum >> 0x10) & 0xff) );
	writeUChar( (unsigned char)((chksum >> 0x18) & 0xff) );

	if( append4bytes )
	{
		writeUChar( 0x00 );
		writeUChar( 0x00 );
		writeUChar( 0x00 );
		writeUChar( 0x00 );
	}
	return true;
}
Exemplo n.º 5
0
bool Packet::appendMore8Bytes()
{
	int i;
	for( i=0; i<8; i++ ) writeUChar( 0x00 );
	return true;
}
Exemplo n.º 6
0
bool L2LoginPacket::appendChecksum( bool append4bytes )
{
	unsigned char *raw = b.getBytesPtr();
	int size = (int)this->real_size;
	unsigned int chksum = 0;
	int count = size; // size-4; // we do not reserve space for checksum
	unsigned int ecx = 0;
	int i = 0;
	int offset = 2;
#ifdef L2LOGINP_DEBUGOUT_CHKSUM
	printf( "L2LoginPacket::appendChecksum(): for( i=%d; i<%d; i+=4)\n",
		offset, count );
#endif // L2LOGINP_DEBUGOUT_CHKSUM
	for( i = offset; i<count; i+=4 )
	{
		ecx  = (raw[i])           & 0x000000ff;
		ecx |= (raw[i+1] << 0x08) & 0x0000ff00;
		ecx |= (raw[i+2] << 0x10) & 0x00ff0000;
		ecx |= (raw[i+3] << 0x18) & 0xff000000;

		chksum ^= ecx;
	}

	ecx  = raw[i]           & 0x000000ff;
	ecx |= raw[i+1] << 0x08 & 0x0000ff00;
	ecx |= raw[i+2] << 0x10 & 0x00ff0000;
	ecx |= raw[i+3] << 0x18 & 0xff000000;

	// write chksum to end of packet
	/*/// L2J style :)
	raw[i]   = (unsigned char)((chksum)         & 0xff);
	raw[i+1] = (unsigned char)((chksum >> 0x08) & 0xff);
	raw[i+2] = (unsigned char)((chksum >> 0x10) & 0xff);
	raw[i+3] = (unsigned char)((chksum >> 0x18) & 0xff);
	*/
	//this->write_ptr = i+4;
	
#ifdef L2LOGINP_DEBUGOUT_CHKSUM
	printf( "L2LoginPacket::appendChecksum(): writing chksum [%04X] at indexes [%d..%d]\n",
		chksum, this->write_ptr, this->write_ptr+3 );
#endif // L2LOGINP_DEBUGOUT_CHKSUM
	
	writeUChar( (unsigned char)((chksum)         & 0xff) );
	writeUChar( (unsigned char)((chksum >> 0x08) & 0xff) );
	writeUChar( (unsigned char)((chksum >> 0x10) & 0xff) );
	writeUChar( (unsigned char)((chksum >> 0x18) & 0xff) );
	// Should we also automatically append 4 0x00 symbols to packet?
	// Before calling appendChecksum(), packet is considered to be
	// aligned at 8-byte border, so adding 4 bytes of checksum
	// breaks this alignment. And adding more 4 zero bytes will
	// resore 8-byte border alignment.
	// But sometimes this adding is not necessary, for example,
	// when encoding packet from Login Server to Client.
	if( append4bytes )
	{
		writeUChar( 0x00 );
		writeUChar( 0x00 );
		writeUChar( 0x00 );
		writeUChar( 0x00 );
	}
	return true;
}