Data Package Design and Definition in Online Games (Presentation)

zhaozj2021-02-16  45

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 packet, server, and client drive game logic by switching the game packets and obtaining a data packet obtained by 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 method of increasing the security of the package is already a mode in which the online game is generally adopted by check code as a method of improving 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. For example, apply for a trading package, it is only possible to use, and the other will receive a packet of a transaction; confirming the trading package and submitting a trading item, which is both sides to be used at the same time when it is determined to be traded.

The design of the packet also complies with the above-down design principles, that is, what functions are first determined, then determine the information that should be included in the package, and finally determine the position and length of this information should be occupied. Analysis and definition of a layer layer, eventually form a perfect packet definition solution. During the actual packet design, the backtracking situation often occurs. Since the initial design is considered for no circumference or other reasons, it is possible to make a modification or display of the package design, and an important issue is to remember to update your design document in time. In my packet design, I use the following packet description form for describing: Package number function Description The corresponding class or structural name type command word command parameter structure and meaning according to the function of the game, we can block the package General structure and general content contained. However, the packet design also includes more content, how to shorten the design length of the packet to improve the transmission speed of the package and the running speed of the package, which is an important issue we should consider. Under normal circumstances, when designing the package, we should try to avoid a packet above one hundred bytes, and the definition of the majority package is controlled within 100 bytes, even 20-50 bytes. In the packet I defined, most of the number within 20 bytes, the package such as the delivery server list and the user list may be bigger. In summary, you should use as short as possible to clearly describe the package function and meaning as much as possible. In the sealing structure design, I have another scalable ideas: dynamically defined the position of each element in the package. In this way, when it is changed to other games or want to replace the package structure of the current game, as long as the dynamic definition of these elements can be changed, it is not necessary to completely redesign the package structure. For example, we define the packet number, packet type, packet parameters, check code, and length, which can form a dynamically defined package structure, which will be a great help to future packaging transplants, one may Dynamically change the game packet of the package structure, which increases the difficulty of the plug-in sealing structure in a considerable extent. When the packet design is performed, it is best to classify according to the different sealing client and the server side. For example, the hall is designed with the gaming server packet and game server and the gaming client's packet is designed, indicating their differences in the package (indicated by different start words), which will be clearer in the overall structure of the package. .

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

New Post(0)