mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 22:15:32 +00:00
Reduced package size
This commit is contained in:
parent
a815d013fe
commit
7898b1181d
4 changed files with 13 additions and 25 deletions
|
@ -58,7 +58,7 @@ void Networking::Update(RakNet::Packet *packet)
|
|||
return;
|
||||
}
|
||||
|
||||
RakNet::BitStream bsIn(&packet->data[2], packet->length, false);
|
||||
RakNet::BitStream bsIn(&packet->data[1], packet->length, false);
|
||||
|
||||
{
|
||||
RakNet::RakNetGUID ignoredGUID;
|
||||
|
@ -68,9 +68,9 @@ void Networking::Update(RakNet::Packet *packet)
|
|||
|
||||
controller->SetStream(&bsIn, 0);
|
||||
|
||||
BasePacket *myPacket = controller->GetPacket(packet->data[1]);
|
||||
BasePacket *myPacket = controller->GetPacket(packet->data[0]);
|
||||
|
||||
if(packet->data[1] == ID_HANDSHAKE)
|
||||
if(packet->data[0] == ID_HANDSHAKE)
|
||||
{
|
||||
DEBUG_PRINTF("ID_HANDSHAKE\n");
|
||||
string passw = "SuperPassword";
|
||||
|
@ -114,7 +114,7 @@ void Networking::Update(RakNet::Packet *packet)
|
|||
return;
|
||||
}
|
||||
|
||||
switch(packet->data[1])
|
||||
switch(packet->data[0])
|
||||
{
|
||||
case ID_GAME_BASE_INFO:
|
||||
{
|
||||
|
@ -283,7 +283,7 @@ void Networking::Update(RakNet::Packet *packet)
|
|||
}
|
||||
|
||||
default:
|
||||
printf("Message with identifier %i has arrived.\n", packet->data[1]);
|
||||
printf("Message with identifier %i has arrived.\n", packet->data[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -385,11 +385,8 @@ int Networking::MainLoop()
|
|||
printf("A client lost the connection.\n");
|
||||
DisconnectPlayer(packet->guid);
|
||||
break;
|
||||
case ID_CUSTOM_MESSAGE:
|
||||
Update(packet);
|
||||
break;
|
||||
default:
|
||||
printf("Message with identifier %i has arrived.\n", packet->data[0]);
|
||||
Update(packet);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,11 +75,9 @@ void Networking::Update()
|
|||
printf("Connection lost.\n");
|
||||
MWBase::Environment::get().getStateManager()->requestQuit();
|
||||
break;
|
||||
case ID_CUSTOM_MESSAGE:
|
||||
ReciveMessage(packet);
|
||||
break;
|
||||
default:
|
||||
printf("Message with identifier %i has arrived.\n", packet->data[0]);
|
||||
ReciveMessage(packet);
|
||||
//printf("Message with identifier %i has arrived.\n", packet->data[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +164,7 @@ void Networking::ReciveMessage(RakNet::Packet *packet)
|
|||
if(packet->length < 3)
|
||||
return;
|
||||
|
||||
RakNet::BitStream bsIn(&packet->data[2], packet->length, false);
|
||||
RakNet::BitStream bsIn(&packet->data[1], packet->length, false);
|
||||
bsIn.Read(id);
|
||||
|
||||
DedicatedPlayer *pl = 0;
|
||||
|
@ -174,9 +172,9 @@ void Networking::ReciveMessage(RakNet::Packet *packet)
|
|||
if(id != myid)
|
||||
pl = Players::GetPlayer(id);
|
||||
|
||||
BasePacket *myPacket = controller.GetPacket(packet->data[1]);
|
||||
BasePacket *myPacket = controller.GetPacket(packet->data[0]);
|
||||
|
||||
switch(packet->data[1])
|
||||
switch(packet->data[0])
|
||||
{
|
||||
case ID_HANDSHAKE:
|
||||
{
|
||||
|
@ -552,7 +550,7 @@ void Networking::ReciveMessage(RakNet::Packet *packet)
|
|||
break;
|
||||
}
|
||||
default:
|
||||
printf("Custom message with identifier %i has arrived in initialization.\n", packet->data[1]);
|
||||
printf("Custom message with identifier %i has arrived in initialization.\n", packet->data[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,12 +9,7 @@
|
|||
|
||||
enum GameMessages
|
||||
{
|
||||
ID_CUSTOM_MESSAGE = ID_USER_PACKET_ENUM+1
|
||||
};
|
||||
|
||||
enum MyGameMesages
|
||||
{
|
||||
ID_GAME_BASE_INFO = 0,
|
||||
ID_GAME_BASE_INFO = ID_USER_PACKET_ENUM+1,
|
||||
ID_GAME_CHARGEN,
|
||||
ID_GAME_UPDATE_POS,
|
||||
ID_GAME_UPDATE_BASESTATS,
|
||||
|
|
|
@ -16,7 +16,6 @@ void BasePacket::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
|
|||
|
||||
if(send)
|
||||
{
|
||||
bs->Write((RakNet::MessageID) ID_CUSTOM_MESSAGE);
|
||||
bs->Write((RakNet::MessageID) packetID);
|
||||
bs->Write(player->guid);
|
||||
}
|
||||
|
@ -67,7 +66,6 @@ void BasePacket::SetSendStream(RakNet::BitStream *bitStream)
|
|||
void BasePacket::RequestData(RakNet::RakNetGUID player)
|
||||
{
|
||||
bsSend->ResetWritePointer();
|
||||
bsSend->Write((RakNet::MessageID) ID_CUSTOM_MESSAGE);
|
||||
bsSend->Write((RakNet::MessageID) packetID);
|
||||
bsSend->Write(player);
|
||||
peer->Send(bsSend, HIGH_PRIORITY, RELIABLE_ORDERED, 0, player, false);
|
||||
|
|
Loading…
Reference in a new issue