forked from mirror/openmw-tes3mp
Add ProcessPlayerPacket and ProcessWorldPacket to client's Networking
This commit is contained in:
parent
ac666edebd
commit
36f218876a
2 changed files with 423 additions and 393 deletions
|
@ -166,13 +166,9 @@ void Networking::Connect(const std::string &ip, unsigned short port)
|
|||
}
|
||||
}
|
||||
|
||||
void Networking::ReceiveMessage(RakNet::Packet *packet)
|
||||
void Networking::ProcessPlayerPacket(RakNet::Packet *packet)
|
||||
{
|
||||
RakNet::RakNetGUID id;
|
||||
|
||||
if (packet->length < 2)
|
||||
return;
|
||||
|
||||
RakNet::BitStream bsIn(&packet->data[1], packet->length, false);
|
||||
bsIn.Read(id);
|
||||
|
||||
|
@ -617,7 +613,39 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
|
|||
}
|
||||
}
|
||||
default:
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Custom message with identifier %i has arrived in initialization.", packet->data[0]);
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Unhandled PlayerPacket with identifier %i has arrived",
|
||||
packet->data[0]);
|
||||
}
|
||||
}
|
||||
|
||||
void Networking::ProcessWorldPacket(RakNet::Packet *packet)
|
||||
{
|
||||
WorldPacket *myPacket = worldController.GetPacket(packet->data[0]);
|
||||
|
||||
switch (packet->data[0])
|
||||
{
|
||||
case ID_WORLD_OBJECT_REMOVAL:
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "%s", "Received ID_WORLD_OBJECT_REMOVAL");
|
||||
}
|
||||
default:
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Unhandled WorldPacket with identifier %i has arrived",
|
||||
packet->data[0]);
|
||||
}
|
||||
}
|
||||
|
||||
void Networking::ReceiveMessage(RakNet::Packet *packet)
|
||||
{
|
||||
if (packet->length < 2)
|
||||
return;
|
||||
|
||||
if (playerController.ContainsPacket(packet->data[0]))
|
||||
{
|
||||
ProcessPlayerPacket(packet);
|
||||
}
|
||||
else if (worldController.ContainsPacket(packet->data[0]))
|
||||
{
|
||||
ProcessWorldPacket(packet);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,6 +59,8 @@ namespace mwmp
|
|||
PlayerPacketController playerController;
|
||||
WorldPacketController worldController;
|
||||
|
||||
void ProcessPlayerPacket(RakNet::Packet *packet);
|
||||
void ProcessWorldPacket(RakNet::Packet *packet);
|
||||
void ReceiveMessage(RakNet::Packet *packet);
|
||||
LocalPlayer *getLocalPlayer();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue