Game Application Method, Device, Server and Storage Medium
By using component identification information to obtain logical code at the game startup, the data loss and stability problems during game startup are solved, and fast startup and high stability game applications are achieved.
Patent Information
- Application Number
- CN202210090224.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-25
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2042-01-25
AI Technical Summary
In the prior art, registering and creating other entities at the start of the game can easily cause server data loss, which is not conducive to the normal operation of the game, and reconstructing the game project programming code will increase workload and instability.
By responding to the target entity creation request triggered by preset game events, use the target entity's component identification information to obtain logical code, create the target entity in the game scenario, maintain the overall programming code of the original game project, register the entities used in the game in advance, and create entities as needed during the game operation.
Reduces entity creation consumption when game starts, improves game startup speed, and improves stability, avoids data loss problems.
Smart Images

Figure CN114461191B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of games, and in particular, to a game application method, device, server, and storage medium. Background Art
[0002] With the development of Internet technology, there are more and more various online games. The startup of a game is the first impression given by the game application program to users, and the startup speed of the game directly determines the user experience. Therefore, improving the game speed has also become a research hotspot.
[0003] In the related art, in order to improve the startup speed of a game, the overall programming code of the game project is reconstructed. When the game starts, some entities are registered and created first. If other entities are needed during the game operation, the other entities are registered, and the entity is created after the registration is completed.
[0004] However, in the related art, when other entities are used, registration and creation are carried out. During this period, it is easy to cause the loss of data sent by the server, which is not conducive to the normal operation of the game. Summary of the Invention
[0005] The purpose of the present invention is to provide a game application method, device, server, and storage medium for the deficiencies in the above-mentioned prior art, so as to solve the problem that in the related art, when other entities are used, registration and creation are carried out, and during this period, it is easy to cause the loss of data sent by the server, which is not conducive to the normal operation of the game.
[0006] To achieve the above object, the technical solutions adopted in the embodiments of the present invention are as follows:
[0007] In a first aspect, an embodiment of the present invention provides a game application method, including:
[0008] Responding to a creation request for a target entity triggered by a preset game event, and obtaining the logic code of the target component according to the identification information of the target component included in the target entity;
[0009] Creating the target entity in the game scene according to the logic code of the target component.
[0010] Optionally, the obtaining the logic code of the target component according to the identification information of the target component corresponding to the target entity includes:
[0011] Parsing the storage path information of the target component from the identification information;
[0012] Obtaining the logic code of the target component according to the storage path information.
[0013] Optionally, parsing the storage path information of the target component from the identification information includes:
[0014] Parsing from the identification information the storage path information and the module identification of the logic code;
[0015] Obtaining the logic code of the target component according to the storage path information includes:
[0016] Obtaining the logic code of the target component according to the storage path information and the module identification.
[0017] Optionally, creating the target entity in the game scene according to the target component includes:
[0018] Instantiating according to the logic code of the target component to obtain the instantiated component;
[0019] Creating the target entity in the game scene according to the instantiated component.
[0020] Optionally, obtaining the logic code of the target component according to the storage path information includes:
[0021] Obtaining, according to the storage path information, from a preset dictionary file the logic code corresponding to the storage path information as the logic code of the target component; multiple logic codes and corresponding storage path information are stored in the preset dictionary file.
[0022] Optionally, before obtaining, according to the storage path information, from a preset dictionary file the logic code corresponding to the storage path information as the logic code of the target component, the method further includes:
[0023] When the game starts, reading the preset target file from memory, where the preset target file stores: game logic code and the offset corresponding to the stored game logic code;
[0024] Generating the preset dictionary file according to the preset target file.
[0025] Optionally, generating the preset dictionary file according to the preset target file includes:
[0026] Determining, according to a first preset file in the preset target file, the location path information and the offset of the game logic code;
[0027] Obtaining the game logic code from a second preset file in the preset target file according to the location path information and the offset of the game logic code;
[0028] The preset dictionary file includes: the path information of the game logic code and the game logic code.
[0029] Optionally, before reading the preset target file from the memory when the game is started, the method further includes:
[0030] Storing the game logic code in the memory;
[0031] Writing the game logic code into the second preset file, and writing the path information and offset of the game logic code in the second preset file into the first preset file to obtain the preset target file;
[0032] The preset target file includes: the first preset file and the second preset file.
[0033] In a second aspect, an embodiment of the present invention further provides a game application device, including:
[0034] An acquisition module, configured to respond to a creation request of a target entity triggered by a preset game event, and acquire the logic code of the target component according to the identification information of the target component included in the target entity;
[0035] A creation module, configured to create the target entity in the game scene according to the logic code of the target component.
[0036] Optionally, the acquisition module is further configured to parse the storage path information of the target component from the identification information; and acquire the logic code of the target component according to the storage path information.
[0037] Optionally, the acquisition module is further configured to parse, from the identification information, the storage path information and the module identification of the logic code;
[0038] The acquisition module is further configured to acquire the logic code of the target component according to the storage path information and the module identification.
[0039] Optionally, the creation module is further configured to instantiate according to the logic code of the target component to obtain an instantiated component; and create the target entity in the game scene according to the instantiated component.
[0040] Optionally, the acquisition module is further configured to acquire, according to the storage path information, the logic code corresponding to the storage path information from a preset dictionary file as the logic code of the target component; and multiple logic codes and corresponding storage path information are stored in the preset dictionary file.
[0041] Optionally, the device further includes:
[0042] A reading module, configured to read the preset target file from the memory when the game starts. The preset target file stores: game logic code, and an offset corresponding to the stored game logic code;
[0043] A generating module, configured to generate the preset dictionary file according to the preset target file.
[0044] Optionally, the generating module is further configured to determine the location path information and offset of the game logic code according to a first preset file in the preset target file; obtain the game logic code from a second preset file in the preset target file according to the location path information and offset of the game logic code; the preset dictionary file includes: the location path information of the game logic code and the game logic code.
[0045] Optionally, the device further includes:
[0046] A storage module, configured to store the game logic code in the memory; write the game logic code into the second preset file, and write the path information and offset of the game logic code in the second preset file into the first preset file to obtain the preset target file; the preset target file includes: the first preset file and the second preset file.
[0047] In a third aspect, an embodiment of the present invention further provides a server, including: a memory and a processor, the memory stores a computer program executable by the processor, and when the processor executes the computer program, it implements the game application method according to any one of the above first aspects.
[0048] In a fourth aspect, an embodiment of the present invention further provides a storage medium, on which a computer program is stored, and when the computer program is read and executed, it implements the game application method according to any one of the above first aspects.
[0049] The beneficial effects of the present invention are as follows: The embodiments of the present application provide a game application method, device, server, and storage medium. The game application method includes: responding to a creation request of a target entity triggered by a preset game event, and obtaining the logic code of the target component according to the identification information of the target component included in the target entity; creating the target entity in the game scene according to the logic code of the target component. By maintaining the overall programming code of the original game project without the need for refactoring, that is, registering in advance the entities used in the game, the workload is significantly reduced, and the stability is improved. Moreover, each entity has identification information. During the running of the game, in response to a creation request for the target entity, the logic code is determined according to the identification information of the entity, and then the entity is created, reducing the consumption caused by entity creation during game startup and enhancing the game startup speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required for the embodiments. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as limiting the scope. For those of ordinary skill in the art, other relevant drawings can be obtained based on these drawings without creative efforts.
[0051] Figure 1 It is a flowchart of a game application method provided by an embodiment of the present invention;
[0052] Figure 2 It is a flowchart of a game application method provided by an embodiment of the present invention;
[0053] Figure 3 It is a flowchart of a game application method provided by an embodiment of the present invention;
[0054] Figure 4 It is a flowchart of a game application method provided by an embodiment of the present invention;
[0055] Figure 5 It is a flowchart of a game application method provided by an embodiment of the present invention;
[0056] Figure 6 It is a flowchart of a game application method provided by an embodiment of the present invention;
[0057] Figure 7 It is a flowchart of a game application method provided by an embodiment of the present invention;
[0058] Figure 8 It is a structural diagram of a game application device provided by an embodiment of the present invention;
[0059] Figure 9A schematic structural diagram of a server provided by an embodiment of the present invention. Detailed implementation manners
[0060] To make the objectives, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are some but not all of the embodiments of the present invention.
[0061] Therefore, the detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application claimed, but merely represents selected embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative efforts shall fall within the scope of protection of the present application.
[0062] In the description of the present application, it should be noted that if terms such as "upper", "lower", etc. indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, or the orientation or positional relationship when the product of this application is normally placed, it is only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and thus should not be construed as a limitation to the present application.
[0063] In addition, terms such as "first", "second", etc. in the description and claims of the present invention and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0064] It should be noted that the features in the embodiments of the present application can be combined with each other without conflict.
[0065] The following explanations are provided for the nouns involved in the embodiments of the present application.
[0066] Entity: Also known as entity, an entity in the game world can be created, destroyed, components can be added or deleted, and each entity is composed of one or more components.
[0067] Component: Also known as Component, it contains data representing its characteristics. For example, the MoveComponent related to movement contains attributes such as speed, position, and orientation. Once an entity has the MoveComponent, it can be considered to have the ability to move.
[0068] System IO time: In a computer, IO refers to Input / Output. Since programs and runtime data reside in memory and are executed by the CPU computing core. Where data exchange is involved, such as writing data from a disk, network, etc. to memory or outputting data from memory to a hard disk, that is IO. System IO time refers to the time required for this writing to memory and output from memory.
[0069] With the development of Internet technology, there are more and more various online games. The startup of a game is the first impression given by the game application to users. The startup speed of the game directly determines the user experience. Therefore, improving the game speed has also become a research hotspot. In related technologies, from the perspective of the script framework structure of the game project script, all entities used in the game are registered and created when the game starts. In the prior art, in order to improve the game startup speed, the overall programming code of the game project is reconstructed, and some entities are registered first when the game starts. If other entities are needed during the game operation.
[0070] In related technologies, when other entities are used, they are registered and created. During this period, it is easy to cause the loss of data sent by the server, which is not conducive to the normal operation of the game; moreover, reconstructing the overall programming code of the game project will have a large workload and instability problems.
[0071] When the game starts, the game client will perform a series of initialization operations, initialize all entities in the game, enable the game to play sounds and special effects, start the engine dependencies of the client, register game objects, precompile, preload files required by the game, etc. Each operation takes time. As the game size increases and the game content becomes more abundant, the number of game objects in the game will inevitably increase. Registering game objects will affect the startup speed.
[0072] A game application method provided by an embodiment of the present application maintains the overall programming code of the original game project without reconstruction, that is, entities used in the game are registered in advance, greatly reducing the workload and improving stability. Moreover, each entity has identification information. During the game operation, in response to a creation request for a target entity, the logical code is determined according to the identification information of the entity, and then the entity is created, reducing the consumption caused by creating entities during game startup and improving the game startup speed.
[0073] The following uses the server as the execution entity to explain the game application method provided in the embodiments of the present application. Among them, the server can be a game server.
[0074] Figure 1 It is a schematic flowchart of a game application method provided in an embodiment of the present invention. As Figure 1 shown, the method may include:
[0075] S101. Respond to the creation request of the target entity triggered by a preset game event, and obtain the logic code of the target component according to the identification information of the target component possessed by the target entity.
[0076] In the embodiments of the present application, the existing game script framework structure can be supported, that is, all entities to be used in the game are registered when the game is started, without reconstructing the game script framework structure, greatly reducing the workload and improving the stability.
[0077] Among them, all entities to be used that have been registered in the game are bound with the identification information of the corresponding components. Each entity can include at least one component, and each entity can be bound with the identification information of the included components.
[0078] In some embodiments, during the running of the game, if a preset game event occurs, a creation request for the target entity corresponding to the preset game event can be triggered. The server can respond to the creation request for the target entity and determine the logic code of the target component according to the identification information of the target component bound to the target entity.
[0079] S102. Create the target entity in the game scene according to the logic code of the target component.
[0080] It should be noted that the server creates the target entity in the game scene according to the logic code of the target component, and then the game logic corresponding to the target entity can be implemented in the game scene for corresponding display and / or other processing.
[0081] For example, the preset game event can be firing a virtual bullet from a virtual gun, then the target entity can be the virtual bullet, and the target entity can include: the physical rigid body component (RigidBodyComponent) of the virtual bullet, the movement trajectory component (RayRailComponent) of the virtual bullet, the sound effect component (AudioComponent) of the virtual bullet, the timer component (CTimerComponent) that triggers the destruction of the bullet, and so on.
[0082] Of course, the above process is only an example. The preset game event can be other types of events, the target entity can also be other types of entities, and the components included in the target entity can also be other types of components. Specifically, it can be set according to the game requirements, and the embodiments of the present application do not specifically limit this.
[0083] In summary, the embodiments of the present application provide a game application method, including: responding to a creation request of a target entity triggered by a preset game event, and obtaining the logic code of the target component according to the identification information of the target component included in the target entity; creating the target entity in the game scene according to the logic code of the target component. Keeping the overall programming code of the original game project without reconstruction, that is, registering the entities used in the game in advance, greatly reducing the workload and improving the stability. Moreover, each entity has identification information. During the operation of the game, in response to a creation request for the target entity, the logic code is determined according to the identification information of the entity, and then the entity is created, reducing the consumption caused by creating entities when the game starts and improving the startup speed of the game.
[0084] It should be noted that when the target entity is a virtual bullet, the program code for registering the target entity is as follows:
[0085] “@saveclspath()
[0086] @components(BULLET_COMPONENTS)
[0087] class Bullet(BulletBase):
[0088] """
[0089] RayCast type bullet
[0090] """”
[0091] In the related art, the program code written for the multiple target components corresponding to the virtual bullet is as follows:
[0092] “from Core.Component.RigidBodyComponent import RigidBodyComponent
[0093] from Component.WeaponSystemComponent.RayRailComponent importRayRailComponent
[0094] from Component.EntityComponent.AudioComponent import AudioComponent
[0095] from Core.Component.CTimerComponent import CTimerComponent
[0096] BULLET_COMPONENTS =
[0097] RigidBodyComponent, / Physical rigid body component
[0098] RayRailComponent, / Movement trajectory component
[0099] AudioComponent, / Play sound effect component
[0100] CTimerComponent, / Trigger timing component
[0101] "
[0102] In the writing of the program code in the above related technology, during the registration process of the virtual bullet entity, the content of BULLET_COMPONENTS is read, so the above from import operations are directly triggered, and all components carried by the virtual bullet entity are instantiated and created, which will reduce the startup speed of the game.
[0103] In the embodiments of the present application, when writing program code, the writing of the target component of the target entity can be improved, and the identification information of the target component is bound to the target entity. For example, the writing of the program code of the components in the above virtual bullet entity is as follows:
[0104] "BULLET_COMPONENTS =
[0105] "Core.Component.RigidBodyComponent.RigidBodyComponent", / Identification information of the physical rigid body component
[0106] "Component.WeaponSystemComponent.RayRailComponent.RayRailComponent", / Identification information of the movement trajectory component
[0107] "Component.EntityComponent.AudioComponent.AudioComponent", / Identification information of the sound effect playing component
[0108] "Core.Component.CTimerComponent.CTimerComponent", / Identification information of the trigger timing component
[0109] "
[0110] The above-mentioned writing method of the program code for the virtual bullet entity, during registration, for the content of BULLET_COMPONENTS read, it is only 4 strings, which will not trigger the from import logic and will not instantiate multiple components in the virtual bullet entity. During the game startup, it saves the time for component instantiation in the entity. Subsequently, it can respond to the creation request and then instantiate and create the components in the entity.
[0111] Optionally, Figure 2 is a schematic flowchart of a game application method provided by an embodiment of the present invention. As Figure 2 shown, the process of obtaining the logic code of the target component according to the identification information of the target component corresponding to the target entity in S101 above may include:
[0112] S201. Parse the storage path information of the target component from the identification information.
[0113] In some embodiments, the identification information of the target component may be string information, and the server may parse the string information of the target component to obtain the storage path information of the target component.
[0114] It should be noted that the number of target components may be at least one. When the number of target components is multiple, the server may parallelly parse the identification information of multiple target components to obtain the storage path information of each target component.
[0115] S202. Obtain the logic code of the target component according to the storage path information.
[0116] In the embodiments of the present application, the server may determine the storage location of the logic code of the target component according to the storage path information, and obtain it from this storage location according to the storage location of the logic code of the target component.
[0117] Similarly, when the number of target components is multiple, the server may parallelly obtain the logic code of each target component according to the storage path information of each target component.
[0118] In practical applications, when there are multiple target components, parsing the identification information of multiple target components in parallel and obtaining the logic codes of multiple target components in parallel can improve the efficiency of obtaining the logic codes of multiple target components.
[0119] Optionally, Figure 3 The following is a schematic flowchart of a game application method provided by an embodiment of the present invention. As Figure 3 shown, the process of parsing the storage path information of the target component from the identification information in S201 above may include:
[0120] S301. Parse the storage path information and the module identifier of the logic code from the identification information.
[0121] Among them, the identification information may be string information.
[0122] In some embodiments, the string information may include: a preset symbol. The information before the preset symbol in the string information may be the storage path information, and the information after the preset symbol may be the module identifier of the logic code.
[0123] For example, for the physical rigid body component (RigidBodyComponent) of a virtual bullet, its identification information may be expressed as:
[0124] “Core.Component.RigidBodyComponent.RigidBodyComponent”
[0125] Among them, the preset symbol may be “.”. Then the storage path information of the physical rigid body component of the virtual bullet may be "Core.Component.RigidBodyComponent", and the module identifier of the logic code of the physical rigid body component of the virtual bullet may be “RigidBodyComponent”.
[0126] The process of obtaining the logic code of the target component according to the storage path information in S202 above may include:
[0127] S302. Obtain the logic code of the target component according to the storage path information and the module identifier.
[0128] In the embodiments of the present application, the server may determine the location where the logic code of the target component is located according to the storage path information and the module identifier, and obtain the logic code of the target component from the location where the logic code of the target component is located.
[0129] Optionally, Figure 4 The following is a schematic flowchart of a game application method provided by an embodiment of the present invention. As Figure 4As shown in the figure, the process of creating a target entity in the game scene according to the target component in S102 may include:
[0130] S401. Instantiate according to the logic code of the target component to obtain the instantiated component.
[0131] In some embodiments, the server may instantiate according to the logic code of at least one target component to obtain at least one instantiated component. Among them, the server may instantiate each target component in sequence, or may instantiate each target component in parallel. The embodiments of the present application do not specifically limit this.
[0132] S402. Create a target entity in the game scene according to the instantiated component.
[0133] Among them, the server may return at least one instantiated component to the target entity reference, that is, hang it back on the target entity to complete the creation of the target entity.
[0134] The program code implementation of the above parsing process and instantiation process is as follows:
[0135] for component in fixComponents:
[0136] # Corresponding to the usage of string import in ComponentList
[0137] if isinstance(component,str):
[0138] moduleName=component.split(".")
[0139] componentName=moduleName[-1]
[0140] moduleName=".".join(moduleName[:-1]) / parsing process
[0141] # INFO("Import Component Path:%s,Class:%s",moduleName,componentName,Tag="Component")
[0142] try:
[0143] __import__(moduleName)
[0144] m=sys.modules[moduleName]
[0145] component = getattr(m, componentName) / instantiation process
[0146] except:
[0147] ERROR("Import Module %s Fail" % moduleName, Tag="Monster")
[0148] ComponentRegister.LazyInitComponent(component)
[0149] For a game application method provided by an embodiment of the present application, an actual test was carried out. The test environment was an encrypted ciphertext environment for code scripts, the PC (personal computer) side, the client was started, and the MagicSniffer (a kind of sniffer) performance analysis software was used to capture frames. The capture time ended from the start of the game to the login interface. Compared with the technical solution in the prior art of registering and creating all entities during the startup process of the game, the optimized game startup duration in the embodiment of the present application was shortened by about 10%. Moreover, there was no need for reconstruction, the stability was high, and there was no problem of data loss in the data sent by the server. Among them, the implementation process of the above game application method can be called the lazyImport mechanism in the game engine.
[0150] Optionally, the process of obtaining the logical code of the target component according to the storage path information in S202 may include: obtaining the logical code corresponding to the storage path information from a preset dictionary file as the logical code of the target component according to the storage path information.
[0151] Among them, multiple logical codes and corresponding storage path information may be stored in the preset dictionary file. The preset dictionary file may be a cache large file dictionary, and the preset dictionary file contains all python references.
[0152] In some embodiments, the server may determine the target storage path information that is the same as the storage path information of the logical code of the target component from the storage path information corresponding to multiple logical codes, and use the logical code corresponding to the target storage path information as the logical code of the target component.
[0153] It should be noted that the multiple logical codes in the preset dictionary file may include: the logical codes of all components required for the game.
[0154] The programming code implementation of obtaining the logical code of the target component from the preset dictionary file is as follows:
[0155] "#print'actually loading encrypted module', full_name
[0156] if USE_CACHE and cache_key in ENCRYPTED_MODULE_CACHE:
[0157] # Get the encrypted script content from the cache
[0158] cdata = ENCRYPTED_MODULE_CACHE[cache_key]
[0159] del ENCRYPTED_MODULE_CACHE[cache_key] / Directly read the logical code of the target component from the preset dictionary file, that is, read out the python data;
[0160] else:
[0161] # Get from the file
[0162] if PATH_LIST:
[0163] if is_patch:
[0164] cdata = open_file_data_in_patch(mod_path)
[0165] if not cdata:
[0166] return None
[0167] else:
[0168] cdata = open_file_data_in_package(mod_path)
[0169] if not cdata:
[0170] return None
[0171] else:
[0172] # Get from the file
[0173] open_file_data = open_file_data_in_patch if is_patch else open_file_data_in_package
[0174] cdata = open_file_data(mod_path)”In the prior art, an I / O operation is required for reading the logic code of each target component.
[0175] Optionally, Figure 5 The flowchart of a game application method provided by an embodiment of the present invention is shown as Figure 5 Before the process of obtaining the logic code corresponding to the storage path information from the preset dictionary file as the logic code of the target component according to the storage path information, the method may further include:
[0176] S501. When the game is started, read a preset target file from the memory.
[0177] The preset target file stores: game logic code and the offset corresponding to the stored game logic code.
[0178] In some embodiments, during the game startup, the server only needs to read the preset target file from the memory once. The preset target file may store the logic code to be used in the game, that is, the game logic code, and the offset generated when storing the game logic code.
[0179] S502. Generate a preset dictionary file according to the preset target file.
[0180] In a possible embodiment, the server may determine multiple logic codes and the corresponding storage path information according to the game logic code in the preset target file and the offset corresponding to the stored game logic code; generate a preset dictionary file according to the multiple logic codes and the corresponding storage path information.
[0181] In summary, when the game is started, read the preset target file from the memory; generate a preset dictionary file according to the preset target file. Only need to read the preset target file from the memory once, and then the preset dictionary file can be generated. Subsequently, when obtaining the logic code of the target component, it can be obtained according to the preset dictionary file, without repeatedly reading the logic code from the memory. During the game startup process, when an entity needs to be created, the logic code can be read from the preset dictionary file. There is no need to find the original file through additional I / O to obtain the logic code, saving the consumption during the game operation, greatly reducing the system I / O time consumption caused by repeatedly reading the logic code, and greatly improving the game startup speed.
[0182] Optionally, Figure 6 The flowchart of a game application method provided by an embodiment of the present invention is shown as Figure 6 As shown, the process of generating a preset dictionary file according to the preset target file in S502 may include:
[0183] S601. Determine the location path information and offset of the game logic code according to the first preset file in the preset target file.
[0184] Among them, the first preset file can be represented as the messiahcachemeta file.
[0185] S602. Obtain the game logic code from the second preset file in the preset target file according to the location path information and offset of the game logic code.
[0186] Among them, the preset dictionary file includes: the location path information of the game logic code and the game logic code. The offset can be the offset generated when the game logic code is stored in the second preset file.
[0187] In addition, the second preset file can be represented as the messiahcachedata file.
[0188] In the embodiment of the present application, the preset target file may include: the first preset file and the second preset file. The first preset file may store the location path information and offset of the game logic code. Based on the information stored in the first preset file, the game logic code can be obtained from the second preset file, and the preset dictionary file can be obtained according to the location path information of the game logic code and the game logic code.
[0189] The programming code for obtaining the preset dictionary file according to the messiahcachemeta file and the messiahcachedata file in the preset target file is as follows:
[0190]
[0191]
[0192] Obtain the location path information and offset of the game logic code from the file;
[0193]
[0194]
[0195] Optionally, Figure 7 is a schematic flowchart of a game application method provided by an embodiment of the present invention. As Figure 7 shown, before the process of reading the preset target file from the memory when the game starts in the above S501, the method may further include:
[0196] S701. Store the game logic code in the memory.
[0197] S702: Write the game logic code into the second preset file, and write the path information and offset of the game logic code in the second preset file into the first preset file to obtain a preset target file.
[0198] The preset target file may include: a first preset file and a second preset file.
[0199] Optionally, the above processes of S701 and S702 may be referred to as Gen_ScriptCache processes.
[0200] In some implementations, the server may write the game logic code into a second preset file, and write the offset of the game logic code in the second preset file into the first preset file to obtain a preset target file.
[0201] The corresponding programming codes for the above-mentioned processes of S701 and S702 are as follows:
[0202]
[0203]
[0204] In the embodiment of the present application, the game logic code (which can be a python inscription) is packaged into a ciphertext stage, and the above-mentioned ScriptCache content is added to achieve the purpose of generating a large cache file offline in advance.
[0205] In some implementations, in the scenario of real machine resource packaging, at the stage of packaging Python into ciphertext, a new ScriptCache process is added to generate a large Cache file in advance, and all resources are packaged according to the ciphertext, large Cache file, and other resources to obtain a game installation package based on all resources. The game terminal can install the game application according to the game installation package, and the game application starts the game after acceleration.
[0206] In addition, in the scenario of Python packaging in the internal development environment, a new _ScriptCache process is added when Python is packaged into ciphertext, and the game is started in the planning development environment through acceleration.
[0207] In summary, whether it is in the resource packaging scenario of the real device or the Python packaging scenario in the internal development environment, the resource packaging tool can be used to package the Python process. In this process, a process for generating ScriptCache is added to offline generate ScriptCache files containing all Python. This can meet the acceleration requirements of both the real device and the internal development environment at the same time. When the game starts, data is obtained by reading the Cache operation, reducing the system IO time consumption caused by repeatedly reading the logic code.
[0208] For a game application method provided by an embodiment of the present application, actual tests were carried out. The test environment was an encrypted ciphertext environment for code scripts, on the PC (personal computer) side, the client was started, and time stamps were added by instrumenting at the beginning of the game startup and at the end of reaching the login interface. The capture time was from the game startup to the end of reaching the login interface. Compared with the technical solution of directly reading the logic code from the memory in the prior art, the optimized game startup duration in the embodiment of the present application was shortened by about 30%. Among them, the implementation process of the above game application method can be called the ScriptCache mechanism in the game engine.
[0209] In summary, an embodiment of the present application provides a game application method, including: responding to a creation request of a target entity triggered by a preset game event, and obtaining the logic code of the target component according to the identification information of the target component included in the target entity; creating the target entity in the game scene according to the logic code of the target component. Keeping the overall programming code of the original game project without reconstruction, that is, registering in advance the entities used in the game, greatly reducing the workload and improving the stability. Moreover, each entity has identification information. During the running of the game, in response to a creation request for the target entity, the logic code is determined according to the identification information of the entity, and then the entity is created, reducing the consumption caused by creating the entity during game startup and improving the game startup speed.
[0210] In the embodiment of the present application, it is supported that on the existing script framework structure, when all entities in the game need to be registered when starting the game, the pressure caused by instantiating all components during startup is reduced by delaying the instantiation of the components carried by the entities. When the game starts, the components and entities are only bound in the form of the identification information of the components. The components bound to the entity are instantiated only when the entity is actually created in the game, achieving the purpose of "creating components on demand" and shortening the time for instantiating all components during startup.
[0211] Moreover, the preset dictionary file contains all the logic codes in the game. In addition to shortening the IO time when starting the game, it also reduces the additional IO consumption caused by the actual instantiation of components during the game operation. It can also support both the online real machine environment and the internal PC development environment simultaneously. Generating the preset dictionary file offline can also have an accelerating effect when the game is started for the first time.
[0212] The following describes the game application device, server, storage medium, etc. for executing the game application method provided in this application. For the specific implementation process and technical effects, refer to the relevant content of the above game application method, which will not be elaborated below.
[0213] Figure 8 The following is a schematic structural diagram of a game application device provided by an embodiment of the present invention, as Figure 8 shown, the device may include:
[0214] An acquisition module 801, configured to respond to a creation request of a target entity triggered by a preset game event, and acquire the logic code of the target component according to the identification information of the target component included in the target entity;
[0215] A creation module 802, configured to create the target entity in the game scene according to the logic code of the target component.
[0216] Optionally, the acquisition module 801 is further configured to parse the storage path information of the target component from the identification information; and acquire the logic code of the target component according to the storage path information.
[0217] Optionally, the acquisition module 801 is further configured to parse from the identification information the storage path information and the module identification of the logic code;
[0218] The acquisition module 801 is further configured to acquire the logic code of the target component according to the storage path information and the module identification.
[0219] Optionally, the creation module 802 is further configured to instantiate according to the logic code of the target component to obtain an instantiated component; and create the target entity in the game scene according to the instantiated component.
[0220] Optionally, the acquisition module 801 is further configured to acquire, according to the storage path information, from a preset dictionary file the logic code corresponding to the storage path information as the logic code of the target component; the preset dictionary file stores a plurality of logic codes and corresponding storage path information.
[0221] Optionally, the device further includes:
[0222] A reading module, configured to read the preset target file from the memory when the game starts, where the preset target file stores: game logic code, and an offset corresponding to the stored game logic code;
[0223] A generating module, configured to generate the preset dictionary file according to the preset target file.
[0224] Optionally, the generating module is further configured to determine the location path information and offset of the game logic code according to a first preset file in the preset target file; obtain the game logic code from a second preset file in the preset target file according to the location path information and offset of the game logic code; the preset dictionary file includes: the location path information of the game logic code and the game logic code.
[0225] Optionally, the device further includes:
[0226] A storage module, configured to store the game logic code into the memory; write the game logic code into the second preset file, and write the path information and offset of the game logic code in the second preset file into the first preset file to obtain the preset target file; the preset target file includes: the first preset file and the second preset file.
[0227] The above device is used to execute the method provided in the foregoing embodiment, and its implementation principle and technical effects are similar, and will not be elaborated here.
[0228] The above modules may be one or more integrated circuits configured to implement the above method, for example: one or more application specific integrated circuits (ASICs), or, one or more digital signal processors (DSPs), or, one or more field programmable gate arrays (FPGAs), etc. Again, when a certain above module is implemented in the form of a processing element dispatching program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processors that can call program code. Again, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0229] Figure 9 The structural schematic diagram of a server provided by an embodiment of the present invention is as Figure 9As shown in the figure, the server may include: a processor 901 and a memory 902.
[0230] Among them, the memory 902 is used to store programs, and the processor 901 calls the programs stored in the memory 902 to execute the method embodiments described above. The specific implementation manners and technical effects are similar and will not be elaborated here.
[0231] Optionally, the present invention further provides a program product, such as a computer-readable storage medium, including a program that is used to execute the method embodiments described above when executed by a processor.
[0232] In several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection to each other can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be in electrical, mechanical or other forms.
[0233] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0234] In addition, the functional units in various embodiments of the present invention can be integrated in one processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above-mentioned integrated units can be implemented in the form of hardware, or in the form of hardware plus software functional units.
[0235] The above-mentioned integrated units implemented in the form of software functional units can be stored in a computer-readable storage medium. The above-mentioned software functional units are stored in a storage medium and include several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to execute some steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (English: Read-Only Memory, abbreviated as: ROM), random access memories (English: Random Access Memory, abbreviated as: RAM), magnetic disks or optical discs that can store program codes.
[0236] The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A game application method, characterized in that, Including: In response to a creation request for a target entity triggered by a preset game event, obtain the logic code of the target component according to the identification information of the target component of the target entity; Create the target entity in the game scene according to the logic code of the target component; The obtaining the logic code of the target component according to the identification information of the target component corresponding to the target entity includes: Parse the storage path information of the target component from the identification information; According to the storage path information, obtain the logic code corresponding to the storage path information from a preset dictionary file as the logic code of the target component; multiple logic codes and corresponding storage path information are stored in the preset dictionary file.
2. The method according to claim 1, wherein The parsing the storage path information of the target component from the identification information includes: Parse from the identification information the storage path information and the module identifier of the logic code; The obtaining the logic code of the target component according to the storage path information includes: Obtain the logic code of the target component according to the storage path information and the module identifier.
3. The method according to claim 1, wherein The creating the target entity in the game scene according to the target component includes: Instantiate according to the logic code of the target component to obtain an instantiated component; Create the target entity in the game scene according to the instantiated component.
4. The method according to claim 2, wherein Before the obtaining the logic code corresponding to the storage path information from a preset dictionary file according to the storage path information, the method further includes: When the game starts, read a preset target file from memory, where the preset target file stores: game logic code, and the offset corresponding to the stored game logic code; Generate the preset dictionary file according to the preset target file.
5. The method according to claim 4, wherein The generating the preset dictionary file according to the preset target file includes: Determine the location path information and offset of the game logic code according to a first preset file in the preset target file; Obtain the game logic code from a second preset file in the preset target file according to the location path information and offset of the game logic code; The preset dictionary file includes: the location path information of the game logic code and the game logic code.
6. The method according to claim 5, characterized in that, Before the reading the preset target file from memory when the game starts, the method further includes: Store the game logic code in the memory; Write the game logic code into the second preset file, and write the path information and offset of the game logic code in the second preset file into the first preset file to obtain the preset target file; The preset target file includes: the first preset file and the second preset file.
7. A game application device, characterized in that, Including: An obtaining module, configured to, in response to a creation request for a target entity triggered by a preset game event, obtain the logic code of the target component according to the identification information of the target component of the target entity; A creating module, configured to create the target entity in the game scene according to the logic code of the target component; The obtaining module is further configured to parse the storage path information of the target component from the identification information; according to the storage path information, obtain, from a preset dictionary file, the logical code corresponding to the storage path information as the logical code of the target component; multiple logical codes and corresponding storage path information are stored in the preset dictionary file.
8. A server, characterized in that, including: a memory and a processor, where the memory stores computer programs executable by the processor, and when the processor executes the computer programs, the game application method according to any one of claims 1-6 above is implemented.
9. A storage medium, characterized in that, A computer program is stored on the storage medium, and when the computer program is read and executed, the game application method according to any one of claims 1-6 above is implemented.
Citation Information
Patent Citations
Method and device for starting applications on mobile equipment
CN101957770A
Dynamic injection of code into running process
CN104137062A