Initial MSVC 2008 projects workspace

This commit is contained in:
alexey.min
2012-02-01 05:25:08 +00:00
commit 03de3bdc95
1446 changed files with 476853 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
#include "stdafx.h"
#include "L2Game_AuthLoginFail.h"
L2Game_AuthLoginFail::L2Game_AuthLoginFail()
{
_initNull();
}
L2Game_AuthLoginFail::L2Game_AuthLoginFail( const unsigned char *bytes, unsigned int length )
{
_initNull();
setBytes( bytes, length );
}
bool L2Game_AuthLoginFail::parse( L2_VERSION ver )
{
UNREFERENCED_PARAMETER(ver);
if( getPacketType() != 0x0A ) return false;
p_reasonCode = readUInt();
return true;
}
bool L2Game_AuthLoginFail::create( L2_VERSION ver )
{
UNREFERENCED_PARAMETER(ver);
setPacketType( 0x0A );
writeUInt( p_reasonCode );
return true;
}
void L2Game_AuthLoginFail::reasonCodeToString( int code, char *outString )
{
switch( code )
{
case REASON_NO_TEXT: strcpy( outString, "REASON_NO_TEXT" ); break;
case REASON_SYSTEM_ERROR_LOGIN_LATER: strcpy( outString, "REASON_SYSTEM_ERROR_LOGIN_LATER" ); break;
case REASON_PASSWORD_DOES_NOT_MATCH_THIS_ACCOUNT: strcpy( outString, "REASON_PASSWORD_DOES_NOT_MATCH_THIS_ACCOUNT" ); break;
case REASON_PASSWORD_DOES_NOT_MATCH_THIS_ACCOUNT2: strcpy( outString, "REASON_PASSWORD_DOES_NOT_MATCH_THIS_ACCOUNT2" ); break;
case REASON_ACCESS_FAILED_TRY_LATER: strcpy( outString, "REASON_ACCESS_FAILED_TRY_LATER" ); break;
case REASON_INCORRECT_ACCOUNT_INFO_CONTACT_CUSTOMER_SUPPORT: strcpy( outString, "REASON_INCORRECT_ACCOUNT_INFO_CONTACT_CUSTOMER_SUPPORT" ); break;
case REASON_ACCESS_FAILED_TRY_LATER2: strcpy( outString, "REASON_ACCESS_FAILED_TRY_LATER2" ); break;
case REASON_ACOUNT_ALREADY_IN_USE: strcpy( outString, "REASON_ACOUNT_ALREADY_IN_USE" ); break;
case REASON_ACCESS_FAILED_TRY_LATER3: strcpy( outString, "REASON_ACCESS_FAILED_TRY_LATER3" ); break;
case REASON_ACCESS_FAILED_TRY_LATER4: strcpy( outString, "REASON_ACCESS_FAILED_TRY_LATER4" ); break;
case REASON_ACCESS_FAILED_TRY_LATER5: strcpy( outString, "REASON_ACCESS_FAILED_TRY_LATER5" ); break;
default: strcpy( outString, "REASON_UNKNOWN" ); break;
}
}

View File

@@ -0,0 +1,32 @@
#ifndef L2GAME_AUTHLOGINFAIL_H_
#define L2GAME_AUTHLOGINFAIL_H_
#include "../L2GamePacket.h"
class L2Game_AuthLoginFail: public L2GamePacket
{
public:
static const int REASON_NO_TEXT = 0;
static const int REASON_SYSTEM_ERROR_LOGIN_LATER = 1;
static const int REASON_PASSWORD_DOES_NOT_MATCH_THIS_ACCOUNT = 2;
static const int REASON_PASSWORD_DOES_NOT_MATCH_THIS_ACCOUNT2 = 3;
static const int REASON_ACCESS_FAILED_TRY_LATER = 4;
static const int REASON_INCORRECT_ACCOUNT_INFO_CONTACT_CUSTOMER_SUPPORT = 5;
static const int REASON_ACCESS_FAILED_TRY_LATER2 = 6;
static const int REASON_ACOUNT_ALREADY_IN_USE = 7;
static const int REASON_ACCESS_FAILED_TRY_LATER3 = 8;
static const int REASON_ACCESS_FAILED_TRY_LATER4 = 9;
static const int REASON_ACCESS_FAILED_TRY_LATER5 = 10;
public:
L2Game_AuthLoginFail();
L2Game_AuthLoginFail( const unsigned char *bytes, unsigned int length );
public:
virtual bool parse( L2_VERSION ver = L2_VERSION_T1 );
virtual bool create( L2_VERSION ver = L2_VERSION_T1 );
public:
static void reasonCodeToString( int code, char *outString );
public:
unsigned int p_reasonCode;
};
#endif

View File

@@ -0,0 +1,42 @@
#include "stdafx.h"
#include "L2Game_CharCreateFail.h"
L2Game_CharCreateFail::L2Game_CharCreateFail()
{
_initNull();
}
L2Game_CharCreateFail::L2Game_CharCreateFail( const unsigned char *bytes, unsigned int length )
{
_initNull();
setBytes( bytes, length );
}
bool L2Game_CharCreateFail::parse( L2_VERSION ver )
{
UNREFERENCED_PARAMETER(ver);
if( getPacketType() != 0x10 ) return false;
p_reasonCode = readUInt();
return true;
}
bool L2Game_CharCreateFail::create( L2_VERSION ver )
{
UNREFERENCED_PARAMETER(ver);
setPacketType( 0x10 );
writeUInt( p_reasonCode );
return true;
}
void L2Game_CharCreateFail::reasonCodeToString( int code, char *outString )
{
switch( code )
{
case REASON_CREATION_FAILED: strcpy( outString, "REASON_CREATION_FAILED" ); break;
case REASON_TOO_MANY_CHARACTERS: strcpy( outString, "REASON_TOO_MANY_CHARACTERS" ); break;
case REASON_NAME_ALREADY_EXISTS: strcpy( outString, "REASON_NAME_ALREADY_EXISTS" ); break;
case REASON_16_ENG_CHARS: strcpy( outString, "REASON_16_ENG_CHARS" ); break;
default: strcpy( outString, "REASON_UNKNOWN" ); break;
}
}

View File

@@ -0,0 +1,28 @@
#ifndef L2GAME_CHARCREATEFAIL_H_
#define L2GAME_CHARCREATEFAIL_H_
#include "../L2GamePacket.h"
class L2Game_CharCreateFail: public L2GamePacket
{
public:
static const int REASON_CREATION_FAILED = 0x00;
static const int REASON_TOO_MANY_CHARACTERS = 0x01;
static const int REASON_NAME_ALREADY_EXISTS = 0x02;
static const int REASON_16_ENG_CHARS = 0x03;
static const int REASON_INCORRECT_NAME = 0x04;
static const int REASON_CREATE_NOT_ALLOWED = 0x05;
static const int REASON_CHOOSE_ANOTHER_SVR = 0x06;
public:
L2Game_CharCreateFail();
L2Game_CharCreateFail( const unsigned char *bytes, unsigned int length );
public:
virtual bool parse( L2_VERSION ver = L2_VERSION_T1 );
virtual bool create( L2_VERSION ver = L2_VERSION_T1 );
public:
static void reasonCodeToString( int code, char *outString );
public:
unsigned int p_reasonCode;
};
#endif

View File

@@ -0,0 +1,30 @@
#include "stdafx.h"
#include "L2Game_CharCreateSuccess.h"
L2Game_CharCreateSuccess::L2Game_CharCreateSuccess()
{
_initNull();
}
L2Game_CharCreateSuccess::L2Game_CharCreateSuccess( const unsigned char *bytes, unsigned int length )
{
_initNull();
setBytes( bytes, length );
}
bool L2Game_CharCreateSuccess::parse( L2_VERSION ver )
{
UNREFERENCED_PARAMETER(ver);
if( getPacketType() != 0x0F ) return false;
if( readUInt() != 0x01 ) return false;
return true;
}
bool L2Game_CharCreateSuccess::create( L2_VERSION ver )
{
UNREFERENCED_PARAMETER(ver);
setPacketType( 0x0F );
writeUInt( 0x01 );
return true;
}

View File

@@ -0,0 +1,16 @@
#ifndef L2GAME_CHARCREATEOK_H_
#define L2GAME_CHARCREATEOK_H_
#include "../L2GamePacket.h"
class L2Game_CharCreateSuccess: public L2GamePacket
{
public:
L2Game_CharCreateSuccess();
L2Game_CharCreateSuccess( const unsigned char *bytes, unsigned int length );
public:
virtual bool parse( L2_VERSION ver = L2_VERSION_T1 );
virtual bool create( L2_VERSION ver = L2_VERSION_T1 );
};
#endif

View File

@@ -0,0 +1,41 @@
#include "stdafx.h"
#include "L2Game_CharDeleteFail.h"
L2Game_CharDeleteFail::L2Game_CharDeleteFail()
{
_initNull();
}
L2Game_CharDeleteFail::L2Game_CharDeleteFail( const unsigned char *bytes, unsigned int length )
{
_initNull();
setBytes( bytes, length );
}
bool L2Game_CharDeleteFail::parse( L2_VERSION ver )
{
UNREFERENCED_PARAMETER(ver);
if( getPacketType() != 0x1E ) return false;
p_reasonCode = readUInt();
return true;
}
bool L2Game_CharDeleteFail::create( L2_VERSION ver )
{
UNREFERENCED_PARAMETER(ver);
setPacketType( 0x1E );
writeUInt( p_reasonCode );
return true;
}
void L2Game_CharDeleteFail::reasonCodeToString( int code, char *outString )
{
switch( code )
{
case REASON_DELETION_FAILED: strcpy( outString, "REASON_DELETION_FAILED" ); break;
case REASON_YOU_MAY_NOT_DELETE_CLAN_MEMBER: strcpy( outString, "REASON_YOU_MAY_NOT_DELETE_CLAN_MEMBER" ); break;
case REASON_CLAN_LEADERS_MAY_NOT_BE_DELETED: strcpy( outString, "REASON_CLAN_LEADERS_MAY_NOT_BE_DELETED" ); break;
default: strcpy( outString, "REASON_UNKNOWN" ); break;
}
}

View File

@@ -0,0 +1,24 @@
#ifndef L2GAME_CHARDELETEFAIL_H_
#define L2GAME_CHARDELETEFAIL_H_
#include "../L2GamePacket.h"
class L2Game_CharDeleteFail: public L2GamePacket
{
public:
static const int REASON_DELETION_FAILED = 0x01;
static const int REASON_YOU_MAY_NOT_DELETE_CLAN_MEMBER = 0x02;
static const int REASON_CLAN_LEADERS_MAY_NOT_BE_DELETED = 0x03;
public:
L2Game_CharDeleteFail();
L2Game_CharDeleteFail( const unsigned char *bytes, unsigned int length );
public:
virtual bool parse( L2_VERSION ver = L2_VERSION_T1 );
virtual bool create( L2_VERSION ver = L2_VERSION_T1 );
public:
static void reasonCodeToString( int code, char *outString );
public:
unsigned int p_reasonCode;
};
#endif

View File

@@ -0,0 +1,16 @@
#include "stdafx.h"
#include "L2Game_CharDeleteSuccess.h"
L2Game_CharDeleteSuccess::L2Game_CharDeleteSuccess()
{
_initNull();
}
L2Game_CharDeleteSuccess::L2Game_CharDeleteSuccess( const unsigned char *bytes, unsigned int length )
{
_initNull();
setBytes( bytes, length );
}

View File

@@ -0,0 +1,14 @@
#ifndef L2GAME_CHARDELETESUCCESS_H_
#define L2GAME_CHARDELETESUCCESS_H_
#include "../L2GamePacket.h"
class L2Game_CharDeleteSuccess: public L2GamePacket
{
public:
L2Game_CharDeleteSuccess();
L2Game_CharDeleteSuccess( const unsigned char *bytes, unsigned int length );
// nothing to parse - just trigger
};
#endif

View File

@@ -0,0 +1,124 @@
#include "stdafx.h"
#include "L2Game_CharSelected.h"
L2Game_CharSelected::L2Game_CharSelected()
{
_initNull();
}
L2Game_CharSelected::L2Game_CharSelected( const unsigned char *bytes, unsigned int length )
{
_initNull();
setBytes( bytes, length );
}
bool L2Game_CharSelected::parse( L2_VERSION ver /*= L2_VERSION_T1*/ )
{
UNREFERENCED_PARAMETER(ver);
if( !this->canReadBytes( 200 ) ) return false; // must be at least 200 bytes
readReset();
readUChar(); // 0x0b CharSelected
wcscpy( p_char_name, readUnicodeStringPtr() ); // char name
p_charId = readUInt(); // char id (objectId)
wcscpy( p_title, readUnicodeStringPtr() ); // title
p_sessionId = readUInt(); // sessionId
p_clanId = readUInt(); // clanId
readD(); // 0x00 (maybe allyId?)
p_sex = readD();
p_race = readD();
p_classId = readUInt();
p_isActive = readD();
p_x = readD();
p_y = readD();
p_z = readD();
p_curHp = readF();
p_curMp = readF();
p_sp = readUInt();
p_exp = readUInt64();
p_level = readD();
p_karma = readD();
p_PK_kills = readD();
p_INT = readD();
p_STR = readD();
p_CON = readD();
p_MEN = readD();
p_DEX = readD();
p_WIT = readD();
readD(); // writeD( 0x0451 ); // game time?
readD(); // writeD( 0x00 ); // 0x00
readD(); // writeD( classId ); // classId already read?
//writeD(0x00); // 4 x 0x00
//writeD(0x00);
//writeD(0x00);
//writeD(0x00);
readD(); readD(); readD(); readD();
//writeB(new byte[64]); // some 64 bytes
int i;
for( i=0; i<16; i++ ) readD(); // read 4 x 16 = 64 bytes
p_opcodeObfuscatorSeed = readUInt();
return true;
}
bool L2Game_CharSelected::create( L2_VERSION ver /*= L2_VERSION_T1*/ )
{
UNREFERENCED_PARAMETER(ver);
writeReset();
writeC(0x0b);
writeS( p_char_name );
writeD( p_charId );
writeS( p_title );
writeD( p_sessionId ); // playOkID1
writeD( p_clanId );
writeD( 0x00 ); // maybe allyId?
writeD( p_sex );
writeD( p_race );
writeD( p_classId );
writeD( p_isActive ); // active ??
writeD( p_x );
writeD( p_y );
writeD( p_z );
writeF( p_curHp );
writeF( p_curMp );
writeD( p_sp );
writeQ( p_exp );
writeD( p_level );
writeD( p_karma );
writeD( p_PK_kills );
writeD( p_INT );
writeD( p_STR );
writeD( p_CON );
writeD( p_MEN );
writeD( p_DEX );
writeD( p_WIT );
writeD( 0x0451 ); //?
writeD( 0x00 ); // some constants
writeD( p_classId );
writeD(0x00); // 4 x 0x00
writeD(0x00);
writeD(0x00);
writeD(0x00);
//writeB(new byte[64]); // some 64 bytes
unsigned char *rndbuf = (unsigned char *)malloc( 64 );
writeBytes( rndbuf, 64 );
free( rndbuf );
writeD( p_opcodeObfuscatorSeed ); // writeD(0x00);
return true;
}

View File

@@ -0,0 +1,43 @@
#ifndef L2GAME_CHARSELECTED_H_
#define L2GAME_CHARSELECTED_H_
#include "../L2GamePacket.h"
class L2Game_CharSelected : public L2GamePacket
{
public:
L2Game_CharSelected();
L2Game_CharSelected( const unsigned char *bytes, unsigned int length );
public:
virtual bool parse( L2_VERSION ver = L2_VERSION_T1 );
virtual bool create( L2_VERSION ver = L2_VERSION_T1 );
public:
wchar_t p_char_name[128]; // char name
unsigned int p_charId; // char id (objectId)
wchar_t p_title[128]; // title (empty here)
unsigned int p_sessionId; // sessionId
unsigned int p_clanId; // clan id
int p_sex; // sex
int p_race; // race 0x01 - elf
unsigned int p_classId; // class Id
int p_isActive; // is Active
int p_x;
int p_y;
int p_z;
double p_curHp; // currentHp
double p_curMp; // currentMp
unsigned int p_sp; // sp
unsigned long long int p_exp; // exp
int p_level; // level (64)
int p_karma; // karma
int p_PK_kills; // PK kills
int p_INT; // INT
int p_STR; // STR
int p_CON; // CON
int p_MEN; // MEN
int p_DEX; // DEX
int p_WIT; // WIT
unsigned int p_opcodeObfuscatorSeed; // opcode obfuscator seed
};
#endif

View File

@@ -0,0 +1,109 @@
#include "stdafx.h"
#include "L2Game_CharSelectionInfo.h"
L2Game_CharSelectionInfo::L2Game_CharSelectionInfo()
{
this->_initNull();
}
L2Game_CharSelectionInfo::L2Game_CharSelectionInfo( const unsigned char *bytes, unsigned int length )
{
this->_initNull();
this->setBytes( bytes, length );
}
bool L2Game_CharSelectionInfo::read_nChars( unsigned int *ret )
{
if( !ret ) return false;
this->readReset();
if( !this->canReadBytes(10) ) return false;
this->readUChar(); // pcode
(*ret) = this->readUInt();
return true;
}
// ret can be NULL
bool L2Game_CharSelectionInfo::read_server_maxChars( unsigned int *ret )
{
if( !ret ) return false;
this->readReset();
if( !this->canReadBytes(10) ) return false;
this->readUChar(); // pcode
this->readUInt(); // nChars
if( ret ) (*ret) = this->readUInt();
this->readUChar(); // read 0x00
return true;
}
bool L2Game_CharSelectionInfo::read_next_charSelectInfoBlock( L2_VERSION l2_version,
struct L2Game_CharSelectionInfoBlock *c )
{
if( !c ) return false;
memset( c, 0, sizeof(L2Game_CharSelectionInfoBlock) );
// TODO: how to detect that packet may be incorrect?
// char info must be AT LEAST 280 bytes long (Hellbound)
if( !this->canReadBytes(280) ) return false;
const wchar_t *wstr = NULL;
int i = 0;
wstr = this->readUnicodeStringPtr();
if( !wstr ) return false;
wcsncpy( c->charName, wstr, 31 );
c->charID = this->readUInt();
wstr = this->readUnicodeStringPtr();
if( !wstr ) return false;
wcsncpy( c->accountName, wstr, 31 );
c->sessionID = readUInt();
c->clanID = readUInt();
readUInt(); // 0x00
c->sex = readUInt();
c->race = readUInt();
c->baseClassID = readUInt();
c->isActive = readUInt();
c->x = readInt();
c->y = readInt();
c->z = readInt();
c->HP_cur = readDouble();
c->MP_cur = readDouble();
c->SP = readUInt();
c->Exp = readUInt64();
c->level = readUInt();
c->karma = readUInt();
c->PK_kills = readUInt();
c->PVP_kills = readUInt();
for( i=0; i<7; i++ ) readUInt(); // 7 0x00
c->iid_hair_all = readUInt();
c->iid_R_ear = readUInt();
c->iid_L_ear = readUInt();
c->iid_neck = readUInt();
c->iid_R_finger = readUInt();
c->iid_L_finger = readUInt();
c->iid_head = readUInt();
c->iid_R_hand = readUInt();
c->iid_L_hand = readUInt();
c->iid_gloves = readUInt();
c->iid_chest = readUInt();
c->iid_legs = readUInt();
c->iid_feet = readUInt();
c->iid_back = readUInt();
c->iid_LR_hand = readUInt();
c->iid_hair = readUInt();
c->iid_hair_2 = readUInt();
c->iid_R_bracelet = readUInt();
c->iid_L_bracelet = readUInt();
for( i=0; i<6; i++ ) readUInt(); // DECO1 .. DECO6
if( l2_version >= L2_VERSION_T23 )
c->iid_belt = readUInt(); // Gracia Final T2.3
c->hairStyle = readUInt();
c->hairColor = readUInt();
c->face = readUInt();
c->HP_max = readDouble();
c->MP_max = readDouble();
c->deleteSeconds = readUInt();
c->classID = readUInt();
c->lastUsedChar = readUInt();
c->enchantEffect = readUChar();
c->augmentID = readUShort();
c->augmentSmth = readUShort();
c->transformID = readUInt();
return true;
}

View File

@@ -0,0 +1,74 @@
#ifndef L2GAME_CHARSELECTIONINFO_H_
#define L2GAME_CHARSELECTIONINFO_H_
#include "../L2GamePacket.h"
struct L2Game_CharSelectionInfoBlock
{
wchar_t charName[32];
unsigned int charID;
wchar_t accountName[32];
unsigned int sessionID;
unsigned int clanID;
unsigned int sex;
unsigned int race;
unsigned int baseClassID;
unsigned int isActive;
int x;
int y;
int z;
double HP_cur;
double MP_cur;
unsigned int SP;
unsigned long long Exp;
unsigned int level;
unsigned int karma;
unsigned int PK_kills;
unsigned int PVP_kills;
unsigned int iid_hair_all;
unsigned int iid_R_ear;
unsigned int iid_L_ear;
unsigned int iid_neck;
unsigned int iid_R_finger;
unsigned int iid_L_finger;
unsigned int iid_head;
unsigned int iid_R_hand;
unsigned int iid_L_hand;
unsigned int iid_gloves;
unsigned int iid_chest;
unsigned int iid_legs;
unsigned int iid_feet;
unsigned int iid_back;
unsigned int iid_LR_hand;
unsigned int iid_hair;
unsigned int iid_hair_2;
unsigned int iid_R_bracelet;
unsigned int iid_L_bracelet;
unsigned int iid_belt; // T2.3
unsigned int hairStyle;
unsigned int hairColor;
unsigned int face;
double HP_max;
double MP_max;
unsigned int deleteSeconds; ///< seconds left before char will be deleted, or 0 if char is not marked to deletion
unsigned int classID;
unsigned int lastUsedChar;
unsigned char enchantEffect;
unsigned short int augmentID;
unsigned short int augmentSmth;
unsigned int transformID;
};
class L2Game_CharSelectionInfo : public L2GamePacket
{
public:
L2Game_CharSelectionInfo();
L2Game_CharSelectionInfo( const unsigned char *bytes, unsigned int length );
public:
bool read_nChars( unsigned int *ret );
bool read_server_maxChars( unsigned int *ret ); // ret can be NULL
bool read_next_charSelectInfoBlock( L2_VERSION l2_version,
struct L2Game_CharSelectionInfoBlock *c );
};
#endif /*L2GAME_CHARSELECTIONINFO_H_*/

View File

@@ -0,0 +1,122 @@
#include "stdafx.h"
#include "L2Game_KeyPacket.h"
/**
* ==========================================
Retail NCSoft
19 00 // p.len 25
2E // pcode
01 // always const
42 55 77 8F C3 05 69 87 // xorkey first part
01 00 00 00 // always const
01 // possible Game Server ID - depends on game server ID
00 00 00 00 // always NULLs
XX XX XX XX // always different, non-nulls: opcode obfuscator
*/
L2Game_KeyPacket::L2Game_KeyPacket()
{
this->_initNull();
}
L2Game_KeyPacket::L2Game_KeyPacket( const unsigned char *bytes, unsigned int length )
{
this->_initNull();
this->setBytes( bytes, length );
}
// key must point to buffer large enough to hold 8 bytes
bool L2Game_KeyPacket::read_key( unsigned char *key )
{
if( !key ) return false;
this->readReset();
if( this->canReadBytes(10) )
{
this->readUChar(); // packet type (0x0e in hellbound, 0x00 - interlude)
this->readUChar(); // 0x01 ?
return this->readBytes( key, 8 );
}
else return false;
}
unsigned char L2Game_KeyPacket::read_GameServerID()
{
if( !this->canReadBytes(5) ) return 0x00;
this->readUInt(); // 01 00 00 00 // always const
return this->readUChar(); // 01 // possible Game Server ID
}
unsigned int L2Game_KeyPacket::read_OpcodeObfuscator()
{
if( !this->canReadBytes(4) ) return 0x00000000;
this->readUInt(); // 00 00 00 00 // always 0x00000000, read 4 NULLs
return this->readUInt(); // XX XX XX XX // always different, opcode obfuscator
}
// keyPacket array points to key bytes received from KeyPacket (8 bytes)
// keyResult will hold resultig key (16 bytes)
void L2Game_KeyPacket::createInitialHellboundKey(
const unsigned char *keyPacket,
unsigned char *keyResult )
{
if( !keyPacket || !keyResult ) return;
// first 8 bytes of key are from KeyPacket
keyResult[0] = keyPacket[0];
keyResult[1] = keyPacket[1];
keyResult[2] = keyPacket[2];
keyResult[3] = keyPacket[3];
keyResult[4] = keyPacket[4];
keyResult[5] = keyPacket[5];
keyResult[6] = keyPacket[6];
keyResult[7] = keyPacket[7];
// last 8 bytes are constant in T1/T1.5/T2/T2.2/T2.3...
keyResult[8] = (unsigned char)0xc8;
keyResult[9] = (unsigned char)0x27;
keyResult[10] = (unsigned char)0x93;
keyResult[11] = (unsigned char)0x01;
keyResult[12] = (unsigned char)0xa1;
keyResult[13] = (unsigned char)0x6c;
keyResult[14] = (unsigned char)0x31;
keyResult[15] = (unsigned char)0x97;
}
/*** Format:
19 00 // plen = 25
2E // pcode
01 // 00 - wrong proto, 01 - proto OK
B6 4D 20 15 CE 0E BC 7A // 1st 8 bytes of crypto key
01 00 00 00 // 0x01
09 // game serverID
00 00 00 00 // wtf?
E3 D1 10 2F // obfuscation key ***/
bool L2Game_KeyPacket::parse( L2_VERSION ver /*= L2_VERSION_T1*/ )
{
UNREFERENCED_PARAMETER( ver );
readReset();
if( !canReadBytes( 19 ) ) return false; // packet size is at least 19 bytes O_o
getPacketType();
this->p_protocolIsOK = readUChar(); // 0x01 - proto OK, 0x00 - proto not supported
readBytes( this->p_initialKey, 8 ); // first 8 bytes of XOR key
readD(); // 0x00000001
this->p_serverId = readUChar(); // server ID
readD(); // 0x00000000;
this->p_obfuscatorSeed = readUInt(); // obfuscator seed
// add last 8 bytes of XOR key - they are constant
createInitialHellboundKey( p_initialKey, p_initialKey );
//
return true;
}
bool L2Game_KeyPacket::create( L2_VERSION ver )
{
UNREFERENCED_PARAMETER( ver );
writeReset();
setPacketType( 0x2E );
writeUChar( p_protocolIsOK );
writeBytes( p_initialKey, 8 );
writeD( 1 );
writeUChar( p_serverId );
writeD( 0 );
writeUInt( p_obfuscatorSeed );
return true;
}

View File

@@ -0,0 +1,32 @@
#ifndef L2GAME_KEYPACKET_H_
#define L2GAME_KEYPACKET_H_
#include "../L2GamePacket.h"
class L2Game_KeyPacket : public L2GamePacket
{
public:
L2Game_KeyPacket();
L2Game_KeyPacket( const unsigned char *bytes, unsigned int length );
public:
// key must point to buffer large enough to hold 8 bytes
bool read_key( unsigned char *key );
unsigned char read_GameServerID();
unsigned int read_OpcodeObfuscator();
public:
// keyPacket array points to key bytes received from KeyPacket (8 bytes)
// keyResult will hold resultig key (16 bytes)
static void createInitialHellboundKey(
const unsigned char *keyPacket,
unsigned char *keyResult );
public:
virtual bool parse( L2_VERSION ver = L2_VERSION_T1 );
virtual bool create( L2_VERSION ver = L2_VERSION_T1 );
public:
unsigned char p_protocolIsOK;
unsigned char p_initialKey[16];
unsigned char p_serverId;
unsigned int p_obfuscatorSeed;
};
#endif /*L2GAME_KEYPACKET_H_*/

View File

@@ -0,0 +1,80 @@
#include "stdafx.h"
#include "L2Game_NewCharacterSuccess.h"
/*
Server: Len 967 [NewCharacterSuccess]
C7 03
0D // opcode
0C 00 00 00 // number of templates
// [ for each template ]
00 00 00 00 // race
00 00 00 00 // class id
46 00 00 00 // 0x46
28 00 00 00 // base STR
0A 00 00 00 // 0x0A
46 00 00 00 // 0x46
1E 00 00 00 // base DEX
0A 00 00 00
46 00 00 00
2B 00 00 00 // base CON
0A 00 00 00
46 00 00 00
15 00 00 00 // base INT
0A 00 00 00
46 00 00 00
0B 00 00 00 // base WIT
0A 00 00 00
46 00 00 00
19 00 00 00 // base MEN
0A 00 00 00
*/
L2Game_NewCharacterSuccess::L2Game_NewCharacterSuccess()
{
_initNull();
}
L2Game_NewCharacterSuccess::L2Game_NewCharacterSuccess( const unsigned char *bytes, unsigned int length )
{
_initNull();
setBytes( bytes, length );
}
int L2Game_NewCharacterSuccess::read_templatesCount()
{
readReset();
getPacketType();
return readInt();
}
bool L2Game_NewCharacterSuccess::read_nextCharacterTemplate( struct L2Game_NewCharacterTemplate *t )
{
if( !t ) return false;
// each template is 80 bytes length (20Ds)
if( !canReadBytes( 80 ) ) return false;
// read
t->race = readD();
t->classID = readD();
readD(); // 0x46
t->base_STR = readD();
readD(); // 0x0A
readD(); // 0x46
t->base_DEX = readD();
readD(); // 0x0A
readD(); // 0x46
t->base_CON = readD();
readD(); // 0x0A
readD(); // 0x46
t->base_INT = readD();
readD(); // 0x0A
readD(); // 0x46
t->base_WIT = readD();
readD(); // 0x0A
readD(); // 0x46
t->base_MEN = readD();
readD(); // 0x0A
return true;
}

View File

@@ -0,0 +1,28 @@
#ifndef H_L2GAME_NEWCHARACTERSUCCESS
#define H_L2GAME_NEWCHARACTERSUCCESS
#include "../L2GamePacket.h"
struct L2Game_NewCharacterTemplate
{
int race;
int classID;
int base_STR;
int base_DEX;
int base_CON;
int base_INT;
int base_WIT;
int base_MEN;
};
class L2Game_NewCharacterSuccess: public L2GamePacket
{
public:
L2Game_NewCharacterSuccess();
L2Game_NewCharacterSuccess( const unsigned char *bytes, unsigned int length );
public:
int read_templatesCount();
bool read_nextCharacterTemplate( struct L2Game_NewCharacterTemplate *t );
};
#endif

View File

@@ -0,0 +1,43 @@
#include "stdafx.h"
#include "L2Game_SSQInfo.h"
L2Game_SSQInfo::L2Game_SSQInfo()
{
_initNull();
}
L2Game_SSQInfo::L2Game_SSQInfo( const unsigned char *bytes, unsigned int length )
{
_initNull();
setBytes( bytes, length );
}
/**
protected final void writeImpl()
{
writeC(0x73);
if (_state == 2) // Dawn Sky
{
writeH(258);
}
else if (_state == 1) // Dusk Sky
{
writeH(257);
}
else
{
writeH(256);
}
}
*/
unsigned short int L2Game_SSQInfo::read_SSQ_SkySatus()
{
if( this->canReadBytes( 3 ) )
{
this->getPacketType();
return this->readUShort();
}
else return SSQ_NORMAL_SKY;
}

View File

@@ -0,0 +1,19 @@
#ifndef L2GAME_SSQINFO_H_
#define L2GAME_SSQINFO_H_
#include "../L2GamePacket.h"
class L2Game_SSQInfo : public L2GamePacket
{
public:
static const unsigned short int SSQ_DAWN_SKY = 258;
static const unsigned short int SSQ_DUSK_SKY = 257;
static const unsigned short int SSQ_NORMAL_SKY = 256;
public:
L2Game_SSQInfo();
L2Game_SSQInfo( const unsigned char *bytes, unsigned int length );
public:
unsigned short int read_SSQ_SkySatus();
};
#endif /* L2GAME_SSQINFO_H_*/