CN111632382A - Game data synchronization method, device, computer and readable storage medium - Google Patents

Game data synchronization method, device, computer and readable storage medium Download PDF

Info

Publication number
CN111632382A
CN111632382A CN202010449889.7A CN202010449889A CN111632382A CN 111632382 A CN111632382 A CN 111632382A CN 202010449889 A CN202010449889 A CN 202010449889A CN 111632382 A CN111632382 A CN 111632382A
Authority
CN
China
Prior art keywords
game
frame
rendering
data packet
frequency
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.)
Granted
Application number
CN202010449889.7A
Other languages
Chinese (zh)
Other versions
CN111632382B (en
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202010449889.7A priority Critical patent/CN111632382B/en
Publication of CN111632382A publication Critical patent/CN111632382A/en
Application granted granted Critical
Publication of CN111632382B publication Critical patent/CN111632382B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/70Game security or game management aspects
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F2300/00Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
    • A63F2300/60Methods for processing data by generating or executing the game program

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Business, Economics & Management (AREA)
  • Computer Security & Cryptography (AREA)
  • General Business, Economics & Management (AREA)
  • Display Devices Of Pinball Game Machines (AREA)

Abstract

The embodiment of the application discloses a game data synchronization method, a game data synchronization device, a computer and a readable storage medium, wherein the method comprises the following steps: counting the frequency of a game frame data packet sent by a game terminal, and taking the frequency as the historical frame frequency corresponding to the game terminal; determining a game frame rendering step length of the game terminal based on the historical frame frequency, and acquiring a game data cache sequence; the game data caching sequence comprises a game frame data packet sent by the game terminal; determining the initial position identification of the game frame data packet which is not rendered in the game data cache sequence, acquiring a target game frame data packet from the game data cache sequence according to the initial position identification and the game frame rendering step length, and generating a target rendering frame according to the target game frame data packet. By the method and the device, smoothness of game frame rendering can be improved.

Description

Game data synchronization method, device, computer and readable storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for synchronizing game data, a computer, and a readable storage medium.
Background
The network game generally refers to an electronic game in which a plurality of users perform interactive entertainment through the internet of a computer, which is also called an online game, and includes Multiplayer online games, such as a Massively Multiplayer Online Role Playing Game (MMORPG) and a Multiplayer online battle sports game (MOBA). When a user is playing a network game, data interaction among users of the network game needs to be guaranteed, and therefore, it is very important to achieve game data synchronization among user terminals of the users. At present, generally, the obtained game data is synchronized in real time, that is, after a local terminal obtains a game frame data packet sent by a game terminal, the game terminal is rendered according to the game frame data packet, when the frequency of generating rendering frames between the local terminal and the game terminal is inconsistent or network delay occurs, a situation that the local terminal cannot obtain the game frame data packet of the game terminal when the local terminal generates the rendering frames may occur, so that the local terminal cannot update the game state of the game terminal, thereby causing discontinuous display content in a game page and poor smoothness of game frame rendering.
Disclosure of Invention
The embodiment of the application provides a game data synchronization method, a game data synchronization device, a computer and a readable storage medium, which can improve the smoothness of game frame rendering.
An embodiment of the present application provides a game data synchronization method, including:
counting the frequency of a game frame data packet sent by a game terminal as the historical frame frequency corresponding to the game terminal;
determining a game frame rendering step length of the game terminal based on the historical frame frequency, and acquiring a game data cache sequence; the game data cache sequence comprises the game frame data packet sent by the game terminal;
determining the initial position identification of the game frame data packet which is not rendered in the game data cache sequence, acquiring a target game frame data packet from the game data cache sequence according to the initial position identification and the game frame rendering step length, and generating a target rendering frame according to the target game frame data packet.
Wherein, the counting the frequency of the game frame data packet sent by the game terminal as the historical frame frequency corresponding to the game terminal comprises:
in a rendering period, acquiring a game frame data packet sent by the game terminal, and adding the game frame data packet to the game data cache sequence;
acquiring a data packet statistical variable, and updating the data packet statistical variable based on the game frame data packet; the data packet statistical variable is used for counting the number of the game frame data packets sent by the game terminal in the rendering period;
and generating the frequency of the game frame data packet transmitted by the game terminal based on the data packet statistical variable and the rendering period as the historical frame frequency corresponding to the game terminal.
Wherein the determining a game frame rendering step size of the game terminal based on the historical frame frequency includes:
and acquiring a frequency average value corresponding to the historical frame frequency, and determining the frequency average value as a game frame rendering step length of the game terminal.
Wherein, the obtaining of the frequency average corresponding to the historical frame frequency includes:
if the number of the historical frame frequencies is less than or equal to a frequency statistical threshold, determining the average value of the historical frame frequencies as a frequency average value corresponding to the historical frame frequencies;
if the number of the historical frame frequencies is larger than the frequency statistical threshold, sequentially acquiring statistical historical frame frequencies from the historical frame frequencies according to the time sequence of the recording time; the number of the statistical historical frame frequencies is the frequency statistical threshold;
and deleting the historical frame frequency except the statistical historical frame frequency in the historical frame frequency, and determining the average value of the statistical historical frame frequency as the frequency average value corresponding to the historical frame frequency.
Wherein, the determining the starting position identifier of the unrendered game frame data packet in the game data cache sequence includes:
acquiring a historical frame rendering position variable, and acquiring a historical frame rendering position identifier from the historical frame rendering position variable; the historical frame rendering position identifier is a position identifier of a historical game frame data packet in the game data cache sequence; the historical game frame data packet is used for generating a rendering frame which is the last rendering frame of the target rendering frame;
determining the historical frame rendering position identifier as the initial position identifier of the game frame data packet which is not rendered;
the method further comprises:
and updating the historical frame rendering position identifier in the historical frame rendering position variable into the position identifier of the target game frame data packet in the game data cache sequence.
Wherein, the obtaining of the target game frame data packet from the game data buffer sequence according to the start position identifier and the game frame rendering step length includes:
obtaining the maximum value of the sequence position of the game data cache sequence;
if the sum of the initial position identification and the game frame rendering step length is greater than or equal to the maximum value of the sequence position, determining the maximum value of the sequence position as a target frame rendering position identification, and acquiring the target game frame data packet corresponding to the target frame rendering position identification from the game data cache sequence;
and if the sum of the initial position identification and the game frame rendering step length is smaller than the maximum value of the sequence position, determining the sum of the initial position identification and the game frame rendering step length as the target frame rendering position identification, and acquiring the target game frame data packet corresponding to the target frame rendering position identification from the game data cache sequence.
Wherein, the obtaining the target game frame data packet corresponding to the target frame rendering position identifier from the game data cache sequence includes:
if the target frame rendering position identifier is an integer, determining a game frame data packet at the target frame rendering position identifier in the game data cache sequence as the target game frame data packet;
if the target frame rendering position identification is a decimal, determining a first frame rendering position identification and a second frame rendering position identification based on the target frame rendering position identification; the game frame data packet corresponding to the first frame rendering position identifier and the game frame data packet corresponding to the second frame rendering position identifier are adjacent in position in the game data cache sequence; the target frame rendering position identification is larger than the first frame rendering position identification and smaller than the second frame rendering position identification;
and generating the target game frame data packet according to the game frame data packet corresponding to the first frame rendering position identifier and the game frame data packet corresponding to the second frame rendering position identifier in the game data cache sequence.
Wherein, the generating the target game frame data packet according to the game frame data packet corresponding to the first frame rendering position identifier and the game frame data packet corresponding to the second frame rendering position identifier in the game data caching sequence includes:
obtaining a game frame data packet at the first frame rendering position identifier and a game frame data packet at the second frame rendering position identifier from the game data cache sequence;
based on the target frame rendering position identification, carrying out interpolation splitting on the game frame data packet at the first frame rendering position identification and the game frame data packet at the second frame rendering position identification to obtain at least two interpolation data packets;
and determining the interpolation data packet corresponding to the target frame rendering position identifier in the at least two interpolation data packets as the target game frame data packet.
Wherein, the method further comprises:
taking the maximum integer value less than or equal to the target frame rendering position identifier as a maximum deletion position identifier;
determining a game frame data packet between the first identifier and the maximum deletion position identifier in the game data cache sequence as a data packet to be deleted;
deleting the data packet to be deleted in the game data cache sequence, updating the target frame rendering position identifier according to the maximum deletion position identifier to obtain an updated target frame rendering position identifier, and updating the value of the historical frame rendering position variable to the updated target frame rendering position identifier.
Wherein, the method further comprises:
if the rendering step length of the game frame is larger than the game rendering step length threshold value, determining that the network state of the local terminal is abnormal, and displaying a network state abnormal prompt;
and acquiring a standby network connection mode of the local terminal, and displaying a network switching prompt message based on the standby network connection mode.
An embodiment of the present application provides a game data synchronization apparatus, where the apparatus includes:
the frequency acquisition module is used for counting the frequency of a game frame data packet sent by a game terminal and taking the frequency as the historical frame frequency corresponding to the game terminal;
a step length determining module, configured to determine a game frame rendering step length of the game terminal based on the historical frame frequency, and obtain a game data cache sequence; the game data cache sequence comprises the game frame data packet sent by the game terminal;
and the data acquisition module is used for determining the initial position identification of the game frame data packet which is not rendered in the game data cache sequence, acquiring a target game frame data packet from the game data cache sequence according to the initial position identification and the game frame rendering step length, and generating a target rendering frame according to the target game frame data packet.
Wherein, above-mentioned frequency acquisition module includes:
a sequence updating unit, configured to acquire a game frame data packet sent by the game terminal in a rendering period, and add the game frame data packet to the game data cache sequence;
the data statistical unit is used for acquiring a data packet statistical variable and updating the data packet statistical variable based on the game frame data packet; the data packet statistical variable is used for counting the number of the game frame data packets sent by the game terminal in the rendering period;
and a frequency determining unit configured to generate a frequency of the game frame data packet transmitted by the game terminal as a history frame frequency corresponding to the game terminal, based on the packet statistical variable and the rendering period.
Wherein, in the aspect of determining the game frame rendering step size of the game terminal based on the historical frame frequency, the step size determining module is specifically configured to:
and acquiring a frequency average value corresponding to the historical frame frequency, and determining the frequency average value as a game frame rendering step length of the game terminal.
Wherein, in the aspect of obtaining the frequency average corresponding to the historical frame frequency, the step length determining module includes:
an average value determining unit, configured to determine an average value of the historical frame frequencies as a frequency average value corresponding to the historical frame frequencies if the number of the historical frame frequencies is less than or equal to a frequency statistical threshold;
a frequency selecting unit, configured to sequentially acquire statistical historical frame frequencies from the historical frame frequencies according to a time sequence of recording time if the number of the historical frame frequencies is greater than the frequency statistical threshold; the number of the statistical historical frame frequencies is the frequency statistical threshold;
the average value determining unit is further configured to delete a history frame frequency other than the statistical history frame frequency from the history frame frequencies, and determine an average value of the statistical history frame frequencies as a frequency average value corresponding to the history frame frequency.
Wherein, in the aspect of determining the starting position identifier of the unrendered game frame data packet in the game data cache sequence, the data acquisition module comprises:
the history acquisition unit is used for acquiring a history frame rendering position variable and acquiring a history frame rendering position identifier from the history frame rendering position variable; the historical frame rendering position identifier is a position identifier of a historical game frame data packet in the game data cache sequence; the historical game frame data packet is used for generating a rendering frame which is the last rendering frame of the target rendering frame;
a position obtaining unit, configured to determine the historical frame rendering position identifier as a start position identifier of the unrendered game frame data packet;
the above apparatus further comprises:
and the position updating module is used for updating the historical frame rendering position identifier in the historical frame rendering position variable into the position identifier of the target game frame data packet in the game data cache sequence.
Wherein, in the aspect of obtaining the target game frame data packet from the game data buffer sequence according to the start position identifier and the game frame rendering step length, the data obtaining module includes:
an upper limit obtaining unit, configured to obtain a maximum value of a sequence position of the game data cache sequence;
a data obtaining unit, configured to determine, if a sum of the start position identifier and the game frame rendering step size is greater than or equal to the maximum sequence position value, the maximum sequence position value as a target frame rendering position identifier, and obtain, from the game data cache sequence, the target game frame data packet corresponding to the target frame rendering position identifier;
the data obtaining unit is further configured to determine, if the sum of the start position identifier and the game frame rendering step size is smaller than the maximum value of the sequence position, the sum of the start position identifier and the game frame rendering step size as the target frame rendering position identifier, and obtain, from the game data cache sequence, the target game frame data packet corresponding to the target frame rendering position identifier.
Wherein, in the aspect of obtaining the target game frame data packet corresponding to the target frame rendering position identifier from the game data cache sequence, the data obtaining unit includes:
a first data obtaining subunit, configured to determine, if the target frame rendering position identifier is an integer, a game frame data packet at the target frame rendering position identifier in the game data cache sequence as the target game frame data packet;
an adjacent position obtaining subunit, configured to determine, based on the target frame rendering position identifier, a first frame rendering position identifier and a second frame rendering position identifier if the target frame rendering position identifier is a decimal; the game frame data packet corresponding to the first frame rendering position identifier and the game frame data packet corresponding to the second frame rendering position identifier are adjacent in position in the game data cache sequence; the target frame rendering position identification is larger than the first frame rendering position identification and smaller than the second frame rendering position identification;
and the second data acquisition subunit is configured to generate the target game frame data packet according to the game frame data packet corresponding to the first frame rendering position identifier and the game frame data packet corresponding to the second frame rendering position identifier in the game data caching sequence.
Wherein, the second data obtaining subunit includes:
an adjacent data obtaining subunit, configured to obtain, from the game data caching sequence, a game frame data packet at the first frame rendering position identifier and a game frame data packet at the second frame rendering position identifier;
an interpolation splitting unit, configured to perform interpolation splitting on the game frame data packet at the first frame rendering position identifier and the game frame data packet at the second frame rendering position identifier based on the target frame rendering position identifier, to obtain at least two interpolation data packets;
and the interpolation data determining subunit is configured to determine, as the target game frame data packet, an interpolation data packet corresponding to the target frame rendering position identifier in the at least two interpolation data packets.
Wherein, above-mentioned device still includes:
an identifier rounding module, configured to use a maximum integer value smaller than or equal to the target frame rendering location identifier as a maximum deletion location identifier;
a deletion waiting determination module, configured to determine, as a deletion waiting data packet, a game frame data packet located between the head identifier and the maximum deletion position identifier in the game data cache sequence;
and the data updating module is used for deleting the data packet to be deleted in the game data cache sequence, updating the target frame rendering position identifier according to the maximum deletion position identifier to obtain an updated target frame rendering position identifier, and updating the value of the historical frame rendering position variable into the updated target frame rendering position identifier.
Wherein, above-mentioned device still includes:
an anomaly determination module, configured to determine that a network state of the local terminal is abnormal and display a network state anomaly prompt if the game frame rendering step size is greater than a game rendering step size threshold;
and the network switching module is used for acquiring the standby network connection mode of the local terminal and displaying a network switching prompt message based on the standby network connection mode.
One aspect of the embodiments of the present application provides a computer device, including a processor, a memory, and an input/output interface;
the processor is respectively connected to the memory and the input/output interface, wherein the input/output interface is configured to receive data and output data, the memory is configured to store program codes, and the processor is configured to call the program codes to execute the game data synchronization method according to the first aspect of the embodiment of the present application.
An aspect of the embodiments of the present application provides a computer-readable storage medium, in which a computer program is stored, where the computer program includes program instructions, and the program instructions, when executed by a processor, perform the game data synchronization method as described above in the first aspect of the embodiments of the present application.
The embodiment of the application has the following beneficial effects:
the frequency of a game frame data packet sent by a game terminal is counted to serve as the historical frame frequency corresponding to the game terminal; determining a game frame rendering step length of the game terminal based on the historical frame frequency, and acquiring a game data cache sequence; determining the initial position identification of the game frame data packet which is not rendered in the game data cache sequence, acquiring a target game frame data packet from the game data cache sequence according to the initial position identification and the game frame rendering step length, and generating a target rendering frame according to the target game frame data packet. Through the process, after the local terminal acquires the game frame data packet sent by the game terminal, the local terminal caches the game frame data packet, determining the game frame rendering step length of the game terminal according to the historical frame frequency of the game terminal, wherein the local terminal can acquire a corresponding game frame data packet from the game data cache sequence according to the game frame rendering step length for rendering, so as to balance the frequency of rendering frame generation by the local terminal and the frequency of game frame data packets acquired by the local terminal and sent by the game terminal, when the rendering frequency of the game between the local terminal and the game terminal is not consistent, the game frame data packets in the game data buffer sequence may be allocated based on the game frame rendering step size, therefore, the local terminal can acquire the game frame data packet in each rendering frame to render the game data of the game terminal, and smoothness of game rendering is improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a diagram of a game data synchronization architecture provided in an embodiment of the present application;
FIG. 2 is a schematic view of a game data synchronization scenario provided in an embodiment of the present application;
FIG. 3 is a flow chart of a method for synchronizing game data according to an embodiment of the present disclosure;
FIG. 4a is a schematic structural diagram of a game data synchronization process provided in an embodiment of the present application;
FIG. 4b is a schematic diagram of a processing procedure of game frame data packets in a scene with inconsistent frequencies according to an embodiment of the present disclosure;
FIG. 5 is a schematic diagram of a detailed process of game data synchronization according to an embodiment of the present disclosure;
FIG. 6 is a schematic diagram of a processing scenario of a game frame data packet according to an embodiment of the present disclosure;
FIG. 7 is a schematic diagram of a target rendering frame generation scene provided by an embodiment of the present application;
FIG. 8 is a schematic diagram of a target game frame data packet generation scenario provided in an embodiment of the present application;
FIG. 9 is a diagram illustrating a structure of a game data synchronization code according to an embodiment of the present application;
fig. 10 is a schematic diagram of a game frame data packet processing process under a network delay jitter state according to an embodiment of the present application;
FIG. 11 is a schematic diagram of a game data synchronization device according to an embodiment of the present application;
fig. 12 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Specifically, some of the terms mentioned in the present application are described as follows:
state synchronization (state synchronization): one of the common synchronization methods for online games is commonly used in MMORPG games, and the local terminal synchronizes the states of other characters. The local terminal only needs to accept the state change transmitted by the server (or other game terminals), then updates the corresponding state of local other character clones, and renders the state.
Deterministic lockstep synchronization (lockstep): one of the common synchronization methods for network games is commonly used in Moba, Real-time strategic Game (RTS) type games, and the local terminal synchronizes operations of other characters. The local terminal sends the operation of the local terminal to the server (or other game terminals), and each game terminal determines the operation of all the characters through a fixed step length (step), obtains a final result and renders the final result.
Smoothness: the game terminal renders a judgment index of the movement of the object. Good smoothness indicates that the movement of the object is progressively continuous; poor smoothness indicates that the movement of the object is discontinuously jumping, so that the smoothness of the rendering of the game frame is better, and the more continuous the game pages displayed in the corresponding game terminal are, the better the visual and experience effects of the user are.
Interpolation: a mathematical method used in rendering of a game terminal. For example, the object is known to be at position a and position B at two times, respectively. Proportionally inserting several points Z between position A and position B1,Z2,…,ZnWhere each point corresponds to a location. When the game terminal is rendering, A, Z can be rendered frame by frame1,…,ZnAnd B, skipping of the position of the object is avoided, and smoothness of game frame rendering is improved to a certain extent. The game engine mostly provides an interpolation function to help calculate the interpolation.
Specifically, referring to fig. 1, fig. 1 is a game data synchronization architecture diagram provided in an embodiment of the present application, and as shown in fig. 1, the present application is implemented by a local terminal 101 and is used for performing game data synchronization between the local terminal 101 and other game terminals (e.g., a game terminal 102a, a game terminal 102b, a game terminal 102c, and the like). The local terminal 101 and the other game terminals may be computer devices, and the computer devices may be servers and terminal devices; the computer device can also be a server with a display function; alternatively, the computer device may also be a terminal device, which is not limited herein.
Specifically, local terminal 101 counts the frequency of the game frame data packets transmitted by game terminal 102a, game terminal 102b, game terminal 102c, and the like, and includes, as the historical frame frequency of the corresponding game terminal, the historical frame frequency of game terminal 102a, the historical frame frequency of game terminal 102b, and the historical frame frequency of game terminal 102 c. Taking the game terminal 102a as an example, after the local terminal 101 acquires the historical frame frequency of the game terminal 102a, the game frame rendering step length of the game terminal 102a is determined based on the historical frame frequency of the game terminal 102a, where the game frame rendering step length is used to indicate that the average frequency of the game frame data packets sent by the game terminal 102a is acquired in one rendering frame time period of the local terminal 101, and for example, when the local terminal 101 generates one rendering frame and acquires two game frame data packets sent by the game terminal 102a, the game frame rendering step length of the game terminal 102a is determined to be 2. The local terminal 101 acquires a game data buffering sequence including a game frame data packet transmitted by the game terminal 102 a. And determining the initial position identification of the game frame data packet which is not rendered in the game data cache sequence, and acquiring the target game frame data packet from the game data cache sequence according to the initial position identification and the game frame rendering step length.
Similarly, the local terminal 101 acquires the target game frame data packet of the game terminal 102b and the target game frame data packet of the game terminal 102c, and generates a target rendering frame based on the target game frame data packet of the game terminal 102a, the target game frame data packet of the game terminal 102b, and the target game frame data packet of the game terminal 102 c.
According to the method and the device, the target game frame data packets of the game equipment performing data interaction with the local terminal are obtained in each rendering period, the target rendering frame is generated according to the target game frame data packets, the local terminal can obtain the corresponding data packets for rendering in each rendering frame, accordingly continuity of the game pages displayed by the local terminal is improved, and smoothness of rendering of the game frames is improved.
It is understood that the method provided by the embodiment of the present application can be executed by a computer device, including but not limited to a terminal device or a server. The computer device may be a server or a terminal device, or a system composed of a server and a terminal device, where the terminal device may be an electronic device including, but not limited to, a mobile phone, a tablet computer, a desktop computer, a notebook computer, a palm computer, a Mobile Internet Device (MID), and the like.
Further, please refer to fig. 2, and fig. 2 is a schematic view of a game data synchronization scene provided in an embodiment of the present application. As shown in fig. 2, the game terminal 201 transmits game frame data packets including a game frame data packet 2021, a game frame data packet 2022, and the like to the local terminal 203 during the rendering period of the local terminal 203. The local terminal 203 counts the frequency of the game frame data packets transmitted by the game terminal 201 as the history frame frequency corresponding to the game terminal. The local terminal 203 determines a game frame rendering step 204 of the game terminal 201 based on the historical frame frequency, and obtains a game data buffering sequence 205, where the game data buffering sequence 205 includes game frame data packets sent by the game terminal 201, such as game frame data packet 2051, game frame data packet 2021, game frame data packet 2022, and the like. The local terminal 203 determines the start position identifier of the unrendered game frame data packet in the game data cache sequence 205, acquires the target game frame data packet 206 from the game data cache sequence 205 according to the start position identifier and the game frame rendering step 204, and generates and displays the target rendering frame 207 according to the target game frame data packet 206.
Through the process, the local terminal can count the frequency of the game frame data packets sent by the game terminal in each rendering period to determine the rendering step length of the game frame of the game terminal, and generate the rendering frame according to the rendering step length of the game frame, so that the frequency of updating the game page between the local terminal and the game terminal can be balanced, that is, the local terminal can acquire the target game frame data packets corresponding to the game terminal in each rendering period, and therefore the continuity of the game page is improved, and the smoothness of the rendering of the game frame is improved.
Further, please refer to fig. 3, fig. 3 is a flowchart of a game data synchronization method according to an embodiment of the present application. As shown in fig. 3, the game data synchronization process includes the steps of:
in step S301, the frequency of the game frame data packet transmitted by the game terminal is counted as the historical frame frequency corresponding to the game terminal.
Specifically, the local terminal may count a frequency of a game frame data packet sent by the game terminal in a rendering period, and use the counted frequency as a historical frame frequency corresponding to the game terminal, where the rendering period is a time period during which the local terminal generates one rendering frame. Specifically, the local terminal may start counting received game frame data packets sent by the game terminal after generating one rendering frame, and when a next rendering frame is generated, obtain a counting result of the game frame data packets sent by the game terminal, and use the counting result as a historical frame frequency corresponding to the game terminal, where the counting result is a frequency of the game frame data packets sent by the game terminal counted by the local terminal in a corresponding rendering period. For example, after the local terminal generates the first rendering frame, the local terminal receives the game frame data packets sent by the game terminal, and when the local terminal generates the second rendering frame, the local terminal acquires 2 game frame data packets sent by the game terminal between the generation of the first rendering frame and the generation of the second rendering frame, and then determines that the game terminal has a history frame frequency of 2 in the second rendering period of the local terminal (after the generation of the first rendering frame and before the generation of the second rendering frame).
Step S302, determining the rendering step length of the game frame of the game terminal based on the historical frame frequency, and acquiring a game data cache sequence.
Specifically, the local terminal determines a game frame rendering step size of the game terminal based on the historical frame frequency. The local terminal stores at least one historical frame frequency, determines a game frame rendering step length of the game terminal based on the at least one historical frame frequency, wherein the game frame rendering step length is used for indicating the number of game frame data packets sent by the game terminal, which can be averagely acquired by the local terminal in one rendering period of the local terminal, and can balance the frequency of generating rendering frames between the local terminal and the game terminal, so that the local terminal can acquire a target rendering frame of the game terminal in each rendering period, and the rendering smoothness of the game frame in the local terminal is improved.
After determining the rendering step length of the game frame of the game terminal, the local terminal acquires a game data cache sequence corresponding to the game terminal, wherein the game data cache sequence comprises a game frame data packet sent by the game terminal. Specifically, after receiving a game frame data packet sent by a game terminal, a local terminal does not render the game frame data packet in real time, but adds the game frame data packet into a game data cache sequence, and obtains a target game frame data packet of the game terminal from the game data cache sequence for rendering by using a game frame rendering step length as a game frame data obtaining period, so that when the frequencies of rendering frames generated between the local terminal and the game terminal are different, the situation that the local terminal cannot obtain the game frame data packet of the game terminal when the rendering frames are generated can be reduced, and the smoothness of game frame rendering in the local terminal is improved.
Step S303, determining the initial position identifier of the game frame data packet which is not rendered in the game data cache sequence, acquiring the target game frame data packet from the game data cache sequence according to the initial position identifier and the game frame rendering step length, and generating a target rendering frame according to the target game frame data packet.
Specifically, the local terminal obtains a start position identifier in the game data cache sequence, where the start position identifier is used to indicate a start position of an unrendered game frame data packet in the game data cache sequence. The frequency of generating the rendering frame between the local terminal and the game terminal is different, the frequency of generating the rendering frame by the local terminal and the frequency of generating the rendering frame by the game terminal are not necessarily in integer multiple relation, and the game frame data packet stored in the game data cache sequence is sent by the game terminal, so that when the local terminal acquires the game frame data packet of the game terminal for rendering, the local terminal can directly acquire the game frame data packet from the game data cache sequence or acquire the game frame data packet based on interpolation processing. If the game frame data packet used in rendering by the local terminal is obtained based on interpolation processing, the start position identifier determined by the local terminal is not necessarily an integer. The starting position mark is used for representing the starting position of a game frame data packet which is not rendered in the game data cache sequence when the local terminal generates the current rendering frame. For example, when the local terminal generates the previous rendering frame, the local terminal acquires the game frame data packet located at the position identifier 2.5 in the game data cache sequence, and if the rendered game frame data packet is deleted, the local terminal determines that the initial position identifier is 0.5 when the rendering frame is generated this time; if the rendered game frame data packet is not deleted, the determined initial position identifier is the position identifier of the game frame data packet for generating the previous rendered frame, namely 2.5, when the local terminal generates the rendered frame at this time.
According to the method and the device, the frequency of the game frame data packet sent by the game terminal is counted to serve as the historical frame frequency corresponding to the game terminal, the game frame rendering step length of the game terminal is determined based on the historical frame frequency, the game data cache sequence is obtained, the initial position identification of the game frame data packet which is not rendered is determined from the game data cache sequence, the target game frame data packet is obtained from the game data cache sequence according to the initial position identification and the game frame rendering step length, and the target rendering frame is generated according to the target game frame data packet. Through the process, the local terminal does not need to render the acquired game frame data packet sent by the game terminal in real time, but determines the game frame data packet used when the local terminal generates the rendering frame according to the game rendering frequency of the local terminal and the game rendering frequency of the game terminal, so that the local terminal can acquire the game frame data packet used for rendering the state of the game terminal in each rendering period, and the rendering smoothness of the game frame is improved.
Further, please refer to fig. 4a, and fig. 4a is a schematic structural diagram of a game data synchronization process according to an embodiment of the present application. As shown in fig. 4a, the game data synchronization process includes a network frame and a rendering frame, where the network frame is used to obtain a game frame data packet of the game terminal, and the rendering frame is used to perform rendering according to the game frame data packet to obtain a rendering frame. The local terminal performs a network synchronization thread on a network frame to realize a serialized network view (onserializationnewview), and performs a rendering thread on a rendering frame to realize the update of a game page. The local terminal receives a game terminal state at a frame X (namely the Xth rendering frame of the game terminal), the game terminal state is sent to the local terminal by the game terminal based on a game frame data packet, the local terminal caches the game terminal state, and the game terminal state continues to be received at a frame (X + 1); wherein, X is an integer and corresponds to the number of frames of the rendering frame generated by the game terminal, in other words, when the game terminal generates the xth rendering frame, the local terminal may acquire the xth game frame data packet sent by the game terminal.
The local terminal obtains the state of the target game terminal from the cache in a frame Y (namely the Yth rendering frame of the local terminal), renders the state of the target game terminal, generates a target rendering frame (the Yth rendering frame), and continues to obtain the state of the target game terminal from the cache in a frame (Y +1) for rendering; and Y is an integer and is used for representing the frame number of the rendering frame generated by the local terminal.
For the local terminal, the network synchronization thread corresponding to the network frame and the rendering thread corresponding to the rendering frame are independent from each other, and the local terminal obtains the game frame data packet received in the network frame through the game data cache sequence in the rendering thread, wherein X is not necessarily the same as Y.
For example, referring to fig. 4b, fig. 4b is a schematic diagram of a processing process of a game frame data packet in a scene with inconsistent frequency according to an embodiment of the present application. As shown in fig. 4b, each time the local terminal generates two rendering frames, it will receive one game frame data packet sent by the game terminal, where each segment shown in fig. 4b represents one rendering period of the corresponding terminal, and a number corresponding to each rendering period of the local terminal represents the number of game frame data packets sent by the game terminal acquired by the local terminal in the rendering period, which may represent the historical frame frequency of the game terminal in the rendering period. For example, the local terminal generates one rendering frame in the rendering period corresponding to the ta1 time period and the rendering period corresponding to the ta2 time period respectively, and the game terminal generates one rendering frame in the rendering period corresponding to the tb1 time period, wherein the sum of the time lengths of the ta1 time period and the ta2 time period is equal to the time length of the tb1 time period.
The local terminal does not acquire a game frame data packet sent by the game terminal in a time period of ta1, and the historical frame frequency of the game terminal in the rendering period is determined to be 0; the local terminal acquires a game frame data packet sent by the game terminal in a tb1 time period at a ta2 time period, determines that the historical frame frequency of the game terminal in the rendering period is 1, determines that the rendering step length (step length for short) of a game frame is 0.5 according to the historical frame frequency 0 and the historical frame frequency 1 assuming that a game data cache sequence is empty, renders game data corresponding to 0.5 packets of the game frame data packet acquired in the rendering period through interpolation splitting, and caches the game frame data packet (which is equivalent to 0.5 valid packets in the game data cache sequence can be used); if the local terminal does not acquire the game frame data packets sent by the game terminal within the time period of ta3, acquiring 0.5 valid packets cached in a rendering cycle corresponding to the time period of ta2, and rendering the game data of the game terminal, wherein the game data caching sequence is empty; similarly, the local terminal acquires the game frame data packets sent by the game terminal in the tb2 time period at the ta4 time period, renders the game data of the game terminal through 0.5 packet of the game frame data packets acquired in the ta4 time period, and adds the game frame data packets to the game data cache sequence for caching, wherein at this time, 0.5 valid packets exist in the game data cache sequence; … are provided.
Through the process, when the game rendering frequency of the local terminal is inconsistent with that of the game terminal, the local terminal can distribute the acquired game frame data packets sent by the game terminal according to the game rendering frequency of the local terminal and the game rendering frequency of the game terminal, so that the local terminal can acquire the game frame data packets of the game terminal in each rendering period. When the game rendering frequency of the game terminal is less than that of the local terminal, the local terminal may have a rendering period in which a game frame data packet sent by the game terminal is not acquired, and the obtained game frame data packet is allocated according to the application, namely, part of the game frame data packet is used for rendering, and part of the game frame data packet is used for caching, so that the local terminal can acquire the unrendered game frame data packet from a game data caching sequence when the game frame data packet sent by the game terminal is not acquired, so as to generate a rendering frame, improve the continuity of display contents in a game page of the game terminal, and further improve the smoothness of game rendering.
Further, referring to fig. 5, fig. 5 is a schematic diagram of a specific flow of game data synchronization provided in an embodiment of the present application. As shown in fig. 5, the method comprises the following steps:
in step S501, the frequency of the game frame data packet transmitted by the game terminal is counted as the historical frame frequency corresponding to the game terminal.
Specifically, the local terminal may obtain a game frame data packet sent by the game terminal in the rendering period, and add the game frame data packet to the game data cache sequence; acquiring a data packet statistical variable, and updating the data packet statistical variable based on the game frame data packet; the data packet statistical variable is used for counting the number of the game frame data packets sent by the game terminal in the rendering period; and generating the frequency of the game frame data packet sent by the game terminal based on the data packet statistical variable and the rendering period as the historical frame frequency corresponding to the game terminal. And after determining the historical frame frequency corresponding to the game terminal in the rendering period, the local terminal adds the historical frame frequency to the historical frame frequency set. The historical frame frequency set comprises at least one historical frame frequency, each historical frame frequency corresponds to one rendering period, the rendering periods corresponding to two adjacent historical frame frequencies in the historical frame frequency set are also adjacent, for example, the historical frame frequency corresponding to the first rendering period is adjacent to the historical frame frequency corresponding to the second rendering period, and the position marks of the historical frame frequency set are adjacent.
Specifically, referring to fig. 6, fig. 6 is a schematic view of a processing scene of a game frame data packet according to an embodiment of the present application. As shown in fig. 6, when the local terminal 601 generates the history rendering frame 6011, a new rendering cycle is started, and a packet statistical variable is created, where the value of the packet statistical variable is 0 by default; if only the value of the data packet statistical variable is cleared without deleting the data packet statistical variable at the end of each rendering cycle, the local terminal 601 directly obtains the data packet statistical variable. Here, the local terminal 601 acquires the game frame data packet 6021 transmitted by the game terminal 602 in the rendering period, updates the value of the packet statistical variable to 1 based on the game frame data packet 6021, and adds the game frame data packet 6021 to the game data buffer sequence 604 in which the game frame data packet 6021 and the like are included, and the value is "Var 1".
The local terminal 601 acquires the game frame data packet 6022 transmitted from the game terminal 602, updates the packet statistic variable based on the game frame data packet 6022, and updates the value of the packet statistic variable to 2, which is denoted by "Var ═ 2". Here, the local terminal 601 adds the game frame data packet 6022 to the game data buffer sequence 604, and at this time, the game data buffer sequence 604 includes the game frame data packet 6021, the game frame data packet 6022, and the like.
If the local terminal 601 generates the target rendering frame after acquiring the game frame data packet 6022, it is considered that the local terminal 601 acquires 2 game frame data packets transmitted by the game terminal in the rendering period, determines that the history frame frequency corresponding to the game terminal is 2, and adds the history frame frequency 2 to the history frame frequency set 605.
Step S502, determining the game frame rendering step size of the game terminal based on the historical frame frequency.
Specifically, the local terminal obtains a frequency average corresponding to the historical frame frequency, and determines the frequency average as a game frame rendering step length of the game terminal. Specifically, the local terminal acquires the number of the historical frame frequencies, if the number of the historical frame frequencies is less than or equal to a frequency statistical threshold, the average value of the historical frame frequencies is determined as a frequency average value corresponding to the historical frame frequencies, and the frequency average value is determined as a game frame rendering step length of the game terminal; if the number of the historical frame frequencies is larger than the frequency statistical threshold, sequentially acquiring statistical historical frame frequencies from the historical frame frequencies according to the time sequence of the recording time, wherein the number of the statistical historical frame frequencies is the frequency statistical threshold, determining the average value of the statistical historical frame frequencies as a frequency average value corresponding to the historical frame frequencies, and determining the frequency average value as the game frame rendering step length of the game terminal. Optionally, when the number of the historical frame frequencies is greater than the frequency statistics threshold, the local terminal deletes the historical frame frequencies other than the statistics historical frame frequency from the historical frame frequencies.
The historical frame frequency is stored in a historical frame frequency set, and the historical frame frequency set may be an array, a queue, a stack, or the like, which is not limited herein. For example, when the set of historical frame frequencies is an array, the subscript in the set of historical frame frequencies may indicate the recording time of the corresponding historical frame frequency, the subscript of the historical frame frequency is an integer starting from 0, and the larger the subscript, the larger the recording time of the corresponding historical frame frequency.
For example, the frequency statistics threshold is 10, the historical frame frequency set is (0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1), after acquiring the historical frame frequency in the current rendering period, the local terminal adds the historical frame frequency to the historical frame frequency set, where the historical frame frequency set is (0, 1, 0, 1, 0, 1, 0, 1, 0); the local terminal acquires that the number of the historical frame frequencies included in the historical frequency set is 11, the number of the historical frame frequencies is greater than a frequency statistical threshold value 10, and the historical frame frequencies are counted in the historical frame frequency set (0,1,0,1,0,1,0,1,0,1,0) Sequentially acquiring statistical historical frame frequency to obtain the statistical historical frame frequency (1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0), namely the historical frame frequency indicated by underlines in the historical frame frequency set; and obtaining that the average value of the statistical historical frame frequency is 0.5, determining the average value of the statistical historical frame frequency to be 0.5 as the frequency average value corresponding to the historical frame frequency, and determining that the rendering step length of the game frame of the game terminal is 0.5.
In step S503, a game data cache sequence is acquired.
Specifically, the local terminal obtains a game data cache sequence, where the game data cache sequence includes a game frame data packet sent by the game terminal, and optionally, if the rendered game frame data packet is deleted after the rendering frame is generated by the local terminal, the game data cache sequence obtained by the local terminal includes a game frame data packet that has not been rendered. The game data buffering sequence may be a queue, an array, a stack, or the like, which is not limited herein. For example, when the game data buffer sequence is a queue, the local terminal may obtain the game frame data packets from the game data buffer sequence according to time sequence for rendering based on the first-in first-out characteristic of the queue.
Step S504, the initial position identification of the game frame data packet which is not rendered is determined in the game data cache sequence.
Specifically, the local terminal acquires a historical frame rendering position variable and acquires a historical frame rendering position identifier from the historical frame rendering position variable; the historical frame rendering position identifier is a position identifier of a historical game frame data packet in a game data cache sequence; the historical game frame data packet is used for generating a rendering frame which is the last rendering frame of the target rendering frame; and determining the historical frame rendering position identifier as the starting position identifier of the game frame data packet which is not rendered. And updating the historical frame rendering position identifier in the historical frame rendering position variable into the position identifier of the target game frame data packet in the game data cache sequence. The historical frame rendering position variable is used for representing, and the local terminal determines a reference position of the target game frame data packet when determining the position identifier of the target game frame data packet in the game data cache sequence, namely the position identifier of the target game frame data packet is determined on the basis of the value of the historical frame rendering position variable. When the game data cache sequence changes, the historical frame rendering position variable is updated, so that the local terminal can directly acquire the historical frame rendering position variable and determine the historical frame rendering position variable as the initial position identifier of the game frame data packet which is not rendered in the game data cache sequence.
For example, if the historical frame rendering position identifier is 2.5, the value of the historical frame rendering position variable is updated to 2.5, and the local terminal acquires that the historical frame rendering position variable is 2.5, it is determined that the initial position identifier of the game frame data packet which is not rendered is 2.5; and if the local terminal deletes the rendered game frame data packet in the game data cache sequence, updating the historical frame rendering position variable based on the historical frame rendering position identifier 2.5 to obtain the value of the historical frame rendering position variable as 0.5.
And step S505, acquiring a target game frame data packet from the game data cache sequence according to the initial position identifier and the game frame rendering step length, and generating a target rendering frame.
Specifically, the local terminal obtains a maximum value of a sequence position of the game data cache sequence, where the maximum value of the sequence position is a maximum position identifier of a game frame data packet in the game data cache sequence, for example, if the game frame data packet is stored in a memory space corresponding to subscript 0 to subscript 2 in the game data cache sequence, the maximum value of the sequence position of the game data cache sequence is 2. The method comprises the steps that a local terminal obtains the sum of an initial position identifier and a game frame rendering step length, if the sum of the initial position identifier and the game frame rendering step length is larger than or equal to the maximum value of a sequence position, the maximum value of the sequence position is determined as a target frame rendering position identifier, and a target game frame data packet corresponding to the target frame rendering position identifier is obtained from a game data cache sequence; and if the sum of the initial position identification and the rendering step length of the game frame is smaller than the maximum value of the sequence position, determining the sum of the initial position identification and the rendering step length of the game frame as the rendering position identification of the target frame, and acquiring a target game frame data packet corresponding to the rendering position identification of the target frame from the game data cache sequence.
For example, referring to fig. 7, fig. 7 is a schematic diagram of a target rendering frame generation scene provided by an embodiment of the present application. As shown in fig. 7, when the local terminal acquires that the game data cache sequence 701 includes a game frame data packet 7011, a game frame data packet 7012, and a game frame data packet 7013, the maximum value of the obtained sequence position is 2, the acquired start position identifier is 0.5, the acquired game frame rendering step size is 0.5, the sum of the start position identifier 0.5 and the game frame rendering step size 0.5 is 1, and is smaller than the maximum value of the sequence position 2, it determines that the target frame rendering position identifier is 1, acquires a target game frame data packet 702 corresponding to the target frame rendering position identifier from the game data cache sequence, and generates a target rendering frame 703 according to the target game frame data packet 702.
Specifically, in the process of acquiring the target game frame data packet according to the target frame rendering position identifier, the target game frame data packet is determined according to the number type by detecting the number type of the target frame rendering position identifier. If the target frame rendering position identifier is an integer, determining the game frame data packet at the target frame rendering position identifier in the game data cache sequence as the target game frame data packet. If the target frame rendering position identification is a decimal, determining a first frame rendering position identification and a second frame rendering position identification based on the target frame rendering position identification; the game frame data packets corresponding to the first frame rendering position identification and the second frame rendering position identification are adjacent in position in the game data cache sequence; the target frame rendering position identification is larger than the first frame rendering position identification and smaller than the second frame rendering position identification. And generating a target game frame data packet according to the game frame data packet corresponding to the first frame rendering position identifier and the game frame data packet corresponding to the second frame rendering position identifier in the game data cache sequence. The decimal is a special expression form of a real number, all fractions can be expressed by decimal, one decimal consists of an integer part, a decimal point and a decimal part, and the decimal comprises a pure decimal and a decimal, wherein the pure decimal is a decimal with the integer part being zero, and the decimal is a decimal with the integer part being not zero.
Further, the local terminal generates a target game frame data packet through the game frame data packet corresponding to the first frame rendering position identifier and the game frame data packet corresponding to the second frame rendering position identifier, specifically, performs interpolation splitting on the game frame data packet corresponding to the first frame rendering position identifier and the game frame data packet corresponding to the second frame rendering position identifier, thereby obtaining the target game frame data packet. Specifically, the local terminal obtains, from a game data cache sequence, a game frame data packet at the first frame rendering position identifier and a game frame data packet at the second frame rendering position identifier; based on the target frame rendering position identification, carrying out interpolation splitting on the game frame data packet at the first frame rendering position identification and the game frame data packet at the second frame rendering position identification to obtain at least two interpolation data packets; and determining the interpolation data packet corresponding to the target frame rendering position identifier in the at least two interpolation data packets as a target game frame data packet.
Specifically, referring to fig. 8, fig. 8 is a schematic view of a target game frame data packet generation scene provided in the embodiment of the present application. As shown in fig. 8, the local terminal obtains the target frame rendering position identifier, and assuming that the target frame rendering position identifier is 1, that is, the target frame rendering position identifier is an integer, obtains the game frame data packet corresponding to the target frame rendering position identifier 1 from the game data caching sequence 801 as the target game frame data packet. The game data buffering sequence 801 includes a game frame data packet 8011 (corresponding to the frame rendering position identifier 0), a game frame data packet 8012 (corresponding to the frame rendering position identifier 1), and a game frame data packet 8013 (corresponding to the frame rendering position identifier 2), and the game frame data packet 8012 corresponding to the target frame rendering position identifier 1 is acquired in the game data buffering sequence 801 as a target game frame data packet, and a target rendering frame 803 is generated according to the target game frame data packet.
Or, the local terminal acquires the target frame rendering position identifier, and assuming that the target frame rendering position identifier is 1.2, that is, the target frame rendering position identifier is a decimal number, acquires the game frame data packet corresponding to the target frame rendering position identifier 1.2 from the game frame data cache sequence 801, and takes the game frame data packet as the target game frame data packet. The game data buffering sequence 801 includes a game frame data packet 8011 (corresponding to the frame rendering position identifier 0), a game frame data packet 8012 (corresponding to the frame rendering position identifier 1), and a game frame data packet 8013 (corresponding to the frame rendering position identifier 2), and determines that the first frame rendering position identifier is 1 and the second frame rendering position identifier is 2 based on the target frame rendering position identifier 1.2. The local terminal acquires a game frame data packet 8012 corresponding to the first frame rendering position identifier 1 and a game frame data packet 8013 corresponding to the second frame rendering position identifier 2, interpolates and splits the game frame data packet 8012 and the game frame data packet 8013 to obtain an interpolation data packet 8021 (corresponding to the frame rendering position identifier 1.2), an interpolation data packet 8022 (corresponding to the frame rendering position identifier 1.4), an interpolation data packet 8023 (corresponding to the frame rendering position identifier 1.6), and an interpolation data packet 8024 (corresponding to the frame rendering position identifier 1.8), acquires the interpolation data packet 8021 corresponding to the target frame rendering position identifier 1.2, and generates a target rendering frame 803 according to the target game frame data packet. Optionally, the interpolation splitting process may be implemented by an interpolation function, which is not limited herein. For example, when the target frame rendering position identifier is 1.2, the game frame data packet corresponding to the first frame rendering position identifier and the game frame data packet corresponding to the second frame rendering position identifier are interpolated and split by a Lerp (stat _ Array, 1.2) interpolation function to obtain the target game frame data packet, where stat _ Array is a game data buffering sequence and 1.2 corresponds to the frame rendering position identifier between stat _ Array [1] and stat _ Array [2 ].
Optionally, the maximum integer value smaller than or equal to the target frame rendering position identifier is used as the maximum deletion position identifier; determining a game frame data packet between a first identifier and a maximum deletion position identifier in a game data cache sequence as a data packet to be deleted; deleting the data packet to be deleted in the game data cache sequence, updating the target frame rendering position identifier according to the maximum deletion position identifier to obtain an updated target frame rendering position identifier, and updating the value of the historical frame rendering position variable into the updated target frame rendering position identifier.
Specifically, the target frame rendering position identifier is rounded down to obtain a maximum deletion position identifier, the game frame data packet between the head identifier and the maximum deletion position identifier in the game data cache sequence is deleted, and the difference value between the target frame rendering position identifier and the maximum deletion position identifier is assigned to the historical frame rendering position variable to serve as the starting position identifier of the game frame data packet which is not rendered in the game data cache sequence and is obtained in the next rendering period of the local terminal. For example, the target frame rendering position identifier is 1.2, the maximum deletion position identifier is determined to be 1 based on the target frame rendering position identifier 1.2, a game frame data packet located between the frame rendering position identifier 0 and the frame rendering position identifier 1 in the game data cache sequence is used as a data packet to be deleted, the data packet to be deleted is deleted, a difference value 0.2 between the target frame rendering position identifier 1.2 and the maximum deletion position identifier 1 is obtained, and the value of the historical frame rendering position variable is updated to be the difference value 0.2.
Step S506, the network state is determined based on the rendering step length of the game frame.
Specifically, if the rendering step length of the game frame is greater than the game rendering step length threshold value, determining that the network state of the local terminal is abnormal, and displaying a network state abnormal prompt; and acquiring a standby network connection mode of the local terminal, and displaying a network switching prompt message based on the standby network connection mode. The larger the rendering step length of the game frame is, the larger the number of game frame data packets of the game terminal, which indicates that the local terminal generates one rendering frame, is, the longer the interval between the local terminal and the two adjacent rendering frames is, and therefore, it can be determined that the network state of the local terminal is abnormal. For example, assuming that the game frame rendering step size is 5, the game rendering step size threshold is 2, and the game frame rendering step size 5 is greater than the game rendering step size threshold 2, it is determined that the network state of the local terminal is abnormal, where the game frame rendering step size 5 indicates that the local terminal generates one rendering frame every time the game terminal generates 5 rendering frames, and thus the larger the game frame rendering step size is, the more abnormal the network state of the local terminal is.
After determining that the network state of the local terminal is abnormal, acquiring a standby network connection mode of the local terminal, wherein the standby network connection mode includes but is not limited to a wireless network (WiFi) or a mobile communication network. The local terminal displays the network switching display message based on the standby network connection mode, for example, assuming that the network connection mode currently used by the local terminal is a wireless network, determines that the network state of the local terminal is abnormal, acquires a standby network connection mode 'mobile communication network', and displays whether the network switching display message 'is switched to the mobile communication network'. The network state abnormity prompt and the network switching display message can be displayed together, namely, whether the current network state is poor or not is switched to a mobile communication network.
Further, the local terminal may obtain target game frame data packets of a plurality of game terminals in the rendering period, and generate a target rendering frame according to the target game frame data packets of each game terminal, where the process of obtaining the target game frame data packet of each game terminal may refer to the specific description shown in steps S501 to S505 in fig. 5.
The embodiment of the application can be applied to games for data synchronization through state synchronization, such as peace and elite. For example, the local terminal enters a game scene of peace and elite, and an account number corresponding to the local terminal in peace and elite is assumed to be game account number 1. When the game account 1 and the game account 2 enter the same game, the local terminal acquires a game frame data packet sent by the game terminal a where the game account 2 is located, so as to render a game page displayed by the local terminal. Specifically, when the local terminal needs to generate the first rendering frame, the local terminal does not acquire the game frame data packet sent by the game terminal a, and the first historical frame frequency is obtained to be 0. Each historical frame frequency acquired by the local terminal can be stored in a historical frame frequency set, the first historical frame frequency is added into the historical frame frequency set to obtain (0), and an initial interface of plano-elite is entered and is used as a first rendering frame generated by the local terminal. Wherein, the start position identifier of the game frame data packet which is not rendered is set to be 0.
When the local terminal needs to generate a second rendering frame, the local terminal acquires a game frame data packet 1 sent by the game terminal a, adds the game frame data packet 1 to a game data cache sequence, obtains a second historical frame frequency of 1, and adds the second historical frame frequency to a historical frame frequency set to obtain (0, 1). Based on the historical frame frequency set (0, 1), determining that the game frame rendering step size of the game terminal A is 0.5, and the local terminal determining that the target frame rendering position identification is 0.5 based on the game frame rendering step size of 0.5 and the starting position identification of 0. The local terminal acquires a target game frame data packet at the 0.5 th position from the game data cache sequence, specifically acquires a game frame data packet 1, performs interpolation processing on the game frame data packet 1 and a game frame data packet corresponding to the initial interface to obtain the target game frame data packet 1 corresponding to the 0.5 th position, and generates a second rendering frame according to the target game frame data packet 1. The second rendering frame can be used for representing the game state of the game terminal A in peaceful Britain when the local terminal generates the second rendering frame; such as the relative position between game account 2 and game account 1 on a game map, or the physical condition of the game account 2 (e.g., knocked down or dead, etc.), or the orientation of the game account 2, etc. At this time, the game data buffer sequence includes { game frame data packet 1}, and the start position identifier of the next rendering period is determined to be 0.5 based on the game frame rendering step size of 0.5.
When the local terminal needs to generate the third rendering frame, the local terminal does not acquire the game frame data packet sent by the game terminal a, obtains a third historical frame frequency of 0, and adds the third historical frame frequency to the historical frame frequency set to obtain (0, 1, 0). Determining that the rendering step length of the game frame of the game terminal A is 0.3 based on the historical frame frequency set (0, 1, 0), obtaining that the rendering position of the target frame is 0.8 by the local terminal based on the rendering step length of the game frame 0.3 and the initial position identification 0.5, obtaining a target game frame data packet 2 at the 0.8 th position from the game data cache sequence, and generating a third rendering frame according to the target game frame data packet 2. The process of acquiring the target game frame data packet may refer to the specific description shown in step S505 in fig. 5, which is not described herein again. The third rendering frame may be used to represent a game state of the game terminal a in peaceful english when the local terminal generates the third rendering frame. At this time, the game data buffer sequence includes { game frame data packet 1}, and the start position identifier of the next rendering period is determined to be 0.8 based on the target frame rendering position identifier 0.8.
Similarly, the local terminal generates a fourth rendering frame, a fifth rendering frame, and the like until the game is finished, and the game account 1 exits from a scene in which data interaction with the game terminal corresponding to another game account is required, that is, the local terminal displays a personal scene of the game account 1, such as a peace and elite home page or an account information display page of the game account 1.
When the game account 1 and a plurality of other game accounts enter the same game, data synchronization is performed on the other game accounts based on the above process of performing data synchronization on the game account 2, wherein rendering step lengths or historical frame frequencies of game frames corresponding to game terminals where the game accounts are located may be different. Since the historical frame frequency set storing the historical frame frequency is constantly changed, taking game terminal a as an example, the rendering step lengths of the game frames corresponding to game terminal a obtained by the local terminal in each rendering period may be different. By setting a frequency statistical threshold value and managing the historical frame frequency counted in the historical frame frequency set, the local terminal can acquire the same rendering step length of the game frame corresponding to the game terminal A in each rendering period.
For example, each time the local terminal generates two rendering frames, one game frame data packet sent by the game terminal a is acquired, assuming that the frequency statistical threshold is 10, the historical frame frequency set acquired by the local terminal is sequentially (0), (0, 1, 0), …, (0, 1, 0, 1, 0, 1, 0, 1), …, the latest ten historical frame frequencies are retained after the local terminal acquires ten or more historical frame frequencies, the game frame rendering step length corresponding to the game terminal a is obtained based on the ten retained historical frame frequencies, at this time, the game frame rendering step length corresponding to the game terminal a is retained at 0.5, only the network state of the game terminal a or the local terminal changes, or an abnormality occurs when data interaction is performed between the game terminal a and the local terminal (e.g., data delay or packet loss due to network failure), etc.), the rendering step length of the game frame corresponding to the game terminal a will change.
The game frame rendering step length may represent a ratio between a frequency at which the local terminal receives the game frame data packets of the game terminal a and a frequency at which the local terminal generates the rendering frame, that is, the number of the acquired game frame data packets sent by the game terminal a when the local terminal generates one rendering frame. The local terminal can balance the frequency of generating the rendering frame by the local terminal and the frequency of acquiring the game frame data packet sent by the game terminal A based on the rendering step length of the game frame, so that the local terminal can acquire the corresponding target game frame data packet in each rendering period to generate the rendering frame corresponding to the rendering period, the continuity of the display content in the game page of the local terminal is improved, and the smoothness of game rendering is further improved.
For example, the local terminal acquires one game frame data packet transmitted by game terminal a every time two rendering frames are generated. For example, the local terminal generates a rendering frame 1, where the rendering frame 1 is used to indicate that the character of the game account 2 corresponding to the game terminal a is knocked down; in a rendering period after the rendering frame 1 is generated, if the local terminal does not acquire the game frame data packet sent by the game terminal a, the local terminal may acquire a target game frame data packet from the game data cache sequence based on a game frame rendering step length, and generate a rendering frame 2 based on the target game frame data packet, where the rendering frame 2 is used to indicate that a role of the game account 2 corresponding to the game terminal a reversely crawls; the local terminal acquires a game frame data packet sent by the game terminal A in a rendering period after the rendering frame 2 is generated, adds the game frame data packet into a game data cache sequence, acquires a target game frame data packet from the game data cache sequence based on a game frame rendering step length, and generates a rendering frame 3 based on the target game frame data packet, wherein the rendering frame 3 is used for indicating that the character of the game account 2 corresponding to the game terminal A is gun-filled and dead.
As can be seen from this, according to the present application, when the local terminal displays the game account 2, the state of the character displayed is "knocked down" to "crawl down" to "gun-refilled dead". If the local terminal does not display the information based on the application, the state of the role of the game account 2 displayed in the local terminal is 'knocked down' to 'knocked down' and then 'gun-filled dead', so that the display content in the game page corresponding to the rendering frame 2 is consistent with the display content in the game page corresponding to the rendering frame 1, and the difference between the display content in the game page corresponding to the rendering frame 3 and the display content in the game page corresponding to the rendering frame 2 is large, which is reflected in the game page displayed by the local terminal, namely the display content of the game page is discontinuous, and the game account 2 in the game page corresponding to the rendering frame 2 is stuck. Therefore, according to the method and the device, the corresponding target game frame data packet can be acquired in each rendering period to generate the rendering frame, and the smoothness of game rendering is improved. According to the method and the device, the corresponding target game frame data packet can be acquired in each rendering period through the rendering step length of the game frame.
By setting the rendering step length of the game frame and the dynamic change of the rendering step length of the game frame, when the interaction of game data is abnormal, such as network delay or packet loss, the frequency of generating the rendering frame by the local terminal and the frequency of acquiring the game frame data packet sent by the game terminal by the local terminal can be balanced, the target game frame data packet can be acquired in each rendering period to generate the rendering frame, and the smoothness of game rendering is further improved.
Further, please refer to fig. 9, fig. 9 is a schematic diagram of a game data synchronization code structure according to an embodiment of the present application. As shown in fig. 9, the game data synchronization code includes two parts, namely a network frame and a rendering frame, where the network frame is used to execute a network synchronization thread to implement a serialized network view, and in the network frame, the local terminal obtains a game frame data packet sent by the game terminal and adds the game frame data packet into a game data cache sequence; the rendering frame is used for executing a rendering thread, and updating of the rendering frame is achieved, and the updating includes three parts, namely data initialization 901, game rendering step size determination 902, and target game frame data packet acquisition 903, and the following are specific:
step 901, data initialization.
Specifically, the local terminal creates and initializes a game data cache sequence and a history frame frequency set, initializes a history frame rendering position variable, and initializes a game frame rendering step length. Specifically, the local terminal allocates a memory space for the game data cache sequence and the historical frame frequency set, and assigns initial values for the historical frame rendering position variable and the game frame rendering step length. The local terminal adds an initial game frame data packet of the game terminal to the game data cache sequence, and the local terminal can render the game state of the game terminal in the first rendering frame through the initial game frame data packet.
Step 902, determining a game rendering step size.
Specifically, the local terminal adds the historical frame frequency to the historical frame frequency set, and retains part of the historical frame frequencies, and the quantity of the retained part of the historical frame frequencies is the same as the frequency statistical threshold. And the local terminal determines the frequency average value of the reserved part of the historical frame frequency as a game frame rendering step length. The process may refer to the specific description shown in step S502 in fig. 5, and is not described herein again.
And step 903, acquiring a target game frame data packet.
Specifically, the local terminal obtains a maximum value of a sequence position of the game data cache sequence, and detects whether the sum of a historical frame rendering position variable and a game frame rendering step length is smaller than the maximum value of the sequence position. If the sum of the historical frame rendering position variable and the game frame rendering step length is larger than or equal to the maximum sequence position value, determining the maximum sequence position value as a target frame rendering position identifier, determining a game frame data packet corresponding to the target frame rendering position identifier as a target game frame data packet, deleting the rendered game frame data packet in the game data cache sequence, and updating the value of the historical frame rendering position variable to an initial value (0). For example, the maximum value of the sequence position is recorded as MaxIndex, the game data buffer sequence is recorded as recvst [ ], and the local terminal deletes the game frame data packets indicated by recvst [0] to recvst [ MaxIndex-1 ].
And if the sum of the historical frame rendering position variable and the game frame rendering step length is smaller than the maximum value of the sequence position, determining the sum of the historical frame rendering position variable and the game frame rendering step length as a target frame rendering position identifier, and acquiring a target game frame data packet based on the target frame rendering position identifier. And acquiring a maximum deletion position identifier which is a maximum integer value less than or equal to the target frame rendering position identifier. Deleting the game frame data packet between the first identifier and the maximum deletion position identifier in the game data cache sequence, and updating the historical frame rendering position variable based on the target frame rendering position identifier.
Specifically, the process may refer to the specific description shown in step S503 to step S505 in fig. 5, and is not described herein again. And the local terminal acquires the target game frame data packet and generates a target rendering frame.
The frequency of a game frame data packet sent by a game terminal is counted to serve as the historical frame frequency corresponding to the game terminal; determining a game frame rendering step length of the game terminal based on the historical frame frequency, and acquiring a game data cache sequence; determining the initial position identification of the game frame data packet which is not rendered in the game data cache sequence, acquiring a target game frame data packet from the game data cache sequence according to the initial position identification and the game frame rendering step length, and generating a target rendering frame according to the target game frame data packet. Through the process, after the local terminal acquires the game frame data packet sent by the game terminal, the local terminal caches the game frame data packet, determining the game frame rendering step length of the game terminal according to the historical frame frequency of the game terminal, wherein the local terminal can acquire a corresponding game frame data packet from the game data cache sequence according to the game frame rendering step length for rendering, so as to balance the frequency of rendering frame generation by the local terminal and the frequency of game frame data packet acquisition by the local terminal, so that when the game rendering frequency between the local terminal and the game terminal is inconsistent, the game frame data packets in the game data buffer sequence can be allocated based on the game frame rendering step length, therefore, the local terminal can acquire the game frame data packet in each rendering frame to render the game data of the game terminal, and smoothness of game rendering is improved.
For example, referring to fig. 10, fig. 10 is a schematic diagram of a process of processing a game frame data packet in a network delay jitter state according to an embodiment of the present application.
As shown in fig. 10, each time the local terminal generates one rendering frame, two game frame data packets sent by the game terminal are received, and a rendering step length (step length for short) of the game frame is determined to be 2, where each segment shown in fig. 10 represents one rendering period of the corresponding terminal, and a number corresponding to each rendering period of the local terminal represents the number of game frame data packets sent by the game terminal acquired by the local terminal in the rendering period, which may represent the historical frame frequency of the game terminal in the rendering period. When the network jitter occurs in the game terminal, the local terminal does not acquire the game frame data packet sent by the game terminal in the rendering period of the network jitter sent by the game terminal. In the next rendering period of network jitter, 4 game frame data packets are acquired, and since the rendering step length of the game frame is 2, the local terminal performs rendering according to 2 game frame data packets with shorter recording time in the 4 acquired game frame data packets, and adds the 2 game frame data packets with longer recording time in the 4 game frame data packets to the game data cache sequence. Specifically, see the process of fig. 4b in which the local terminal processes the game frame data packet sent by the game terminal.
Because the local terminal determines the game frame data packet used for generating the current rendering frame based on the game frame rendering step length, after the first network jitter occurs, the local terminal receives the game frame data packet sent by the game terminal during the network jitter, and because the game frame rendering step length is determined by the game rendering frequency of the local terminal and the game rendering frequency of the game terminal, when the local terminal generates the rendering frame, 2 game frame data packets are used for rendering, and other game frame data packets are added into the game data cache sequence for caching, so that 2 game frame data packets are always stored in the game data cache sequence. Therefore, even if network jitter occurs again in the subsequent game terminal, the local terminal can acquire the game frame data packet from the game data cache sequence for rendering. Further, when the network jitter occurs at the game terminal for the first time, if the game data caching sequence of the local terminal is not empty, the local terminal may also acquire the game frame data packet for rendering in the rendering period of the network jitter occurring for the first time. Therefore, smoothness of game rendering can be improved through the method and the device.
Referring to fig. 11, fig. 11 is a schematic view of a game data synchronization apparatus according to an embodiment of the present application. The game data synchronization means may be a computer program (including program code) running on a computer device, for example, the consensus network management means is an application software; the apparatus may be used to perform the corresponding steps in the methods provided by the embodiments of the present application. As shown in fig. 11, the game data synchronization apparatus 110 may be used in the computer device in the embodiment corresponding to fig. 3 or fig. 5, specifically, the apparatus may include: a frequency acquisition module 11, a step length determination module 12 and a data acquisition module 13.
A frequency obtaining module 11, configured to count a frequency of a game frame data packet sent by a game terminal, where the frequency is used as a historical frame frequency corresponding to the game terminal;
a step length determining module 12, configured to determine a game frame rendering step length of the game terminal based on the historical frame frequency, and obtain a game data cache sequence; the game data cache sequence comprises the game frame data packet sent by the game terminal;
a data obtaining module 13, configured to determine an initial position identifier of an unrendered game frame data packet in the game data cache sequence, obtain a target game frame data packet from the game data cache sequence according to the initial position identifier and the game frame rendering step length, and generate a target rendering frame according to the target game frame data packet.
Wherein, the frequency obtaining module 11 includes:
a sequence updating unit 111, configured to obtain, in a rendering period, a game frame data packet sent by the game terminal, and add the game frame data packet to the game data cache sequence;
a data statistics unit 112, configured to obtain a data packet statistics variable, and update the data packet statistics variable based on the game frame data packet; the data packet statistical variable is used for counting the number of the game frame data packets sent by the game terminal in the rendering period;
a frequency determining unit 113, configured to generate a frequency of the game frame data packet transmitted by the game terminal as a history frame frequency corresponding to the game terminal, based on the packet statistical variable and the rendering period.
In the aspect of determining the game frame rendering step size of the game terminal based on the historical frame frequency, the step size determining module 12 is specifically configured to:
and acquiring a frequency average value corresponding to the historical frame frequency, and determining the frequency average value as a game frame rendering step length of the game terminal.
In the aspect of obtaining the frequency average corresponding to the historical frame frequency, the step length determining module 12 includes:
an average determining unit 121, configured to determine an average of the historical frame frequencies as a frequency average corresponding to the historical frame frequencies if the number of the historical frame frequencies is less than or equal to a frequency statistic threshold;
a frequency selecting unit 122, configured to sequentially obtain statistical historical frame frequencies from the historical frame frequencies according to a time sequence of recording time if the number of the historical frame frequencies is greater than the frequency statistical threshold; the number of the statistical historical frame frequencies is the frequency statistical threshold;
the average determining unit 121 is further configured to delete a history frame frequency other than the statistical history frame frequency from the history frame frequencies, and determine an average of the statistical history frame frequencies as a frequency average corresponding to the history frame frequency.
In determining the identifier of the starting position of the unrendered game frame data packet in the game data cache sequence, the data obtaining module 13 includes:
a history obtaining unit 131, configured to obtain a history frame rendering position variable, and obtain a history frame rendering position identifier from the history frame rendering position variable; the historical frame rendering position identifier is a position identifier of a historical game frame data packet in the game data cache sequence; the historical game frame data packet is used for generating a rendering frame which is the last rendering frame of the target rendering frame;
a position obtaining unit 132, configured to determine the historical frame rendering position identifier as a start position identifier of the unrendered game frame data packet;
the apparatus 110 further comprises:
a location updating module 14, configured to update the historical frame rendering location identifier in the historical frame rendering location variable to a location identifier of the target game frame data packet in the game data cache sequence.
Wherein, in the aspect of obtaining the target game frame data packet from the game data buffer sequence according to the start position identifier and the game frame rendering step length, the data obtaining module 13 includes:
an upper limit obtaining unit 133 for obtaining a maximum value of the sequence position of the game data buffer sequence;
a data obtaining unit 134, configured to determine, if a sum of the start position identifier and the game frame rendering step size is greater than or equal to the maximum sequence position value, the maximum sequence position value as a target frame rendering position identifier, and obtain, from the game data cache sequence, the target game frame data packet corresponding to the target frame rendering position identifier;
the data obtaining unit 134 is further configured to determine, if the sum of the start position identifier and the game frame rendering step size is smaller than the maximum value of the sequence position, the sum of the start position identifier and the game frame rendering step size as the target frame rendering position identifier, and obtain, from the game data cache sequence, the target game frame data packet corresponding to the target frame rendering position identifier.
In the aspect of acquiring the target game frame data packet corresponding to the target frame rendering position identifier from the game data buffer sequence, the data acquiring unit 134 includes:
a first data obtaining subunit 1341, configured to determine, if the target frame rendering position identifier is an integer, a game frame data packet at the target frame rendering position identifier in the game data caching sequence as the target game frame data packet;
an adjacent position obtaining subunit 1342, configured to determine, based on the target frame rendering position identifier, a first frame rendering position identifier and a second frame rendering position identifier if the target frame rendering position identifier is a decimal; the game frame data packet corresponding to the first frame rendering position identifier and the game frame data packet corresponding to the second frame rendering position identifier are adjacent in position in the game data cache sequence; the target frame rendering position identification is larger than the first frame rendering position identification and smaller than the second frame rendering position identification;
the second data obtaining subunit 1343 is configured to generate the target game frame data packet according to the game frame data packet corresponding to the first frame rendering position identifier and the game frame data packet corresponding to the second frame rendering position identifier in the game data caching sequence.
The second data obtaining subunit 1343 includes:
an adjacent data obtaining subunit 1343a, configured to obtain, from the game data buffering sequence, a game frame data packet at the first frame rendering position identifier and a game frame data packet at the second frame rendering position identifier;
an interpolation splitting subunit 1343b, configured to perform interpolation splitting on the game frame data packet at the first frame rendering position identifier and the game frame data packet at the second frame rendering position identifier based on the target frame rendering position identifier, so as to obtain at least two interpolation data packets;
the interpolation data determining subunit 1343c is configured to determine, as the target game frame data packet, an interpolation data packet corresponding to the target frame rendering position identifier in the at least two interpolation data packets.
Wherein, the apparatus 110 further comprises:
an identifier rounding module 15, configured to use a maximum integer value smaller than or equal to the target frame rendering location identifier as a maximum deletion location identifier;
a to-be-deleted determining module 16, configured to determine, as a to-be-deleted data packet, a game frame data packet located between the head identifier and the maximum deletion position identifier in the game data cache sequence;
and a data updating module 17, configured to delete the to-be-deleted data packet in the game data cache sequence, update the target frame rendering position identifier according to the maximum deletion position identifier, obtain an updated target frame rendering position identifier, and update the value of the historical frame rendering position variable to the updated target frame rendering position identifier.
Wherein, the apparatus 110 further comprises:
an anomaly determination module 18, configured to determine that a network state of the local terminal is abnormal and display a network state anomaly prompt if the game frame rendering step size is greater than a game rendering step size threshold;
and a network switching module 19, configured to acquire a standby network connection mode of the local terminal, and display a network switching prompt message based on the standby network connection mode.
The embodiment of the application provides a game data synchronization device, which is used for counting the frequency of a game frame data packet sent by a game terminal as the historical frame frequency corresponding to the game terminal; determining a game frame rendering step length of the game terminal based on the historical frame frequency, and acquiring a game data cache sequence; determining the initial position identification of the game frame data packet which is not rendered in the game data cache sequence, acquiring a target game frame data packet from the game data cache sequence according to the initial position identification and the game frame rendering step length, and generating a target rendering frame according to the target game frame data packet. Through the process, after the local terminal acquires the game frame data packet sent by the game terminal, the local terminal caches the game frame data packet, determining the game frame rendering step length of the game terminal according to the historical frame frequency of the game terminal, wherein the local terminal can acquire a corresponding game frame data packet from the game data cache sequence according to the game frame rendering step length for rendering, so as to balance the frequency of rendering frame generation by the local terminal and the frequency of game frame data packets acquired by the local terminal and sent by the game terminal, when the rendering frequency of the game between the local terminal and the game terminal is not consistent, the game frame data packets in the game data buffer sequence may be allocated based on the game frame rendering step size, therefore, the local terminal can acquire the game frame data packet in each rendering frame to render the game data of the game terminal, and smoothness of game rendering is improved.
Referring to fig. 12, fig. 12 is a schematic structural diagram of a computer device according to an embodiment of the present application. As shown in fig. 12, the computer device in the embodiment of the present application may include: one or more processors 1201, memory 1202, and input-output interface 1203. The processor 1201, the memory 1202, and the input/output interface 1203 are connected by a bus 1204. The memory 1202 is configured to store a computer program, where the computer program includes program instructions, and the input/output interface 1203 is configured to receive data and output data, so as to implement game data interaction between the game terminals; the processor 1201 is configured to execute the program instructions stored in the memory 1202 to perform the following operations:
counting the frequency of a game frame data packet sent by a game terminal as the historical frame frequency corresponding to the game terminal;
determining a game frame rendering step length of the game terminal based on the historical frame frequency, and acquiring a game data cache sequence; the game data cache sequence comprises the game frame data packet sent by the game terminal;
determining the initial position identification of the game frame data packet which is not rendered in the game data cache sequence, acquiring a target game frame data packet from the game data cache sequence according to the initial position identification and the game frame rendering step length, and generating a target rendering frame according to the target game frame data packet.
In some possible embodiments, the processor 1201 may be a Central Processing Unit (CPU), and the processor may be other general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 1202 may include both read-only memory and random access memory, and provides instructions and data to the processor 1201 and the input output interface 1203. A portion of the memory 1202 may also include non-volatile random access memory. For example, memory 1202 may also store device type information.
In a specific implementation, the computer device may execute, through each built-in functional module thereof, the implementation manner provided in each step in fig. 3 or fig. 5, which may be specifically referred to the implementation manner provided in each step in fig. 3 or fig. 5, and is not described herein again.
The embodiment of the present application provides a computer device, including: the processor, the input/output interface and the memory, and the processor acquires the computer instructions in the memory, and executes the steps of the method shown in the above-mentioned fig. 3 or fig. 5 to perform the game data synchronization operation. Counting the frequency of a game frame data packet sent by a game terminal to be used as the historical frame frequency corresponding to the game terminal; determining a game frame rendering step length of the game terminal based on the historical frame frequency, and acquiring a game data cache sequence; determining the initial position identification of the game frame data packet which is not rendered in the game data cache sequence, acquiring a target game frame data packet from the game data cache sequence according to the initial position identification and the game frame rendering step length, and generating a target rendering frame according to the target game frame data packet. Through the process, after the local terminal acquires the game frame data packet sent by the game terminal, the local terminal caches the game frame data packet, determining the game frame rendering step length of the game terminal according to the historical frame frequency of the game terminal, wherein the local terminal can acquire a corresponding game frame data packet from the game data cache sequence according to the game frame rendering step length for rendering, so as to balance the frequency of rendering frame generation by the local terminal and the frequency of game frame data packets acquired by the local terminal and sent by the game terminal, when the rendering frequency of the game between the local terminal and the game terminal is not consistent, the game frame data packets in the game data buffer sequence may be allocated based on the game frame rendering step size, therefore, the local terminal can acquire the game frame data packet in each rendering frame to render the game data of the game terminal, and smoothness of game rendering is improved.
An embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, where the computer program includes program instructions, and when the program instructions are executed by the processor, the method for synchronizing game data provided in each step in fig. 3 or 5 may be implemented, for specific reference, the implementation manner provided in each step in fig. 3 or 5 may be referred to, and details are not described herein again. In addition, the beneficial effects of the same method are not described in detail. For technical details not disclosed in embodiments of the computer-readable storage medium referred to in the present application, reference is made to the description of embodiments of the method of the present application. By way of example, program instructions may be deployed to be executed on one computer device or on multiple computer devices at one site or distributed across multiple sites and interconnected by a communication network.
The computer-readable storage medium may be the game data synchronization apparatus provided in any of the foregoing embodiments or an internal storage unit of the computer device, such as a hard disk or a memory of the computer device. The computer readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a Smart Memory Card (SMC), a Secure Digital (SD) card, a flash card (flash card), and the like, provided on the computer device. Further, the computer-readable storage medium may also include both an internal storage unit and an external storage device of the computer device. The computer-readable storage medium is used for storing the computer program and other programs and data required by the computer device. The computer readable storage medium may also be used to temporarily store data that has been output or is to be output.
The terms "first," "second," and the like in the description and in the claims and drawings of the embodiments of the present application are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "comprises" and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, apparatus, product, or apparatus that comprises a list of steps or elements is not limited to the listed steps or modules, but may alternatively include other steps or modules not listed or inherent to such process, method, apparatus, product, or apparatus.
Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the examples described in connection with the embodiments disclosed herein may be embodied in electronic hardware, computer software, or combinations of both, and that the components and steps of the examples have been described in a functional general in the foregoing description for the purpose of illustrating clearly the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The method and the related apparatus provided by the embodiments of the present application are described with reference to the flowchart and/or the structural diagram of the method provided by the embodiments of the present application, and each flow and/or block of the flowchart and/or the structural diagram of the method, and the combination of the flow and/or block in the flowchart and/or the block diagram can be specifically implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block or blocks of the block diagram. These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block or blocks of the block diagram. These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block or blocks.
The above disclosure is only for the purpose of illustrating the preferred embodiments of the present application and is not to be construed as limiting the scope of the present application, so that the present application is not limited thereto, and all equivalent variations and modifications can be made to the present application.

Claims (15)

1. A game data synchronization method, the method comprising:
counting the frequency of a game frame data packet sent by a game terminal, wherein the frequency is used as the historical frame frequency corresponding to the game terminal;
determining a game frame rendering step length of the game terminal based on the historical frame frequency, and acquiring a game data cache sequence; the game data caching sequence comprises the game frame data packet sent by the game terminal;
determining the initial position identification of the game frame data packet which is not rendered in the game data cache sequence, acquiring a target game frame data packet from the game data cache sequence according to the initial position identification and the game frame rendering step length, and generating a target rendering frame according to the target game frame data packet.
2. The method of claim 1, wherein the counting the frequency of the game frame data packets transmitted by the game terminal as the historical frame frequency corresponding to the game terminal comprises:
in a rendering period, acquiring a game frame data packet sent by the game terminal, and adding the game frame data packet to the game data cache sequence;
acquiring a data packet statistical variable, and updating the data packet statistical variable based on the game frame data packet; the data packet statistical variable is used for counting the number of the game frame data packets sent by the game terminal in the rendering period;
and generating the frequency of the game frame data packet sent by the game terminal based on the data packet statistical variable and the rendering period, wherein the frequency is used as the historical frame frequency corresponding to the game terminal.
3. The method of claim 1, wherein said determining a game frame rendering step size for the game terminal based on the historical frame frequency comprises:
and acquiring a frequency average value corresponding to the historical frame frequency, and determining the frequency average value as a game frame rendering step length of the game terminal.
4. The method of claim 3, wherein the obtaining a frequency mean corresponding to the historical frame frequency comprises:
if the number of the historical frame frequencies is less than or equal to a frequency statistical threshold, determining the average value of the historical frame frequencies as a frequency average value corresponding to the historical frame frequencies;
if the number of the historical frame frequencies is larger than the frequency statistical threshold, sequentially acquiring statistical historical frame frequencies from the historical frame frequencies according to the time sequence of the recording time; the number of the statistical historical frame frequencies is the frequency statistical threshold;
and deleting the historical frame frequency except the statistical historical frame frequency in the historical frame frequency, and determining the average value of the statistical historical frame frequency as the frequency average value corresponding to the historical frame frequency.
5. The method of claim 1, wherein determining a starting location identification of an unrendered game frame data packet in the game data buffering sequence comprises:
acquiring a historical frame rendering position variable, and acquiring a historical frame rendering position identifier from the historical frame rendering position variable; the historical frame rendering position identifier is a position identifier of a historical game frame data packet in the game data cache sequence; the historical game frame data packet is used for generating a rendering frame which is the last rendering frame of the target rendering frames;
determining the historical frame rendering position identification as the starting position identification of the game frame data packet which is not rendered;
the method further comprises:
and updating the historical frame rendering position identifier in the historical frame rendering position variable into the position identifier of the target game frame data packet in the game data cache sequence.
6. The method of claim 5, wherein said retrieving a target game frame data packet from said game data buffer sequence based on said start position identifier and said game frame rendering step size comprises:
acquiring the maximum value of the sequence position of the game data cache sequence;
if the sum of the initial position identification and the game frame rendering step length is greater than or equal to the maximum sequence position, determining the maximum sequence position as a target frame rendering position identification, and acquiring the target game frame data packet corresponding to the target frame rendering position identification from the game data cache sequence;
if the sum of the initial position identification and the game frame rendering step length is smaller than the maximum value of the sequence position, determining the sum of the initial position identification and the game frame rendering step length as the target frame rendering position identification, and acquiring the target game frame data packet corresponding to the target frame rendering position identification from the game data cache sequence.
7. The method of claim 6, wherein said retrieving the target game frame data packet corresponding to the target frame rendering position identifier from the game data buffering sequence comprises:
if the target frame rendering position identifier is an integer, determining a game frame data packet at the target frame rendering position identifier in the game data cache sequence as the target game frame data packet;
if the target frame rendering position identification is a decimal, determining a first frame rendering position identification and a second frame rendering position identification based on the target frame rendering position identification; the game frame data packets corresponding to the first frame rendering position identification and the second frame rendering position identification are adjacent in position in the game data cache sequence; the target frame rendering position identification is larger than the first frame rendering position identification and smaller than the second frame rendering position identification;
and generating the target game frame data packet according to the game frame data packet corresponding to the first frame rendering position identifier and the game frame data packet corresponding to the second frame rendering position identifier in the game data cache sequence.
8. The method of claim 7, wherein generating the target game frame data packets according to the game frame data packets corresponding to the first frame rendering position identifier and the second frame rendering position identifier in the game data buffering sequence comprises:
obtaining a game frame data packet at the first frame rendering position identifier and a game frame data packet at the second frame rendering position identifier from the game data cache sequence;
based on the target frame rendering position identifier, performing interpolation splitting on the game frame data packet at the first frame rendering position identifier and the game frame data packet at the second frame rendering position identifier to obtain at least two interpolation data packets;
and determining the interpolation data packet corresponding to the target frame rendering position identifier in the at least two interpolation data packets as the target game frame data packet.
9. The method of claim 6, wherein the method further comprises:
taking the maximum integer value which is less than or equal to the target frame rendering position identifier as a maximum deletion position identifier;
determining a game frame data packet between the first identifier and the maximum deletion position identifier in the game data cache sequence as a data packet to be deleted;
deleting the data packet to be deleted in the game data cache sequence, updating the target frame rendering position identifier according to the maximum deletion position identifier to obtain an updated target frame rendering position identifier, and updating the value of the historical frame rendering position variable into the updated target frame rendering position identifier.
10. The method of claim 1, wherein the method further comprises:
if the game frame rendering step length is larger than the game rendering step length threshold value, determining that the network state of the local terminal is abnormal, and displaying a network state abnormal prompt;
and acquiring a standby network connection mode of the local terminal, and displaying a network switching prompt message based on the standby network connection mode.
11. A game data synchronization apparatus, characterized in that the apparatus comprises:
the frequency acquisition module is used for counting the frequency of a game frame data packet sent by a game terminal and taking the frequency as the historical frame frequency corresponding to the game terminal;
the step length determining module is used for determining the game frame rendering step length of the game terminal based on the historical frame frequency and acquiring a game data cache sequence; the game data caching sequence comprises the game frame data packet sent by the game terminal;
and the data acquisition module is used for determining the initial position identification of the game frame data packet which is not rendered in the game data cache sequence, acquiring a target game frame data packet from the game data cache sequence according to the initial position identification and the game frame rendering step length, and generating a target rendering frame according to the target game frame data packet.
12. The apparatus of claim 11, wherein the frequency acquisition module comprises:
the sequence updating unit is used for acquiring a game frame data packet sent by the game terminal in a rendering period and adding the game frame data packet to the game data cache sequence;
the data counting unit is used for acquiring a data packet counting variable and updating the data packet counting variable based on the game frame data packet; the data packet statistical variable is used for counting the number of the game frame data packets sent by the game terminal in the rendering period;
and the frequency determining unit is used for generating the frequency of the game frame data packet sent by the game terminal based on the data packet statistical variable and the rendering period, and the frequency is used as the historical frame frequency corresponding to the game terminal.
13. The apparatus of claim 11, wherein the step size determination module is specifically configured to:
and acquiring a frequency average value corresponding to the historical frame frequency, and determining the frequency average value as a game frame rendering step length of the game terminal.
14. A computer device comprising a processor, a memory, an input output interface;
the processor is connected to the memory and the input/output interface, respectively, wherein the input/output interface is configured to receive data and output data, the memory is configured to store program codes, and the processor is configured to call the program codes to perform the method according to any one of claims 1 to 10.
15. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program comprising program instructions which, when executed by a processor, perform the method according to any one of claims 1-10.
CN202010449889.7A 2020-05-25 2020-05-25 Game data synchronization method, device, computer and readable storage medium Active CN111632382B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010449889.7A CN111632382B (en) 2020-05-25 2020-05-25 Game data synchronization method, device, computer and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010449889.7A CN111632382B (en) 2020-05-25 2020-05-25 Game data synchronization method, device, computer and readable storage medium

Publications (2)

Publication Number Publication Date
CN111632382A true CN111632382A (en) 2020-09-08
CN111632382B CN111632382B (en) 2021-06-25

Family

ID=72324460

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010449889.7A Active CN111632382B (en) 2020-05-25 2020-05-25 Game data synchronization method, device, computer and readable storage medium

Country Status (1)

Country Link
CN (1) CN111632382B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114510140A (en) * 2020-11-16 2022-05-17 深圳市万普拉斯科技有限公司 Frequency modulation method and device and electronic equipment

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5411386B1 (en) * 2013-08-12 2014-02-12 株式会社 ディー・エヌ・エー Server and method for providing game
CN107222510A (en) * 2017-07-21 2017-09-29 腾讯科技(深圳)有限公司 A kind of game synchronization method, system and relevant device
CN108721898A (en) * 2018-06-01 2018-11-02 深圳市腾讯网络信息技术有限公司 The determination method and apparatus of frame per second, storage medium, electronic device
CN108765531A (en) * 2018-03-27 2018-11-06 广东欧珀移动通信有限公司 Image rendering method, device, storage medium and intelligent terminal
CN109395384A (en) * 2018-09-12 2019-03-01 Oppo广东移动通信有限公司 Game rendering method and Related product
CN109771949A (en) * 2019-01-14 2019-05-21 珠海金山网络游戏科技有限公司 A kind of method and system of the interior dynamic adjustment rendering grade of game
US10362320B2 (en) * 2017-04-21 2019-07-23 Zenimax Media Inc. Systems and methods for rendering and pre-encoded load estimation based encoder hinting
CN110681155A (en) * 2019-09-29 2020-01-14 Oppo广东移动通信有限公司 Game optimization method, game optimization device and mobile terminal
CN111167116A (en) * 2019-09-29 2020-05-19 腾讯科技(深圳)有限公司 Smooth display method, terminal and computer storage medium

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5411386B1 (en) * 2013-08-12 2014-02-12 株式会社 ディー・エヌ・エー Server and method for providing game
US10362320B2 (en) * 2017-04-21 2019-07-23 Zenimax Media Inc. Systems and methods for rendering and pre-encoded load estimation based encoder hinting
CN107222510A (en) * 2017-07-21 2017-09-29 腾讯科技(深圳)有限公司 A kind of game synchronization method, system and relevant device
CN108765531A (en) * 2018-03-27 2018-11-06 广东欧珀移动通信有限公司 Image rendering method, device, storage medium and intelligent terminal
CN108721898A (en) * 2018-06-01 2018-11-02 深圳市腾讯网络信息技术有限公司 The determination method and apparatus of frame per second, storage medium, electronic device
CN109395384A (en) * 2018-09-12 2019-03-01 Oppo广东移动通信有限公司 Game rendering method and Related product
CN109771949A (en) * 2019-01-14 2019-05-21 珠海金山网络游戏科技有限公司 A kind of method and system of the interior dynamic adjustment rendering grade of game
CN110681155A (en) * 2019-09-29 2020-01-14 Oppo广东移动通信有限公司 Game optimization method, game optimization device and mobile terminal
CN111167116A (en) * 2019-09-29 2020-05-19 腾讯科技(深圳)有限公司 Smooth display method, terminal and computer storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114510140A (en) * 2020-11-16 2022-05-17 深圳市万普拉斯科技有限公司 Frequency modulation method and device and electronic equipment
CN114510140B (en) * 2020-11-16 2024-04-16 深圳市万普拉斯科技有限公司 Frequency modulation method and device and electronic equipment

Also Published As

Publication number Publication date
CN111632382B (en) 2021-06-25

Similar Documents

Publication Publication Date Title
CN107222510B (en) A kind of game synchronization method, system and relevant device
JP7465959B2 (en) Data processing method, apparatus, computer device and computer program
CN112154669B (en) Correlation of video stream frame timestamps based on system clock
CN111246178B (en) Video processing method and device, storage medium and electronic device
CN111124230B (en) Input response method, device, electronic equipment and computer readable storage medium
CN107145355B (en) Page layout adjusting method and device, storage medium, processor and terminal
CN108668158B (en) Bullet screen synchronization method, client and bullet screen server
CN109213462B (en) Android horizontal and vertical screen data synchronization method and device, terminal and readable medium
CN112642143B (en) Method, device, storage medium and electronic equipment for realizing information synchronization
CN110639207A (en) Game data synchronization method, device, storage medium and processor
CN105760238B (en) The treating method and apparatus and system of graphics instructional data
WO2014187108A1 (en) Server, client and video processing method
CN108156509B (en) Video playing method and device and user terminal
CN111265863B (en) Target object position correction method, device, equipment and medium
US20090094534A1 (en) Server apparatus and control method of server apparatus
EP3936206A1 (en) Method for displaying frames in game application program, apparatus, terminal, and storage medium
CN111632382B (en) Game data synchronization method, device, computer and readable storage medium
CN108156500B (en) Multimedia data time correction method, computer device and computer readable storage medium
CN109821235B (en) Game video recording method, device and server
CN115955590A (en) Video processing method, video processing device, computer equipment and medium
CN113473215B (en) Screen recording method, device, terminal and storage medium
CN115228084B (en) Game picture synchronization method and related equipment
CN111760273B (en) Game fragment processing method, device and equipment
US10142689B2 (en) Server, terminal, information processing method, information processing program, and computer-readable recording medium storing information processing programs
US10159899B2 (en) Video game processing program, video game processing system and video game processing method

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
GR01 Patent grant
GR01 Patent grant