Game Engine Analysis 7

zhaozj2021-02-16  63

Game Engine Analysis 7

Original author: Jake Simpson Translator: to the sea Email: GameWorldChina@myway.com

Section 7 Networks and Connective Game Environments

Online game

I remember that some young people sitting in the GDC (Game Developer Conference) listened to the development of X-Wing VS Tie Fighter entitled "drowning in the internet" speech, all about working online games in real time. . How correct it is to choose that topic. When it starts to handle the loss of packets, the order, and latent (a packet is sent to its destination), it is still overwhelmed. However it is possible. There are some smart and experience for the Internet, but it is affirmation. Take a lot of online games, from Quake III, Unreal Tournament, COUNTER STRIKE until Everquest and Ultima Online.

Today, most of the games that have a long-lasting life have at least some connection components. The purest single game is easy to play once, maybe twice, or even three times if it is a very good game, but once the game is over, it is a high altitude. If you want to have any long-term vitality, then multiplayer game is the core of the situation, and that means to deal with the Internet, open the Pandora's box for the coder.

So what is it to deal with the Internet? The first thing is to understand how the Internet works, and the point-to-peer-to-peer-to-peer-to-peer / server architecture is discussed. Point-to-point is that you run games on both machines and simply sharing inputs between them. Each individual game assumes that it is correct and only combines the input from another machine in its one frame. The client / server is a machine running game, and other machines are just a terminal, accept input from the player, and render anything that the server makes it rendered.

The advantage of the client / server is that every machine will show the same game, because all processing is completed in one place, without spanning multiple machines, you can consider synchronization problems between each machine. Insufficient, the server itself requires some important CPU usable time to handle each connected client, and a suitable network connection to ensure that each client receives its update in time.

Learn about IP

We have heard that TCP / IP (Transfer Control Protocol / Network Agreement) and UDP (User Packet Protocol) have a lot of experience in the WEB network about these protocols. In fact, there are some excellent TCP / IP guidance on the Cisco website. We will introduce some of the basic knowledge of TCP / IP on higher levels to better understand the challenges facing online game designers using these standard protocols.

TCP / IP and UDP / IP are two-layer communication protocol system. The IP layer is responsible for the transmission of an internet package. The UDP or TCP layer passes a large packet to the IP. IP divides the packet into a small subcap, add an envelope to each data package, calculate the IP address of the destination, how should I arrive there, then Packets are sent to your ISP, or if you connect to the network. This is like writing, writing a post on a postcard, putting the stamp, writing the address, plug a mailbox, it will be sent away.

UDP and TCP are high-level protocols for receiving packets from your coder or game and decide how to handle these packets. The difference between UDP and TCP is that TCP guarantees the transfer and order of packets, and UDP does not guarantee. UDP is a small road that is directly and IP conversation, and TCP is an interface between you and IP. It is like there is an administrator assistant between you and your emails. Using UDP you will typing your letter and put them in an envelope. With TCP, you will only grant your administrator port, and the administrator will do all work and track confirmation letters. However, all of these surprisingly accompanied by your work. To determine that the data packet is delivered to the destination via the Internet, TCP looks forward to sending a response package from the destination to each packet it sent (the network term is ACK). If it does not receive the ACK in a certain period of time, it stops sending any new packets, resend the lost packet, and will continue until the response from the destination. When you visit a webpage, we have seen this situation, downloading it in halfway and then stopping again then starting. It may be a packet where it is lost (assuming from time to time ISP), which is sent to the previous TCP request to resend it before any more packets.

All of this is that there is a delay between the sender and the actual packet actually being delivered. Sometimes this can spend a few seconds, if you just download a file or a web page, this is not an occasion, but if this is a game packet, there are at least ten times per second, then you really have trouble. , Especially because it stops all other things. In fact, this problem is actually this problem, so there is almost no game to use TCP as the main Internet protocol unless it is not a real-time action game. Most games use udp - they cannot guarantee order or reliable delivery, but it does so quickly - or the result is at least faster than TCP / IP. Now let's understand these, next?

Client prediction

Because UDP is obviously a quick response game, we will have to handle the loss and chart of the packet. Side and this is how tips. I don't have to say too much code secret, I can say that there is a way. As a beginning, there is a client prophecy, a word that is discussed is quite. When you connect to a large server as a client, you can't see the update from the server, and the client predicts work. The game part that is running on your computer looks at the input you are giving it, and in the absence of any abandonment information from the server, it is considered to continue to continue. It will display the guess data, then correct itself when it gets the latest state from the server's world, if needed. You may be surprised by the efficacy of this method. Generally speaking, most of the time data packets are not easy to lose - most of the time is a few seconds, in which case the game does not have much time deviation from the server to actually think that is happening. Off is indeed a bigger change over time, and there is a timeout function in most games. When you have no contact from the server, you will stop the game.

The type of game you are creating is here - the first person shooting game does not need this effective client prophecy, because in most cases only deal with "Where am I, do I have to shoot?". In the third person, you have to be more accurate, so you can accurately predict the animation of your role being playing, and a smooth action. In this case, a smooth animation is exactly necessary. Heretic II has a big problem in this regard, and Raven has always been handled by Raven when it starts network encoding.

Of course, if you have a very good network connection, such as broadband connections, then this problem is far less important. There is a wider pipe with a large packet, which is faster to your network. In fact, the broadband is not more duct for the main advantages of the game, but greatly reduces the delay, especially your first jump to ISP. For a 56K modem, the first hop typical delay is 100ms, which has seriously increasing the potential communication time of any game server on the network. For broadband connections such as DSL, the first jump is more than 20ms. Using a command line called TraceRoute (Tracert.exe) and specify a target IP address or domain name, you can find out your first jump. Carefully observe the first jump, because this is almost always you to your ISP's network connectivity. And observe how much jump in your ISP network until you see a different domain name listed on a given jump. Note that broadband does not always solve the latency problem. You are still subject to the Slow Router / Server and Packet from the server to the server to reach your hop (vice versa). There is a broadband connection to be easily alleviated, but it is impossible to disappear. Of course, if you plan to run a server, you will need a bandwidth with enough fast upstream data rate because only one modem cannot handle the load generated by a server.

It is worth mentioning that if you want to play online games on PS2 or Xbox, you will need a broadband connection because both do not support the modem.

Package size, intelligent data transmission, and anti-cheating

What else must be processed is the size of the packet. If you are running to attack each other in a game, you can get quite large from a machine to another machine from a machine, and reach some modem without bandwidth to handle these data. This is becoming special and those games with a large surface system. The problem here is because you have this very good surface system, you can see very far, so you can see many other gamers, so that you grow rapidly for accurate rendering. . What can we do?

Ok, first, it is necessary to send absolutely necessary things to any given client, so he only gets what to observe from his perspective. There is no significance of people who send people outside his vision - he will not see these. At the same time, it is best to ensure that only data that actually changes between each frame. If a guy is still playing the same animation, it is meaningless to resend data. Of course, if this does bring some problems when the packet is lost, but this is why a good online programmer is paid a lot of money to handle something like this.

There are still some other things to handle. Recently, there is a lot of distressing cables that are happening. This is where some people modify the game to give them unfair interests. Although this is not part of the network in strict sense, it does happen. Sometimes people will create some modules, allowing them to immediately aim at anyone who enters the field, or simply allows them to look through the wall, or let other game players can't see themselves. Most time these things can be processed inside the network layer or on the server. Anyone with a 100% hit rate is simply kicked out, because it is impossible in the range of manpower.

Game developers must do everything possible to stop cheating, but very unfortunately, people do what people can break through. All you can do is difficult to make cheating, when you try to discover it.

Ok, now it is here. In Section 8, we will look at the fun world of the game scripting system, rendering or enable pre-defined scenarios and behaviors, depending on events that have occurred during the game.

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

New Post(0)