CN110812836A - Game synchronization method and device, computer equipment and storage medium - Google Patents

Game synchronization method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN110812836A
CN110812836A CN201911052233.5A CN201911052233A CN110812836A CN 110812836 A CN110812836 A CN 110812836A CN 201911052233 A CN201911052233 A CN 201911052233A CN 110812836 A CN110812836 A CN 110812836A
Authority
CN
China
Prior art keywords
game
state
client
original
determining
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201911052233.5A
Other languages
Chinese (zh)
Inventor
曹狄
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Netstar Information Technology Co Ltd
Original Assignee
Guangzhou Netstar Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Netstar Information Technology Co Ltd filed Critical Guangzhou Netstar Information Technology Co Ltd
Priority to CN201911052233.5A priority Critical patent/CN110812836A/en
Publication of CN110812836A publication Critical patent/CN110812836A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/30Interconnection arrangements between game servers and game devices; Interconnection arrangements between game devices; Interconnection arrangements between game servers
    • A63F13/35Details of game servers
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/70Game security or game management aspects
    • A63F13/75Enforcing rules, e.g. detecting foul play or generating lists of cheating players
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/131Protocols for games, networked simulations or virtual reality

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Business, Economics & Management (AREA)
  • Computer Security & Cryptography (AREA)
  • General Business, Economics & Management (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The embodiment of the invention discloses a game synchronization method, a game synchronization device, computer equipment and a storage medium, which are applied to a server side, wherein the server side is used for maintaining the states of games participated by at least two client sides, and the method comprises the following steps: receiving an operation triggered in the game and sent by one client; updating a state of the game in response to the operation; carrying out validity check on the operation according to the game state; if the operation is legal, recording the operation into the state of the game, and maintaining the state of the game; sending an operation confirmation message to the client, wherein the client is used for responding to the operation confirmation message and updating the state of the game according to the operation; and synchronizing the operation to other clients, wherein the other clients are used for updating the state of the game according to the operation. The safety of the game can be ensured, and the load of the server serving as a central node is greatly reduced.

Description

Game synchronization method and device, computer equipment and storage medium
Technical Field
The present invention relates to a synchronization technology, and in particular, to a game synchronization method, apparatus, computer device, and storage medium.
Background
In the game participated by a plurality of clients, the plurality of clients need to be connected with the server, and data interaction is carried out with the server in a synchronous mode, so that the state of the game in each client is real-time and consistent.
The existing synchronization methods are mainly divided into the following two types:
1. operation synchronization
The server mainly plays the role of orderly delivery of game instructions, the logic of the game is realized at the client, the game operation is initiated by the client, the game operation is broadcast to other clients after being verified by the server, and the other clients independently update the state of the game according to the game operation after receiving the game operation and render and display the picture of the game.
The server side does not need to compile and calculate the state of the game in real time, the design is general, and the load of the central node is high.
However, the client side has game logic, cheating is easy to realize by cracking the client side, and the safety is low.
2. State synchronization
The logic of the game is realized at the server, the client is similar to a presentation layer of the server data, the game operation initiated by the client is verified by the server, and meanwhile, the server updates the state of the game according to the game operation in real time and actively broadcasts the change data of the game state to the client for rendering and displaying.
Because the server side has the logic of the game, the cheating behavior needs to attack the server side, and the safety is higher.
However, the server needs to update the states of multiple games in real time, synchronization has delay, most of the states are accurate to the state of the previous frame, the load of the central node is high, the accuracy is low, the accuracy depends on the refresh frequency, and the pressure of the central node is increased due to the increase of the refresh frequency.
Disclosure of Invention
The embodiment of the invention provides a game synchronization method, a game synchronization device, computer equipment and a storage medium, and aims to solve the problem of considering both the safety and the load of a central node and the synchronization accuracy.
In a first aspect, an embodiment of the present invention provides a game synchronization method, which is applied to a server, where the server is configured to maintain states of games that at least two clients participate in, and the method includes:
receiving an operation triggered in the game and sent by one client;
updating a state of the game in response to the operation;
carrying out validity check on the operation according to the game state;
if the operation is legal, recording the operation into the state of the game, and maintaining the state of the game;
sending an operation confirmation message to the client, wherein the client is used for responding to the operation confirmation message and updating the state of the game according to the operation;
and synchronizing the operation to other clients, wherein the other clients are used for updating the state of the game according to the operation.
In a second aspect, an embodiment of the present invention further provides a game synchronization apparatus, which is applied to a server, where the server is configured to maintain states of games that at least two clients participate in, and the apparatus includes:
the operation receiving module is used for receiving the operation which is sent by one client and is triggered in the game;
a state updating module for updating the state of the game in response to the operation;
the legality checking module is used for checking the legality of the operation according to the state of the game;
the operation application module is used for recording the operation into the game state and maintaining the game state if the operation is legal;
an operation confirmation message sending module, configured to send an operation confirmation message to the client, where the client is configured to respond to the operation confirmation message and update the state of the game according to the operation;
and the operation synchronization module is used for synchronizing the operation to other clients, and the other clients are used for updating the state of the game according to the operation.
In a third aspect, an embodiment of the present invention further provides a computer device, where the computer device includes:
one or more processors;
a memory for storing one or more programs;
when the one or more programs are executed by the one or more processors, cause the one or more processors to implement the synchronization method for a game as described in the first aspect.
In a fourth aspect, the present invention further provides a computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the synchronization method for a game according to the first aspect.
In this embodiment, the server and the clients respectively have game logics, the server maintains the states of games in which at least two clients participate, if the server receives an operation triggered in a game and sent by one of the clients, the server can respond to the operation to update the states of the games, and performs validity check on the operation according to the states of the games, so as to ensure the security of the games and prevent the clients from being cracked, if the operation is legal, the operation is updated to the states of the games, and the states of the games are maintained, because the states of the games do not need to be updated in real time according to frames, the frequency of updating the states of the games can be greatly reduced, the load of the server as a central node is greatly reduced, the frequency of updating the states of the games within 1 second can reach 20-30 times, and for games with lower frequency of operation, the states of the games updated by hundreds of times can be reduced, the load reduction of the central node is obvious, in addition, the server side informs the current client side and other client sides to update the game state according to the operation, the normal operation of the game can be ensured, and the synchronization precision is high and can reach the millisecond level because the current state is returned by the server side.
Drawings
FIG. 1 is a flow chart of a method for synchronizing games according to an embodiment of the present invention;
FIGS. 2A and 2B are diagrams of a game according to an embodiment of the present invention;
FIG. 3 is a flow chart of a game synchronization method according to a second embodiment of the present invention;
FIG. 4 is a flow chart of a game synchronization method according to a third embodiment of the present invention;
fig. 5 is a schematic structural diagram of a synchronization device for a game according to a fourth embodiment of the present invention;
fig. 6 is a schematic structural diagram of a computer device according to a fifth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
Fig. 1 is a flowchart of a game synchronization method according to an embodiment of the present invention, which is applicable to a case where a server and a client respectively possess game logic, and the server updates a game state in response to the client, where the game logic refers to preset game environments, game object attributes, game operation rules, and the like.
Furthermore, the embodiment is particularly suitable for small and medium-sized games with large concurrency and high requirements on instantaneity, interactivity and safety.
In one example, as shown in fig. 2A and 2B, in a game in which two users participate, each user has a certain score, and the user can control a chick to walk on a track, the chick can collide on the same track, if the chick reaches the bottom line, the opponent is deducted, and the score is deducted, i.e. the chick is lost.
In this example, the logic of the game includes a runway (environment), a category of the chicken (including weight, speed, etc.) (attributes of the game object), collision rules, deduction rules (run rules, etc.) of the chicken, and so on.
The method may be performed by a game synchronization apparatus, which may be implemented by software and/or hardware, and may be configured in a computer device, and the computer device may install a server (server), for example, a server, a workstation, and the like, and specifically includes the following steps:
s101, receiving an operation triggered in the game and sent by one of the clients.
In a specific implementation, the embodiment may be applied to a server, where the server is configured to maintain the state of the game in which at least two clients participate.
The client may be a browser, where the browser may load a page where a game is located, may also be an independent game application, may also be an applet or a plug-in the application, and the like, which is not limited in this embodiment.
After logging in an account at a client, a user can open a game with other users (represented by the client), and in the game, the user controls a game object to compete with the other users, wherein the game object can be a virtual character, a virtual machine (such as an airplane, a tank and the like), a virtual pet (such as a chicken and the like) and the like.
Further, the game may be a 2D game or a 3D game, which is not limited in this embodiment.
Taking a 2D game as an example, a 2D game, i.e., a two-dimensional game, can be interacted according to the needs of a user, and includes a horizontal version 2D game (i.e., a game screen is fixed in a horizontal direction) and may also include a vertical version 2D game (i.e., a game screen is fixed in a vertical direction).
In the present embodiment, each client owns the logic of the game, and updates the state of the game in real time at a preset refresh frequency (30 frames/sec).
When the client side triggers the operation in the game, the client side informs the server side of the operation, and relatively speaking, the server side can receive the operation which is sent by the client side and is triggered in the game.
In one case, the user's behavior triggers an action at the client that can be used to control a virtual character in the game, e.g., an action that can be used to place a chicken on a course, as shown in fig. 2A and 2B.
In this case, the server may receive an operation triggered based on the user behavior in the game, which is sent by one of the clients.
In another case, an action is automatically triggered during the running of the game, which can be used to change the user attributes in the game, e.g., as shown in fig. 2A and 2B, an action can be used to deduct the score of a user.
In this case, the server may receive an operation triggered in the game based on the user attribute, which is sent by one of the clients.
Of course, the above operations are only examples, and when the embodiment is implemented, other operations may be set according to actual situations, and the embodiment is not limited to this. In addition, besides the above operations, those skilled in the art may also adopt other operations according to actual needs, and this embodiment also does not limit this.
And S102, responding to the operation, and updating the state of the game.
The state of the game can be influenced by triggering operation in the game, namely when the operation is not carried out, the state in the game is predictable, the client can update the state of the game by itself when the client does not need to obtain key information, the server does not need to update the state of the game in real time, and the state of the game is updated immediately according to the predicted state when the operation of the client comes next time.
For example, as shown in fig. 2A and 2B, a chicken is at position x in the runway when the client triggers the last operation1The speed is v, and the client is at the position x in the runway when triggering the operation of the time t2=x1+vt。
S103, verifying the legality of the operation according to the game state.
In the concrete implementation, the client updates the state of the game in real time according to the logic of the game, the triggered operation carries information representing the state of the game, the information is compared with the state of the game updated by the server, if the information is the same as the state of the game updated by the server, the operation is determined to be legal, the operation passes the validity check, and if the information is different from the game updated by the server, the operation is determined to be illegal and does not pass the validity check.
In one case, if the operation is used for a controlled virtual role, on one hand, the operation carries a role attribute of the virtual role, and then the role attribute of the virtual role controlled by the operation may be determined as a target role attribute.
On the other hand, the character attributes of the same virtual character are determined from the state of the game as the original character attributes.
In one example, the server determines a virtual character (e.g. chicken) according to the logic (e.g. probability, user level, etc.) of the game at the last operation time, the virtual character having specified attributes (e.g. weight, speed, etc.) of the chicken as a virtual character that the client can control at the local operation time, and updates the virtual character to the state of the game, and notifies the virtual character to the client so that the client can use the virtual character at the local operation time, at this time, the server can determine the virtual character determined at the last operation time and controlled at the current operation time from the state of the game, and determine the character attribute of the virtual character as the original character attribute.
Further, for the operation of the client, the server may determine a virtual character according to the logic (such as probability, user level, etc.) of the game in response to the operation, update the virtual character to the state of the game, and notify the client of the virtual character, the client being used for controlling the virtual character at the next operation.
Of course, the above manner of determining the original role attribute is only an example, and when the embodiment is implemented, other manners of determining the original role attribute may be set according to an actual situation, for example, the attribute of the virtual role is fixedly recorded in a database, and the like, which is not limited in this embodiment. In addition, besides the above-mentioned manner of determining the original role attribute, a person skilled in the art may also adopt other manners of determining the original role attribute according to actual needs, which is not limited in this embodiment.
And comparing the original role attribute with the target role attribute, and judging whether the original role attribute is the same as the target role attribute.
If the original role attribute is the same as the target role attribute, the virtual role controlled by the client can be determined to be the same as the virtual role controlled by the server, and the operation is determined to be legal.
If the original role attribute is different from the target role attribute, the virtual role controlled by the client is determined to be different from the virtual role controlled by the server, the client has the risk of being cracked, and the illegal operation is determined.
In another case, on the one hand, the state of the virtual character of the operation control in the game (such as the course where the chicken is located and its position) is determined as the target state.
On the other hand, the states of other virtual characters in the game (such as the runway and the positions of other chickens) are determined from the states of the game as original states.
And comparing the original state with the target state, and judging whether the original state conflicts with the target state.
And if the original state and the target state do not conflict, determining that the operation is legal.
And if the original state conflicts with the target state, determining that the operation is illegal.
In one example, the original state includes an original position of the virtual character in the game, and the target state includes a target position of the virtual character in the game, and in this example, the original position and the target position may be compared to perform collision detection.
And if the original position and the target position are mutually blocked, determining that the original state conflicts with the target state.
And if the original position and the target position are not mutually blocked, determining that the original state and the target state are not in conflict.
In yet another case, in one aspect, a user attribute of the operational change (e.g., a score of the user, a prop of the user, a virtual currency of the user, etc.) may be determined as the target user attribute.
On the other hand, the user attribute is determined from the state of the game as the original user attribute.
And comparing the original user attribute with the target user attribute, and judging whether the original user attribute is the same as the target user attribute.
And if the original user attribute is the same as the target user attribute, determining that the operation is legal.
And if the original user attribute is different from the target user attribute and the client has the risk of being cracked, determining that the operation is illegal.
Of course, the above validity checks are only examples, and when the embodiment is implemented, other validity checks may be set according to actual situations, which is not limited in the embodiment. In addition, besides the above validity check, a person skilled in the art may also adopt other validity checks according to actual needs, and this embodiment also does not limit this.
And S104, if the operation is legal, recording the operation into the game state, and maintaining the game state.
If the server side verifies that the operation of the client side is legal, the operation is recorded into the game state, namely, the operation is applied to the game to be effective, and when the subsequent client side synchronizes the game state, the operation can be synchronized.
Thereafter, for the game, the state of the game is maintained, that is, the state of the game at the server side is temporarily stopped, and the game is waited for updating by the next operation.
And S105, sending an operation confirmation message to the client.
And if the server side verifies that the operation of the client side is legal, sending a confirmation message to the client side, responding to the operation confirmation message by the client side, confirming that the operation is legal, and updating the state of the game in real time according to the operation.
And S106, synchronizing the operation to other clients.
And if the server side verifies that the operation of the client side is legal, synchronizing the operation to other client sides except the client side triggering the operation, wherein the other client sides are used for updating the state of the game in real time according to the operation.
In this embodiment, the server and the clients respectively have game logics, the server maintains the states of games in which at least two clients participate, if the server receives an operation triggered in a game and sent by one of the clients, the server can respond to the operation to update the states of the games, and performs validity check on the operation according to the states of the games, so as to ensure the security of the games and prevent the clients from being cracked, if the operation is legal, the operation is updated to the states of the games, and the states of the games are maintained, because the states of the games do not need to be updated in real time according to frames, the frequency of updating the states of the games can be greatly reduced, the load of the server as a central node is greatly reduced, the frequency of updating the states of the games within 1 second can reach 20-30 times, and for games with lower frequency of operation, the states of the games updated by hundreds of times can be reduced, the load reduction of the central node is obvious, in addition, the server side informs the current client side and other client sides to update the game state according to the operation, the normal operation of the game can be ensured, and the synchronization precision is high and can reach the millisecond level because the current state is returned by the server side.
In order to make those skilled in the art better understand the present embodiment, the operation synchronization, the state synchronization, and the passive state synchronization method in the present embodiment are compared below by taking the game shown in fig. 2A and 2B as an example.
The operation of the client can be divided into the operation triggered by the active user behavior (such as placing a chick in the track) as shown in fig. 2A and the operation triggered by the user attribute change (such as the chick cross-line deduction) as shown in fig. 2B.
For the user to place a chicken into the racetrack:
1. application operation synchronization
Each client records the number of the chickens on the competition field, the weight, the speed and other role attributes of each chicken, and respectively calculates the positions to which the current chickens move, whether collision occurs and other states in real time.
When a user places a chick to a runway, the client performs collision detection locally to judge whether the chick is blocked or not, if the chick is blocked, the client directly prompts the user that the chick is not placed, if the chick is not blocked, the user directly prompts the user that the chick is placed successfully, if the chick is not blocked, the user displays that the chick is placed successfully, the state of a local game is refreshed, and meanwhile, the operation of placing the chick to the runway is sent to the server.
The server serves as a transmitter of the operation of the client, simply records the operation, and then sends the operation to other clients participating in the game of the local game, and the other clients display the chick on the runway in the local game according to the operation.
In the synchronization mode, all the state updating and operation judgment are completed by the client, and the server only performs corresponding broadcast distribution during operation, so that the server has no great computational pressure in the game process, and has no great requirement on the performance of the server even if a large number of games are processed in parallel; however, the validity of the operation cannot be verified at the server, and when the client is cracked, the security of the game has great hidden trouble.
2. Application state synchronization
The server side pushes the positions of all the chickens in the game to the client side in real time at 30 frames/second to achieve smooth display.
When a user places a chick to a runway, when the client sends an operation of placing the chick to the runway to the server, the server compares the result of the calculation of the position of the chick in the previous game with the position of the chick placed at this time, if the result is not mutually blocked and the chick placed at this time is provided by the server, the server judges that the placement is successful, returns the successful result and the chick which can be placed at the next time to the client, and broadcasts the operation to other clients participating in the game of the local game to inform the clients of updating the state of the latest game.
Because the calculation result of the server is frequent, the time error is 1/30 seconds when the position comparison is carried out, the server self keeps the state of the current whole game, the attribute of whether the client illegally places or changes the chicken by self can be verified, the client refuses the game in illegal time, and the game is controllable and the safety is guaranteed; however, since the server needs to perform 30 calculations per game per second for smooth display, the load of the server is greatly increased.
3. Application passive state synchronization
Each client calculates the current game state in real time, when a user initiates the operation of placing the chicken to a certain runway, the client locally judges whether the obstacle exists or not according to the game state, if so, the client directly returns an error, and if not, the client initiates the operation to the server.
When the server receives the operation of the client, the server calculates the time difference between the last operation and the current operation, deduces the state of the current game according to the time difference, performs collision detection on the operation of the client and the state of the current game, records the timestamp of the current operation if the client is not in the interference state, broadcasts the operation to other clients participating in the game, and notifies the clients of updating the state of the latest game.
Because the operation of the user is not frequent, compared with thirty times per second calculation of state synchronization, the calculation can be ignored, meanwhile, because the operation of all the client sides is verified by the server side, the safety and controllability of the game are guaranteed, and because the calculation of the server side is not timed and quantitative, 1/30 second time error in the state synchronization is avoided, and the real-time performance is better.
And (3) for the cross-line deduction of the chickens:
1. application operation synchronization
The client calculates the state of the game in real time by itself, displays the corresponding state change to the user when triggering the deduction, and can also broadcast the operation of triggering the deduction such as the thread passing by the chick and the like to other clients to realize cheating operation.
2. Application state synchronization
The server side can calculate the state of the current game in real time, the operation of the deduction is broadcasted to each client side when the deduction is triggered, the client side does not calculate the operation of the deduction and the like, only the deduction operation sent by the server side is simply displayed, and the safety is high.
3. Application passive state synchronization
The client calculates the state of the game in real time by itself, the operation is sent to the server when the deduction is triggered, the server triggers calculation passively and broadcasts the verification result to other clients for displaying, and the client triggers the operation of checking the deduction by the server, so that the calculation amount is reduced while the safety is ensured.
Example two
Fig. 3 is a flowchart of a game synchronization method according to a second embodiment of the present invention, where the present embodiment further adds an illegal processing operation based on the foregoing embodiment, and the method specifically includes the following steps:
s301, receiving an operation triggered in the game and sent by one of the clients.
S302, responding to the operation, and updating the state of the game.
S303, carrying out validity check on the operation according to the game state.
S304, if the operation is illegal, rejecting the operation.
S305, synchronizing the state of the game to the client.
And if the server side verifies that the operation of the client side is illegal and the client side has the risk of being cracked, rejecting the operation of the client side, synchronizing the state of the game maintained by the server side to the client side, and applying the state of the game by the client side.
Generally, a server sends a synchronization notification to a client, and the client immediately responds to the synchronization notification to send a state synchronization request to the server and pull the state of a game from the server.
However, when the network environment is poor, there is a delay in the client responding to the synchronization notification, and at this time, the server receives the state synchronization request sent by the client, updates the state of the game in response to the state synchronization request, and synchronizes the updated state to the client.
EXAMPLE III
Fig. 4 is a flowchart of a game synchronization method according to a third embodiment of the present invention, where the present embodiment further adds a heartbeat and a restart processing operation based on the foregoing embodiments, and the method specifically includes the following steps:
s401, receiving an operation triggered in the game and sent by one of the clients.
S402, responding to the operation, and updating the state of the game.
S403, verifying the legality of the operation according to the state of the game.
S404, if the operation is legal, recording the operation into the game state, and maintaining the game state.
S405, sending an operation confirmation message to the client.
And the client is used for responding to the operation confirmation message and updating the state of the game according to the operation.
S406, synchronizing the operation to other clients.
And the other clients are used for updating the state of the game according to the operation.
And S407, receiving the heartbeat request packet sent by the client.
S408, responding to the heartbeat request packet, and sending a heartbeat confirmation packet to the client.
And S409, responding to the heartbeat request packet, and updating the state of the game.
In this embodiment, the client and the server are kept in long connection, and if the operation is not triggered, the client may generate a heartbeat request packet (e.g., ping) at a certain interval and send the heartbeat request packet to the server.
After receiving the heartbeat request packet of the client, the server confirms that the server is in long connection with the client, on one hand, the server generates the heartbeat confirmation packet and sends the heartbeat confirmation packet to the client, and on the other hand, the server responds to the heartbeat request packet to update the state of the game, so that the frequency of updating the state of the game is improved, excessive change of the state of the game is avoided, the time for subsequently updating the state of the game is reduced, and the speed for responding to the operation of the subsequent client is ensured.
And S410, storing the state of the game to a designated storage area.
S411, when the server is restarted, reading the state of the game from the storage area.
In this embodiment, the server is provided with a storage area, which is a cache, such as a Redis (key-value database).
The server side can store the state of each game into the storage area when updating the state of the game for each game.
If the server is restarted under the conditions of updating the system version, failure and the like, the state of each game can be read from the storage area, the service is recovered, and the state of the game at the current time can be updated when the client triggers operation next time, so that the client is not substantially influenced by the restart.
Example four
Fig. 5 is a schematic structural diagram of a game synchronization apparatus according to a fourth embodiment of the present invention, which is applied to a server, where the server is configured to maintain states of games that at least two clients participate in, and the apparatus may specifically include the following modules:
an operation receiving module 501, configured to receive an operation triggered in the game and sent by one of the clients;
a state updating module 502, configured to update a state of the game in response to the operation;
a validity checking module 503, configured to perform validity checking on the operation according to the game state;
an operation application module 504, configured to record the operation into the state of the game and maintain the state of the game if the operation is legal;
an operation confirmation message sending module 505, configured to send an operation confirmation message to the client, where the client is configured to respond to the operation confirmation message and update the state of the game according to the operation;
an operation synchronization module 506, configured to synchronize the operation to other clients, where the other clients are configured to update the state of the game according to the operation.
In one embodiment of the present invention, the operation receiving module 501 includes:
the first receiving submodule is used for receiving an operation which is sent by one client and is triggered in the game based on user behaviors, and the operation is used for controlling virtual characters in the game;
alternatively, the first and second electrodes may be,
and the second receiving submodule is used for receiving an operation which is sent by one of the clients and is triggered in the game based on the user attribute, and the operation is used for changing the user attribute in the game.
In an embodiment of the present invention, the validity checking module 503 includes:
the target role attribute determining submodule is used for determining the role attribute of the virtual role controlled by the operation as the target role attribute;
an original role attribute determining submodule, configured to determine a role attribute of the virtual role from the state of the game, as an original role attribute;
the role attribute judging submodule is used for judging whether the original role attribute is the same as the target role attribute;
the first legality determining submodule is used for determining that the operation is legal if the original role attribute is the same as the target role attribute;
and the first illegal determining submodule is used for determining that the operation is illegal if the original role attribute is different from the target role attribute.
In an example of the embodiment of the present invention, the original role attribute determining submodule includes:
a virtual character extracting unit configured to determine, from the state of the game, a virtual character that is determined at the last operation and that is controlled by the client at the current operation;
and the role attribute determining unit is used for determining the role attribute of the virtual role as the original role attribute.
In another embodiment of the present invention, the validity checking module 503 includes:
a target state determination submodule for determining a state of the virtual character controlled by the operation in the game as a target state;
the initial state determining submodule is used for determining the states of other virtual characters in the game from the states of the game as initial states;
the state conflict judgment submodule is used for judging whether the original state conflicts with the target state;
a second legality determining submodule, configured to determine that the operation is legal if the original state and the target state do not conflict with each other;
and the second illegal determining submodule is used for determining that the operation is illegal if the original state conflicts with the target state.
In one example of the embodiment of the present invention, the original state includes an original position where the virtual character is located in the game, and the target state includes a target position where the virtual character is located in the game;
the state conflict judgment submodule includes:
a position comparison unit for comparing the original position with the target position;
a conflict determination unit, configured to determine that the original state conflicts with the target state if the original position and the target position hinder each other;
and the conflict-free determining unit is used for determining that the original state and the target state do not conflict if the original position and the target position are not mutually blocked.
In another embodiment of the present invention, the validity checking module 503 includes:
a target user attribute determining submodule, configured to determine a user attribute of the operation change, as a target user attribute;
an original user attribute determining submodule for determining a user attribute from the state of the game as an original user attribute;
a user attribute judging submodule for judging whether the original user attribute is the same as the target user attribute;
a third legality determining submodule, configured to determine that the operation is legal if the original user attribute is the same as the target user attribute;
and the third illegal determining submodule is used for determining that the operation is illegal if the original user attribute is different from the target user attribute.
In one embodiment of the present invention, further comprising:
the operation rejection module is used for rejecting the operation if the operation is illegal;
and the state synchronization module is used for synchronizing the state of the game to the client.
In one embodiment of the present invention, the state synchronization module includes:
the state synchronization request receiving submodule is used for receiving a state synchronization request sent by the client;
a request updating submodule for updating the state of the game in response to the state synchronization request;
and the update synchronization submodule is used for synchronizing the updated state to the client.
In one embodiment of the present invention, further comprising:
a virtual role determination module for determining a virtual role in response to the operation, the virtual role having specified attributes;
the virtual character application module is used for updating the virtual character to the state of the game;
and the virtual role notification module is used for notifying the client of the virtual role, and the client is used for controlling the virtual role in the next operation.
In one embodiment of the present invention, further comprising:
a heartbeat request packet receiving module, configured to receive a heartbeat request packet sent by the client;
a heartbeat confirmation packet sending module, configured to send a heartbeat confirmation packet to the client in response to the heartbeat request packet;
and the game updating module is used for responding to the heartbeat request packet and updating the state of the game.
In one embodiment of the present invention, further comprising:
the state storage module is used for storing the state of the game to a specified storage area;
and the state reading module is used for reading the state of the game from the storage area when the server is restarted.
The game synchronizing device provided by the embodiment of the invention can execute the game synchronizing method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
EXAMPLE five
Fig. 6 is a schematic structural diagram of a computer device according to a fifth embodiment of the present invention. As shown in fig. 6, the computer apparatus includes a processor 600, a memory 601, a communication module 602, an input device 603, and an output device 604; the number of processors 600 in the computer device may be one or more, and one processor 600 is taken as an example in fig. 6; the processor 600, the memory 601, the communication module 602, the input device 603 and the output device 604 in the computer apparatus may be connected by a bus or other means, and the connection by the bus is exemplified in fig. 6.
The memory 601, which is a computer-readable storage medium, may be used to store software programs, computer-executable programs, and modules, such as modules corresponding to the synchronization method of the game in the present embodiment (for example, an operation receiving module 501, a status updating module 502, a validity checking module 503, an operation application module 504, an operation confirmation message sending module 505, and an operation synchronization module 506 in the synchronization apparatus of the game shown in fig. 5). The processor 600 executes various functional applications of the computer device and data processing by executing software programs, instructions and modules stored in the memory 601, that is, implements the synchronization method of the game described above.
The memory 601 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to use of the computer device, and the like. Further, the memory 601 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples, memory 601 may further include memory located remotely from processor 600, which may be connected to a computer device through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
And the communication module 602 is configured to establish a connection with the display screen and implement data interaction with the display screen. The input device 603 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the computer apparatus.
The computer device provided by the embodiment of the invention can execute the game synchronization method provided by any embodiment of the invention, and has corresponding functions and beneficial effects.
EXAMPLE six
An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements a synchronization method for a game, and is applied to a server, where the server is configured to maintain states of games in which at least two clients participate, and the method includes:
receiving an operation triggered in the game and sent by one client;
updating a state of the game in response to the operation;
carrying out validity check on the operation according to the game state;
if the operation is legal, recording the operation into the state of the game, and maintaining the state of the game;
sending an operation confirmation message to the client, wherein the client is used for responding to the operation confirmation message and updating the state of the game according to the operation;
and synchronizing the operation to other clients, wherein the other clients are used for updating the state of the game according to the operation.
Of course, the computer program of the computer-readable storage medium provided by the embodiment of the present invention is not limited to the method operations described above, and may also perform related operations in the synchronization method of the game provided by any embodiment of the present invention.
From the above description of the embodiments, it is obvious for those skilled in the art that the present invention can be implemented by software and necessary general hardware, and certainly, can also be implemented by hardware, but the former is a better embodiment in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which may be stored in a computer-readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device) to execute the methods according to the embodiments of the present invention.
It should be noted that, in the embodiment of the synchronization device for the game, the included units and modules are only divided according to the functional logic, but are not limited to the above division as long as the corresponding functions can be realized; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present invention.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (15)

1. A method for synchronizing games, applied to a server, the server maintaining states of games in which at least two clients participate, the method comprising:
receiving an operation triggered in the game and sent by one client;
updating a state of the game in response to the operation;
carrying out validity check on the operation according to the game state;
if the operation is legal, recording the operation into the state of the game, and maintaining the state of the game;
sending an operation confirmation message to the client, wherein the client is used for responding to the operation confirmation message and updating the state of the game according to the operation;
and synchronizing the operation to other clients, wherein the other clients are used for updating the state of the game according to the operation.
2. The method of claim 1, wherein receiving the operation triggered in the game sent by one of the clients comprises:
receiving an operation which is sent by one client and is triggered in the game based on user behaviors, wherein the operation is used for controlling a virtual character in the game;
alternatively, the first and second electrodes may be,
and receiving an operation which is sent by one client and is triggered in the game based on the user attribute, wherein the operation is used for changing the user attribute in the game.
3. The method of claim 1, wherein the legality checking the operation according to the state of the game comprises:
determining the role attribute of the virtual role controlled by the operation as a target role attribute;
determining the character attribute of the virtual character from the state of the game as the original character attribute;
judging whether the original role attribute is the same as the target role attribute;
if the original role attribute is the same as the target role attribute, determining that the operation is legal;
and if the original role attribute is different from the target role attribute, determining that the operation is illegal.
4. The method of claim 3, wherein the determining the character attributes of the virtual character from the state of the game as the original character attributes comprises:
determining a virtual character which is determined in the last operation and is controlled by the client in the current operation from the state of the game;
and determining the role attribute of the virtual role as the original role attribute.
5. The method of claim 1, wherein the legality checking the operation according to the state of the game comprises:
determining the state of the virtual character controlled by the operation in the game as a target state;
determining the states of other virtual characters in the game from the states of the game as original states;
judging whether the original state conflicts with the target state;
if the original state and the target state are not in conflict, determining that the operation is legal;
and if the original state conflicts with the target state, determining that the operation is illegal.
6. The method of claim 5, wherein the original state comprises an original position of the virtual character in the game, and the target state comprises a target position of the virtual character in the game;
the determining whether the original state conflicts with the target state includes:
comparing the original position with the target position;
if the original position and the target position are mutually obstructed, determining that the original state conflicts with the target state;
and if the original position and the target position are not mutually blocked, determining that the original state and the target state are not in conflict.
7. The method of claim 1, wherein the legality checking the operation according to the state of the game comprises:
determining the user attribute of the operation change as a target user attribute;
determining user attributes from the state of the game as original user attributes;
judging whether the original user attribute is the same as the target user attribute;
if the original user attribute is the same as the target user attribute, determining that the operation is legal;
and if the original user attribute is different from the target user attribute, determining that the operation is illegal.
8. The method of any of claims 1-7, further comprising:
if the operation is illegal, rejecting the operation;
synchronizing a state of the game to the client.
9. The method of claim 8, wherein synchronizing the state of the game to the client that triggered the operation comprises:
receiving a state synchronization request sent by the client;
updating a state of the game in response to the state synchronization request;
synchronizing the updated state to the client.
10. The method of any of claims 1-7, further comprising:
determining, in response to the operation, a virtual role, the virtual role having specified attributes;
updating the virtual character to a state of the game;
and informing the client of the virtual role, wherein the client is used for controlling the virtual role in the next operation.
11. The method of any of claims 1-7, further comprising:
receiving a heartbeat request packet sent by the client;
responding to the heartbeat request packet, and sending a heartbeat confirmation packet to the client;
updating a state of the game in response to the heartbeat request packet.
12. The method of any of claims 1-7, further comprising:
storing the state of the game to a designated storage area;
and when the server is restarted, reading the state of the game from the storage area.
13. A game synchronization apparatus applied to a server, the server being configured to maintain a state of a game in which at least two clients participate, the apparatus comprising:
the operation receiving module is used for receiving the operation which is sent by one client and is triggered in the game;
a state updating module for updating the state of the game in response to the operation;
the legality checking module is used for checking the legality of the operation according to the state of the game;
the operation application module is used for recording the operation into the game state and maintaining the game state if the operation is legal;
an operation confirmation message sending module, configured to send an operation confirmation message to the client, where the client is configured to respond to the operation confirmation message and update the state of the game according to the operation;
and the operation synchronization module is used for synchronizing the operation to other clients, and the other clients are used for updating the state of the game according to the operation.
14. A computer device, characterized in that the computer device comprises:
one or more processors;
a memory for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement a method of synchronizing a game as claimed in any one of claims 1-12.
15. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out a method of synchronization of a game according to any one of claims 1-12.
CN201911052233.5A 2019-10-31 2019-10-31 Game synchronization method and device, computer equipment and storage medium Pending CN110812836A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911052233.5A CN110812836A (en) 2019-10-31 2019-10-31 Game synchronization method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911052233.5A CN110812836A (en) 2019-10-31 2019-10-31 Game synchronization method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN110812836A true CN110812836A (en) 2020-02-21

Family

ID=69551688

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911052233.5A Pending CN110812836A (en) 2019-10-31 2019-10-31 Game synchronization method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110812836A (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111346371A (en) * 2020-03-02 2020-06-30 腾讯科技(深圳)有限公司 Information processing method and device and computer readable storage medium
CN111773680A (en) * 2020-07-28 2020-10-16 网易(杭州)网络有限公司 Virtual role position checking method and device, electronic equipment and storage medium
CN111901341A (en) * 2020-07-28 2020-11-06 北京字节跳动网络技术有限公司 State synchronization method and device
CN111957037A (en) * 2020-06-18 2020-11-20 苏州幻塔网络科技有限公司 Game state control method, device, apparatus, system and storage medium
CN112657181A (en) * 2020-12-21 2021-04-16 北京像素软件科技股份有限公司 State synchronization method and device
CN113181633A (en) * 2021-03-26 2021-07-30 百果园技术(新加坡)有限公司 Game data synchronization method, system and device
CN117046103A (en) * 2023-07-18 2023-11-14 广州三七极梦网络技术有限公司 Game fight processing method, device, equipment and storage medium

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002066139A (en) * 2000-08-24 2002-03-05 Taito Corp Game system and recording medium storing game program
CN103780619A (en) * 2014-01-08 2014-05-07 深圳市掌玩网络技术有限公司 Wide area network real-time interactive game synchronization method and device, and system
CN107970603A (en) * 2017-12-15 2018-05-01 百度移信网络技术(北京)有限公司 Method for gaming, client, server-side, game host, equipment and storage medium
CN108057241A (en) * 2017-12-12 2018-05-22 苏州蜗牛数字科技股份有限公司 A kind of sports type game server system and its exchange method
CN108159691A (en) * 2017-12-06 2018-06-15 北京像素软件科技股份有限公司 Game state synchronous method and system
CN109045703A (en) * 2018-07-24 2018-12-21 合肥爱玩动漫有限公司 A method of detection network game external store
CN109718556A (en) * 2019-01-30 2019-05-07 腾讯科技(深圳)有限公司 Game data processing method, device and server
CN110166276A (en) * 2018-11-23 2019-08-23 深圳市腾讯信息技术有限公司 A kind of localization method, device, terminal device and the medium of frame synchronization exception
CN110339575A (en) * 2018-04-08 2019-10-18 腾讯科技(深圳)有限公司 It practises fraud in a kind of determining online game the method and device of user

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002066139A (en) * 2000-08-24 2002-03-05 Taito Corp Game system and recording medium storing game program
CN103780619A (en) * 2014-01-08 2014-05-07 深圳市掌玩网络技术有限公司 Wide area network real-time interactive game synchronization method and device, and system
CN108159691A (en) * 2017-12-06 2018-06-15 北京像素软件科技股份有限公司 Game state synchronous method and system
CN108057241A (en) * 2017-12-12 2018-05-22 苏州蜗牛数字科技股份有限公司 A kind of sports type game server system and its exchange method
CN107970603A (en) * 2017-12-15 2018-05-01 百度移信网络技术(北京)有限公司 Method for gaming, client, server-side, game host, equipment and storage medium
CN110339575A (en) * 2018-04-08 2019-10-18 腾讯科技(深圳)有限公司 It practises fraud in a kind of determining online game the method and device of user
CN109045703A (en) * 2018-07-24 2018-12-21 合肥爱玩动漫有限公司 A method of detection network game external store
CN110166276A (en) * 2018-11-23 2019-08-23 深圳市腾讯信息技术有限公司 A kind of localization method, device, terminal device and the medium of frame synchronization exception
CN109718556A (en) * 2019-01-30 2019-05-07 腾讯科技(深圳)有限公司 Game data processing method, device and server

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111346371A (en) * 2020-03-02 2020-06-30 腾讯科技(深圳)有限公司 Information processing method and device and computer readable storage medium
CN111346371B (en) * 2020-03-02 2021-01-01 腾讯科技(深圳)有限公司 Information processing method and device and computer readable storage medium
CN111957037A (en) * 2020-06-18 2020-11-20 苏州幻塔网络科技有限公司 Game state control method, device, apparatus, system and storage medium
CN111773680A (en) * 2020-07-28 2020-10-16 网易(杭州)网络有限公司 Virtual role position checking method and device, electronic equipment and storage medium
CN111901341A (en) * 2020-07-28 2020-11-06 北京字节跳动网络技术有限公司 State synchronization method and device
CN111901341B (en) * 2020-07-28 2022-05-24 北京字节跳动网络技术有限公司 State synchronization method and device
CN111773680B (en) * 2020-07-28 2024-04-26 网易(杭州)网络有限公司 Virtual character position verification method and device, electronic equipment and storage medium
CN112657181A (en) * 2020-12-21 2021-04-16 北京像素软件科技股份有限公司 State synchronization method and device
CN113181633A (en) * 2021-03-26 2021-07-30 百果园技术(新加坡)有限公司 Game data synchronization method, system and device
CN113181633B (en) * 2021-03-26 2024-02-13 百果园技术(新加坡)有限公司 Game data synchronization method, system and device
CN117046103A (en) * 2023-07-18 2023-11-14 广州三七极梦网络技术有限公司 Game fight processing method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN110812836A (en) Game synchronization method and device, computer equipment and storage medium
US20220379202A1 (en) Data packet synchronization method and apparatus, device, and storage medium
US11878251B2 (en) Method of synchronizing online game, and server device
EP3807766B1 (en) Shadow tracking of real-time interactive simulations for complex system analysis
CN108744504B (en) Game data processing method and device, game server and game system
EP3934775B1 (en) Peer-to-peer multiplayer cloud gaming architecture
CN111614708A (en) Transaction system based on block chain
CN110764871A (en) Cloud platform-based mimicry application packaging and control system and method
CN109966741B (en) Position updating method, device, equipment and storage medium
CN114344892A (en) Data processing method and related device
CN111625353A (en) Virtual resource distribution processing method, device, server and storage medium
US9977795B1 (en) System and method for multiplayer network gaming
JP7178421B2 (en) Information processing method, device, program, and recording medium
CN117407713A (en) Training management method and related device for distributed model training
CN106453223B (en) Seamless world game server system
CN113244609A (en) Multi-picture display method and device, storage medium and electronic equipment
CN109718543B (en) Same-screen processing method and device
US12005348B2 (en) Game delivery system
CN112138372B (en) Data synchronization method in distributed system and related equipment
CN117242462A (en) Edge device, edge server, and synchronization thereof for improving distributed training of Artificial Intelligence (AI) models in AI systems
US20130059662A1 (en) Semi-synchronous multi-participant application updates
CN110086861B (en) Collaborative simulation method, system, server and client
CN105978746A (en) Game server cluster system and method for improving game space service
US20240165513A1 (en) Data processing method and apparatus for virtual scene, electronic device, computer-readable storage medium, and computer program product
CN113181633B (en) Game data synchronization method, system and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20200221