forked from mirror/openmw-tes3mp
Add ProcessPlayerPacket method to server's Networking
This commit is contained in:
parent
f0fa5e8771
commit
2602c1f71a
2 changed files with 230 additions and 213 deletions
|
@ -48,29 +48,10 @@ Networking::~Networking()
|
||||||
LOG_QUIT();
|
LOG_QUIT();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Networking::Update(RakNet::Packet *packet)
|
void Networking::ProcessPlayerPacket(RakNet::Packet *packet)
|
||||||
{
|
{
|
||||||
Player *player = Players::GetPlayer(packet->guid);
|
Player *player = Players::GetPlayer(packet->guid);
|
||||||
|
|
||||||
RakNet::BitStream bsIn(&packet->data[1], packet->length, false);
|
|
||||||
|
|
||||||
{
|
|
||||||
RakNet::RakNetGUID ignoredGUID;
|
|
||||||
bsIn.Read(ignoredGUID);
|
|
||||||
(void)ignoredGUID;
|
|
||||||
}
|
|
||||||
|
|
||||||
playerController->SetStream(&bsIn, 0);
|
|
||||||
|
|
||||||
if (player == 0)
|
|
||||||
{
|
|
||||||
playerController->GetPacket(ID_HANDSHAKE)->RequestData(packet->guid);
|
|
||||||
Players::NewPlayer(packet->guid);
|
|
||||||
player = Players::GetPlayer(packet->guid);
|
|
||||||
playerController->GetPacket(ID_USER_MYID)->Send(Players::GetPlayer(packet->guid), false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerPacket *myPacket = playerController->GetPacket(packet->data[0]);
|
PlayerPacket *myPacket = playerController->GetPacket(packet->data[0]);
|
||||||
|
|
||||||
if (packet->data[0] == ID_HANDSHAKE)
|
if (packet->data[0] == ID_HANDSHAKE)
|
||||||
|
@ -379,6 +360,39 @@ void Networking::Update(RakNet::Packet *packet)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Networking::Update(RakNet::Packet *packet)
|
||||||
|
{
|
||||||
|
Player *player = Players::GetPlayer(packet->guid);
|
||||||
|
|
||||||
|
RakNet::BitStream bsIn(&packet->data[1], packet->length, false);
|
||||||
|
|
||||||
|
{
|
||||||
|
RakNet::RakNetGUID ignoredGUID;
|
||||||
|
bsIn.Read(ignoredGUID);
|
||||||
|
(void)ignoredGUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player == 0)
|
||||||
|
{
|
||||||
|
playerController->SetStream(&bsIn, 0);
|
||||||
|
|
||||||
|
playerController->GetPacket(ID_HANDSHAKE)->RequestData(packet->guid);
|
||||||
|
Players::NewPlayer(packet->guid);
|
||||||
|
player = Players::GetPlayer(packet->guid);
|
||||||
|
playerController->GetPacket(ID_USER_MYID)->Send(Players::GetPlayer(packet->guid), false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (playerController->ContainsPacket(packet->data[0]))
|
||||||
|
{
|
||||||
|
playerController->SetStream(&bsIn, 0);
|
||||||
|
ProcessPlayerPacket(packet);
|
||||||
|
}
|
||||||
|
else if (worldController->ContainsPacket(packet->data[0]))
|
||||||
|
{
|
||||||
|
worldController->SetStream(&bsIn, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Networking::NewPlayer(RakNet::RakNetGUID guid)
|
void Networking::NewPlayer(RakNet::RakNetGUID guid)
|
||||||
{
|
{
|
||||||
playerController->GetPacket(ID_GAME_BASE_INFO)->RequestData(guid);
|
playerController->GetPacket(ID_GAME_BASE_INFO)->RequestData(guid);
|
||||||
|
|
|
@ -20,7 +20,10 @@ namespace mwmp
|
||||||
void NewPlayer(RakNet::RakNetGUID guid);
|
void NewPlayer(RakNet::RakNetGUID guid);
|
||||||
void DisconnectPlayer(RakNet::RakNetGUID guid);
|
void DisconnectPlayer(RakNet::RakNetGUID guid);
|
||||||
void KickPlayer(RakNet::RakNetGUID guid);
|
void KickPlayer(RakNet::RakNetGUID guid);
|
||||||
|
|
||||||
|
void ProcessPlayerPacket(RakNet::Packet *packet);
|
||||||
void Update(RakNet::Packet *packet);
|
void Update(RakNet::Packet *packet);
|
||||||
|
|
||||||
unsigned short NumberOfConnections() const;
|
unsigned short NumberOfConnections() const;
|
||||||
unsigned int MaxConnections() const;
|
unsigned int MaxConnections() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue