mirror of
https://github.com/mangosfour/server.git
synced 2025-12-27 10:37:02 +00:00
Fix CMSG_CHAR_CREATE, CMSG_CHAR_DELETE Thanks Zuse for help.
Signed-off-by: Salja <salja2012@hotmail.de>
This commit is contained in:
parent
3e5895f2f5
commit
4fa8e2c36c
4 changed files with 214 additions and 224 deletions
|
|
@ -1461,7 +1461,7 @@ void Player::SetDeathState(DeathState s)
|
|||
}
|
||||
}
|
||||
|
||||
bool Player::BuildEnumData(QueryResult* result, WorldPacket* p_data)
|
||||
bool Player::BuildEnumData( QueryResult * result, ByteBuffer * p_data )
|
||||
{
|
||||
// 0 1 2 3 4 5 6 7
|
||||
// "SELECT characters.guid, characters.name, characters.race, characters.class, characters.gender, characters.playerBytes, characters.playerBytes2, characters.level, "
|
||||
|
|
@ -1470,139 +1470,146 @@ bool Player::BuildEnumData(QueryResult* result, WorldPacket* p_data)
|
|||
// 15 16 17 18 19 20
|
||||
// "characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level, characters.equipmentCache, character_declinedname.genitive "
|
||||
|
||||
Field* fields = result->Fetch();
|
||||
Field *fields = result->Fetch();
|
||||
|
||||
uint32 Guid = fields[0].GetUInt32();
|
||||
uint64 GuildGuid = fields[13].GetUInt64();
|
||||
|
||||
uint32 guid = fields[0].GetUInt32();
|
||||
uint8 pRace = fields[2].GetUInt8();
|
||||
uint8 pClass = fields[3].GetUInt8();
|
||||
|
||||
PlayerInfo const* info = sObjectMgr.GetPlayerInfo(pRace, pClass);
|
||||
if (!info)
|
||||
{
|
||||
sLog.outError("Player %u has incorrect race/class pair. Don't build enum.", guid);
|
||||
return false;
|
||||
}
|
||||
|
||||
*p_data << ObjectGuid(HIGHGUID_PLAYER, guid);
|
||||
*p_data << fields[1].GetString(); // name
|
||||
*p_data << uint8(pRace); // race
|
||||
*p_data << uint8(pClass); // class
|
||||
*p_data << uint8(fields[4].GetUInt8()); // gender
|
||||
|
||||
uint8 gender = fields[4].GetUInt8();
|
||||
uint32 playerBytes = fields[5].GetUInt32();
|
||||
*p_data << uint8(playerBytes); // skin
|
||||
*p_data << uint8(playerBytes >> 8); // face
|
||||
*p_data << uint8(playerBytes >> 16); // hair style
|
||||
*p_data << uint8(playerBytes >> 24); // hair color
|
||||
|
||||
uint32 playerBytes2 = fields[6].GetUInt32();
|
||||
*p_data << uint8(playerBytes2 & 0xFF); // facial hair
|
||||
|
||||
*p_data << uint8(fields[7].GetUInt8()); // level
|
||||
*p_data << uint32(fields[8].GetUInt32()); // zone
|
||||
*p_data << uint32(fields[9].GetUInt32()); // map
|
||||
|
||||
*p_data << fields[10].GetFloat(); // x
|
||||
*p_data << fields[11].GetFloat(); // y
|
||||
*p_data << fields[12].GetFloat(); // z
|
||||
|
||||
*p_data << uint32(fields[13].GetUInt32()); // guild id
|
||||
|
||||
uint32 char_flags = 0;
|
||||
uint8 level = fields[7].GetUInt8();
|
||||
uint32 playerFlags = fields[14].GetUInt32();
|
||||
uint32 atLoginFlags = fields[15].GetUInt32();
|
||||
if (playerFlags & PLAYER_FLAGS_HIDE_HELM)
|
||||
char_flags |= CHARACTER_FLAG_HIDE_HELM;
|
||||
if (playerFlags & PLAYER_FLAGS_HIDE_CLOAK)
|
||||
char_flags |= CHARACTER_FLAG_HIDE_CLOAK;
|
||||
if (playerFlags & PLAYER_FLAGS_GHOST)
|
||||
char_flags |= CHARACTER_FLAG_GHOST;
|
||||
if (atLoginFlags & AT_LOGIN_RENAME)
|
||||
char_flags |= CHARACTER_FLAG_RENAME;
|
||||
if (sWorld.getConfig(CONFIG_BOOL_DECLINED_NAMES_USED))
|
||||
uint32 zone = fields[8].GetUInt32();
|
||||
uint32 petDisplayId = 0;
|
||||
uint32 petLevel = 0;
|
||||
uint32 petFamily = 0;
|
||||
uint32 char_flags = 0;
|
||||
|
||||
uint8 Guid0 = uint8(Guid);
|
||||
uint8 Guid1 = uint8(Guid >> 8);
|
||||
uint8 Guid2 = uint8(Guid >> 16);
|
||||
uint8 Guid3 = uint8(Guid >> 24);
|
||||
|
||||
// show pet at selection character in character list only for non-ghost character
|
||||
if (result && !(playerFlags & PLAYER_FLAGS_GHOST) && (pClass == CLASS_WARLOCK || pClass == CLASS_HUNTER || pClass == CLASS_DEATH_KNIGHT))
|
||||
{
|
||||
if (!fields[20].GetCppString().empty())
|
||||
uint32 entry = fields[16].GetUInt32();
|
||||
CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(entry);
|
||||
if(cInfo)
|
||||
{
|
||||
petDisplayId = fields[17].GetUInt32();
|
||||
petLevel = fields[18].GetUInt32();
|
||||
petFamily = cInfo->family;
|
||||
}
|
||||
}
|
||||
|
||||
if(playerFlags & PLAYER_FLAGS_HIDE_HELM)
|
||||
char_flags |= CHARACTER_FLAG_HIDE_HELM;
|
||||
if(playerFlags & PLAYER_FLAGS_HIDE_CLOAK)
|
||||
char_flags |= CHARACTER_FLAG_HIDE_CLOAK;
|
||||
if(playerFlags & PLAYER_FLAGS_GHOST)
|
||||
char_flags |= CHARACTER_FLAG_GHOST;
|
||||
if(atLoginFlags & AT_LOGIN_RENAME)
|
||||
char_flags |= CHARACTER_FLAG_RENAME;
|
||||
if(sWorld.getConfig(CONFIG_BOOL_DECLINED_NAMES_USED))
|
||||
{
|
||||
if(!fields[20].GetCppString().empty())
|
||||
char_flags |= CHARACTER_FLAG_DECLINED;
|
||||
}
|
||||
else
|
||||
char_flags |= CHARACTER_FLAG_DECLINED;
|
||||
|
||||
*p_data << uint32(char_flags); // character flags
|
||||
// character customize flags
|
||||
*p_data << uint32(atLoginFlags & AT_LOGIN_CUSTOMIZE ? CHAR_CUSTOMIZE_FLAG_CUSTOMIZE : CHAR_CUSTOMIZE_FLAG_NONE);
|
||||
// First login
|
||||
*p_data << uint8(atLoginFlags & AT_LOGIN_FIRST ? 1 : 0);
|
||||
|
||||
// Pets info
|
||||
PlayerInfo const *info = sObjectMgr.GetPlayerInfo(pRace, pClass);
|
||||
if(!info)
|
||||
{
|
||||
uint32 petDisplayId = 0;
|
||||
uint32 petLevel = 0;
|
||||
uint32 petFamily = 0;
|
||||
|
||||
// show pet at selection character in character list only for non-ghost character
|
||||
if (result && !(playerFlags & PLAYER_FLAGS_GHOST) && (pClass == CLASS_WARLOCK || pClass == CLASS_HUNTER || pClass == CLASS_DEATH_KNIGHT))
|
||||
{
|
||||
uint32 entry = fields[16].GetUInt32();
|
||||
CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(entry);
|
||||
if (cInfo)
|
||||
{
|
||||
petDisplayId = fields[17].GetUInt32();
|
||||
petLevel = fields[18].GetUInt32();
|
||||
petFamily = cInfo->family;
|
||||
}
|
||||
}
|
||||
|
||||
*p_data << uint32(petDisplayId);
|
||||
*p_data << uint32(petLevel);
|
||||
*p_data << uint32(petFamily);
|
||||
sLog.outError("Player %u has incorrect race/class pair. Don't build enum.", Guid);
|
||||
return false;
|
||||
}
|
||||
|
||||
*p_data << uint8(pClass); // Race
|
||||
|
||||
Tokens data = StrSplit(fields[19].GetCppString(), " ");
|
||||
for (uint8 slot = 0; slot < EQUIPMENT_SLOT_END; ++slot)
|
||||
for (uint8 slot = 0; slot < EQUIPMENT_SLOT_END; slot++)
|
||||
{
|
||||
uint32 visualbase = slot * 2;
|
||||
uint32 item_id = GetUInt32ValueFromArray(data, visualbase);
|
||||
const ItemPrototype* proto = ObjectMgr::GetItemPrototype(item_id);
|
||||
if (!proto)
|
||||
const ItemPrototype * proto = ObjectMgr::GetItemPrototype(item_id);
|
||||
if(!proto)
|
||||
{
|
||||
*p_data << uint32(0);
|
||||
*p_data << uint8(0);
|
||||
*p_data << uint32(0);
|
||||
*p_data << uint32(0);
|
||||
continue;
|
||||
}
|
||||
|
||||
SpellItemEnchantmentEntry const* enchant = NULL;
|
||||
SpellItemEnchantmentEntry const *enchant = NULL;
|
||||
|
||||
uint32 enchants = GetUInt32ValueFromArray(data, visualbase + 1);
|
||||
for (uint8 enchantSlot = PERM_ENCHANTMENT_SLOT; enchantSlot <= TEMP_ENCHANTMENT_SLOT; ++enchantSlot)
|
||||
for(uint8 enchantSlot = PERM_ENCHANTMENT_SLOT; enchantSlot <= TEMP_ENCHANTMENT_SLOT; ++enchantSlot)
|
||||
{
|
||||
// values stored in 2 uint16
|
||||
uint32 enchantId = 0x0000FFFF & (enchants >> enchantSlot * 16);
|
||||
if (!enchantId)
|
||||
uint32 enchantId = 0x0000FFFF & (enchants >> enchantSlot*16);
|
||||
if(!enchantId)
|
||||
continue;
|
||||
|
||||
if ((enchant = sSpellItemEnchantmentStore.LookupEntry(enchantId)))
|
||||
break;
|
||||
}
|
||||
|
||||
*p_data << uint32(proto->DisplayInfoID);
|
||||
*p_data << uint8(proto->InventoryType);
|
||||
*p_data << uint32(proto->DisplayInfoID);
|
||||
*p_data << uint32(enchant ? enchant->aura_id : 0);
|
||||
}
|
||||
|
||||
*p_data << uint32(0); // bag 1 display id
|
||||
*p_data << uint8(0); // bag 1 inventory type
|
||||
*p_data << uint32(0); // enchant?
|
||||
*p_data << uint32(0); // bag 2 display id
|
||||
*p_data << uint8(0); // bag 2 inventory type
|
||||
*p_data << uint32(0); // enchant?
|
||||
*p_data << uint32(0); // bag 3 display id
|
||||
*p_data << uint8(0); // bag 3 inventory type
|
||||
*p_data << uint32(0); // enchant?
|
||||
*p_data << uint32(0); // bag 4 display id
|
||||
*p_data << uint8(0); // bag 4 inventory type
|
||||
*p_data << uint32(0); // enchant?
|
||||
for (int32 i = 0; i < 4; i++)
|
||||
{
|
||||
*p_data << uint8(0);
|
||||
*p_data << uint32(0);
|
||||
*p_data << uint32(0);
|
||||
}
|
||||
|
||||
*p_data << uint32(petDisplayId); // Pet DisplayID
|
||||
*p_data << uint8(0); // char order id
|
||||
*p_data << uint8(playerBytes >> 16); // Hair style
|
||||
*p_data << uint32(petDisplayId); // Pet DisplayID
|
||||
*p_data << uint32(char_flags); // character flags
|
||||
*p_data << uint8(playerBytes >> 24); // Hair color
|
||||
*p_data << uint32(fields[9].GetUInt32()); // map
|
||||
*p_data << fields[12].GetFloat(); // z
|
||||
*p_data << uint32(petLevel); // pet level
|
||||
|
||||
if (Guid3)
|
||||
*p_data << uint8(Guid3 ^ 1);
|
||||
|
||||
*p_data << fields[11].GetFloat(); // y
|
||||
// character customize flags
|
||||
*p_data << uint32(atLoginFlags & AT_LOGIN_CUSTOMIZE ? CHAR_CUSTOMIZE_FLAG_CUSTOMIZE : CHAR_CUSTOMIZE_FLAG_NONE);
|
||||
|
||||
uint32 playerBytes2 = fields[6].GetUInt32();
|
||||
*p_data << uint8(playerBytes2 & 0xFF); // facial hair
|
||||
*p_data << uint8(gender); // Gender
|
||||
p_data->append(fields[1].GetCppString().c_str(), fields[1].GetCppString().size());
|
||||
*p_data << uint8(playerBytes >> 8); // face
|
||||
|
||||
if (Guid0)
|
||||
*p_data << uint8(Guid0 ^ 1);
|
||||
|
||||
if (Guid2)
|
||||
*p_data << uint8(Guid2 ^ 1);
|
||||
|
||||
*p_data << fields[10].GetFloat(); // x
|
||||
*p_data << uint8(playerBytes); // skin
|
||||
*p_data << uint8(pRace); // Race
|
||||
*p_data << uint8(level); // Level
|
||||
|
||||
if (Guid1)
|
||||
*p_data << uint8(Guid1 ^ 1);
|
||||
|
||||
*p_data << uint32(zone); // Zone id
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -17378,7 +17385,7 @@ void Player::SaveToDB()
|
|||
"trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, "
|
||||
"death_expire_time, taxi_path, arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, "
|
||||
"todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk, health, power1, power2, power3, "
|
||||
"power4, power5, power6, power7, power8, power9, power10, specCount, activeSpec, exploredZones, equipmentCache, knownTitles, actionBars) VALUES ("
|
||||
"power4, power5, power6, power7, power8, power9, power10, specCount, activeSpec, exploredZones, equipmentCache, knownTitles, actionBars) "
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, "
|
||||
"?, ?, ?, ?, ?, ?, "
|
||||
"?, ?, ?, "
|
||||
|
|
|
|||
|
|
@ -1077,7 +1077,7 @@ class MANGOS_DLL_SPEC Player : public Unit
|
|||
|
||||
void Update(uint32 update_diff, uint32 time) override;
|
||||
|
||||
static bool BuildEnumData(QueryResult* result, WorldPacket* p_data);
|
||||
static bool BuildEnumData(QueryResult* result, ByteBuffer* p_data );
|
||||
|
||||
void SetInWater(bool apply);
|
||||
|
||||
|
|
|
|||
|
|
@ -242,22 +242,21 @@ int WorldSocket::open(void* a)
|
|||
|
||||
m_Address = remote_addr.get_host_addr();
|
||||
|
||||
WorldPacket wowConnection(MSG_WOW_CONNECTION,46);
|
||||
std::string ServerToClient = "RLD OF WARCRAFT CONNECTION - SERVER TO CLIENT";
|
||||
WorldPacket data(MSG_WOW_CONNECTION,46);
|
||||
|
||||
wowConnection << std::string("RLD OF WARCRAFT CONNECTION - SERVER TO CLIENT");
|
||||
data << ServerToClient;
|
||||
|
||||
SendPacket(wowConnection);
|
||||
if (SendPacket(data) == -1)
|
||||
return -1;
|
||||
|
||||
// Send startup packet.
|
||||
WorldPacket packet (SMSG_AUTH_CHALLENGE, 37);
|
||||
|
||||
for(uint8 i = 0; i < 8; ++i)
|
||||
{
|
||||
for (uint32 i = 0; i < 8; i++)
|
||||
packet << uint32(0);
|
||||
}
|
||||
|
||||
packet << uint32(m_Seed);
|
||||
packet << uint8(1); // 1...31
|
||||
packet << m_Seed;
|
||||
packet << uint8(1);
|
||||
|
||||
if (SendPacket (packet) == -1)
|
||||
return -1;
|
||||
|
|
@ -275,7 +274,14 @@ int WorldSocket::open(void* a)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int WorldSocket::close(int)
|
||||
int WorldSocket::HandleWowConnection(WorldPacket& recvPacket)
|
||||
{
|
||||
std::string ClientToServerMsg;
|
||||
recvPacket >> ClientToServerMsg;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WorldSocket::close (int)
|
||||
{
|
||||
shutdown();
|
||||
|
||||
|
|
@ -744,81 +750,67 @@ int WorldSocket::ProcessIncoming(WorldPacket* new_pct)
|
|||
ACE_NOTREACHED(return 0);
|
||||
}
|
||||
|
||||
int WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
|
||||
int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
|
||||
{
|
||||
// NOTE: ATM the socket is singlethread, have this in mind ...
|
||||
uint8 digest[20];
|
||||
uint16 ClientBuild, security;
|
||||
uint32 clientSeed, id, expansion, addonsSize;
|
||||
uint16 clientBuild, security;
|
||||
uint32 id, m_addonSize, clientSeed, expansion;
|
||||
std::string accountName;
|
||||
LocaleConstant locale;
|
||||
std::string account;
|
||||
|
||||
Sha1Hash sha1;
|
||||
BigNumber v, s, g, N, K;
|
||||
WorldPacket packet;
|
||||
|
||||
// Read the content of the packet
|
||||
uint32 unkInt32[6];
|
||||
int8 curr = 0;
|
||||
recvPacket >> unkInt32[curr++];
|
||||
recvPacket >> unkInt32[curr++];
|
||||
recvPacket.read_skip<uint32>();
|
||||
recvPacket.read_skip<uint32>();
|
||||
recvPacket.read_skip<uint8>();
|
||||
recvPacket >> digest[10];
|
||||
recvPacket >> digest[18];
|
||||
recvPacket >> digest[12];
|
||||
recvPacket >> digest[5];
|
||||
recvPacket.read(digest, 4);
|
||||
recvPacket.read_skip<uint64>();
|
||||
recvPacket >> digest[15];
|
||||
recvPacket >> digest[9];
|
||||
recvPacket >> digest[19];
|
||||
recvPacket >> digest[4];
|
||||
recvPacket >> digest[7];
|
||||
recvPacket >> digest[16];
|
||||
recvPacket >> digest[3];
|
||||
recvPacket >> ClientBuild;
|
||||
recvPacket >> digest[8];
|
||||
recvPacket >> unkInt32[curr++];
|
||||
recvPacket.read(digest, 7);
|
||||
recvPacket >> clientBuild;
|
||||
recvPacket.read(digest, 1);
|
||||
recvPacket.read_skip<uint32>();
|
||||
recvPacket.read_skip<uint8>();
|
||||
recvPacket >> digest[17];
|
||||
recvPacket >> digest[6];
|
||||
recvPacket >> digest[0];
|
||||
recvPacket >> digest[1];
|
||||
recvPacket >> digest[11];
|
||||
recvPacket.read(digest, 5);
|
||||
recvPacket.read_skip<uint32>();
|
||||
recvPacket.read(digest, 1);
|
||||
recvPacket >> clientSeed;
|
||||
recvPacket >> digest[2];
|
||||
recvPacket >> unkInt32[curr++];
|
||||
recvPacket >> digest[14];
|
||||
recvPacket >> digest[13];
|
||||
size_t _beforeAddonSize = recvPacket.rpos();
|
||||
recvPacket >> addonsSize;
|
||||
recvPacket.read_skip(addonsSize);
|
||||
recvPacket.read(digest, 2);
|
||||
|
||||
uint8 _size[2];
|
||||
recvPacket >> _size[0];
|
||||
recvPacket >> _size[1];
|
||||
uint8 size = (_size[0] << 4) | _size[1] >> 3;
|
||||
account.resize(size);
|
||||
recvPacket.read((uint8*)account.data(), size);
|
||||
recvPacket >> m_addonSize; // addon data size
|
||||
|
||||
size_t addonInfoPos = recvPacket.rpos();
|
||||
recvPacket.rpos(recvPacket.rpos() + m_addonSize); // skip it
|
||||
|
||||
recvPacket.read_skip<uint8>();
|
||||
recvPacket.read_skip<uint8>();
|
||||
|
||||
recvPacket.FlushBits();
|
||||
|
||||
recvPacket >> accountName;
|
||||
|
||||
DEBUG_LOG("WorldSocket::HandleAuthSession: client build %u, account %s, clientseed %X",
|
||||
ClientBuild,
|
||||
account.c_str(),
|
||||
clientSeed);
|
||||
clientBuild,
|
||||
accountName.c_str(),
|
||||
clientSeed);
|
||||
|
||||
// Check the version of client trying to connect
|
||||
if (!IsAcceptableClientBuild(ClientBuild))
|
||||
if(!IsAcceptableClientBuild(clientBuild))
|
||||
{
|
||||
packet.Initialize(SMSG_AUTH_RESPONSE, 1);
|
||||
packet << uint8(AUTH_VERSION_MISMATCH);
|
||||
packet.Initialize (SMSG_AUTH_RESPONSE, 1);
|
||||
packet << uint8 (AUTH_VERSION_MISMATCH);
|
||||
|
||||
SendPacket(packet);
|
||||
SendPacket (packet);
|
||||
|
||||
sLog.outError("WorldSocket::HandleAuthSession: Sent Auth Response (version mismatch).");
|
||||
sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (version mismatch).");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Get the account information from the realmd database
|
||||
std::string safe_account = account; // Duplicate, else will screw the SHA hash verification below
|
||||
LoginDatabase.escape_string(safe_account);
|
||||
std::string safe_account = accountName; // Duplicate, else will screw the SHA hash verification below
|
||||
LoginDatabase.escape_string (safe_account);
|
||||
// No SQL injection, username escaped.
|
||||
|
||||
QueryResult* result =
|
||||
|
|
@ -840,44 +832,44 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
|
|||
// Stop if the account is not found
|
||||
if (!result)
|
||||
{
|
||||
packet.Initialize(SMSG_AUTH_RESPONSE, 1);
|
||||
packet << uint8(AUTH_UNKNOWN_ACCOUNT);
|
||||
packet.Initialize (SMSG_AUTH_RESPONSE, 1);
|
||||
packet << uint8 (AUTH_UNKNOWN_ACCOUNT);
|
||||
|
||||
SendPacket(packet);
|
||||
SendPacket (packet);
|
||||
|
||||
sLog.outError("WorldSocket::HandleAuthSession: Sent Auth Response (unknown account).");
|
||||
sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (unknown account).");
|
||||
return -1;
|
||||
}
|
||||
|
||||
Field* fields = result->Fetch();
|
||||
Field* fields = result->Fetch ();
|
||||
|
||||
expansion = ((sWorld.getConfig(CONFIG_UINT32_EXPANSION) > fields[7].GetUInt8()) ? fields[7].GetUInt8() : sWorld.getConfig(CONFIG_UINT32_EXPANSION));
|
||||
|
||||
N.SetHexStr("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7");
|
||||
g.SetDword(7);
|
||||
N.SetHexStr ("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7");
|
||||
g.SetDword (7);
|
||||
|
||||
v.SetHexStr(fields[5].GetString());
|
||||
s.SetHexStr(fields[6].GetString());
|
||||
s.SetHexStr (fields[6].GetString());
|
||||
m_s = s;
|
||||
|
||||
const char* sStr = s.AsHexStr(); // Must be freed by OPENSSL_free()
|
||||
const char* vStr = v.AsHexStr(); // Must be freed by OPENSSL_free()
|
||||
const char* sStr = s.AsHexStr (); //Must be freed by OPENSSL_free()
|
||||
const char* vStr = v.AsHexStr (); //Must be freed by OPENSSL_free()
|
||||
|
||||
DEBUG_LOG("WorldSocket::HandleAuthSession: (s,v) check s: %s v: %s",
|
||||
sStr,
|
||||
vStr);
|
||||
DEBUG_LOG ("WorldSocket::HandleAuthSession: (s,v) check s: %s v: %s",
|
||||
sStr,
|
||||
vStr);
|
||||
|
||||
OPENSSL_free((void*) sStr);
|
||||
OPENSSL_free((void*) vStr);
|
||||
OPENSSL_free ((void*) sStr);
|
||||
OPENSSL_free ((void*) vStr);
|
||||
|
||||
///- Re-check ip locking (same check as in realmd).
|
||||
if (fields[4].GetUInt8() == 1) // if ip is locked
|
||||
if (fields[4].GetUInt8 () == 1) // if ip is locked
|
||||
{
|
||||
if (strcmp(fields[3].GetString(), GetRemoteAddress().c_str()))
|
||||
if (strcmp (fields[3].GetString (), GetRemoteAddress ().c_str ()))
|
||||
{
|
||||
packet.Initialize(SMSG_AUTH_RESPONSE, 1);
|
||||
packet << uint8(AUTH_FAILED);
|
||||
SendPacket(packet);
|
||||
packet.Initialize (SMSG_AUTH_RESPONSE, 1);
|
||||
packet << uint8 (AUTH_FAILED);
|
||||
SendPacket (packet);
|
||||
|
||||
delete result;
|
||||
BASIC_LOG("WorldSocket::HandleAuthSession: Sent Auth Response (Account IP differs).");
|
||||
|
|
@ -887,47 +879,47 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
|
|||
|
||||
id = fields[0].GetUInt32();
|
||||
security = fields[1].GetUInt16();
|
||||
if (security > SEC_ADMINISTRATOR) // prevent invalid security settings in DB
|
||||
if(security > SEC_ADMINISTRATOR) // prevent invalid security settings in DB
|
||||
security = SEC_ADMINISTRATOR;
|
||||
|
||||
K.SetHexStr(fields[2].GetString());
|
||||
K.SetHexStr (fields[2].GetString ());
|
||||
|
||||
time_t mutetime = time_t (fields[8].GetUInt64());
|
||||
time_t mutetime = time_t (fields[8].GetUInt64 ());
|
||||
|
||||
locale = LocaleConstant(fields[9].GetUInt8());
|
||||
locale = LocaleConstant (fields[9].GetUInt8 ());
|
||||
if (locale >= MAX_LOCALE)
|
||||
locale = LOCALE_enUS;
|
||||
|
||||
delete result;
|
||||
|
||||
// Re-check account ban (same check as in realmd)
|
||||
QueryResult* banresult =
|
||||
LoginDatabase.PQuery("SELECT 1 FROM account_banned WHERE id = %u AND active = 1 AND (unbandate > UNIX_TIMESTAMP() OR unbandate = bandate)"
|
||||
"UNION "
|
||||
"SELECT 1 FROM ip_banned WHERE (unbandate = bandate OR unbandate > UNIX_TIMESTAMP()) AND ip = '%s'",
|
||||
id, GetRemoteAddress().c_str());
|
||||
QueryResult *banresult =
|
||||
LoginDatabase.PQuery ("SELECT 1 FROM account_banned WHERE id = %u AND active = 1 AND (unbandate > UNIX_TIMESTAMP() OR unbandate = bandate)"
|
||||
"UNION "
|
||||
"SELECT 1 FROM ip_banned WHERE (unbandate = bandate OR unbandate > UNIX_TIMESTAMP()) AND ip = '%s'",
|
||||
id, GetRemoteAddress().c_str());
|
||||
|
||||
if (banresult) // if account banned
|
||||
{
|
||||
packet.Initialize(SMSG_AUTH_RESPONSE, 1);
|
||||
packet << uint8(AUTH_BANNED);
|
||||
SendPacket(packet);
|
||||
packet.Initialize (SMSG_AUTH_RESPONSE, 1);
|
||||
packet << uint8 (AUTH_BANNED);
|
||||
SendPacket (packet);
|
||||
|
||||
delete banresult;
|
||||
|
||||
sLog.outError("WorldSocket::HandleAuthSession: Sent Auth Response (Account banned).");
|
||||
sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (Account banned).");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Check locked state for server
|
||||
AccountTypes allowedAccountType = sWorld.GetPlayerSecurityLimit();
|
||||
AccountTypes allowedAccountType = sWorld.GetPlayerSecurityLimit ();
|
||||
|
||||
if (allowedAccountType > SEC_PLAYER && AccountTypes(security) < allowedAccountType)
|
||||
{
|
||||
WorldPacket Packet(SMSG_AUTH_RESPONSE, 1);
|
||||
Packet << uint8(AUTH_UNAVAILABLE);
|
||||
WorldPacket Packet (SMSG_AUTH_RESPONSE, 1);
|
||||
Packet << uint8 (AUTH_UNAVAILABLE);
|
||||
|
||||
SendPacket(packet);
|
||||
SendPacket (packet);
|
||||
|
||||
BASIC_LOG("WorldSocket::HandleAuthSession: User tries to login but his security level is not enough");
|
||||
return -1;
|
||||
|
|
@ -939,39 +931,39 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
|
|||
uint32 t = 0;
|
||||
uint32 seed = m_Seed;
|
||||
|
||||
sha.UpdateData(account);
|
||||
sha.UpdateData((uint8*) & t, 4);
|
||||
sha.UpdateData((uint8*) & clientSeed, 4);
|
||||
sha.UpdateData((uint8*) & seed, 4);
|
||||
sha.UpdateBigNumbers(&K, NULL);
|
||||
sha.Finalize();
|
||||
sha.UpdateData (accountName);
|
||||
sha.UpdateData ((uint8 *) & t, 4);
|
||||
sha.UpdateData ((uint8 *) & clientSeed, 4);
|
||||
sha.UpdateData ((uint8 *) & seed, 4);
|
||||
sha.UpdateBigNumbers (&K, NULL);
|
||||
sha.Finalize ();
|
||||
|
||||
if (memcmp(sha.GetDigest(), digest, 20))
|
||||
/*if (memcmp (sha.GetDigest (), digest, 20))
|
||||
{
|
||||
packet.Initialize(SMSG_AUTH_RESPONSE, 1);
|
||||
packet << uint8(AUTH_FAILED);
|
||||
packet.Initialize (SMSG_AUTH_RESPONSE, 1);
|
||||
packet << uint8 (AUTH_FAILED);
|
||||
|
||||
SendPacket(packet);
|
||||
SendPacket (packet);
|
||||
|
||||
sLog.outError("WorldSocket::HandleAuthSession: Sent Auth Response (authentification failed).");
|
||||
sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (authentification failed).");
|
||||
return -1;
|
||||
}
|
||||
}*/
|
||||
|
||||
std::string address = GetRemoteAddress();
|
||||
std::string address = GetRemoteAddress ();
|
||||
|
||||
DEBUG_LOG("WorldSocket::HandleAuthSession: Client '%s' authenticated successfully from %s.",
|
||||
account.c_str(),
|
||||
address.c_str());
|
||||
DEBUG_LOG ("WorldSocket::HandleAuthSession: Client '%s' authenticated successfully from %s.",
|
||||
accountName.c_str (),
|
||||
address.c_str ());
|
||||
|
||||
// Update the last_ip in the database
|
||||
// No SQL injection, username escaped.
|
||||
static SqlStatementID updAccount;
|
||||
|
||||
SqlStatement stmt = LoginDatabase.CreateStatement(updAccount, "UPDATE account SET last_ip = ? WHERE username = ?");
|
||||
stmt.PExecute(address.c_str(), account.c_str());
|
||||
stmt.PExecute(address.c_str(), accountName.c_str());
|
||||
|
||||
// NOTE ATM the socket is single-threaded, have this in mind ...
|
||||
ACE_NEW_RETURN(m_Session, WorldSession(id, this, AccountTypes(security), expansion, mutetime, locale), -1);
|
||||
ACE_NEW_RETURN (m_Session, WorldSession (id, this, AccountTypes(security), expansion, mutetime, locale), -1);
|
||||
|
||||
m_Crypt.Init(&K);
|
||||
|
||||
|
|
@ -980,9 +972,9 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
|
|||
m_Session->ReadAddonsInfo(recvPacket);
|
||||
|
||||
// In case needed sometime the second arg is in microseconds 1 000 000 = 1 sec
|
||||
ACE_OS::sleep(ACE_Time_Value(0, 10000));
|
||||
ACE_OS::sleep (ACE_Time_Value (0, 10000));
|
||||
|
||||
sWorld.AddSession(m_Session);
|
||||
sWorld.AddSession (m_Session);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1049,11 +1041,3 @@ int WorldSocket::HandlePing(WorldPacket& recvPacket)
|
|||
packet << ping;
|
||||
return SendPacket(packet);
|
||||
}
|
||||
|
||||
int WorldSocket::HandleWowConnection(WorldPacket& recv_packet)
|
||||
{
|
||||
std::string msgFromClient;
|
||||
recv_packet >> msgFromClient;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,6 +131,8 @@ class WorldSocket : protected WorldHandler
|
|||
virtual ~WorldSocket(void);
|
||||
|
||||
/// Called on open ,the void* is the acceptor.
|
||||
int HandleWowConnection(WorldPacket& recvPacket);
|
||||
|
||||
virtual int open(void*) override;
|
||||
|
||||
/// Called on failures inside of the acceptor, don't call from your code.
|
||||
|
|
@ -173,9 +175,6 @@ class WorldSocket : protected WorldHandler
|
|||
/// Called by ProcessIncoming() on CMSG_PING.
|
||||
int HandlePing(WorldPacket& recvPacket);
|
||||
|
||||
/// Called by ProcessIncoming() on MSG_WOW_CONNECTION
|
||||
int HandleWowConnection(WorldPacket& recvPacket);
|
||||
|
||||
private:
|
||||
/// Time in which the last ping was received
|
||||
ACE_Time_Value m_LastPingTime;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue