void WorldSession::HandleCharCreate( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data, 1+1+1+1+2+2+2+2+1+1+1+1+1+1+1+1); Player * pNewChar = new Player(this); // prevent character creating with invalid name if(new_name.empty()) { sLog.outError("Account:[%d] but tried to Create character with empty [name]", GetAccountId()); return; } std::string pass1; std::string pass2; if(pNewChar->Create( objmgr.GenerateLowGuid(HIGHGUID_PLAYER), new_name, recv_data, pass1, pass2 )) { Item* shirt = pNewChar->CreateItem( 864, 1 ); if( shirt ) { uint8 slot = shirt->GetProto()->EquipmentSlot; uint8 dest = slot; if( pNewChar->CanEquipItem( slot, dest, shirt, false ) == EQUIP_ERR_OK ) pNewChar->EquipItem( dest, shirt, false ); else delete shirt; } ///- Add level 1 survival gears pNewChar->AddNewInventoryItem( 10012, 1 ); pNewChar->AddNewInventoryItem( 19001, 1 ); pNewChar->AddNewInventoryItem( 20711, 1 ); pNewChar->AddNewInventoryItem( 21011, 1 ); pNewChar->AddNewInventoryItem( 22401, 1 ); ///- Adding default pet (Guo Jia evo) /* Pet* pet = pNewChar->CreatePet( 3402 ); if( pet ) { uint8 slot = 0; uint8 dest = slot; if( pNewChar->CanSummonPet( slot, dest, pet, false ) == PET_ERR_OK ) pNewChar->SummonPet( 0, pet ); else delete pet; } */ pNewChar->SaveToDB(); delete pNewChar; } else { // Player not create (problem?) delete pNewChar; ///- TODO: Send char create error to client return; } std::string md5pass1 = md5(pass1); std::string md5pass2 = md5(pass2); ///- Commit pending player creation transaction, for login preparation loginDatabase.PExecute("UPDATE accounts SET md5pass1 = '%s', md5pass2 = '%s' WHERE accountid = %u", md5pass1.c_str(), md5pass2.c_str(), GetAccountId()); CharacterDatabase.CommitTransaction(); ///- do a small delay to make sure player save to database completed ZThread::Thread::sleep(10); std::string IP_str = _socket ? _socket->GetRemoteAddress().c_str() : "-"; sLog.outString("Account: %d (IP: %s) Create Character:[%s]", GetAccountId(), IP_str.c_str(), new_name.c_str()); sLog.outChar("Account: %d (IP: %s) Create Character:[%s]", GetAccountId(), IP_str.c_str(), new_name.c_str()); ///- Clear new name after new player creation new_name = ""; WorldPacket data; data << (uint8 ) pass1.size(); data << (uint32) GetAccountId(); data << (uint32) 0x00; data << pass1; HandlePlayerLoginOpcode( data ); }