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,15 @@
#include "pch.h"
#include "Log.h"
#include "l2c_utils.h"
#include "net/GameClient/GameClient.h"
#include "../ServerPackets.h"
#include "GS.h"
L2GamePacket *ServerPackets::CharCreateFail( GameClient *pl, int reason )
{
pl = NULL; // reference to player not needed
L2Game_CharCreateFail *p = new L2Game_CharCreateFail();
p->p_reasonCode = (unsigned int)reason;
p->create( L2_VERSION_T23 );
return p;
}

View File

@@ -0,0 +1,14 @@
#include "pch.h"
#include "Log.h"
#include "l2c_utils.h"
#include "net/GameClient/GameClient.h"
#include "../ServerPackets.h"
#include "GS.h"
L2GamePacket *ServerPackets::CharCreateOK( GameClient *pl )
{
pl = NULL; // reference to player not needed
L2Game_CharCreateSuccess *p = new L2Game_CharCreateSuccess();
p->create( L2_VERSION_T23 );
return p;
}

View File

@@ -0,0 +1,225 @@
#include "pch.h"
#include "Log.h"
#include "l2c_utils.h"
#include "net/GameClient/GameClient.h"
#include "../ServerPackets.h"
#include "GS.h"
#include "world/templates/item/L2ItemTemplate.h"
L2GamePacket *ServerPackets::CharacterSelectionInfo( GameClient *pl )
{
GameServer *gs = GameServer::getInstance();
MysqlConnection *con = gs->getDBConnection();
L2Game_CharSelectionInfoBlock csb[7];
memset( &csb, 0, sizeof(csb) );
int i = 0;
int num_chars = 0;
unsigned int max_lastAccess = 0;
int activeCharIndex = -1;
MysqlQuery q;
q.create( L"SELECT account_name, charId, char_name, level, maxHp, curHp, maxMp, curMp, face, hairStyle, "
L"hairColor, sex, heading, x, y, z, exp, sp, karma, pvpkills, pkkills, clanid, race, classid, "
L"deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, "
L"base_class, transform_id FROM characters WHERE account_name='%s' LIMIT 7", pl->getAccount() );
if( con->executeQuery( q ) )
{
i = 0;
while( q.getNextRow() )
{
unsigned int lastAccess = q.getFieldUInt( "lastAccess" );
if( lastAccess > max_lastAccess )
{
max_lastAccess = lastAccess;
activeCharIndex = i;
}
//
q.getFieldStrW( 0, csb[i].accountName, 32 );
csb[i].charID = q.getFieldUInt( 1 );
q.getFieldStrW( 2, csb[i].charName, 32 );
csb[i].level = q.getFieldUInt( 3 );
csb[i].HP_max = q.getFieldDouble( 4 );
csb[i].HP_cur = q.getFieldDouble( 5 );
csb[i].MP_max = q.getFieldDouble( 6 );
csb[i].MP_cur = q.getFieldDouble( 7 );
csb[i].face = q.getFieldUInt( 8 );
csb[i].hairStyle = q.getFieldUInt( 9 );
csb[i].hairColor = q.getFieldUInt( 10 );
csb[i].sex = q.getFieldUInt( 11 );
//q.getFieldUInt( 12, ???? ); // no heading
csb[i].x = q.getFieldInt( 13 );
csb[i].y = q.getFieldInt( 14 );
csb[i].z = q.getFieldInt( 15 );
csb[i].Exp = q.getFieldUInt64( 16 );
csb[i].SP = q.getFieldUInt( 17 );
csb[i].karma = q.getFieldUInt( 18 );
csb[i].PVP_kills = q.getFieldUInt( 19 );
csb[i].PK_kills = q.getFieldUInt( 20 );
csb[i].clanID = q.getFieldUInt( 21 );
csb[i].race = q.getFieldUInt( 22 );
csb[i].classID = q.getFieldUInt( 23 );
csb[i].deleteSeconds = q.getFieldUInt( 24 );
//q.getFieldUInt( 25, can craft??? );
//q.getFieldStrW( 26, title?? );
//q.getFieldUInt( 27, rec_have );
csb[i].baseClassID = q.getFieldUInt( "base_class" );
csb[i].isActive = 1;
// fake
//csb[i].iid_chest = 0x0967; // DC Robe
//csb[i].iid_R_hand = 0x2ec2; // Common Branch of Mother tree
//
i++;
}
num_chars = i;
}
else
{
LogError( L"CharacterSelectionInfo: MySQL error: %s", con->getErrorStr() );
}
// TODO: load also equipped inventory items
for( i=0; i<num_chars; i++ )
{
q.clear();
q.create( L"SELECT object_id,item_id,loc_data,enchant_level FROM items WHERE owner_id=%u AND loc='PAPERDOLL'", csb[i].charID );
if( con->executeQuery( q ) )
{
while( q.getNextRow() )
{
int slot = q.getFieldInt( "loc_data" );
int item_id = q.getFieldInt( "item_id" );
int enchant_level = q.getFieldInt( "enchant_level" );
//
switch( slot )
{
case 1: csb[i].iid_R_ear = item_id; break;
case 2: csb[i].iid_L_ear = item_id; break;
//case 3: LREAR
case 4: csb[i].iid_neck = item_id; break;
case 5: csb[i].iid_L_finger = item_id; break;
case 6: csb[i].iid_R_finger = item_id; break;
//case 7: LRFINGER
case 8: csb[i].iid_head = item_id; break;
case 9: csb[i].iid_R_hand = item_id; break;
case 10: csb[i].iid_L_hand = item_id; break;
case 11: csb[i].iid_gloves = item_id; break;
case 12: csb[i].iid_chest = item_id; break;
case 13: csb[i].iid_legs = item_id; break;
case 14: csb[i].iid_feet = item_id; break;
case 15: csb[i].iid_back = item_id; break;
case 16: csb[i].iid_R_hand = csb[i].iid_L_hand = item_id; break; // LRHAND
case 17: csb[i].iid_chest = item_id; break; // fullarmor?
case 18: csb[i].iid_hair = item_id; break;
//case 19: ALLDRESS
case 20: csb[i].iid_hair_2 = item_id; break;
case 21: csb[i].iid_hair_all = item_id; break;
case 22: csb[i].iid_R_bracelet = item_id; break;
case 23: csb[i].iid_L_bracelet = item_id; break;
// 24..29 DECOs
case 30: csb[i].iid_belt = item_id; break;
}
if( slot == SLOT_R_HAND && enchant_level > 0 ) // weapon
csb[i].enchantEffect = (unsigned char)(enchant_level & 0x000000FF);
}
}
else
{
LogError( L"CharacterSelectionInfo: MySQL error: %s", con->getErrorStr() );
}
}
q.clear();
gs->releaseDBConnection( con );
// retreive playOk1
unsigned char playKey[8];
memset( playKey, 0, 8 );
pl->getPlayKey( playKey );
unsigned int playOk1 = *(unsigned int *)&playKey[0];
//
L2GamePacket *p = new L2GamePacket();
p->setPacketType( 0x09 );
p->writeD( num_chars ); // number of chars
p->writeD( 0x07 ); // server max_chars
p->writeC( 0x00 ); // 0x00
//
for( i=0; i<num_chars; i++ )
{
p->writeS( csb[i].charName );
p->writeUInt( csb[i].charID );
p->writeS( pl->getAccount() );
p->writeUInt( playOk1 ); // TODO: playOK id 1
p->writeUInt( csb[i].clanID );
p->writeD( 0x00 );
//
p->writeUInt( csb[i].sex );
p->writeUInt( csb[i].race );
p->writeUInt( csb[i].baseClassID );
p->writeUInt( (i == activeCharIndex) ? 0x01 : 0x00 ); // is active
//
p->writeInt( csb[i].x );
p->writeInt( csb[i].y );
p->writeInt( csb[i].z );
p->writeDouble( csb[i].HP_cur );
p->writeDouble( csb[i].MP_cur );
//
p->writeUInt( csb[i].SP );
p->writeUInt64( csb[i].Exp );
p->writeUInt( csb[i].level );
//
p->writeUInt( csb[i].karma );
p->writeUInt( csb[i].PK_kills );
p->writeUInt( csb[i].PVP_kills );
//
p->writeD( 0x00 ); p->writeD( 0x00 ); p->writeD( 0x00 ); p->writeD( 0x00 );
p->writeD( 0x00 ); p->writeD( 0x00 ); p->writeD( 0x00 ); // 7 0x00
//
// 26 inventory item ids // TODO: equipment ids
p->writeD( csb[i].iid_hair_all ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_HAIRALL));
p->writeD( csb[i].iid_R_ear ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_REAR));
p->writeD( csb[i].iid_L_ear ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_LEAR));
p->writeD( csb[i].iid_neck ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_NECK));
p->writeD( csb[i].iid_R_finger ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_RFINGER));
p->writeD( csb[i].iid_L_finger ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_LFINGER));
p->writeD( csb[i].iid_head ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_HEAD));
p->writeD( csb[i].iid_R_hand ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
p->writeD( csb[i].iid_L_hand ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_LHAND));
p->writeD( csb[i].iid_gloves ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_GLOVES));
p->writeD( csb[i].iid_chest ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_CHEST));
p->writeD( csb[i].iid_legs ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_LEGS));
p->writeD( csb[i].iid_feet ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_FEET));
p->writeD( csb[i].iid_back ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_BACK));
p->writeD( csb[i].iid_LR_hand ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_LRHAND));
p->writeD( csb[i].iid_hair ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
p->writeD( csb[i].iid_hair_2 ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_HAIR2));
p->writeD( csb[i].iid_R_bracelet ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_RBRACELET));
p->writeD( csb[i].iid_L_bracelet ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_LBRACELET));
p->writeD( 0x00 ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_DECO1));
p->writeD( 0x00 ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_DECO2));
p->writeD( 0x00 ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_DECO3));
p->writeD( 0x00 ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_DECO4));
p->writeD( 0x00 ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_DECO5));
p->writeD( 0x00 ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_DECO6));
p->writeD( csb[i].iid_belt ); //writeD(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_BELT));
//
p->writeUInt( csb[i].hairStyle );
p->writeUInt( csb[i].hairColor );
p->writeUInt( csb[i].face );
//LogDebug( L"Writing hs,hc,face = %u,%u,%u", csb[i].hairStyle, csb[i].hairColor, csb[i].face );
//
p->writeDouble( csb[i].HP_max );
p->writeDouble( csb[i].MP_max );
//
p->writeUInt( csb[i].deleteSeconds );
p->writeUInt( csb[i].classID ); // not base classid
p->writeUInt( 0x00 ); // TODO: is last used char
//
p->writeC( 0x00 ); // TODO: enchant Effect
p->writeD( 0x00 ); // TODO: aug. ID
p->writeD( 0x00 ); // transformID is always 0 here
}
//
//FILE *_f = fopen( "CharacterSelectionInfo.log", "wt" );
//p->dumpToFile( _f );
//fclose( _f );
//
return p;
}

View File

@@ -0,0 +1,27 @@
#include "pch.h"
#include "Log.h"
#include "l2c_utils.h"
#include "net/GameClient/GameClient.h"
#include "../ServerPackets.h"
#include "GS.h"
L2GamePacket *ServerPackets::KeyPacket( GameClient *pl )
{
#ifdef ENABLE_OBF
unsigned int obf_seed = rand();
#else
unsigned int obf_seed = 0;
#endif
pl->setOpcodeObfuscationSeed( obf_seed );
//
L2Game_KeyPacket *p = new L2Game_KeyPacket();
p->p_protocolIsOK = pl->isProtocolOk();
p->p_obfuscatorSeed = obf_seed;
p->p_serverId = (unsigned char)GameServer::getInstance()->getServerId();
// initial key is random bytes...
L2Game_KeyPacket::createInitialHellboundKey( p->p_initialKey, p->p_initialKey );
p->create( L2_VERSION_T23 );
// enable crypt on client
pl->enable_XOR_crypt( true, p->p_initialKey );
return p;
}

View File

@@ -0,0 +1,106 @@
#include "pch.h"
#include "Log.h"
#include "l2c_utils.h"
#include "net/GameClient/GameClient.h"
#include "../ServerPackets.h"
#include "GS.h"
//
#include "world/model/base/ClassIdTree.h"
#include "datatables/CharTemplateTable.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
*/
L2GamePacket *ServerPackets::NewCharacterSuccess( GameClient *pl )
{
pl = NULL; // reference to player is not needed here
//
unsigned int numTemplates = 0;
L2Game_NewCharacterTemplate tmpl[32];
int ic = 0;
ClassIdTree *cidtree = ClassIdTree::getInstance();
for( ic = 0; ic < ClassIdTree::NUM_CLASS_IDS; ic++ )
{
// no Inspector, though it's base class
if( ic == ClassId::CID_INSPECTOR ) continue;
// get ClassId if class
const ClassId *cid = cidtree->getClassId( ic );
if( cid )
{
// no parents, base classes
if( cid->getParentId() == ClassId::CID_NONE )
{
// get template base stats for class
const L2PlayerTemplate *plt = CharTemplateTable::getTemplate( ic );
if( plt )
{
tmpl[numTemplates].classID = ic;
tmpl[numTemplates].base_CON = plt->baseCON;
tmpl[numTemplates].base_DEX = plt->baseDEX;
tmpl[numTemplates].base_INT = plt->baseINT;
tmpl[numTemplates].base_MEN = plt->baseMEN;
tmpl[numTemplates].base_STR = plt->baseSTR;
tmpl[numTemplates].base_WIT = plt->baseWIT;
tmpl[numTemplates].race = (int)plt->race;
numTemplates++;
}
}
}
if( numTemplates >= 32 ) break;
}
//
L2GamePacket *p = new L2GamePacket();
p->setPacketType( 0x0D ); // NewCharacterSuccess
p->writeUInt( numTemplates );
for( ic = 0; ic < (int)numTemplates; ic++ )
{
p->writeD( tmpl[ic].race );
p->writeD( tmpl[ic].classID );
p->writeD( 0x46 );
p->writeD( tmpl[ic].base_STR );
p->writeD( 0x0A );
p->writeD( 0x46 );
p->writeD( tmpl[ic].base_DEX );
p->writeD( 0x0A );
p->writeD( 0x46 );
p->writeD( tmpl[ic].base_CON );
p->writeD( 0x0A );
p->writeD( 0x46 );
p->writeD( tmpl[ic].base_INT );
p->writeD( 0x0A );
p->writeD( 0x46 );
p->writeD( tmpl[ic].base_WIT );
p->writeD( 0x0A );
p->writeD( 0x46 );
p->writeD( tmpl[ic].base_MEN );
p->writeD( 0x0A );
}
return p;
}