Data Package Design and Definition in Online Games (Presentation)

xiaoxiao2021-03-06  24

In contact with the online game pack design, there are some preliminary ideas, I want to borrow this article, and also make a record, so that I will update my ideas later. Technical development of online games is divided into three main aspects: server design, client design, database design. The intermediary that implements game logic between servers and clients is the game data packet, server, and client to drive game logic by swapping game packets and obtaining data packets based on analyzing. The essence of online games is interactive, and the interaction control is completed by the server and client, and the collaboration must rely on data to complete. The package in the current online game is a variety of definitions, but inductive, generally have the following elements: packet length, packet type, packet parameters, check code, etc. The package length is used to determine the length of the current game packet, which provides this data because in the underlying TCP network transmission, the transmission sometimes combines several small data packets into a large The packet is sent out, and during the merge process, it is not merged with each logically complete packet, and sometimes it may be divided into a logically complete game data package because of this merge. During the transmission, it is transmitted during the transmission, so that after the current data is sent to the recipient, the data packets of the tail will inevitably cause the "broken" phenomenon, in order to determine the case of this broken distinct, the concrete content of the broken end, the game The packet will generally provide this information, according to this information acceptor, know if the received package is broken. If there is a broken tail, the broken packet is made with the next packet. Splicing generates a complete data package that is originally in logical sense. The packet type is used to identify what type of packet of the current packet is indicated by it. Packing parameters are more specific descriptions for packet types, which specifies the parameters must be made in this type of packet instructions. For example, a packet, its packet type, can be expressed in a value, and the specific speech content and the person who speaks as a package parameter. The role of the check code is to verify the contents of the packets to ensure that the package is not changed during the transfer process, and at the same time, according to the check code, it can be determined that this packet is not a legitimate package in the format. The code code is used as a method of improving the security of the package. Packet design, generally determine the overall structure of the package, and then which packages can be made, and what should be contained in each package, and finally writing the number of bytes and meaning of the segments in the package. The specific design of the packet is generally divided according to the game function. For example, there is chat function in the game, you have to design the client and server chat packet, the client has a data package that describes the content and spokesman information, and there is a user's speech content and spokesman The broadcast packet of information, through it, the server side can send the current player's speech to other nearby players. For example, if there is a trading function in the game, then there should be the following packets with this function: Apply for trading packages, apply for trading, allow or reject the trading package, allow or refuse to traded packets, submit transactions Item pack, submit the packet of trading items, confirm the trading package, cancel the trading package, cancel the trading packet, transaction success or failure information package. It should be noted that in these packets, some are used and the other is not used, and some are the bags used by both parties.

转载请注明原文地址:https://www.9cbs.com/read-43557.html

New Post(0)