- add destination node to NetOutputPacket constructor

This commit is contained in:
Magnus Norddahl 2018-11-12 02:04:32 +01:00
parent b203dddf6c
commit 3538ef8a15
3 changed files with 7 additions and 13 deletions

View file

@ -10,7 +10,7 @@
class NetOutputPacket class NetOutputPacket
{ {
public: public:
NetOutputPacket() : stream(buffer + 1, MAX_MSGLEN - 1) { buffer[0] = 0; } NetOutputPacket(int node) : node(node), stream(buffer + 1, MAX_MSGLEN - 1) { buffer[0] = 0; }
int node = 0; int node = 0;
ByteOutputStream stream; ByteOutputStream stream;

View file

@ -78,8 +78,7 @@ NetClient::NetClient(FString server)
mServerNode = mComm->Connect(server); mServerNode = mComm->Connect(server);
mStatus = NodeStatus::InPreGame; mStatus = NodeStatus::InPreGame;
NetOutputPacket packet; NetOutputPacket packet(mServerNode);
packet.node = mServerNode;
NetCommand cmd ( NetPacketType::ConnectRequest ); NetCommand cmd ( NetPacketType::ConnectRequest );
cmd.addString("ZDoom Connect Request"); cmd.addString("ZDoom Connect Request");
@ -178,8 +177,7 @@ void NetClient::EndCurrentTic()
int targettic = (mSendTic + mServerTicDelta); int targettic = (mSendTic + mServerTicDelta);
NetOutputPacket packet; NetOutputPacket packet(mServerNode);
packet.node = mServerNode;
NetCommand cmd ( NetPacketType::Tic ); NetCommand cmd ( NetPacketType::Tic );
cmd.addByte (targettic); // target gametic cmd.addByte (targettic); // target gametic

View file

@ -135,8 +135,7 @@ void NetServer::EndCurrentTic()
{ {
if (mNodes[i].Status == NodeStatus::InGame) if (mNodes[i].Status == NodeStatus::InGame)
{ {
NetOutputPacket packet; NetOutputPacket packet(i);
packet.node = i;
NetCommand cmd ( NetPacketType::Tic); NetCommand cmd ( NetPacketType::Tic);
cmd.addByte ( gametic ); cmd.addByte ( gametic );
@ -287,8 +286,7 @@ void NetServer::OnConnectRequest(NetNode &node, ByteInputStream &stream)
playeringame[node.Player] = true; playeringame[node.Player] = true;
players[node.Player].settings_controller = false; players[node.Player].settings_controller = false;
NetOutputPacket response; NetOutputPacket response(node.NodeIndex);
response.node = node.NodeIndex;
NetCommand cmd ( NetPacketType::ConnectResponse ); NetCommand cmd ( NetPacketType::ConnectResponse );
cmd.addByte ( 1 ); // Protocol version cmd.addByte ( 1 ); // Protocol version
@ -303,8 +301,7 @@ void NetServer::OnConnectRequest(NetNode &node, ByteInputStream &stream)
{ {
node.Status = NodeStatus::Closed; node.Status = NodeStatus::Closed;
NetOutputPacket response; NetOutputPacket response(node.NodeIndex);
response.node = node.NodeIndex;
NetCommand cmd ( NetPacketType::ConnectResponse ); NetCommand cmd ( NetPacketType::ConnectResponse );
cmd.addByte ( 1 ); // Protocol version cmd.addByte ( 1 ); // Protocol version
@ -373,8 +370,7 @@ void NetServer::CmdSpawnPlayer(ByteOutputStream &stream, int player)
void NetServer::FullUpdate(NetNode &node) void NetServer::FullUpdate(NetNode &node)
{ {
NetOutputPacket packet; NetOutputPacket packet(node.NodeIndex);
packet.node = node.NodeIndex;
// Inform the client about all players already in the game. // Inform the client about all players already in the game.
for ( int i = 0; i < MAXPLAYERNAME; ++i ) for ( int i = 0; i < MAXPLAYERNAME; ++i )