Tutorials to .com

Tutorials to .com » Software » Game-developer » Quake source code analysis (draft) .4

Quake source code analysis (draft) .4

Print View , by: iSee ,Total views: 16 ,Word Count: 523 ,Date: Tue, 9 Jun 2009 Time: 12:36 PM

Summary of the network part of Quake:
(1) part of the network is divided into two parts to receive and send.
(2) to send some data packets are divided into local and remote transmission of data packet transmission in two parts.
(3) local data packet transmission from NET_SendLoopbackPacket () is responsible for.
(4) data packet transmission from remote Sys_SendPacket () is responsible for.
(5) data packet transmission and packet transmission can be divided into single and multi-packet transmission.
(6) NET_SendPacket () can be local or remote does not send more than one packet size of packets. That is, a single packet transmission.
(7) Netchan_Transmit ()
According to the size of the packet transmission choice, if a packet larger than the packet size,
Then call Netchan_TransmitNextFragment () function,
Will need to send the data blocks (MAX_MSGLEN) cut into the size of a number of such (MAX_PACKETLEN - 100) of the packet, and then start NET_SendPacket () to send.
Otherwise, if the packet is less than the size of a packet, then a direct call NET_SendPacket () to send.
The data packet is NET_SendPacket () will first be sent before Netchan_ScramblePacket () encrypt (data upset inside) and then CL_Netchan_Encode () to encode them.
This is the multi-packet transmission.
From the above description can be seen in multi-packet transmission in fact ultimately have to be transformed into a single packet transmission.
(8) to receive packet data packets are divided into local and remote receiver to receive packets.
(9) local data packets received: NET_GetLoopbackPacket ()
(10) to receive packets in different places: Sys_GetPacket ()
(11) when the system receives data packets in different places SE_PACKET events will trigger when the event arrived Com_EventLoop (), the start CL_PacketEvent () to deal with from the client to send packets
Start SV_PacketEvent () server-side processing of data packets sent over.
CL_PacketEvent ()? CL_Netchan_Process ()? Netchan_Process ()
SV_PacketEvent ()? SV_Netchan_Process ()? Netchan_Process ()
For those multi-packet data, by CL_Netchan_Process () or SV_Netchan_Process () to deal with, it will have to wait until all the packets have to take down after the call
Netchan_UnScramblePacket () to decrypt, and then use CL_Netchan_Decode () decoder. Finally, users can read a complete packet.
(12) when the system receives data packets to the local direct start
CL_PacketEvent () or SV_PacketEvent ()
And there is no need to wait for the packet. Because these packets do not enter the network, so
while (NET_GetLoopbackPacket (NS_CLIENT, & adr, & msg))
while (NET_GetLoopbackPacket (NS_SERVER, & adr, & msg))
Above all by cutting the cycle of one-time read out to the full packet.
The use of NET_SendPacket ()
A function of direct transmission of data has NET_OutOfBandPrint ()? NET_SendPacket ()
Note: The NET_OutOfBandPrint () to send out packets, the first four bytes must be FFFFFFFF, or -1.
They will be SV_ConnectionlessPacket () and CL_ConnectionlessPacket () to deal with.

Game Developer Tutorial Articles

Can't Find What You're Looking For?

Rating: Not yet rated


No comments posted.