State synchronization method and device
By obtaining and predicting game character status in massively multiplayer online games, it solves the difficulty and high complexity of status synchronization in the existing technology and improves the game experience and processing efficiency.
Patent Information
- Application Number
- CN202011515017.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-21
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2040-12-21
AI Technical Summary
Existing technology In massively multiplayer online games, game character status synchronization has problems such as difficulty in instant effect, high complexity, and difficulty in implementation, resulting in poor experience and high complexity.
By obtaining the operation input and status of the current frame of the game character sent by the server, predicting the status of the next frame, and processing based on the predicted status, the status synchronization of the game scene is achieved. If the predicted status does not match the actual status, it will be corrected to ensure that the status takes effect immediately. .
It improves the game experience, avoids the problems of high complexity and difficulty in implementation, and achieves instant synchronization and efficient processing of game character status.
Smart Images

Figure CN112657181B
Abstract
Description
Technical Field
[0001] The present application relates to the field of terminal game application technology, and in particular to a state synchronization method and device. Background Art
[0002] In online game scenarios, especially in massively multiplayer online games, the problem of how to synchronize the status of various game characters in the game scenario is particularly important. Common processing methods in the current prior art include, for example, each client sends information to the server, which processes it uniformly, or directly simulates the status of game characters of other clients based on the scenario, and when receiving input information sent by other clients, rolls back the entire game and corrects the status of the game characters.
[0003] The technical solutions adopted in the prior art either have the defect that the game character status itself is difficult to take effect immediately, resulting in a poor user experience, or have the problem of high complexity and high implementation difficulty caused by the need for frequent rollback processing. Summary of the invention
[0004] The purpose of the present application includes, for example, providing a state synchronization method and device, which can improve the user experience and avoid high complexity problems.
[0005] The embodiments of the present application can be implemented as follows:
[0006] In a first aspect, the present application provides a state synchronization method, which is applied to any client in a synchronization system comprising multiple clients, each of which is in communication connection with a server, and the method comprises:
[0007] Obtaining the current operation input and current state of the game character of the current frame corresponding to any client sent by the server;
[0008] Predicting the state of the game character in a subsequent frame according to the acquired current operation input;
[0009] Based on the acquired current state, the predicted state of the game character predicted in advance according to the previous frame information is processed to achieve state synchronization of the game character in the game scene.
[0010] In an optional embodiment, the step of processing the predicted state of the game character predicted in advance according to the previous frame information based on the acquired current state to achieve state synchronization of the game character in the game scene includes:
[0011] Comparing whether the current state obtained is the same as the predicted state of the game character predicted in advance based on the previous frame information;
[0012] If they are the same, no action will be taken;
[0013] If they are not the same, the predicted state of the game character is corrected to the current state to achieve state synchronization of the game character in the game scene.
[0014] In an optional embodiment, the method further comprises:
[0015] Upon receiving an operation instruction, generating a predicted state of the own game character according to the operation instruction, and changing the state of the own game character to the predicted state;
[0016] Sending the operation instruction and the predicted state to the server, so that the server verifies the predicted state according to the operation instruction;
[0017] The game character status is processed according to the verification result fed back by the server.
[0018] In an optional implementation, the step of processing the state of the own game character according to the verification result fed back by the server includes:
[0019] When the verification result indicates that the predicted state verification has passed, the state of the own game character is changed into the predicted state in effect;
[0020] When the verification result indicates that the predicted state verification fails, the state of the own game character is restored to the state before being changed to the predicted state.
[0021] In an optional implementation manner, the server stores a complete state of the game character corresponding to each of the clients, and the complete state includes all state information from the time when the game character enters the game scene to the current state;
[0022] The method further comprises:
[0023] Before entering the game scene, a status acquisition request is sent to the server;
[0024] Receiving the complete status of the game character corresponding to each of the clients in the game scene returned by the server based on the status acquisition request;
[0025] The state of the corresponding game character in the current game scene is updated according to the received complete state.
[0026] In a second aspect, the present application provides a state synchronization method, which is applied to a server communicating with each client included in a synchronization system, and the method includes:
[0027] Obtaining an operation instruction for a corresponding game character sent by any client, and a predicted state predicted based on the operation instruction;
[0028] The predicted state is verified based on the operation instruction, and after the verification is passed, the operation instruction and the predicted state of any client are broadcast in the synchronization system, so that other clients can achieve state synchronization of game characters in the game scene based on the operation instruction and the predicted state.
[0029] In an optional implementation, the step of verifying the predicted state based on the current operation input includes:
[0030] Get scene object information in the game scene;
[0031] Obtaining a corresponding operation result according to the operation instruction and the predicted state;
[0032] Verify whether the operation result complies with the setting rule of the scene object, and if so, determine that the predicted state verification passes.
[0033] In an optional implementation, the step of verifying the predicted state based on the current operation input includes:
[0034] Acquire the operation type of the operation instruction, and obtain the corresponding operation result according to the operation instruction and the predicted state;
[0035] Obtaining a preset and saved setting range corresponding to the operation type;
[0036] Detect whether the operation result is within the set range, and if so, determine that the predicted state check has passed.
[0037] In an optional implementation manner, the current game character of any client is changed to the predicted state, and the method further includes:
[0038] Acquire the operation type of the operation instruction, and obtain the corresponding operation result according to the operation instruction and the predicted state;
[0039] Obtaining a preset and saved setting range corresponding to the operation type;
[0040] Detect whether the operation result is within the set range, and if so, determine that the predicted state check has passed.
[0041] In a third aspect, the present application provides a state synchronization device, which is applied to any client in a synchronization system including multiple clients, each of which is connected to a server for communication, and the device includes:
[0042] A first acquisition module is used to acquire the current operation input and current state of the game character corresponding to any client in the current frame sent by the server;
[0043] A prediction module, used for predicting the state of the game character in the next frame according to the current operation input obtained;
[0044] The synchronization module is used to process the predicted state of the game character predicted in advance according to the previous frame information based on the acquired current state, so as to achieve the state synchronization of the game character in the game scene.
[0045] In a fourth aspect, the present application provides a state synchronization device, which is applied to a server communicating with each client included in a synchronization system, and the device includes:
[0046] A second acquisition module is used to acquire an operation instruction sent by any client for a corresponding game character, and a predicted state predicted based on the operation instruction;
[0047] The verification module is used to verify the predicted state based on the operation instruction, and after the verification is passed, the operation instruction and the predicted state of any client are broadcast in the synchronization system, so that other clients can achieve state synchronization of game characters in the game scene based on the operation instruction and the predicted state.
[0048] The beneficial effects of the embodiments of the present application include, for example:
[0049] The present application provides a state synchronization method and device, which obtains the current operation input and current state of the current frame of the game character corresponding to any client sent by the server, so as to predict the state of the next frame of the game character according to the obtained current operation input, and process the predicted state of the game character predicted in advance according to the previous frame information based on the obtained current state, thereby realizing the state synchronization of the game assumptions in the game scene. In this scheme, the state of the game character can be predicted based on the operation information of the game character, and the state itself can be realized immediately to improve the experience, and the predicted state can also be processed based on the received state of other game characters, avoiding the problems of high complexity and high implementation difficulty in the prior art that each time the input information of other game characters is received, the rollback process needs to be performed. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0051] Figure 1 A schematic diagram of an application scenario of the state synchronization method provided in an embodiment of the present application;
[0052] Figure 2 A flowchart of a state synchronization method provided in an embodiment of the present application;
[0053] Figure 3 for Figure 2 Flow chart of the sub-steps of step S130;
[0054] Figure 4 A flowchart of a prediction state verification method in a state synchronization method provided in an embodiment of the present application;
[0055] Figure 5 A flowchart of a complete state acquisition method in a state synchronization method provided in an embodiment of the present application;
[0056] Figure 6 Another flow chart of the state synchronization method provided in an embodiment of the present application;
[0057] Figure 7 for Figure 6 Flow chart of the sub-steps of step S420;
[0058] Figure 8 for Figure 6 Another flowchart of the sub-steps of step S420;
[0059] Fig. 9 A functional module block diagram of a state synchronization device provided in an embodiment of the present application;
[0060] Fig.10 Another functional module block diagram of the state synchronization device provided in an embodiment of the present application;
[0061] Fig.11 A structural block diagram of an electronic device provided in an embodiment of the present application.
[0062] Icons: 100 - client; 110 - state synchronization device; 111 - first acquisition module; 112 - prediction module; 113 - synchronization module; 114 - second acquisition module; 115 - verification module; 120 - memory; 130 - processor; 140 - communication unit; 200 - server. DETAILED DESCRIPTION
[0063] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.
[0064] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0065] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0066] It should be noted that, in the absence of conflict, the features in the embodiments of the present application may be combined with each other.
[0067] The online game synchronization protocol belongs to the application layer and relies on transport layer technologies such as TCP, UDP, or encapsulated network libraries. Online game synchronization itself does not care about the details of the underlying transport protocol, but only cares about the characteristics of the transport protocol: whether the order is guaranteed, whether there will be packet loss, etc. In the existing technology, when implementing online game synchronization, the following methods are mainly used:
[0068] One way is to use the standard C / S mode state synchronization method, in which each terminal sends a request to the server, which processes the request and broadcasts the result to each terminal. This method is highly secure because all logic is on the server, and it is low in complexity and simple to implement. However, the disadvantage is that the input of the terminal cannot take effect immediately, resulting in a poor user experience, and because the amount of data that needs to be synchronized is large, all logic is processed on the server, which puts a lot of processing pressure on the server.
[0069] Another way is to use frame lock synchronization. This method requires all terminals to start from the same initial state, and each terminal only sends its own input information. After receiving the input of other terminals, each terminal simulates the same result with the received input. This method requires a small amount of data to be synchronized, and has low complexity and simple implementation. However, the security is poor, so most of the logic is basically processed in the terminal, and when a terminal joins the game late, because each terminal only sends its own input and has no concept of the current state, in a game scenario with a fixed duration and a long number of participants, the terminal that joins late can also start from the initial state and quickly process all inputs from the initial state to the time of joining to catch up with the current game state. However, in a multiplayer large-scale online game scenario, it is difficult for a terminal that joins late to synchronize the state of other terminals. In addition, since the input of all terminals needs to arrive before executing the game logic, the actual game experience of each terminal depends on the terminal with the highest network delay, and the experience is poor.
[0070] Another method is a combination of frame lock synchronization and client prediction. In this method, when each terminal is controlling its own character, the input can take effect immediately, without waiting for the input from other terminals to arrive, and the game can be directly simulated (predicted). After the input from other terminals is transmitted over the network, the entire game is rolled back to the previous state, and the input from other terminals is reapplied to calculate the correct result, and the predicted result is corrected to the correct result. The advantage of this method is that the experience is good, and the network delay no longer depends on the terminal with the highest delay. However, this method is complex and difficult to implement. The game logic and rendering need to be separated, the game logic supports efficient stepping and rollback, and the historical state needs to be stored.
[0071] Based on the above research findings, the present application provides a state synchronization solution to at least partially improve the problems existing in the above prior art.
[0072] See also Figure 1 , is a schematic diagram of an application scenario of the state synchronization method provided in an embodiment of the present application, wherein the application scenario includes a synchronization system and a server 200, wherein the synchronization system includes multiple clients 100, each client 100 is in communication connection with the server 200, wherein each client 100 in the synchronization system can be in communication connection with each other. The server 200 can receive messages, data, etc. sent by each client 100, and process the received messages and data, and then feed them back to the corresponding client 100, or broadcast them in the synchronization system to inform other clients 100.
[0073] In this embodiment, the client 100 may be, but is not limited to, a terminal device such as a smart phone, a tablet computer, a personal computer, a laptop computer, etc. In this embodiment, a scenario in which a user operates a game through the client 100 is used as an example for explanation. Each client 100 may be installed with a relevant game application, and the server 200 may be a background server of the game application.
[0074] Understandably, Figure 1 The scenario shown is only a feasible example. In other feasible embodiments, the scenario may also include only Figure 1 Some of the components shown may also include other components.
[0075] Figure 2 A schematic diagram of a state synchronization method provided in an embodiment of the present application is shown. The state synchronization method can be performed by Figure 1 Executed by any client 100 shown in .
[0076] It should be understood that in other embodiments, the order of some steps in the state synchronization method of this embodiment can be exchanged according to actual needs, or some steps can be omitted or deleted. The detailed steps of the state synchronization method are introduced as follows.
[0077] Step S110 , obtaining the current operation input and current state of the game character of the current frame corresponding to any client 100 sent by the server 200 .
[0078] Step S120, predicting the state of the game character in the next frame according to the acquired current operation input.
[0079] Step S130, based on the acquired current state, the predicted state of the game character predicted in advance according to the previous frame information is processed to achieve state synchronization of the game character in the game scene.
[0080] In this embodiment, the user can log in to the game account on the client 100 held by the user to enter the game scene. After entering the game scene, the user can control his own game character, such as controlling the game character to move forward, run, jump, etc. In a multiplayer large-scale online game scene, there are often multiple game characters, and each game character is controlled by a corresponding user through his client 100. Therefore, for each user, it is necessary to synchronize the status of other game characters on his own client 100, so as to present an accurate global status in the game scene on his own client 100, so as to determine the operation of controlling his own game character.
[0081] During implementation, when a user needs to control his or her own game character, the latest status of the game characters of other clients 100 may not be obtained at this time. Therefore, the client 100 corresponding to the user can only predict the latest status of the game characters of other clients 100 through their previous status or previous input, and thus determine the control of his or her own game character based on the predicted latest status of other game characters.
[0082] On this basis, the operation information and state information of the game characters of other clients 100 will be forwarded to each client 100 in the synchronization system after being processed by the server 200. Therefore, for a certain client 100, although it has previously predicted the state of the game characters of other clients 100, the actual current state of other clients 100 will eventually be forwarded to itself through the server 200.
[0083] The information forwarded by the server 200 to itself includes the current operation input and current state of the current frame of the game character of the other client 100. The so-called current operation input is the latest manipulation of the game character, for example, controlling the game character to run, jump, etc., and the current state is based on the current real state of the game character.
[0084] Therefore, after receiving the current operation input of other game characters forwarded by the server 200, the state of the other game characters in the next frame can be predicted based on the obtained current operation input, and the predicted state can be used to present in the game scene of the next frame of its own client 100 as a reference for the manipulation of its own game character.
[0085] In addition, it can be known from the above that the state of other game characters is predicted based on the previous state or input of other clients 100. Therefore, when the real state of other clients 100 arrives, the predicted state of the game characters predicted in advance based on the previous frame information can be processed based on the current state of other game characters obtained. This ensures that the state of each game character in the final game scene is its real state.
[0086] In this embodiment, the state of the game character can be predicted based on its operation information, which can achieve the purpose of instant state effectiveness and improve the user experience. In addition, the predicted state can be processed based on the received state of other valid characters, avoiding the high complexity and difficulty of implementation in the prior art that each time the input information of other game characters is received, the rollback process needs to be performed.
[0087] In this embodiment, it can be seen from the above that when receiving the current state of other game characters, the state predicted by the game character corresponding to itself can be processed according to the current state, and this step can be implemented in the following way, see Figure 3 :
[0088] Step S131, compare whether the current state obtained is the same as the predicted state of the game character predicted in advance based on the previous frame information. If they are the same, execute the following step S132; if they are not the same, execute the following step S133.
[0089] Step S132, no processing.
[0090] Step S133, correcting the predicted state of the game character to the current state, so as to achieve state synchronization of the game character in the game scene.
[0091] In this embodiment, the prediction of each client 100 on the game character of another client 100 is accurate in most cases. For example, if the previous operation of another game character is to move forward, it is easy to predict the distance that the game character can move forward by this operation, or if another game character releases a skill, it is easy to predict the effect that the skill can trigger. In other words, the subsequent state of another character can be predicted more accurately through its previous state.
[0092] Based on this, in this embodiment, a method is adopted to receive the current state of the game character of other clients 100 and correct the predicted state of the game character. The method adopted in the prior art is to predict the state of other game characters in advance, and roll back the entire game to the previous state after receiving the real input of other game characters, and then re-apply the input of other game characters to calculate the correct state, and correct the predicted state to the correct state. This method adopted in the prior art requires multiple rollback processes during the game, and the processing complexity is high.
[0093] In this embodiment, the predicted state is corrected based on the received current state, and processing is performed only when the predicted state is different from the received current state. This can ensure a high accuracy rate and avoid the problem of high complexity.
[0094] In this embodiment, for a certain client 100, when controlling the game, it is necessary to predict the status of other game characters so as to synchronize the status. At the same time, for its own game character, its own control of the game character needs to be verified by the server 200 to avoid cheating in the game scene. Based on this consideration, please refer to Figure 4The state synchronization method provided in this embodiment also includes the following steps:
[0095] Step S210, when an operation instruction is received, a predicted state of the own game character is generated according to the operation instruction, and the state of the own game character is changed to the predicted state.
[0096] Step S220: sending the operation instruction and the predicted state to the server 200, so that the server 200 verifies the predicted state according to the operation instruction.
[0097] Step S230, processing the game character status according to the verification result fed back by the server 200.
[0098] In this embodiment, the user can control the game character through the client 100, and the client 100 can generate the predicted state of its own game character according to the operation instruction issued by the user. For example, when the operation instruction is to move forward one step, the predicted state can be the state after moving forward a certain distance, such as one meter or ten meters, etc. And the state of its own game character is changed to the predicted state.
[0099] However, the predicted state generated by the client 100 itself may not be reasonable. For example, if the operation instruction is to move forward one step, then the prediction that the game character can move forward one meter is relatively reasonable, but if the game character is predicted to move forward ten meters, then the prediction is unreasonable. Therefore, in this embodiment, after each client 100 predicts the state of its own game character, it needs to send the operation instruction and the predicted state to the server 200, and the server 200 verifies the predicted state according to the operation instruction.
[0100] After receiving the operation instruction and predicted state sent by the client 100, the server 200 can verify the predicted state based on the operation instruction, and after the verification is passed, broadcast the operation instruction and predicted state of the client 100 in the synchronization system to inform other clients 100. After obtaining the operation instruction and predicted state of the client 100, other clients 100 can synchronize the state in the game scene in the above manner based on the obtained information.
[0101] Optionally, in this embodiment, when the server 200 verifies the predicted state of the client 100, it mainly verifies the rationality and correctness of the predicted state. As a possible implementation method, the server 200 can verify the correctness of the predicted state in the following manner:
[0102] The server 200 can obtain scene object information in the game scene, obtain corresponding operation results according to the above operation instructions and predicted states, and verify whether the operation results comply with the setting rules of the scene objects. If so, it is determined that the predicted state verification has passed.
[0103] Among them, scene objects may include objects in the game scene such as trees, walls, water surfaces, sky, etc., and scene object information may include the positions of trees, walls, etc., the position and area of water surfaces, the position of the sky, etc.
[0104] The operation result obtained based on the operation instruction and the predicted state can be understood as the behavior triggered by the operation instruction, based on which the state of the game character can be changed to the predicted state. For example, if the operation instruction is to move forward, the operation result can be the specific movement operation under the operation instruction, such as the distance traveled, the direction traveled, etc., and the predicted state is the state reached after the specific behavior operation.
[0105] Optionally, the operation result is checked to see if it complies with the setting rules of the scene object. For example, if it is shown that there is an obstacle such as a tree or a wall in the direction of travel, but the game character is shown to have passed the obstacle based on the operation result and the predicted state, it indicates that the predicted state is inaccurate. If the operation result and the predicted state comply with the setting rules of the scene object, it can be determined that the predicted state verification has passed.
[0106] In addition, in another implementation, the server 200 may verify the rationality of the predicted state in the following manner:
[0107] The server 200 can obtain the operation type of the operation instruction, and obtain the corresponding operation result according to the operation instruction and the predicted state, obtain the pre-set and saved setting range corresponding to the operation type, and detect whether the operation result is within the setting range. If so, it is determined that the predicted state verification has passed.
[0108] In this embodiment, for example, the operation instruction may be to control the game character to move forward one step, and the operation result may be the specific triggered forward distance, such as one meter or ten meters. When the operation instruction is such a moving instruction, a preset setting range of the relevant moving distance may be obtained. For example, if the distance to move forward one step is one meter, it can be determined that the predicted state is reasonable within the setting range, that is, the verification is passed. If the distance to move forward one step is ten meters, it exceeds the setting range, and it can be determined that the predicted state is unreasonable, that is, the verification is not passed.
[0109] After verifying the predicted state in the above manner, the server 200 may feed back the verification result to the client 100. After receiving the verification result fed back by the server 200, the client 100 may process the state of its own game character.
[0110] Optionally, if the verification result indicates that the predicted state verification of the client 100 has passed, it can be known from the above that the client 100 has changed the state of its own game character to the predicted state when obtaining the predicted state, so the state of its own game character changed to the predicted state can be effective. If the verification result indicates that the predicted state verification of the client 100 has not passed, the state of its own game character can be restored to the state before changing to the predicted state.
[0111] In this way, through the above method, cheating behavior of a user of a certain client 100 during the game process can be avoided, and fairness in the game process can be guaranteed.
[0112] In this embodiment, it is also considered that some clients join the game after the game has been going on for a while. In order to avoid these users having difficulty synchronizing the status of other game characters, in this embodiment, the server 200 also stores the complete status of the game character corresponding to each client 100, which includes all status information from the time the game character enters the game scene to the current state. Based on this, please refer to Figure 5 The state synchronization method provided in this embodiment also includes the following steps:
[0113] Step S310, before entering the game scene, sending a status acquisition request to the server 200.
[0114] Step S320, receiving the complete status of the game character corresponding to each of the clients 100 in the game scene returned by the server 200 based on the status acquisition request.
[0115] Step S330: updating the state of the corresponding game character in the current game scene according to the received complete state.
[0116] For each client 100, if the game has been going on for a while when the client 100 enters the game scene, the client 100 can send a request to the server 200 to obtain the complete status of other clients 100 in the game scene. In this way, for users who join the game later, they can accurately synchronize with the status of other clients 100 based on the complete status saved by the server 200, even if they join later, and realize the synchronization of the game character status in the game scene.
[0117] The present application also provides a state synchronization method applied to the server 200. Figure 6, which is a flow chart of the state synchronization method. It should be understood that in other embodiments, the order of some steps in the state synchronization method of this embodiment can be interchanged according to actual needs, or some steps can be omitted or deleted. The detailed steps of the state synchronization method are described as follows.
[0118] Step S410, obtaining an operation instruction for a corresponding game character sent by any client 100, and a predicted state predicted based on the operation instruction.
[0119] Step S420, verifying the predicted state based on the operation instruction, and broadcasting the operation instruction and the predicted state of any client 100 in the synchronization system after the verification is passed, so that other clients 100 can synchronize the states of the game characters in the game scene based on the operation instruction and the predicted state.
[0120] In this embodiment, the server 200 can verify the predicted state of each client 100 based on the operation instructions of the client 100, and if the verification passes, broadcast it to other clients 100, so that other clients 100 can synchronize the state in the game scene.
[0121] For details not provided in the state synchronization method of this embodiment, please refer to the related description of the state synchronization method applied to any client 100 mentioned above, and this embodiment will not be described in detail here.
[0122] As a possible implementation, see Figure 7 In this embodiment, the server 200 can verify the predicted state of the client 100 in the following manner:
[0123] Step S421, obtaining scene object information in the game scene.
[0124] Step S422: Obtain a corresponding operation result according to the operation instruction and the predicted state.
[0125] Step S423, verifying whether the operation result complies with the setting rule of the scene object, and if so, determining that the prediction state verification has passed.
[0126] In this embodiment, the server 200 can combine the scene object information in the game scene to verify whether the predicted state of the client 100 is correct, so as to avoid cheating by the user during the game.
[0127] Also, as another possible implementation, see Figure 8 In this embodiment, the server 200 can also verify the predicted state of the client 100 in the following manner:
[0128] Step S424, obtaining the operation type of the operation instruction, and obtaining the corresponding operation result according to the operation instruction and the predicted state.
[0129] Step S425, obtaining a preset and saved setting range corresponding to the operation type.
[0130] Step S426, detecting whether the operation result is within the set range, and if so, determining that the predicted state check has passed.
[0131] In this embodiment, the server 200 may also verify the rationality of the predicted state in combination with a preset range.
[0132] Furthermore, after the client 100 obtains the predicted state, it changes its own game character to the predicted state. After verification by the server 200, if the verification of the predicted state fails, the server 200 can control the client 100 to restore the state of its own game character to the state before it was changed to the predicted state.
[0133] It should be noted that for the details not described in this embodiment, please refer to the description of the above embodiments, and this embodiment will not be repeated here.
[0134] In addition, in order to more clearly describe the state synchronization method provided by the present application, the following schematically shows the pseudo code for implementing the state synchronization method:
[0135]
[0136]
[0137]
[0138] like Fig. 9 , which is a functional module block diagram of a state synchronization device 110 applied to the client 100 according to an embodiment of the present application. The device includes a first acquisition module 111 , a prediction module 112 and a synchronization module 113 .
[0139] The first acquisition module 111 is used to acquire the current operation input and current state of the game character in the current frame corresponding to any client 100 sent by the server 200.
[0140] In this embodiment, the description of the first acquisition module 111 can be specifically referred to in Figure 2 The detailed description of step S110 shown in FIG. 1 , that is, step S110 may be executed by the first acquisition module 111 .
[0141] The prediction module 112 is used to predict the state of the game character in the next frame according to the current operation input obtained.
[0142] In this embodiment, the description of the prediction module 112 can be specifically referred to in Figure 2 The detailed description of step S120 is shown, that is, step S120 may be performed by the prediction module 112 .
[0143] The synchronization module 113 is used to process the predicted state of the game character predicted in advance according to the previous frame information based on the acquired current state, so as to achieve state synchronization of the game character in the game scene.
[0144] In this embodiment, the description of the synchronization module 113 can be specifically referred to in Figure 2 The detailed description of step S130 shown in FIG. 1 is that step S130 may be executed by the synchronization module 113 .
[0145] In a possible implementation, the synchronization module 113 may process the prediction state in the following manner:
[0146] Comparing whether the current state obtained is the same as the predicted state of the game character predicted in advance based on the previous frame information;
[0147] If they are the same, no action will be taken;
[0148] If they are not the same, the predicted state of the game character is corrected to the current state to achieve state synchronization of the game character in the game scene.
[0149] In a possible implementation, the state synchronization device 110 further includes a generation module, which is used to:
[0150] Upon receiving an operation instruction, generating a predicted state of the own game character according to the operation instruction, and changing the state of the own game character to the predicted state;
[0151] Sending the operation instruction and the predicted state to the server 200, so that the server 200 verifies the predicted state according to the operation instruction;
[0152] The game character status is processed according to the verification result fed back by the server 200.
[0153] In a possible implementation, the above generation module may be specifically used for:
[0154] When the verification result indicates that the predicted state verification has passed, the state of the own game character is changed into the predicted state in effect;
[0155] When the verification result indicates that the predicted state verification fails, the state of the own game character is restored to the state before being changed to the predicted state.
[0156] In a possible implementation, the server 200 stores the complete status of the game character corresponding to each of the clients 100, and the complete status includes all status information from the time when the game character enters the game scene to the current state. The status synchronization device 110 further includes a request module, which is used to:
[0157] Before entering the game scene, a status acquisition request is sent to the server 200;
[0158] Receiving the complete status of the game characters corresponding to each of the clients 100 in the game scene returned by the server 200 based on the status acquisition request;
[0159] The state of the corresponding game character in the current game scene is updated according to the received complete state.
[0160] like Fig.10 , which is a functional module block diagram of a state synchronization device 110 applied to the server 200 according to an embodiment of the present application. The device includes a second acquisition module 114 and a verification module 115 .
[0161] The second acquisition module 114 is used to acquire an operation instruction sent by any client 100 for a corresponding game character, and a predicted state predicted based on the operation instruction.
[0162] In this embodiment, the description of the second acquisition module 114 can be specifically referred to in Figure 6 The detailed description of step S410 shown in FIG. 4 shows that step S410 may be executed by the second acquisition module 114 .
[0163] The verification module 115 is used to verify the predicted state based on the operation instruction, and after the verification is passed, the operation instruction and the predicted state of any client 100 are broadcast in the synchronization system, so that other clients 100 can achieve state synchronization of game characters in the game scene based on the operation instruction and the predicted state.
[0164] In this embodiment, the description of the verification module 115 can be specifically referred to in Figure 6 The detailed description of step S420 shown in FIG. 1 , that is, step S420 may be executed by the verification module 115 .
[0165] In a possible implementation, the verification module 115 may be used to verify the predicted state in the following manner:
[0166] Get scene object information in the game scene;
[0167] Obtaining a corresponding operation result according to the operation instruction and the predicted state;
[0168] Verify whether the operation result complies with the setting rule of the scene object, and if so, determine that the predicted state verification passes.
[0169] In a possible implementation, the verification module 115 may also be used to verify the predicted state in the following manner:
[0170] Acquire the operation type of the operation instruction, and obtain the corresponding operation result according to the operation instruction and the predicted state;
[0171] Obtaining a preset and saved setting range corresponding to the operation type;
[0172] Detect whether the operation result is within the set range, and if so, determine that the predicted state check has passed.
[0173] In a possible implementation, the current game character of any client 100 is changed to the predicted state, and the verification module 115 can also be used to:
[0174] When the predicted state check fails, any one of the clients 100 is controlled to restore the state of its own game character to the state before it is changed to the predicted state.
[0175] like Fig.11 As shown, the embodiment of the present application further provides an electronic device, which may be the above-mentioned client 100 or server 200. The electronic device includes a state synchronization device 110, a memory 120, a processor 130 and a communication unit 140.
[0176] The memory 120, the processor 130 and the communication unit 140 are electrically connected to each other directly or indirectly to realize the transmission or interaction of information. For example, these elements can be electrically connected to each other through one or more communication buses or signal lines. The memory 120 stores software function modules stored in the memory 120 in the form of software or firmware. The processor 130 executes various functional applications and data processing by running software programs and modules stored in the memory 120, such as the state synchronization device 110 in the embodiment of the present application, that is, realizing the state synchronization method in the embodiment of the present application.
[0177] The memory 120 may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc. The memory 120 is used to store a program, and the processor 130 executes the program after receiving an execution instruction. The communication unit 140 is used to establish communication between the electronic device and other external devices.
[0178] The processor 130 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor 130 may be a general-purpose processor, including a central processing unit (CPU), a graphics processing unit (GPU), a network processor (NP), etc. It can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor 130 can also be any conventional processor, etc.
[0179] The embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by the processor 130, the steps of the above-mentioned state synchronization method are executed.
[0180] In summary, the present application provides a state synchronization method and device, which obtains the current operation input and current state of the current frame of the game character corresponding to any client 100 sent by the server 200, so as to predict the state of the next frame of the game character according to the obtained current operation input, and processes the predicted state of the game character predicted in advance according to the previous frame information based on the obtained current state, thereby realizing the state synchronization of the game assumptions in the game scene. In this scheme, the state of the game character can be predicted based on the operation information of the game character, and the state itself can be realized immediately to improve the experience, and the predicted state can also be processed based on the received state of other game characters, avoiding the problems of high complexity and high implementation difficulty in the prior art that each time the input information of other game characters is received, the rollback process needs to be performed.
[0181] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A state synchronization method, It is characterized in that Applied to any client in a synchronization system comprising a plurality of clients, each of the clients being in communication connection with a server, the method comprising: Obtaining the current operation input and current state of the game character of the current frame corresponding to any client sent by the server; Predicting the state of the game character in a subsequent frame according to the acquired current operation input; Based on the acquired current state, the predicted state of the game character predicted in advance according to the previous frame information is processed to achieve state synchronization of the game character in the game scene; When receiving an operation instruction from a user, the predicted state of the own game character is generated according to the operation instruction, and the state of the own game character is changed to the predicted state; the operation instruction and the predicted state are sent to the server, so that the server verifies the predicted state according to the operation instruction; and the state of the own game character is processed according to the verification result fed back by the server.
2. The state synchronization method according to claim 1, It is characterized in that The step of processing the predicted state of the game character predicted in advance according to the previous frame information based on the acquired current state to achieve state synchronization of the game character in the game scene includes: Comparing whether the current state obtained is the same as the predicted state of the game character predicted in advance based on the previous frame information; If they are the same, no action will be taken; If they are not the same, the predicted state of the game character is corrected to the current state to achieve state synchronization of the game character in the game scene.
3. The state synchronization method according to claim 1, It is characterized in that The step of processing the state of the game character according to the verification result fed back by the server includes: When the verification result indicates that the predicted state verification has passed, the state of the own game character is changed into the predicted state in effect; When the verification result indicates that the predicted state verification fails, the state of the own game character is restored to the state before being changed to the predicted state.
4. The state synchronization method according to claim 1, It is characterized in that The server stores the complete status of the game character corresponding to each client, and the complete status includes all status information from the time when the game character enters the game scene to the current state; The method further comprises: Before entering the game scene, a status acquisition request is sent to the server; Receiving the complete status of the game character corresponding to each of the clients in the game scene returned by the server based on the status acquisition request; The state of the corresponding game character in the current game scene is updated according to the received complete state.
5. A state synchronization method, It is characterized in that Applied to a server communicating with each client included in a synchronization system, the method comprises: Obtaining an operation instruction for a corresponding game character sent by any client, and a predicted state predicted based on the operation instruction; the predicted state is obtained by the client predicting the state of the next frame of the game character according to the current operation input obtained; wherein the operation instruction is issued by a user, and when the client receives the operation instruction issued by the user, it generates the predicted state of its own game character according to the operation instruction, changes the state of its own game character to the predicted state, and sends the operation instruction and the predicted state to the server; The predicted state is verified based on the operation instruction, and after the verification is passed, the operation instruction and the predicted state of any client are broadcast in the synchronization system, so that other clients can achieve state synchronization of game characters in the game scene based on the operation instruction and the predicted state.
6. The state synchronization method according to claim 5, It is characterized in that The step of verifying the predicted state based on the operation instruction includes: Get scene object information in the game scene; Obtaining a corresponding operation result according to the operation instruction and the predicted state; Verify whether the operation result complies with the setting rule of the scene object, and if so, determine that the predicted state verification passes.
7. The state synchronization method according to claim 5, It is characterized in that The step of verifying the predicted state based on the operation instruction includes: Acquire the operation type of the operation instruction, and obtain the corresponding operation result according to the operation instruction and the predicted state; Obtaining a preset and saved setting range corresponding to the operation type; Detect whether the operation result is within the set range, and if so, determine that the predicted state check has passed.
8. The state synchronization method according to claim 5, It is characterized in that The current game character of any client is changed to the predicted state, and the method further comprises: Acquire the operation type of the operation instruction, and obtain the corresponding operation result according to the operation instruction and the predicted state; Obtaining a preset and saved setting range corresponding to the operation type; Detect whether the operation result is within the set range, and if so, determine that the predicted state check has passed.
9. A state synchronization device, It is characterized in that Applied to any client in a synchronization system comprising a plurality of clients, each of the clients being in communication connection with a server, the device comprising: A first acquisition module is used to acquire the current operation input and current state of the game character corresponding to any client in the current frame sent by the server; A prediction module, used for predicting the state of the game character in the next frame according to the current operation input obtained; A synchronization module for processing the predicted state of the game character predicted in advance according to the previous frame information based on the acquired current state to achieve state synchronization of the game character in the game scene; The generation module is used to generate a predicted state of its own game character according to the operation instruction when receiving an operation instruction from the user, and change the state of its own game character to the predicted state; send the operation instruction and the predicted state to the server so that the server verifies the predicted state according to the operation instruction; and process the state of its own game character according to the verification result fed back by the server.
10. A state synchronization device, It is characterized in that Applicable to a server communicating with each client included in a synchronization system, the device comprising: The second acquisition module is used to acquire an operation instruction for a corresponding game character sent by any client, and a predicted state predicted based on the operation instruction; the predicted state is obtained by the client predicting the state of the next frame of the game character according to the acquired current operation input; wherein the operation instruction is issued by the user, and when the client receives the operation instruction issued by the user, it generates the predicted state of its own game character according to the operation instruction, changes the state of its own game character to the predicted state, and sends the operation instruction and the predicted state to the server; The verification module is used to verify the predicted state based on the operation instruction, and after the verification is passed, the operation instruction and the predicted state of any client are broadcast in the synchronization system, so that other clients can achieve state synchronization of game characters in the game scene based on the operation instruction and the predicted state.
