mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-24 22:47:25 +00:00
chore: continue work on removing raw packet reading (#1404)
* chore: continue work on removing raw packet reading tested that logging in, deleted a char, renaming a char, and transfeering to a zone all work still * Address Feedback
This commit is contained in:
parent
b683413a60
commit
dbe4a0ced3
@ -2,7 +2,6 @@
|
|||||||
#include "PlayerContainer.h"
|
#include "PlayerContainer.h"
|
||||||
#include "eChatInternalMessageType.h"
|
#include "eChatInternalMessageType.h"
|
||||||
#include "BitStreamUtils.h"
|
#include "BitStreamUtils.h"
|
||||||
#include "PacketUtils.h"
|
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "eObjectBits.h"
|
#include "eObjectBits.h"
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include "CDClientManager.h"
|
#include "CDClientManager.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "PacketUtils.h"
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include "CDDestructibleComponentTable.h"
|
#include "CDDestructibleComponentTable.h"
|
||||||
#include "CDClientDatabase.h"
|
#include "CDClientDatabase.h"
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#include "SkillComponent.h"
|
#include "SkillComponent.h"
|
||||||
#include "SwitchComponent.h"
|
#include "SwitchComponent.h"
|
||||||
#include "UserManager.h"
|
#include "UserManager.h"
|
||||||
#include "PacketUtils.h"
|
|
||||||
#include "Metrics.hpp"
|
#include "Metrics.hpp"
|
||||||
#include "dZoneManager.h"
|
#include "dZoneManager.h"
|
||||||
#include "MissionComponent.h"
|
#include "MissionComponent.h"
|
||||||
@ -389,8 +388,6 @@ void EntityManager::ConstructEntity(Entity* entity, const SystemAddress& sysAddr
|
|||||||
Game::server->Send(&stream, sysAddr, false);
|
Game::server->Send(&stream, sysAddr, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// PacketUtils::SavePacket("[24]_"+std::to_string(entity->GetObjectID()) + "_" + std::to_string(m_SerializationCounter) + ".bin", (char*)stream.GetData(), stream.GetNumberOfBytesUsed());
|
|
||||||
|
|
||||||
if (entity->IsPlayer()) {
|
if (entity->IsPlayer()) {
|
||||||
if (entity->GetGMLevel() > eGameMasterLevel::CIVILIAN) {
|
if (entity->GetGMLevel() > eGameMasterLevel::CIVILIAN) {
|
||||||
GameMessages::SendToggleGMInvis(entity->GetObjectID(), true, sysAddr);
|
GameMessages::SendToggleGMInvis(entity->GetObjectID(), true, sysAddr);
|
||||||
@ -434,8 +431,6 @@ void EntityManager::SerializeEntity(Entity* entity) {
|
|||||||
if (std::find(m_EntitiesToSerialize.begin(), m_EntitiesToSerialize.end(), entity->GetObjectID()) == m_EntitiesToSerialize.end()) {
|
if (std::find(m_EntitiesToSerialize.begin(), m_EntitiesToSerialize.end(), entity->GetObjectID()) == m_EntitiesToSerialize.end()) {
|
||||||
m_EntitiesToSerialize.push_back(entity->GetObjectID());
|
m_EntitiesToSerialize.push_back(entity->GetObjectID());
|
||||||
}
|
}
|
||||||
|
|
||||||
//PacketUtils::SavePacket(std::to_string(m_SerializationCounter) + "_[27]_"+std::to_string(entity->GetObjectID()) + ".bin", (char*)stream.GetData(), stream.GetNumberOfBytesUsed());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityManager::DestructAllEntities(const SystemAddress& sysAddr) {
|
void EntityManager::DestructAllEntities(const SystemAddress& sysAddr) {
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#include "WorldPackets.h"
|
#include "WorldPackets.h"
|
||||||
#include "Character.h"
|
#include "Character.h"
|
||||||
#include "BitStream.h"
|
#include "BitStream.h"
|
||||||
#include "PacketUtils.h"
|
|
||||||
#include "ObjectIDManager.h"
|
#include "ObjectIDManager.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "GeneralUtils.h"
|
#include "GeneralUtils.h"
|
||||||
@ -268,24 +267,40 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet)
|
|||||||
User* u = GetUser(sysAddr);
|
User* u = GetUser(sysAddr);
|
||||||
if (!u) return;
|
if (!u) return;
|
||||||
|
|
||||||
std::string name = PacketUtils::ReadString(8, packet, true);
|
LUWString LUWStringName(33);
|
||||||
|
uint32_t firstNameIndex;
|
||||||
|
uint32_t middleNameIndex;
|
||||||
|
uint32_t lastNameIndex;
|
||||||
|
uint32_t shirtColor;
|
||||||
|
uint32_t shirtStyle;
|
||||||
|
uint32_t pantsColor;
|
||||||
|
uint32_t hairStyle;
|
||||||
|
uint32_t hairColor;
|
||||||
|
uint32_t lh;
|
||||||
|
uint32_t rh;
|
||||||
|
uint32_t eyebrows;
|
||||||
|
uint32_t eyes;
|
||||||
|
uint32_t mouth;
|
||||||
|
|
||||||
uint32_t firstNameIndex = PacketUtils::ReadU32(74, packet);
|
CINSTREAM_SKIP_HEADER;
|
||||||
uint32_t middleNameIndex = PacketUtils::ReadU32(78, packet);
|
inStream.Read(LUWStringName);
|
||||||
uint32_t lastNameIndex = PacketUtils::ReadU32(82, packet);
|
inStream.Read(firstNameIndex);
|
||||||
|
inStream.Read(middleNameIndex);
|
||||||
|
inStream.Read(lastNameIndex);
|
||||||
|
inStream.IgnoreBytes(9);
|
||||||
|
inStream.Read(shirtColor);
|
||||||
|
inStream.Read(shirtStyle);
|
||||||
|
inStream.Read(pantsColor);
|
||||||
|
inStream.Read(hairStyle);
|
||||||
|
inStream.Read(hairColor);
|
||||||
|
inStream.Read(lh);
|
||||||
|
inStream.Read(rh);
|
||||||
|
inStream.Read(eyebrows);
|
||||||
|
inStream.Read(eyes);
|
||||||
|
inStream.Read(mouth);
|
||||||
|
|
||||||
|
const auto name = LUWStringName.GetAsString();
|
||||||
std::string predefinedName = GetPredefinedName(firstNameIndex, middleNameIndex, lastNameIndex);
|
std::string predefinedName = GetPredefinedName(firstNameIndex, middleNameIndex, lastNameIndex);
|
||||||
|
|
||||||
uint32_t shirtColor = PacketUtils::ReadU32(95, packet);
|
|
||||||
uint32_t shirtStyle = PacketUtils::ReadU32(99, packet);
|
|
||||||
uint32_t pantsColor = PacketUtils::ReadU32(103, packet);
|
|
||||||
uint32_t hairStyle = PacketUtils::ReadU32(107, packet);
|
|
||||||
uint32_t hairColor = PacketUtils::ReadU32(111, packet);
|
|
||||||
uint32_t lh = PacketUtils::ReadU32(115, packet);
|
|
||||||
uint32_t rh = PacketUtils::ReadU32(119, packet);
|
|
||||||
uint32_t eyebrows = PacketUtils::ReadU32(123, packet);
|
|
||||||
uint32_t eyes = PacketUtils::ReadU32(127, packet);
|
|
||||||
uint32_t mouth = PacketUtils::ReadU32(131, packet);
|
|
||||||
|
|
||||||
LOT shirtLOT = FindCharShirtID(shirtColor, shirtStyle);
|
LOT shirtLOT = FindCharShirtID(shirtColor, shirtStyle);
|
||||||
LOT pantsLOT = FindCharPantsID(pantsColor);
|
LOT pantsLOT = FindCharPantsID(pantsColor);
|
||||||
|
|
||||||
@ -377,7 +392,9 @@ void UserManager::DeleteCharacter(const SystemAddress& sysAddr, Packet* packet)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LWOOBJID objectID = PacketUtils::ReadS64(8, packet);
|
CINSTREAM_SKIP_HEADER;
|
||||||
|
LWOOBJID objectID;
|
||||||
|
inStream.Read(objectID);
|
||||||
uint32_t charID = static_cast<uint32_t>(objectID);
|
uint32_t charID = static_cast<uint32_t>(objectID);
|
||||||
|
|
||||||
LOG("Received char delete req for ID: %llu (%u)", objectID, charID);
|
LOG("Received char delete req for ID: %llu (%u)", objectID, charID);
|
||||||
@ -411,14 +428,18 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LWOOBJID objectID = PacketUtils::ReadS64(8, packet);
|
CINSTREAM_SKIP_HEADER;
|
||||||
|
LWOOBJID objectID;
|
||||||
|
inStream.Read(objectID);
|
||||||
GeneralUtils::ClearBit(objectID, eObjectBits::CHARACTER);
|
GeneralUtils::ClearBit(objectID, eObjectBits::CHARACTER);
|
||||||
GeneralUtils::ClearBit(objectID, eObjectBits::PERSISTENT);
|
GeneralUtils::ClearBit(objectID, eObjectBits::PERSISTENT);
|
||||||
|
|
||||||
uint32_t charID = static_cast<uint32_t>(objectID);
|
uint32_t charID = static_cast<uint32_t>(objectID);
|
||||||
LOG("Received char rename request for ID: %llu (%u)", objectID, charID);
|
LOG("Received char rename request for ID: %llu (%u)", objectID, charID);
|
||||||
|
|
||||||
std::string newName = PacketUtils::ReadString(16, packet, true);
|
LUWString LUWStringName(33);
|
||||||
|
inStream.Read(LUWStringName);
|
||||||
|
const auto newName = LUWStringName.GetAsString();
|
||||||
|
|
||||||
Character* character = nullptr;
|
Character* character = nullptr;
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
#include "eGameActivity.h"
|
#include "eGameActivity.h"
|
||||||
|
|
||||||
#include "dServer.h"
|
#include "dServer.h"
|
||||||
#include "PacketUtils.h"
|
|
||||||
#include "Spawner.h"
|
#include "Spawner.h"
|
||||||
#include "MovingPlatformComponent.h"
|
#include "MovingPlatformComponent.h"
|
||||||
#include "Preconditions.h"
|
#include "Preconditions.h"
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
#include "PacketUtils.h"
|
|
||||||
|
|
||||||
#include "CDClientManager.h"
|
#include "CDClientManager.h"
|
||||||
#include "GameMessages.h"
|
#include "GameMessages.h"
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include "GameMessages.h"
|
#include "GameMessages.h"
|
||||||
#include "User.h"
|
#include "User.h"
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
#include "PacketUtils.h"
|
|
||||||
#include "BitStreamUtils.h"
|
#include "BitStreamUtils.h"
|
||||||
#include "BitStream.h"
|
#include "BitStream.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
@ -1726,8 +1725,6 @@ void GameMessages::SendStartCelebrationEffect(Entity* entity, const SystemAddres
|
|||||||
bitStream.Write<uint32_t>(0); //subtext
|
bitStream.Write<uint32_t>(0); //subtext
|
||||||
|
|
||||||
SEND_PACKET;
|
SEND_PACKET;
|
||||||
|
|
||||||
//PacketUtils::SavePacket("StartCelebrationEffect.bin", (char*)bitStream.GetData(), bitStream.GetNumberOfBytesUsed());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1950,7 +1947,6 @@ void GameMessages::SendBBBSaveResponse(const LWOOBJID& objectId, const LWOOBJID&
|
|||||||
bitStream.Write(buffer[i]);
|
bitStream.Write(buffer[i]);
|
||||||
|
|
||||||
SEND_PACKET;
|
SEND_PACKET;
|
||||||
//PacketUtils::SavePacket("eGameMessageType::BBB_SAVE_RESPONSE.bin", reinterpret_cast<char*>(bitStream.GetData()), bitStream.GetNumberOfBytesUsed());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Property
|
// Property
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
#include "dServer.h"
|
#include "dServer.h"
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
#include "Character.h"
|
#include "Character.h"
|
||||||
#include "PacketUtils.h"
|
|
||||||
#include "BitStreamUtils.h"
|
#include "BitStreamUtils.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "EntityManager.h"
|
#include "EntityManager.h"
|
||||||
@ -305,7 +304,6 @@ void Mail::HandleDataRequest(RakNet::BitStream* packet, const SystemAddress& sys
|
|||||||
}
|
}
|
||||||
|
|
||||||
Game::server->Send(&bitStream, sysAddr, false);
|
Game::server->Send(&bitStream, sysAddr, false);
|
||||||
// PacketUtils::SavePacket("Max_Mail_Data.bin", (const char*)bitStream.GetData(), bitStream.GetNumberOfBytesUsed());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mail::HandleAttachmentCollect(RakNet::BitStream* packet, const SystemAddress& sysAddr, Entity* player) {
|
void Mail::HandleAttachmentCollect(RakNet::BitStream* packet, const SystemAddress& sysAddr, Entity* player) {
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
#include "InstanceManager.h"
|
#include "InstanceManager.h"
|
||||||
#include "MasterPackets.h"
|
#include "MasterPackets.h"
|
||||||
#include "PersistentIDManager.h"
|
#include "PersistentIDManager.h"
|
||||||
#include "PacketUtils.h"
|
|
||||||
#include "FdbToSqlite.h"
|
#include "FdbToSqlite.h"
|
||||||
#include "BitStreamUtils.h"
|
#include "BitStreamUtils.h"
|
||||||
#include "Start.h"
|
#include "Start.h"
|
||||||
@ -504,17 +503,17 @@ void HandlePacket(Packet* packet) {
|
|||||||
uint32_t theirZoneID = 0;
|
uint32_t theirZoneID = 0;
|
||||||
uint32_t theirInstanceID = 0;
|
uint32_t theirInstanceID = 0;
|
||||||
ServerType theirServerType;
|
ServerType theirServerType;
|
||||||
std::string theirIP = "";
|
LUString theirIP(33);
|
||||||
|
|
||||||
inStream.Read(theirPort);
|
inStream.Read(theirPort);
|
||||||
inStream.Read(theirZoneID);
|
inStream.Read(theirZoneID);
|
||||||
inStream.Read(theirInstanceID);
|
inStream.Read(theirInstanceID);
|
||||||
inStream.Read(theirServerType);
|
inStream.Read(theirServerType);
|
||||||
theirIP = PacketUtils::ReadString(24, packet, false); //24 is the current offset
|
inStream.Read(theirIP);
|
||||||
|
|
||||||
if (theirServerType == ServerType::World) {
|
if (theirServerType == ServerType::World) {
|
||||||
if (!Game::im->IsPortInUse(theirPort)) {
|
if (!Game::im->IsPortInUse(theirPort)) {
|
||||||
Instance* in = new Instance(theirIP, theirPort, theirZoneID, theirInstanceID, 0, 12, 12);
|
Instance* in = new Instance(theirIP.string, theirPort, theirZoneID, theirInstanceID, 0, 12, 12);
|
||||||
|
|
||||||
SystemAddress copy;
|
SystemAddress copy;
|
||||||
copy.binaryAddress = packet->systemAddress.binaryAddress;
|
copy.binaryAddress = packet->systemAddress.binaryAddress;
|
||||||
@ -553,47 +552,42 @@ void HandlePacket(Packet* packet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case eMasterMessageType::SET_SESSION_KEY: {
|
case eMasterMessageType::SET_SESSION_KEY: {
|
||||||
RakNet::BitStream inStream(packet->data, packet->length, false);
|
CINSTREAM_SKIP_HEADER;
|
||||||
uint64_t header = inStream.Read(header);
|
|
||||||
uint32_t sessionKey = 0;
|
uint32_t sessionKey = 0;
|
||||||
std::string username;
|
|
||||||
|
|
||||||
inStream.Read(sessionKey);
|
inStream.Read(sessionKey);
|
||||||
username = PacketUtils::ReadString(12, packet, false);
|
LUString username(33);
|
||||||
|
inStream.Read(username);
|
||||||
|
|
||||||
for (auto it : activeSessions) {
|
for (auto it : activeSessions) {
|
||||||
if (it.second == username) {
|
if (it.second == username.string) {
|
||||||
activeSessions.erase(it.first);
|
activeSessions.erase(it.first);
|
||||||
|
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::NEW_SESSION_ALERT);
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::NEW_SESSION_ALERT);
|
||||||
bitStream.Write(sessionKey);
|
bitStream.Write(sessionKey);
|
||||||
bitStream.Write<uint32_t>(username.size());
|
bitStream.Write(username);
|
||||||
for (auto character : username) {
|
|
||||||
bitStream.Write(character);
|
|
||||||
}
|
|
||||||
SEND_PACKET_BROADCAST;
|
SEND_PACKET_BROADCAST;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
activeSessions.insert(std::make_pair(sessionKey, username));
|
activeSessions.insert(std::make_pair(sessionKey, username.string));
|
||||||
LOG("Got sessionKey %i for user %s", sessionKey, username.c_str());
|
LOG("Got sessionKey %i for user %s", sessionKey, username.string.c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eMasterMessageType::REQUEST_SESSION_KEY: {
|
case eMasterMessageType::REQUEST_SESSION_KEY: {
|
||||||
RakNet::BitStream inStream(packet->data, packet->length, false);
|
CINSTREAM_SKIP_HEADER;
|
||||||
uint64_t header = inStream.Read(header);
|
LUWString username(33);
|
||||||
std::string username = PacketUtils::ReadString(8, packet, false);
|
inStream.Read(username);
|
||||||
|
LOG("Requesting session key for %s", username.GetAsString().c_str());
|
||||||
for (auto key : activeSessions) {
|
for (auto key : activeSessions) {
|
||||||
if (key.second == username) {
|
if (key.second == username.GetAsString()) {
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::SESSION_KEY_RESPONSE);
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::SESSION_KEY_RESPONSE);
|
||||||
bitStream.Write(key.first);
|
bitStream.Write(key.first);
|
||||||
bitStream.Write(LUString(key.second, 64));
|
bitStream.Write(username);
|
||||||
Game::server->Send(&bitStream, packet->systemAddress, false);
|
Game::server->Send(&bitStream, packet->systemAddress, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "AuthPackets.h"
|
#include "AuthPackets.h"
|
||||||
#include "PacketUtils.h"
|
|
||||||
#include "BitStreamUtils.h"
|
#include "BitStreamUtils.h"
|
||||||
|
|
||||||
#include "dNetCommon.h"
|
#include "dNetCommon.h"
|
||||||
@ -297,13 +296,12 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd
|
|||||||
for (auto& stamp : stamps) stamp.Serialize(&loginResponse);
|
for (auto& stamp : stamps) stamp.Serialize(&loginResponse);
|
||||||
|
|
||||||
server->Send(&loginResponse, sysAddr, false);
|
server->Send(&loginResponse, sysAddr, false);
|
||||||
|
|
||||||
//Inform the master server that we've created a session for this user:
|
//Inform the master server that we've created a session for this user:
|
||||||
if (responseCode == eLoginResponse::SUCCESS) {
|
if (responseCode == eLoginResponse::SUCCESS) {
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::SET_SESSION_KEY);
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::SET_SESSION_KEY);
|
||||||
bitStream.Write(sessionKey);
|
bitStream.Write(sessionKey);
|
||||||
bitStream.Write(LUString(username, 66));
|
bitStream.Write(LUString(username));
|
||||||
server->SendToMaster(&bitStream);
|
server->SendToMaster(&bitStream);
|
||||||
|
|
||||||
LOG("Set sessionKey: %i for user %s", sessionKey, username.c_str());
|
LOG("Set sessionKey: %i for user %s", sessionKey, username.c_str());
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
#include "RakNetTypes.h"
|
#include "RakNetTypes.h"
|
||||||
#include "BitStream.h"
|
#include "BitStream.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include "PacketUtils.h"
|
|
||||||
#include "BitStreamUtils.h"
|
#include "BitStreamUtils.h"
|
||||||
#include "dServer.h"
|
#include "dServer.h"
|
||||||
#include "eConnectionType.h"
|
#include "eConnectionType.h"
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "MasterPackets.h"
|
#include "MasterPackets.h"
|
||||||
#include "BitStream.h"
|
#include "BitStream.h"
|
||||||
#include "PacketUtils.h"
|
|
||||||
#include "dCommonVars.h"
|
#include "dCommonVars.h"
|
||||||
#include "dServer.h"
|
#include "dServer.h"
|
||||||
#include "eConnectionType.h"
|
#include "eConnectionType.h"
|
||||||
@ -88,7 +87,7 @@ void MasterPackets::SendZoneTransferResponse(dServer* server, const SystemAddres
|
|||||||
bitStream.Write(zoneInstance);
|
bitStream.Write(zoneInstance);
|
||||||
bitStream.Write(zoneClone);
|
bitStream.Write(zoneClone);
|
||||||
bitStream.Write<uint16_t>(serverPort);
|
bitStream.Write<uint16_t>(serverPort);
|
||||||
bitStream.Write(LUString(serverIP, static_cast<uint32_t>(serverIP.size() + 1)));
|
bitStream.Write(LUString(serverIP, 255));
|
||||||
|
|
||||||
server->Send(&bitStream, sysAddr, false);
|
server->Send(&bitStream, sysAddr, false);
|
||||||
}
|
}
|
||||||
@ -100,12 +99,12 @@ void MasterPackets::HandleServerInfo(Packet* packet) {
|
|||||||
uint32_t theirPort = 0;
|
uint32_t theirPort = 0;
|
||||||
uint32_t theirZoneID = 0;
|
uint32_t theirZoneID = 0;
|
||||||
uint32_t theirInstanceID = 0;
|
uint32_t theirInstanceID = 0;
|
||||||
std::string theirIP = "";
|
LUString theirIP(33);
|
||||||
|
|
||||||
inStream.Read(theirPort);
|
inStream.Read(theirPort);
|
||||||
inStream.Read(theirZoneID);
|
inStream.Read(theirZoneID);
|
||||||
inStream.Read(theirInstanceID);
|
inStream.Read(theirInstanceID);
|
||||||
theirIP = PacketUtils::ReadString(inStream.GetReadOffset(), packet, false); //20 is the current offset
|
inStream.Read(theirIP);
|
||||||
|
|
||||||
//TODO: Actually mark this server as an available server in the manager
|
//TODO: Actually mark this server as an available server in the manager
|
||||||
}
|
}
|
||||||
@ -118,7 +117,7 @@ void MasterPackets::SendServerInfo(dServer* server, Packet* packet) {
|
|||||||
bitStream.Write(server->GetZoneID());
|
bitStream.Write(server->GetZoneID());
|
||||||
bitStream.Write(server->GetInstanceID());
|
bitStream.Write(server->GetInstanceID());
|
||||||
bitStream.Write(server->GetServerType());
|
bitStream.Write(server->GetServerType());
|
||||||
bitStream.Write(LUString(server->GetIP(), server->GetIP().size()));
|
bitStream.Write(LUString(server->GetIP()));
|
||||||
|
|
||||||
server->SendToMaster(&bitStream);
|
server->SendToMaster(&bitStream);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include "WorldPackets.h"
|
#include "WorldPackets.h"
|
||||||
#include "dCommonVars.h"
|
#include "dCommonVars.h"
|
||||||
#include "BitStream.h"
|
#include "BitStream.h"
|
||||||
#include "PacketUtils.h"
|
|
||||||
#include "GeneralUtils.h"
|
#include "GeneralUtils.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
// Custom Classes
|
// Custom Classes
|
||||||
#include "MasterPackets.h"
|
#include "MasterPackets.h"
|
||||||
#include "PacketUtils.h"
|
|
||||||
#include "dServer.h"
|
#include "dServer.h"
|
||||||
|
|
||||||
// C++
|
// C++
|
||||||
@ -25,20 +24,30 @@ void ZoneInstanceManager::RequestZoneTransfer(dServer* server, uint32_t zoneID,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Handles a zone transfer response
|
//! Handles a zone transfer response
|
||||||
void ZoneInstanceManager::HandleRequestZoneTransferResponse(uint64_t requestID, Packet* packet) {
|
void ZoneInstanceManager::HandleRequestZoneTransferResponse(Packet* packet) {
|
||||||
|
CINSTREAM_SKIP_HEADER;
|
||||||
bool mythranShift = static_cast<bool>(packet->data[16]);
|
uint64_t requestID;
|
||||||
uint32_t zoneID = PacketUtils::ReadU32(17, packet);
|
inStream.Read(requestID);
|
||||||
uint32_t zoneInstance = PacketUtils::ReadU32(21, packet);
|
bool mythranShift;
|
||||||
uint32_t zoneClone = PacketUtils::ReadU32(25, packet);
|
uint8_t tmp;
|
||||||
uint16_t serverPort = PacketUtils::ReadU16(29, packet);
|
inStream.Read(tmp);
|
||||||
std::string serverIP = PacketUtils::ReadString(31, packet, false);
|
mythranShift = tmp > 0;
|
||||||
|
uint32_t zoneID;
|
||||||
|
inStream.Read(zoneID);
|
||||||
|
uint32_t zoneInstance;
|
||||||
|
inStream.Read(zoneInstance);
|
||||||
|
uint32_t zoneClone;
|
||||||
|
inStream.Read(zoneClone);
|
||||||
|
uint16_t serverPort;
|
||||||
|
inStream.Read(serverPort);
|
||||||
|
LUString serverIP(255);
|
||||||
|
inStream.Read(serverIP);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < this->requests.size(); ++i) {
|
for (uint32_t i = 0; i < this->requests.size(); ++i) {
|
||||||
if (this->requests[i]->requestID == requestID) {
|
if (this->requests[i]->requestID == requestID) {
|
||||||
|
|
||||||
// Call the request callback
|
// Call the request callback
|
||||||
this->requests[i]->callback(mythranShift, zoneID, zoneInstance, zoneClone, serverIP, serverPort);
|
this->requests[i]->callback(mythranShift, zoneID, zoneInstance, zoneClone, serverIP.string, serverPort);
|
||||||
|
|
||||||
delete this->requests[i];
|
delete this->requests[i];
|
||||||
this->requests.erase(this->requests.begin() + i);
|
this->requests.erase(this->requests.begin() + i);
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// C++
|
|
||||||
#define _VARIADIC_MAX 10
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -56,7 +54,7 @@ public:
|
|||||||
\param requestID The request ID
|
\param requestID The request ID
|
||||||
\param packet The packet
|
\param packet The packet
|
||||||
*/
|
*/
|
||||||
void HandleRequestZoneTransferResponse(uint64_t requestID, Packet* packet);
|
void HandleRequestZoneTransferResponse(Packet* packet);
|
||||||
|
|
||||||
void CreatePrivateZone(dServer* server, uint32_t zoneID, uint32_t zoneClone, const std::string& password);
|
void CreatePrivateZone(dServer* server, uint32_t zoneID, uint32_t zoneClone, const std::string& password);
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#include "eServerMessageType.h"
|
#include "eServerMessageType.h"
|
||||||
#include "eMasterMessageType.h"
|
#include "eMasterMessageType.h"
|
||||||
|
|
||||||
#include "PacketUtils.h"
|
|
||||||
#include "BitStreamUtils.h"
|
#include "BitStreamUtils.h"
|
||||||
#include "MasterPackets.h"
|
#include "MasterPackets.h"
|
||||||
#include "ZoneInstanceManager.h"
|
#include "ZoneInstanceManager.h"
|
||||||
@ -127,8 +126,7 @@ Packet* dServer::ReceiveFromMaster() {
|
|||||||
if (static_cast<eConnectionType>(packet->data[1]) == eConnectionType::MASTER) {
|
if (static_cast<eConnectionType>(packet->data[1]) == eConnectionType::MASTER) {
|
||||||
switch (static_cast<eMasterMessageType>(packet->data[3])) {
|
switch (static_cast<eMasterMessageType>(packet->data[3])) {
|
||||||
case eMasterMessageType::REQUEST_ZONE_TRANSFER_RESPONSE: {
|
case eMasterMessageType::REQUEST_ZONE_TRANSFER_RESPONSE: {
|
||||||
uint64_t requestID = PacketUtils::ReadU64(8, packet);
|
ZoneInstanceManager::Instance()->HandleRequestZoneTransferResponse(packet);
|
||||||
ZoneInstanceManager::Instance()->HandleRequestZoneTransferResponse(requestID, packet);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eMasterMessageType::SHUTDOWN:
|
case eMasterMessageType::SHUTDOWN:
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#include <csignal>
|
#include <csignal>
|
||||||
|
|
||||||
#include "AuthPackets.h"
|
#include "AuthPackets.h"
|
||||||
#include "PacketUtils.h"
|
|
||||||
#include "BitStreamUtils.h"
|
#include "BitStreamUtils.h"
|
||||||
#include "WorldPackets.h"
|
#include "WorldPackets.h"
|
||||||
#include "UserManager.h"
|
#include "UserManager.h"
|
||||||
@ -664,24 +663,25 @@ void HandleMasterPacket(Packet* packet) {
|
|||||||
if (static_cast<eConnectionType>(packet->data[1]) != eConnectionType::MASTER || packet->length < 4) return;
|
if (static_cast<eConnectionType>(packet->data[1]) != eConnectionType::MASTER || packet->length < 4) return;
|
||||||
switch (static_cast<eMasterMessageType>(packet->data[3])) {
|
switch (static_cast<eMasterMessageType>(packet->data[3])) {
|
||||||
case eMasterMessageType::REQUEST_PERSISTENT_ID_RESPONSE: {
|
case eMasterMessageType::REQUEST_PERSISTENT_ID_RESPONSE: {
|
||||||
uint64_t requestID = PacketUtils::ReadU64(8, packet);
|
CINSTREAM_SKIP_HEADER;
|
||||||
uint32_t objectID = PacketUtils::ReadU32(16, packet);
|
uint64_t requestID;
|
||||||
|
inStream.Read(requestID);
|
||||||
|
uint32_t objectID;
|
||||||
|
inStream.Read(objectID);
|
||||||
ObjectIDManager::HandleRequestPersistentIDResponse(requestID, objectID);
|
ObjectIDManager::HandleRequestPersistentIDResponse(requestID, objectID);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case eMasterMessageType::SESSION_KEY_RESPONSE: {
|
case eMasterMessageType::SESSION_KEY_RESPONSE: {
|
||||||
//Read our session key and to which user it belongs:
|
//Read our session key and to which user it belongs:
|
||||||
RakNet::BitStream inStream(packet->data, packet->length, false);
|
CINSTREAM_SKIP_HEADER;
|
||||||
uint64_t header = inStream.Read(header);
|
|
||||||
uint32_t sessionKey = 0;
|
uint32_t sessionKey = 0;
|
||||||
std::string username;
|
|
||||||
|
|
||||||
inStream.Read(sessionKey);
|
inStream.Read(sessionKey);
|
||||||
username = PacketUtils::ReadString(12, packet, false);
|
LUWString username(33);
|
||||||
|
inStream.Read(username);
|
||||||
|
|
||||||
//Find them:
|
//Find them:
|
||||||
auto it = m_PendingUsers.find(username);
|
auto it = m_PendingUsers.find(username.GetAsString());
|
||||||
if (it == m_PendingUsers.end()) return;
|
if (it == m_PendingUsers.end()) return;
|
||||||
|
|
||||||
//Convert our key:
|
//Convert our key:
|
||||||
@ -694,12 +694,12 @@ void HandleMasterPacket(Packet* packet) {
|
|||||||
Game::server->Disconnect(it->second.sysAddr, eServerDisconnectIdentifiers::INVALID_SESSION_KEY);
|
Game::server->Disconnect(it->second.sysAddr, eServerDisconnectIdentifiers::INVALID_SESSION_KEY);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
LOG("User %s authenticated with correct key.", username.c_str());
|
LOG("User %s authenticated with correct key.", username.GetAsString().c_str());
|
||||||
|
|
||||||
UserManager::Instance()->DeleteUser(packet->systemAddress);
|
UserManager::Instance()->DeleteUser(packet->systemAddress);
|
||||||
|
|
||||||
//Create our user and send them in:
|
//Create our user and send them in:
|
||||||
UserManager::Instance()->CreateUser(it->second.sysAddr, username, userHash);
|
UserManager::Instance()->CreateUser(it->second.sysAddr, username.GetAsString(), userHash);
|
||||||
|
|
||||||
auto zone = Game::zoneManager->GetZone();
|
auto zone = Game::zoneManager->GetZone();
|
||||||
if (zone) {
|
if (zone) {
|
||||||
@ -722,7 +722,7 @@ void HandleMasterPacket(Packet* packet) {
|
|||||||
UserManager::Instance()->RequestCharacterList(it->second.sysAddr);
|
UserManager::Instance()->RequestCharacterList(it->second.sysAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_PendingUsers.erase(username);
|
m_PendingUsers.erase(username.GetAsString());
|
||||||
|
|
||||||
//Notify master:
|
//Notify master:
|
||||||
{
|
{
|
||||||
@ -737,8 +737,9 @@ void HandleMasterPacket(Packet* packet) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eMasterMessageType::AFFIRM_TRANSFER_REQUEST: {
|
case eMasterMessageType::AFFIRM_TRANSFER_REQUEST: {
|
||||||
const uint64_t requestID = PacketUtils::ReadU64(8, packet);
|
CINSTREAM_SKIP_HEADER;
|
||||||
|
uint64_t requestID;
|
||||||
|
inStream.Read(requestID);
|
||||||
LOG("Got affirmation request of transfer %llu", requestID);
|
LOG("Got affirmation request of transfer %llu", requestID);
|
||||||
|
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
@ -757,30 +758,22 @@ void HandleMasterPacket(Packet* packet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case eMasterMessageType::NEW_SESSION_ALERT: {
|
case eMasterMessageType::NEW_SESSION_ALERT: {
|
||||||
RakNet::BitStream inStream(packet->data, packet->length, false);
|
CINSTREAM_SKIP_HEADER;
|
||||||
uint64_t header = inStream.Read(header);
|
|
||||||
uint32_t sessionKey = inStream.Read(sessionKey);
|
uint32_t sessionKey = inStream.Read(sessionKey);
|
||||||
|
|
||||||
std::string username;
|
LUString username(33);
|
||||||
|
inStream.Read(username);
|
||||||
uint32_t len;
|
LOG("Got new session alert for user %s", username.string.c_str());
|
||||||
inStream.Read(len);
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < len; i++) {
|
|
||||||
char character; inStream.Read<char>(character);
|
|
||||||
username += character;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Find them:
|
//Find them:
|
||||||
User* user = UserManager::Instance()->GetUser(username.c_str());
|
User* user = UserManager::Instance()->GetUser(username.string.c_str());
|
||||||
if (!user) {
|
if (!user) {
|
||||||
LOG("Got new session alert for user %s, but they're not logged in.", username.c_str());
|
LOG("But they're not logged in?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check the key:
|
//Check the key:
|
||||||
if (sessionKey != std::atoi(user->GetSessionKey().c_str())) {
|
if (sessionKey != std::atoi(user->GetSessionKey().c_str())) {
|
||||||
LOG("Got new session alert for user %s, but the session key is invalid.", username.c_str());
|
LOG("But the session key is invalid!", username.string.c_str());
|
||||||
Game::server->Disconnect(user->GetSystemAddress(), eServerDisconnectIdentifiers::INVALID_SESSION_KEY);
|
Game::server->Disconnect(user->GetSystemAddress(), eServerDisconnectIdentifiers::INVALID_SESSION_KEY);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -853,16 +846,19 @@ void HandlePacket(Packet* packet) {
|
|||||||
|
|
||||||
switch (static_cast<eWorldMessageType>(packet->data[3])) {
|
switch (static_cast<eWorldMessageType>(packet->data[3])) {
|
||||||
case eWorldMessageType::VALIDATION: {
|
case eWorldMessageType::VALIDATION: {
|
||||||
std::string username = PacketUtils::ReadString(0x08, packet, true);
|
CINSTREAM_SKIP_HEADER;
|
||||||
std::string sessionKey = PacketUtils::ReadString(74, packet, true);
|
LUWString username(33);
|
||||||
std::string clientDatabaseChecksum = PacketUtils::ReadString(packet->length - 33, packet, false);
|
inStream.Read(username);
|
||||||
|
|
||||||
|
LUWString sessionKey(33);
|
||||||
// sometimes client puts a null terminator at the end of the checksum and sometimes doesn't, weird
|
// sometimes client puts a null terminator at the end of the checksum and sometimes doesn't, weird
|
||||||
clientDatabaseChecksum = clientDatabaseChecksum.substr(0, 32);
|
inStream.Read(sessionKey);
|
||||||
|
LUString clientDatabaseChecksum(32);
|
||||||
|
inStream.Read(clientDatabaseChecksum);
|
||||||
|
|
||||||
// If the check is turned on, validate the client's database checksum.
|
// If the check is turned on, validate the client's database checksum.
|
||||||
if (Game::config->GetValue("check_fdb") == "1" && !databaseChecksum.empty()) {
|
if (Game::config->GetValue("check_fdb") == "1" && !databaseChecksum.empty()) {
|
||||||
auto accountInfo = Database::Get()->GetAccountInfo(username);
|
auto accountInfo = Database::Get()->GetAccountInfo(username.GetAsString());
|
||||||
if (!accountInfo) {
|
if (!accountInfo) {
|
||||||
LOG("Client's account does not exist in the database, aborting connection.");
|
LOG("Client's account does not exist in the database, aborting connection.");
|
||||||
Game::server->Disconnect(packet->systemAddress, eServerDisconnectIdentifiers::CHARACTER_NOT_FOUND);
|
Game::server->Disconnect(packet->systemAddress, eServerDisconnectIdentifiers::CHARACTER_NOT_FOUND);
|
||||||
@ -870,7 +866,7 @@ void HandlePacket(Packet* packet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Developers may skip this check
|
// Developers may skip this check
|
||||||
if (accountInfo->maxGmLevel < eGameMasterLevel::DEVELOPER && clientDatabaseChecksum != databaseChecksum) {
|
if (accountInfo->maxGmLevel < eGameMasterLevel::DEVELOPER && clientDatabaseChecksum.string != databaseChecksum) {
|
||||||
LOG("Client's database checksum does not match the server's, aborting connection.");
|
LOG("Client's database checksum does not match the server's, aborting connection.");
|
||||||
Game::server->Disconnect(packet->systemAddress, eServerDisconnectIdentifiers::WRONG_GAME_VERSION);
|
Game::server->Disconnect(packet->systemAddress, eServerDisconnectIdentifiers::WRONG_GAME_VERSION);
|
||||||
return;
|
return;
|
||||||
@ -880,14 +876,14 @@ void HandlePacket(Packet* packet) {
|
|||||||
//Request the session info from Master:
|
//Request the session info from Master:
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::REQUEST_SESSION_KEY);
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::REQUEST_SESSION_KEY);
|
||||||
bitStream.Write(LUString(username, 64));
|
bitStream.Write(username);
|
||||||
Game::server->SendToMaster(&bitStream);
|
Game::server->SendToMaster(&bitStream);
|
||||||
|
|
||||||
//Insert info into our pending list
|
//Insert info into our pending list
|
||||||
tempSessionInfo info;
|
tempSessionInfo info;
|
||||||
info.sysAddr = SystemAddress(packet->systemAddress);
|
info.sysAddr = SystemAddress(packet->systemAddress);
|
||||||
info.hash = sessionKey;
|
info.hash = sessionKey.GetAsString();
|
||||||
m_PendingUsers.insert(std::make_pair(username, info));
|
m_PendingUsers.insert(std::make_pair(username.GetAsString(), info));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1098,7 +1094,6 @@ void HandlePacket(Packet* packet) {
|
|||||||
|
|
||||||
SystemAddress sysAddr = packet->systemAddress;
|
SystemAddress sysAddr = packet->systemAddress;
|
||||||
SEND_PACKET;
|
SEND_PACKET;
|
||||||
// PacketUtils::SavePacket("lxfml packet " + std::to_string(bbbModel.id) + ".bin", (char*)bitStream.GetData(), bitStream.GetNumberOfBytesUsed());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user