Disclosure of Invention
In view of this, embodiments of the present application provide a method and an apparatus for updating a virtual item, a computing device, and a computer-readable storage medium, so as to solve technical defects in the prior art.
According to a first aspect of the embodiments of the present application, there is provided a virtual item updating method, applied to a client, including:
acquiring the geographic position information of the current geographic position of the client;
determining a grid identifier corresponding to the virtual item to be updated in a map and a client grid version number corresponding to the grid identifier according to the geographic position information, wherein the map is divided into a plurality of grids in advance, and each grid is provided with a corresponding grid identifier;
generating a synchronization request according to the grid identification and the grid version number of the client, and sending the synchronization request to a server;
and receiving the virtual item updating information corresponding to the grid identification sent by the server, and updating the virtual item in the grid corresponding to the grid identification according to the virtual item updating information.
Optionally, the virtual item updating method further includes:
receiving a server grid version number corresponding to the grid identifier sent by the server;
and updating the grid version number of the client according to the server grid version number corresponding to the grid identifier.
Optionally, the obtaining of the geographic location information of the current geographic location of the client includes:
and acquiring the geographical position information of the current geographical position of the client according to a preset time interval.
Optionally, the obtaining of the geographic location information of the current geographic location of the client according to a preset time interval includes:
and acquiring the longitude and latitude coordinates of the current geographic position of the client according to a preset time interval.
Optionally, determining, according to the geographic location information, a grid identifier corresponding to the geographic location in the map, includes:
and determining the grid identification corresponding to the geographic position in the map according to the longitude and latitude coordinates.
Optionally, the grid includes a preset grid side length;
determining the grid identifier corresponding to the geographic position in the map according to the longitude and latitude coordinates, wherein the grid identifier comprises the following steps:
and determining the corresponding grid identification of the geographic position in the map according to the longitude and latitude coordinates and the grid side length.
According to a second aspect of the embodiments of the present application, there is provided a virtual item updating method, applied to a server, including:
receiving a synchronization request sent by a client, wherein the synchronization request comprises a grid identifier and a client grid version number corresponding to the grid identifier;
determining that the grid identification corresponds to virtual item update information in response to the synchronization request;
and sending the virtual prop updating information to the client.
Optionally, the server is a distributed server, and includes a logic server and at least one node server;
responding to the synchronization request to determine that the grid identification corresponds to virtual item update information, wherein the steps comprise:
the logic server determines a target node server corresponding to the grid identification according to the grid identification;
and the target node server determines the virtual item updating information corresponding to the grid identification according to the grid identification and the client grid version number.
Optionally, the determining, by the logic server, the target node server corresponding to the grid identifier according to the grid identifier includes:
acquiring the number of node servers in the distributed server and the number of service threads started in each node service;
and determining a target node server corresponding to the grid identifier according to the grid identifier, the number of the node servers and the number of service threads in each node server.
Optionally, the determining, by the target node server, the virtual item update information corresponding to the grid identifier according to the grid identifier and the client grid version number includes:
acquiring a server grid version number corresponding to the grid identifier stored in the target node server;
and under the condition that the client grid version number is different from the server grid version number corresponding to the grid identifier, determining the virtual item updating information corresponding to the grid identifier according to the client grid version number and the server grid version number corresponding to the grid identifier.
Optionally, determining, according to the client grid version number and the server grid version number corresponding to the grid identifier, virtual item update information corresponding to the grid identifier includes:
under the condition that the server grid version number corresponding to the grid identifier is equal to the client grid version number plus 1, taking the incremental information between the server grid version number corresponding to the grid identifier and the client grid version number as the virtual prop updating information corresponding to the grid identifier; or
And under the condition that the server grid version number corresponding to the grid identifier is greater than the client grid version number plus 1, taking the total information corresponding to the server grid version number corresponding to the grid identifier as the virtual item updating information corresponding to the grid identifier.
According to a third aspect of the embodiments of the present application, there is provided a virtual item updating method, including:
a client acquires the geographic position information of the current geographic position of the client; determining a grid identifier corresponding to the virtual item to be updated in a map and a client grid version number corresponding to the grid identifier according to the geographic position information, wherein the map is divided into a plurality of grids in advance, and each grid is provided with a corresponding grid identifier; generating a synchronization request according to the grid identification and the grid version number of the client, and sending the synchronization request to a server;
the server responds to the synchronization request to determine the updating information of the virtual prop corresponding to the grid identification; sending the virtual prop updating information to the client;
and the client updates the virtual prop in the grid corresponding to the grid identification according to the virtual prop updating information.
According to a fourth aspect of the embodiments of the present application, there is provided a virtual item updating apparatus, configured at a client, including:
the acquisition module is configured to acquire the geographic position information of the current geographic position of the client;
the first determining module is configured to determine a grid identifier corresponding to the virtual item to be updated in a map and a client grid version number corresponding to the grid identifier according to the geographic position information, wherein the map is divided into a plurality of grids in advance, and each grid has a corresponding grid identifier;
the first sending module is configured to generate a synchronization request according to the grid identifier and the client grid version number and send the synchronization request to a server;
and the first receiving module is configured to receive the virtual item updating information corresponding to the grid identifier sent by the server, and update the virtual item in the grid corresponding to the grid identifier according to the virtual item updating information.
Optionally, the apparatus further comprises:
the first receiving module is further configured to receive a server grid version number corresponding to the grid identifier sent by the server; and updating the grid version number of the client according to the server grid version number corresponding to the grid identifier.
Optionally, the obtaining module is further configured to obtain geographic location information of the current geographic location of the client according to a preset time interval.
Optionally, the obtaining module is further configured to obtain the longitude and latitude coordinates of the current geographic location of the client according to a preset time interval.
Optionally, the first determining module is further configured to determine, according to the longitude and latitude coordinates, a grid identifier corresponding to the geographic location in a map.
Optionally, the grid includes a preset grid side length;
optionally, the first determining module is further configured to determine a grid identifier corresponding to the geographic location in a map according to the longitude and latitude coordinates and the grid side length.
According to a fifth aspect of the embodiments of the present application, there is provided a virtual item updating apparatus configured on a server, including:
the second receiving module is configured to receive a synchronization request sent by a client, wherein the synchronization request comprises a grid identifier and a client grid version number corresponding to the grid identifier;
a second determination module configured to determine that the grid identification corresponds to virtual item update information in response to the synchronization request;
a second sending module configured to send the virtual item update information to the client.
Optionally, the server is a distributed server, and includes a logic server and at least one node server;
the second determining module includes:
a first determining submodule configured to determine, by the logic server, a target node server corresponding to the grid identifier according to the grid identifier;
and the second determining submodule is configured to determine, by the target node server, virtual item update information corresponding to the grid identifier according to the grid identifier and the client grid version number.
Optionally, the first determining submodule is further configured to obtain the number of node servers in the distributed server and the number of service threads enabled in each node service; and determining a target node server corresponding to the grid identifier according to the grid identifier, the number of the node servers and the number of service threads in each node server.
Optionally, the second determining submodule is further configured to obtain a server grid version number corresponding to the grid identifier stored in the target node server; and under the condition that the client grid version number is different from the server grid version number corresponding to the grid identifier, determining the virtual item updating information corresponding to the grid identifier according to the client grid version number and the server grid version number corresponding to the grid identifier.
Optionally, the second determining submodule is further configured to, when the server grid version number corresponding to the grid identifier is equal to the client grid version number plus 1, use incremental information between the server grid version number corresponding to the grid identifier and the client grid version number as virtual item update information corresponding to the grid identifier; or when the server grid version number corresponding to the grid identifier is greater than the client grid version number plus 1, using the total information corresponding to the server grid version number corresponding to the grid identifier as the virtual item update information corresponding to the grid identifier.
According to a sixth aspect of the embodiments of the present application, there is provided a virtual item updating apparatus, including:
a client acquires the geographic position information of the current geographic position of the client; determining a grid identifier corresponding to the virtual item to be updated in a map and a client grid version number corresponding to the grid identifier according to the geographic position information, wherein the map is divided into a plurality of grids in advance, and each grid is provided with a corresponding grid identifier; generating a synchronization request according to the grid identification and the grid version number of the client, and sending the synchronization request to a server;
the server responds to the synchronization request to determine the updating information of the virtual prop corresponding to the grid identification; sending the virtual prop updating information to the client;
and the client updates the virtual prop in the grid corresponding to the grid identification according to the virtual prop updating information.
According to a seventh aspect of embodiments of the present application, there is provided a computing device comprising a memory, a processor and computer instructions stored on the memory and executable on the processor, the processor implementing the steps of the virtual prop updating method when executing the instructions.
According to an eighth aspect of the embodiments of the present application, there is provided a computer-readable storage medium storing computer instructions which, when executed by a processor, implement the steps of the virtual item updating method.
The virtual prop updating method provided by the embodiment of the application is applied to a client, the current geographical position of the client is obtained, the grid corresponding to the virtual prop to be updated in a map can be simply and quickly confirmed by determining the grid identifier corresponding to the current geographical position, the pressure of a server is reduced by the execution of the client in the process of determining the grid identifier by the geographical position, the grid identifier and the grid version number of the client are sent to the server, the virtual prop updating information sent by the server is received, only the virtual prop updating information corresponding to the grid identifier needs to be obtained, all the virtual prop updating information in the map does not need to be obtained, and the obtained data volume is greatly reduced; and updating the virtual props in the grid according to the virtual prop updating information, so that computing resources are saved, the updating response speed is improved, and further the user experience is improved.
The virtual item updating method provided by the embodiment of the application is applied to a server, receives a synchronization request sent by a client, and only needs to acquire the virtual item updating information corresponding to the grid identifier without calculating all the virtual item updating information in a map, so that the consumption of invalid calculation resources is reduced, and the operation pressure of the server is reduced.
Secondly, the distributed server cluster is used for sending the synchronization request to different node servers, so that the operation efficiency is further improved, and the synchronization requests sent by different clients can be processed at the same time. The response speed is further improved, the operation pressure of the server is reduced, and the game delay is reduced.
Detailed Description
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present application. This application is capable of implementation in many different ways than those herein set forth and of similar import by those skilled in the art without departing from the spirit of this application and is therefore not limited to the specific implementations disclosed below.
The terminology used in the one or more embodiments of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of the present application. As used in one or more embodiments of the present application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used in one or more embodiments of the present application refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It will be understood that, although the terms first, second, etc. may be used herein in one or more embodiments of the present application to describe various information, these information should not be limited by these terms. These terms are only used to distinguish one type of information from another. For example, a first aspect may be termed a second aspect, and, similarly, a second aspect may be termed a first aspect, without departing from the scope of one or more embodiments of the present application. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.
In the present application, a virtual item updating method and apparatus, a computing device, and a computer-readable storage medium are provided, which are described in detail in the following embodiments one by one.
FIG. 1 shows a block diagram of a computing device 100 according to an embodiment of the present application. The components of the computing device 100 include, but are not limited to, memory 110 and processor 120. The processor 120 is coupled to the memory 110 via a bus 130 and a database 150 is used to store data.
Computing device 100 also includes access device 140, access device 140 enabling computing device 100 to communicate via one or more networks 160. Examples of such networks include the Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the internet. Access device 140 may include one or more of any type of network interface (e.g., a Network Interface Card (NIC)) whether wired or wireless, such as an IEEE802.11 Wireless Local Area Network (WLAN) wireless interface, a worldwide interoperability for microwave access (Wi-MAX) interface, an ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a bluetooth interface, a Near Field Communication (NFC) interface, and so forth.
In one embodiment of the present application, the above-mentioned components of the computing device 100 and other components not shown in fig. 1 may also be connected to each other, for example, by a bus. It should be understood that the block diagram of the computing device architecture shown in FIG. 1 is for purposes of example only and is not limiting as to the scope of the present application. Those skilled in the art may add or replace other components as desired.
Computing device 100 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., tablet, personal digital assistant, laptop, notebook, netbook, etc.), a mobile phone (e.g., smartphone), a wearable computing device (e.g., smartwatch, smartglasses, etc.), or other type of mobile device, or a stationary computing device such as a desktop computer or PC. Computing device 100 may also be a mobile or stationary server.
Processor 120 may execute the steps in the virtual item update method shown in fig. 2. Fig. 2 shows a flowchart of a virtual item updating method according to an embodiment of the present application, where the virtual item updating method is applied to a client, and includes steps 202 to 208.
Step 202: and acquiring the geographic position information of the current geographic position of the client.
The client starts a game for a player and participates in the game, and the client can be a mobile phone, a tablet personal computer and other terminals.
Optionally, the obtaining of the geographic location information of the current geographic location of the client includes: and acquiring the geographical position information of the current geographical position of the client according to a preset time interval.
In practical application, the geographic position information of the client needs to be acquired according to a preset time interval, for example, the geographic position information of the client is acquired every 1 second or every 10 seconds, and the geographic position information in the application is a longitude and latitude coordinate of a current position acquired by the client through GPS positioning.
In the embodiment provided in the present application, for example, a player carries a client to start a game at a location a, and longitude and latitude coordinates of a geographic location a where the client is located are obtained as (113.601 × 22.354%), where 113.601 × represents longitude and 22.354 × represents latitude.
Step 204: and determining a grid identifier corresponding to the virtual item to be updated in a map and a client grid version number corresponding to the grid identifier according to the geographical position information, wherein the map is divided into a plurality of grids in advance, and each grid has a corresponding grid identifier.
After the geographical position information of the client is obtained, the virtual item to be updated can be determined to be updated in the grid where the geographical position information is located according to the geographical position information, namely, the grid identification corresponding to the virtual item to be updated in the map is determined.
When needing to be noted, the map is divided into a plurality of grids in advance, and each grid is provided with a corresponding grid mark.
Referring to fig. 3, fig. 3 is a schematic diagram showing the earth divided into a plurality of grids in the embodiment of the present application, the longitude of the earth is 360 ° from west-180 ° to east 180 °, the circumference of the equator is about 40000 km, and the longitude can be equally divided into 4 × 10 according to the calculation of 1 m on a side7The included angle between two adjacent longitude lines is 360 degrees (4 × 10)7) 0.000009 degrees, the latitude of the earth has a total of 180 degrees from south-90 degrees to north 90 degrees, the length of the meridian is about 20000 kilometers, and the meridian can be equally divided into 2 × 10 degrees according to the side length of 1 meter7And the included angle between two adjacent weft yarns is 180 degrees/2 × 107) 0.000009 DEG, the earth is now divided into a total of 8 × 1014The grid with 1 meter side length, when the grid side length is 1000 meters, the earth is divided into 8 × 10 in total11The included angle between adjacent warps or wefts of each grid is 0.009 degree, and when the side length of each grid is 1 × 106In the rice season, the earth is divided into 8 × 10 points in total8And the included angle of the adjacent warp or weft is 9 degrees.
The method for calculating the grid mark comprises the steps of firstly determining the preset side length of the grid, determining the longitude mark and the latitude mark of the current position according to the side length of the grid and the longitude and latitude coordinates of the current position, and then determining the grid mark according to the longitude mark and the latitude mark.
Specifically, see the following equation (1) for calculating the longitude flag of the current location information.
Longitude designation (X +180) × 106/(9 × S) formula (1)
Wherein, X is a longitude coordinate in the current position information, S is a preset grid side length, and the value of the longitude mark is a calculation result which is rounded downwards.
See the following equation (2) for calculating the latitude index of the current location information.
Latitude mark (Y +90) × 106/(9 × S) formula (2)
And Y is a longitude coordinate in the current position information, S is a preset grid side length, and the value of the latitude mark is rounded downwards as a calculation result.
After the longitude mark and the latitude mark are determined, the grid mark can be determined according to the following formula (3).
Grid identifier (longitude identifier × 10)8+ latitude identification formula (3)
The longitude is identified as the calculation result of formula 1, and the latitude is identified as the calculation result of formula 2.
After the grid identifier corresponding to the virtual prop to be updated in the map is determined, the client grid version number of the grid identifier in the client is determined at the same time, and the initial value of the client grid version number is 0.
In the embodiment provided by the application, according to the fact that the length of a preset grid side is 1000 meters with longitude and latitude coordinates (113.601 × 22.354), the longitude mark of the current position information is 32622 and the latitude mark is 12483, the grid mark corresponding to the current position information is further determined to be 3262200012483, and the client grid version number corresponding to the grid mark is obtained to be 0.
Step 206: and generating a synchronization request according to the grid identifier and the grid version number of the client, and sending the synchronization request to a server.
In the embodiment provided by the application, a synchronization request Q (3262200012483, 0) is generated according to the grid identifier 3262200012483 and the client grid version number 0, and the synchronization request Q is sent to the server.
Step 208: and receiving the virtual item updating information corresponding to the grid identification sent by the server, and updating the virtual item in the grid corresponding to the grid identification according to the virtual item updating information.
And receiving virtual item updating information which is sent by a server and corresponds to the grid identification and acquired in response to the synchronization request, wherein the updating information comprises the virtual item identification and the virtual item longitude and latitude of the virtual item in the grid corresponding to the grid identification, and updating the virtual item in the grid according to the virtual item updating information.
Each virtual item has a corresponding virtual item identifier, the virtual item identifiers are a grid identifier and a virtual item number, and if the grid identifier is 3262200012483 and the virtual item number is 0001, the virtual item identifier is 32622000124830001.
Optionally, the method further includes receiving a server grid version number corresponding to the grid identifier sent by the server; and updating the grid version number of the client according to the server grid version number corresponding to the grid identifier.
When the virtual prop is updated, the grid version number of the client is updated to the grid version number of the server, and the uniformity of the version numbers is guaranteed, so that the uniformity of data in the game is guaranteed.
In a specific application, in a preset time period, the number of virtual props generated in the same grid is fixed, such as: 1000 virtual items are generated in one grid per hour, or 50000 virtual items are generated in one grid per day.
In the embodiment provided by the present application, the client receives virtual item update information I and server grid version number 500 sent by the server and corresponding to grid identifier 3262200012483, updates the virtual item in the grid corresponding to grid identifier 3262200012483 according to virtual item update information I, and updates the client grid version number to 500.
The virtual prop updating method provided by the embodiment of the application is applied to a client, the current geographical position of the client is obtained, the grid corresponding to the virtual prop to be updated in a map can be simply and quickly confirmed by determining the grid identifier corresponding to the current geographical position, the pressure of a server is reduced by executing the client in the process of determining the grid identifier by the geographical position, the grid identifier and the grid version number of the client are sent to the server, the virtual prop updating information sent by the server is received, the virtual prop in the grid is updated according to the virtual prop updating information, computing resources are saved, the updating response speed is improved, and further the user experience is improved.
Fig. 4 shows a flowchart of a virtual item updating method according to an embodiment of the present application, where the virtual item updating method is applied to a server, and includes steps 402 to 406.
Step 402: receiving a synchronization request sent by a client, wherein the synchronization request comprises a grid identifier and a client grid version number corresponding to the grid identifier.
Optionally, the server is a distributed server cluster, and includes a logic server and at least one node server, where the logic server determines, according to the grid identifier, a target node server corresponding to the grid identifier.
Specifically, the determining, by the logic server, the target node server corresponding to the grid identifier according to the grid identifier includes:
acquiring the number of node servers in the distributed server and the number of service threads started in each node service; and determining a target node server corresponding to the grid identifier according to the grid identifier, the number of the node servers and the number of service threads in each node server.
In practical application, the distributed server cluster comprises at least one node server, a plurality of service threads are started in each node server, and each grid in the map corresponds to one service thread in one node server.
See equation (4) below for the target node server for the computational grid.
Target node server ═ grid identification% (M × N)/N formula (4)
Wherein M is the number of the node servers, N is the number of service threads in each node server, and% is the modulo operation.
In practical applications, each core of the node server can compute 5000 grids, and a node server with 16 cores can compute 8 ten thousand grids.
In the embodiment provided by the present application, a synchronization request Q (3262200012483, 0) is received, where 3262200012483 is a grid identifier, 0 is a client grid version number, and taking that a distributed server cluster includes 2 node servers, each server includes 4 service threads as an example, 2 node servers are respectively a node server 0 and a node server 1, and the service threads in each node server are respectively a thread 0, a thread 1, a thread 2, and a thread 3. And determining that the target node server corresponding to the grid identifier is the node server 0.
Step 404: and determining that the grid identification corresponds to virtual item updating information in response to the synchronization request.
Optionally, the target node server determines, according to the grid identifier and the client grid version number, virtual item update information corresponding to the grid identifier.
In practical application, a service thread corresponding to the grid identifier in the target node server needs to be determined first, and a method for determining the service thread is shown in the following formula (5).
Thread mark ═ grid mark% N formula (5)
Wherein, N is the number of service threads in each node server, and the% is the operation of modulus.
In the embodiment provided by the application, following the above example, each node server includes 4 service threads, determines, according to grid identifier 3262200012483, that the thread identifier corresponding to the grid identifier is thread 3, and invokes thread 3 on node server 0 to determine virtual item update information corresponding to grid identifier 3262200012483.
Optionally, the determining, by the target node server, the virtual item update information corresponding to the grid identifier according to the grid identifier and the client grid version number includes: acquiring a server grid version number corresponding to the grid identifier stored in the target node server; and under the condition that the client grid version number is different from the server grid version number corresponding to the grid identifier, determining the virtual item updating information corresponding to the grid identifier according to the client grid version number and the server grid version number corresponding to the grid identifier.
In practical application, the target node server comprises a server grid version number corresponding to the grid identifier, and when the virtual item updating information corresponding to the grid identifier is determined, the server grid version number is compared with a client grid version number.
Under the condition that the server grid version number corresponding to the grid identifier is consistent with the client grid version number, the virtual item updating information of the client is consistent with the target node server;
under the condition that the server grid version number corresponding to the grid identifier is equal to the client grid version number +1, incremental information between the server grid version number corresponding to the grid identifier and the client grid version number is used as virtual item updating information corresponding to the grid identifier, at the moment, the difference between the virtual item updating information in the client and the virtual item updating information in the server is not large, and the incremental information is used as the virtual item updating information, so that the data transmission quantity is reduced, the synchronization efficiency is improved, and the game delay is reduced;
and under the condition that the grid version number of the server corresponding to the grid identifier is greater than the grid version number +1 of the client, the difference between the data information in the target node server and the data information version in the client is large, and in order to ensure the consistency of data, the total information corresponding to the grid version number of the server corresponding to the grid identifier is used as the virtual prop updating information corresponding to the grid identifier.
In the embodiment provided by the present application, the server grid version number corresponding to the grid identifier 3262200012483 is 500, and the client grid version number corresponding to the received grid identifier 3262200012483 is 0, so that the total information I corresponding to the server grid version number 500 corresponding to the grid identifier 3262200012483 is used as the virtual item update information corresponding to the grid identifier.
Step 406: and sending the virtual prop updating information to the client.
Optionally, the method further includes sending the server grid version number corresponding to the grid identifier and the virtual item update information to the client.
In the embodiment provided by the present application, the virtual item update information I determined in step 404 is sent to the client together with the server grid version number 500 corresponding to the grid identifier.
The virtual prop updating method provided by the embodiment of the application is applied to a server, receives a synchronization request sent by a client, only needs to acquire the virtual prop updating information corresponding to the grid identifier, does not need to calculate all the virtual prop updating information in a map, reduces the consumption of invalid computing resources, reduces the operating pressure of the server, updates the full amount of information corresponding to the server grid number corresponding to the grid identifier as the virtual prop updating information to the client under the condition that the difference between the server grid version number corresponding to the grid identifier and the client grid version number is large, and ensures the consistency of the client and the server prop information.
Secondly, the distributed server cluster is used for sending the synchronization request to different node servers, so that the operation efficiency is further improved, and the synchronization requests sent by different clients can be processed at the same time. The response speed is further improved, the operation pressure of the server is reduced, and the game delay is reduced.
Referring to fig. 5, fig. 5 shows a virtual item update method provided in another embodiment of the present application, including steps 502 to 506:
step 502: a client acquires the geographic position information of the current geographic position of the client; determining a grid identifier corresponding to the virtual item to be updated in a map and a client grid version number corresponding to the grid identifier according to the geographic position information, wherein the map is divided into a plurality of grids in advance, and each grid is provided with a corresponding grid identifier; generating a synchronization request according to the grid identification and the grid version number of the client, and sending the synchronization request to a server;
step 504: the server responds to the synchronization request to determine the updating information of the virtual prop corresponding to the grid identification; sending the virtual prop updating information to the client;
step 506: and the client updates the virtual prop in the grid corresponding to the grid identification according to the virtual prop updating information.
For specific operation steps from step 502 to step 506, refer to the foregoing virtual item updating method for the client and the virtual item updating method for the server, which are not described herein again.
Corresponding to the above embodiment of the method for updating a virtual item for a client, the present application further provides an embodiment of a virtual item updating apparatus, and fig. 6 shows a schematic structural diagram of the virtual item updating apparatus according to an embodiment of the present application, where the virtual item updating apparatus is configured at the client. As shown in fig. 6, the apparatus includes:
an obtaining module 602, configured to obtain geographic location information of the current geographic location of the client.
A first determining module 604, configured to determine, according to the geographic position information, a grid identifier corresponding to the virtual item to be updated in a map and a client grid version number corresponding to the grid identifier, where the map is divided into multiple grids in advance, and each grid has a corresponding grid identifier.
A first sending module 606 configured to generate a synchronization request according to the grid identifier and the client grid version number, and send the synchronization request to a server.
A first receiving module 608, configured to receive the virtual item update information corresponding to the grid identifier sent by the server, and update the virtual item in the grid corresponding to the grid identifier according to the virtual item update information.
Optionally, the first receiving module 608 is further configured to receive a server grid version number corresponding to the grid identifier sent by the server; and updating the grid version number of the client according to the server grid version number corresponding to the grid identifier.
Optionally, the obtaining module 602 is further configured to obtain geographic location information of the current geographic location of the client according to a preset time interval.
Optionally, the obtaining module 602 is further configured to obtain the longitude and latitude coordinates of the current geographic location of the client according to a preset time interval.
Optionally, the first determining module 604 is further configured to determine, according to the longitude and latitude coordinates, a grid identifier corresponding to the geographic location in a map.
Optionally, the grid includes a preset grid side length;
optionally, the first determining module 604 is further configured to determine a grid identifier corresponding to the geographic location in the map according to the longitude and latitude coordinates and the grid side length.
The virtual prop updating device provided by the embodiment of the application is configured at the client, the current geographical position of the client is obtained, the grid corresponding to the virtual prop to be updated in a map can be simply and quickly confirmed by determining the grid identifier corresponding to the current geographical position, the pressure of the server is reduced by executing the client in the process of determining the grid identifier by the geographical position, the grid identifier and the grid version number of the client are sent to the server, the virtual prop updating information sent by the server is received, the virtual prop in the grid is updated according to the virtual prop updating information, the computing resources are saved, the updating response speed is improved, and the user experience is further improved.
Corresponding to the above embodiment of the virtual item updating method for a server, the present application further provides an embodiment of a virtual item updating apparatus, and fig. 7 shows a schematic structural diagram of the virtual item updating apparatus according to an embodiment of the present application, where the virtual item updating apparatus is configured in the server. As shown in fig. 7, the apparatus includes:
a second receiving module 702, configured to receive a synchronization request sent by a client, where the synchronization request includes a grid identifier and a client grid version number corresponding to the grid identifier.
A second determining module 704 configured to determine that the grid identification corresponds to virtual item update information in response to the synchronization request.
A second sending module 706 configured to send the virtual item update information to the client.
Optionally, the server is a distributed server, and includes a logic server and at least one node server;
the second determining module 704 includes:
a first determining submodule configured to determine, by the logic server, a target node server corresponding to the grid identifier according to the grid identifier;
and the second determining submodule is configured to determine, by the target node server, virtual item update information corresponding to the grid identifier according to the grid identifier and the client grid version number.
Optionally, the first determining submodule is further configured to obtain the number of node servers in the distributed server and the number of service threads enabled in each node service; and determining a target node server corresponding to the grid identifier according to the grid identifier, the number of the node servers and the number of service threads in each node server.
Optionally, the second determining submodule is further configured to obtain a server grid version number corresponding to the grid identifier stored in the target node server; and under the condition that the client grid version number is different from the server grid version number corresponding to the grid identifier, determining the virtual item updating information corresponding to the grid identifier according to the client grid version number and the server grid version number corresponding to the grid identifier.
Optionally, the second determining submodule is further configured to, when the server grid version number corresponding to the grid identifier is equal to the client grid version number plus 1, use incremental information between the server grid version number corresponding to the grid identifier and the client grid version number as virtual item update information corresponding to the grid identifier; or when the server grid version number corresponding to the grid identifier is greater than the client grid version number plus 1, using the total information corresponding to the server grid version number corresponding to the grid identifier as the virtual item update information corresponding to the grid identifier.
The virtual item updating device provided by the application is configured in the server, receives the synchronization request sent by the client, and only needs to acquire the virtual item updating information corresponding to the grid identifier without calculating all the virtual item updating information in the map, so that the consumption of invalid calculation resources is reduced, and the operation pressure of the server is reduced.
Secondly, the distributed server cluster is used for sending the synchronization request to different node servers, so that the operation efficiency is further improved, and the synchronization requests sent by different clients can be processed at the same time. The response speed is further improved, the operation pressure of the server is reduced, and the game delay is reduced.
The embodiment of the application discloses a virtual item updating device, which comprises a virtual item updating device configured at a client in the embodiment and a virtual item updating device configured at a server in the embodiment.
An embodiment of the present application further provides a computing device, which includes a memory, a processor, and computer instructions stored in the memory and executable on the processor, where the processor executes the instructions to implement the steps of the virtual prop updating method.
An embodiment of the present application further provides a computer-readable storage medium, which stores computer instructions, and when the instructions are executed by a processor, the instructions implement the steps of the virtual item updating method as described above.
The above is an illustrative scheme of a computer-readable storage medium of the present embodiment. It should be noted that the technical solution of the storage medium and the technical solution of the virtual item updating method belong to the same concept, and details that are not described in detail in the technical solution of the storage medium can be referred to the description of the technical solution of the virtual item updating method.
The foregoing description of specific embodiments of the present application has been presented. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The computer instructions comprise computer program code which may be in the form of source code, object code, an executable file or some intermediate form, or the like. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
It should be noted that, for the sake of simplicity, the above-mentioned method embodiments are described as a series of acts or combinations, but those skilled in the art should understand that the present application is not limited by the described order of acts, as some steps may be performed in other orders or simultaneously according to the present application. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required in this application.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
The preferred embodiments of the present application disclosed above are intended only to aid in the explanation of the application. Alternative embodiments are not exhaustive and do not limit the invention to the precise embodiments described. Obviously, many modifications and variations are possible in light of the above teaching. The embodiments were chosen and described in order to best explain the principles of the application and its practical applications, to thereby enable others skilled in the art to best understand and utilize the application. The application is limited only by the claims and their full scope and equivalents.