Talking about the game server-functional modules (1)

Source: Internet
Author: User

From http://www.cppblog.com/ziyebuboka/
The role of game servers in online games cannot be considered. To what extent can a game become bigger, there is still a lot to rely on. This article Article From the perspective of the function module, let's talk about the implementation of a perfect game server.
I. Role of the game server: connects various online game clients to implement communication, connection, and data operations on each client
Ii. First, we should look at the big classification: Game servers have 1 in general architecture.
1: log on to the server that authenticates all account-related operations. We call it registerserver for short.
2: game logic operation server. We call it gameserver for short.
You do not need to elaborate on the process of logging on to the game world as a player: The Player opens the game client (there will be an update operation before, however, this is only a file comparison and download process connecting to the Update Server. We will not list it as a game server.) Speaking of this, we will find that there are currently two categories of game login, one is to select a server and then enter an account. The other is to enter an account and then select a server. The difference is as follows:
Select the server first and then enter the account. Generally, the registerserver is paired with the gameserver, that is, you select the server first, and then you connect to the registerserver of the server, use this registerserver for account verification. Another type of account is to create a central registerserver (or a random one, because register sometimes gets a lot of O & M configurations for Dynamic Balancing ), after the account is verified successfully, the server list is displayed. After the player selects the server, the specified server registerserver is used to query the role list of the server (of course, I have no opinion on the process of querying the role list from gameserver if the server is not used here ). After returning, the client enters the role selection interface. The client is disconnected from the registerserver, the player selects the role, connects to the gameserver, extracts the role from the database, registers the role to enter the game server world, and reports the role information to the client, the client enters the game world. Then the message is sent and sent ......
The above is a login process for all the servers in a common one-to-one architecture. Here, my friends should have some knowledge about the basic functions of registerserver and gameserver. One is for login verification. (If a small company in the garbage collection site does not have a registered account homepage, it will also directly register an account in the game through this ...) The process of logging on to the game world.
A bit more advanced is to add a chat server, because the chat function is too performance-consuming, especially the public chat, you can say, the number of people on the server can be sent back...
For example, if you send 50 words in a single sentence, that is, if 100 people have a certain number of k users, for example, if 5 k people send a single sentence, it will be a for loop with a large population, the Network consumes 5000*100 bytes.
So if you look at the time limits of public chat about various games, you don't have to pay for them. He can't help it.
Therefore, a performance optimization solution is provided here. A chat server is added, that is, when a player successfully logs in to the game server and connects to the chat server, the chat server has a full-server online role table. Let's send a large for loop and the 5000*100. At least it has no impact on gameserver.
Well, the basic introduction of a common server should be mentioned here, and readers should have a basic understanding. I will not elaborate on the specific architecture, so I will try again later. The title is used to analyze the server.
Only the game server is analyzed here, And registerserver is not considered.
The role of a game server is that all game data operations will be completed here. We will only use the client as the display and a complete cache of data. All operations can be completed only after the game server is verified.
Function module category (redundant or missing between myself, please add ):
1: script Module
2: attribute Module
3: Network Module
4: database module
5: Log Module
The functions listed above must be implemented for a complete game server. For details
1: script Module
There is no script module, and script planning will have to be a breeze, Lua preferred is very good.
For more information about Lua, we recommend Lua. Program Design. You don't have to go into it.
The programmer needs to write several CPP statements, and the complete function is --- "arbitrary call of the Lua function (or execution of a Lua file) in C ++ ), in Lua, you can call the C ++ function interface that you provide to the script. After such a function is implemented, the workload of programmers is reduced, A large part of logical programming will be handed over to the planners.
For example, if the program implements an interface such as say (lpcstr szsay), you can call this interface function mysay () Say ("Welcome to the game world") end.
Available places: The use logic of specific items, the logic of special tasks, the activity logic, and the special NPC logic. You can use Lua for running as long as you want.
For example, a basket of interfaces can be implemented in C ++: additem adds an item changemap to jump to a map or even addlevel, and Lua calls this interface, and then performs some operations in C ++, for example, when a player clicks an item, the script of the corresponding item is called. For example, click the blood bottle to call the Lua's blood bottle script and execute the Lua function to call addhp.
The script module is very important and can be very convenient for work, as well as debugging and maintenance. Because the server does not need to re-compile the script, it means that it can be modified at will during debugging, you can even modify an item function, a task, or an activity at will during operation ..., you only need c ++ to Lua and reload the Lua function.
For specific examples of game application scripts, you can find them on the Internet.
2: attribute module: Well, I don't know if it is OK to get this name. I also don't think it is very suitable. Do you have a better name?
The basic attribute configuration of the NPC and the basic attribute configuration of the item are called attribute configuration, which means that you need to provide a module for planning and entering each attribute configuration, gui configuration or task configuration. For this, we recommend that you use an Excel worksheet.
For example, the NPC table contains at least the NPC name model number, the amount of blood, the amount of blue, the movement speed of AI, and so on. Then there are plans to fill in the configuration here. For example, AI is a corresponding script file.
This reading table is implemented by the programmer, and the function requires liberalization. Otherwise, you will be planning to add a new one, so that you will not start from reading Code You have to change it. It is certainly possible to add a new table corresponding to the npcproperty struct directly.
If it is OK, it is best to provide an editing tool for planning. The same task mode can also be achieved: task description task requires dialogue 1 conversation 2 conversation 3 reward 1 reward 2 reward 3
Item: item name model No. Occupation level Attack Script
Otherwise, you will not be stupid enough to think that these are all written in the code. Some people may want to use XML, but I don't want to use XML here. Why is it clear in Excel? Just a line of entries.
This module is the world of numerical Planning Task Planning
3: The network mode is fast: there is no basic function to say. The gaming world can also be formed on top of this, and links are maintained to send and receive messages.
4: database module: In fact, I am keen on using the factory mode to save the data. The logic of the local debugging server is in the local document mode, and the database is used when the server is tested on the Internet, therefore, it is more appropriate to call the data operation module here, that is, the specific operations for gamers to save data, save gang information, and so on. This is very important.
5: Log Module: This Log Module is divided into two categories: game server debugging and maintenance logs and game operation logs. You can choose to use local documents or database mode to record the logs.
There is nothing to say about debugging and maintenance logs. The operation logs are provided to the customer service, records of GM operations such as who consumed the transaction flow to the item flow. For example, if a player's equipment is stolen, this can be proved.

I can't write any more, mark one tomorrow to write two, and let me know where to say it is wrong. I will correct it, write it out tomorrow, and then perform operations in the game world.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.