Game script processing method, device, computer equipment and storage medium
By describing game script statements in a domain-specific language and generating an abstract syntax tree, and combining it with the rendering engine to read matching rendering components one by one, it solves the problem of long parsing time caused by the complexity of the game script code and improves game execution efficiency.
Patent Information
- Application Number
- CN202110980792.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-25
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2041-08-25
AI Technical Summary
The code structure of existing game scripts is complex, resulting in long parsing times and affecting game execution efficiency.
Game script statements are described in a domain-specific language, an abstract syntax tree is generated, and the rendering engine reads and matches the rendering components one by one for rendering, simplifying the script parsing process.
It improves the execution efficiency of game scripts, reduces parsing time, and avoids corner problems caused by code complexity.
Smart Images

Figure CN113797545B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a game script processing method, device, computer equipment and storage medium. Background Art
[0002] With the development of game development technology, game scripts are a specific descriptive language, an executable file written in a certain format, used to control game applications. However, as the game plot becomes more complex, the amount of code in the game script also increases. The code structure in the current game script is intricate and the data is deeply nested. When the game engine needs to read the game script to render the game screen, it takes a long time to parse the game script, resulting in low execution efficiency of the game script. Summary of the invention
[0003] Based on this, it is necessary to provide a game script processing method, device, computer equipment and storage medium to address the above technical problems, describe the game script statements in the game script through a domain-specific language, and streamline the game script statements through the domain-specific language. This can not only avoid many corner cases, but also the streamlined game script statements do not need to spend too much time parsing during the execution process, thereby improving the execution efficiency of the game script.
[0004] A game script processing method, the method comprising:
[0005] Obtaining the game script content to be processed, where the game script content to be processed includes a plurality of game script statements to be executed, and the game script statements to be executed are described in a domain specific language;
[0006] Parsing the game script content to be processed to obtain an abstract syntax tree set corresponding to the game script content to be processed, the abstract syntax tree set including multiple abstract syntax trees, which are tree-like representations of the abstract syntax structure of the corresponding game script statement to be executed;
[0007] The rendering engine reads each abstract syntax tree in the abstract syntax tree set one by one, and calls a rendering component matching the read abstract syntax tree for rendering.
[0008] In one of the embodiments, obtaining the game script content to be processed includes: obtaining the game script content edited by an editor, uploading the game script content to a content distribution network, sending an acquisition request, and pulling the game script content to be processed from the content distribution network according to the acquisition request.
[0009] In one of the embodiments, the game script content to be processed is parsed to obtain an abstract syntax tree set corresponding to the game script content to be processed, including: calling a target operating system file, the target operating system file is written according to a preset grammar rule of the target operating system, and a plurality of filtered game script statements to be executed are obtained from each game script statement to be executed according to the target operating system file, and the filtered plurality of game script statements to be executed are converted into corresponding tag sequences, and a matching callback function is called, and each tag sequence is converted through the callback function to obtain an abstract syntax tree set.
[0010] In one of the embodiments, each abstract syntax tree in an abstract syntax tree set is read one by one by a rendering engine, and a rendering component matching the read abstract syntax tree is called for rendering, including: reading a current abstract syntax tree by a rendering engine, the current abstract syntax tree being any one in the abstract syntax tree set, and when a target game script statement corresponding to the current abstract syntax tree is a game script instruction statement, determining a current rendering component matching the current abstract syntax tree according to the abstract syntax tree description information of the current abstract syntax tree, and rendering the current abstract syntax tree by the current rendering component.
[0011] In one of the embodiments, it also includes: when the target game script statement corresponding to the current abstract syntax tree is a game script logic statement, and the target game script statement is a game script judgment statement, judging whether a preset judgment condition is met according to the description information of the current abstract syntax tree, wherein the game script logic statement includes a game script judgment statement and a game script loop statement; if the condition is met, obtaining the current game script statement corresponding to the current abstract syntax tree, the current game script statement is any one of the multiple target game script statements corresponding to the current abstract syntax tree, judging whether the current game script statement is a game script instruction statement to determine whether it is necessary to call the current rendering component matching the current game script statement for rendering.
[0012] In one of the embodiments, whether the current game script statement is a game script instruction statement is determined to determine whether it is necessary to call a matching current rendering component for rendering, including: when the current game script statement is a game script instruction statement, determining a matching current rendering component based on the script statement description information of the current game script statement, and rendering the current game script statement through the current rendering component.
[0013] In one of the embodiments, each abstract syntax tree in an abstract syntax tree set is read one by one by a rendering engine, and a rendering component matching the read abstract syntax tree is called for rendering, including: each abstract syntax tree in the abstract syntax tree set is read one by one by a rendering engine, a target rendering component matching the read abstract syntax tree is determined from rendering components registered with an onion model, a rendering context is judged by the target rendering component to determine whether it needs to be rendered, and if rendering is required, the read abstract syntax tree is rendered by the target rendering component.
[0014] A game script processing device, the device comprising:
[0015] An acquisition module is used to acquire the game script content to be processed, the game script content to be processed includes a plurality of game script statements to be executed, and the game script statements to be executed are described in a domain specific language;
[0016] A parsing module, used to parse the game script content to be processed to obtain an abstract syntax tree set corresponding to the game script content to be processed, wherein the abstract syntax tree set includes multiple abstract syntax trees, and the abstract syntax tree is a tree representation of the abstract syntax structure of the corresponding game script statement to be executed;
[0017] The rendering module is used to read each abstract syntax tree in the abstract syntax tree set one by one through the rendering engine, and call the rendering component matching the read abstract syntax tree for rendering.
[0018] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the following steps are implemented:
[0019] Obtaining the game script content to be processed, where the game script content to be processed includes a plurality of game script statements to be executed, and the game script statements to be executed are described in a domain specific language;
[0020] Parsing the game script content to be processed to obtain an abstract syntax tree set corresponding to the game script content to be processed, the abstract syntax tree set including multiple abstract syntax trees, which are tree-like representations of the abstract syntax structure of the corresponding game script statement to be executed;
[0021] The rendering engine reads each abstract syntax tree in the abstract syntax tree set one by one, and calls a rendering component matching the read abstract syntax tree for rendering.
[0022] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0023] Obtaining the game script content to be processed, where the game script content to be processed includes a plurality of game script statements to be executed, and the game script statements to be executed are described in a domain specific language;
[0024] Parsing the game script content to be processed to obtain an abstract syntax tree set corresponding to the game script content to be processed, the abstract syntax tree set including multiple abstract syntax trees, which are tree-like representations of the abstract syntax structure of the corresponding game script statement to be executed;
[0025] The rendering engine reads each abstract syntax tree in the abstract syntax tree set one by one, and calls a rendering component matching the read abstract syntax tree for rendering.
[0026] The above-mentioned game script processing method, device, computer equipment and storage medium obtain the content of the game script to be processed, the content of the game script to be processed includes multiple game script statements to be executed, and the game script statements to be executed are described in a domain-specific language. The game script content to be processed is parsed to obtain an abstract syntax tree set corresponding to the game script content to be processed, and the abstract syntax tree set includes multiple abstract syntax trees, which are tree-like representations of the abstract syntax structure of the corresponding game script statements to be executed. The rendering engine reads each abstract syntax tree in the abstract syntax tree set one by one, and calls the rendering component that matches the read abstract syntax tree for rendering. Therefore, the game script statements in the game script can be described in a domain-specific language, and the game script statements can be simplified using the domain-specific language, which can not only avoid many corner problems, but also the simplified game script statements do not need to spend too much time parsing during the execution process, thereby improving the execution efficiency of the game script. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 An application environment diagram of a game script processing method in one embodiment;
[0028] Figure 2 A flowchart of a method for processing a game script in one embodiment;
[0029] Figure 3 A schematic diagram of a process for obtaining game script content to be processed in an embodiment;
[0030] Figure 4 A schematic diagram of a process of parsing game script content to be processed in one embodiment;
[0031] Figure 5 A flowchart of a rendering engine reading step in one embodiment;
[0032] Figure 5A A schematic diagram of the structure of the game script content in one embodiment;
[0033] Figure 6 A flowchart of a rendering engine reading step in one embodiment;
[0034] Figure 7 A flowchart of a rendering engine reading step in one embodiment;
[0035] Figure 8 is a structural block diagram of a game script processing device in one embodiment;
[0036] Fig. 9 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0038] The game script processing method provided in this application can be applied to Figure 1 In the application environment shown, the terminal 102 communicates with the server 104 through a network. The terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, and portable wearable devices, and the server 104 may be implemented as an independent server or a server cluster consisting of multiple servers.
[0039] Specifically, the server 104 obtains the game script content to be processed, which includes multiple game script statements to be executed. The game script statements to be executed are described in a domain-specific language. The game script content to be processed is parsed to obtain an abstract syntax tree set corresponding to the game script content to be processed. The abstract syntax tree set includes multiple abstract syntax trees, which are tree-like representations of the abstract syntax structure of the corresponding game script statements to be executed. The rendering engine reads each abstract syntax tree in the abstract syntax tree set one by one, calls a rendering component that matches the read abstract syntax tree for rendering, and sends the rendered game screen to the terminal 102 for display.
[0040] In one embodiment, Figure 2 As shown, a game script processing method is provided, which is applied to Figure 1 The server in the example is used to illustrate the following steps:
[0041] Step 202, obtaining the game script content to be processed, the game script content to be processed includes a plurality of game script statements to be executed, and the game script statements to be executed are described in a domain specific language.
[0042] Among them, the game script content is used to control the game application program, and the game script content is composed of at least one game script statement, and the pending game script content here is the game script content waiting to be processed, and the pending game script content includes multiple pending game script statements, and the pending game script statements here are described in a domain-specific language, which is a custom language and can also be called DSL (Domain Special Language). The pending game script statements can be formulated using a domain-specific language based on actual business conditions, actual product conditions, or actual application scenarios. For example, the pending game script statements described in a domain-specific language can be: player name = "xxx" file = "xxx", sound name = "xxx" file = "xxx", etc.
[0043] Step 204, parse the game script content to be processed to obtain an abstract syntax tree set corresponding to the game script content to be processed, the abstract syntax tree set includes multiple abstract syntax trees, and the abstract syntax tree is a tree representation of the abstract syntax structure of the corresponding game script statement to be executed.
[0044] Among them, after obtaining the game script content to be processed, the game script content to be processed can be parsed. The parsing of the game script content to be processed can specifically be to perform an abstract analysis of the grammatical structure of each game script statement to be executed, and then convert it according to the analyzed abstract grammatical structure to obtain each abstract syntax tree, and an abstract syntax tree set composed of each abstract syntax tree. Among them, the abstract syntax tree is a tree-like representation of the abstract syntax structure of the corresponding game script statement to be executed. Among them, the abstract syntax tree can also be called AST (abstract syntax code, abstract syntax tree), that is, the abstract syntax tree is associated with the game script statement to be executed.
[0045] Among them, the grammatical structure of each game script statement to be executed is abstractly analyzed, and then converted according to the analyzed abstract grammatical structure to obtain each abstract syntax tree. Specifically, each game script statement to be executed in the game script content to be processed is parsed into a token (tag sequence), and then the token is converted into a corresponding AST.
[0046] Step 206: read each abstract syntax tree in the abstract syntax tree set one by one through the rendering engine, and call the rendering component matching the read abstract syntax tree to perform rendering.
[0047] Among them, the rendering engine is an engine for rendering, and multiple rendering components can be pre-registered in the rendering engine, and different rendering contents can be rendered through different rendering components. Specifically, after obtaining the abstract syntax tree set, the rendering engine can read each abstract syntax tree in the abstract syntax tree set one by one. Since the abstract syntax tree contains various descriptive information, including the name of the rendering component, the rendering content, etc., the matching rendering component can be called through the read abstract syntax tree, and the read abstract syntax tree can be rendered through the rendering component.
[0048] For example, the read abstract syntax tree is about the background rendering component, and the rendering content is about the content related to the rendering background. Therefore, the background rendering component is called to render the background content of the read abstract syntax tree through the background rendering component.
[0049] In the above-mentioned game script processing method, the content of the game script to be processed is obtained, and the content of the game script to be processed includes multiple game script statements to be executed. The game script statements to be executed are described in a domain-specific language. The content of the game script to be processed is parsed to obtain an abstract syntax tree set corresponding to the content of the game script to be processed. The abstract syntax tree set includes multiple abstract syntax trees, and the abstract syntax tree is a tree-like representation of the abstract syntax structure of the corresponding game script statement to be executed. The rendering engine reads each abstract syntax tree in the abstract syntax tree set one by one, and calls the rendering component that matches the read abstract syntax tree for rendering. Therefore, the game script statements in the game script can be described in a domain-specific language, and the game script statements can be simplified using the domain-specific language, which can not only avoid many corner problems, but also the simplified game script statements do not need to spend too much time parsing during the execution process, thereby improving the execution efficiency of the game script.
[0050] In one embodiment, Figure 3 As shown, get the game script content to be processed, including:
[0051] Step 302, obtaining the game script content edited by the editor, and uploading the game script content to the content distribution network.
[0052] Step 304: Send an acquisition request, and pull the game script content to be processed from the content distribution network according to the acquisition request.
[0053] The editor here is a tool for editing the game script content. The game script content can be edited through the editor. Specifically, the game script statements can be formulated according to the actual business situation, the actual product situation or the actual application scenario to obtain the game script content. The game script content edited by the editor is uploaded to the content delivery network CDN (Content Delivery Network). The content delivery network CDN is an intelligent virtual network built on the basis of the existing network. It relies on edge servers deployed in various places. Through the load balancing, content distribution, scheduling and other functional modules of the central platform, users can obtain the required content nearby, reduce network congestion, and improve the user access response speed and hit rate. The key technologies of CDN are mainly content storage and distribution technologies.
[0054] Therefore, a request is sent. The so-called request is used to request the content of the game script to be processed. The request can carry the address of the acquirer, and the content of the game script to be processed can be pulled from the content distribution network nearby according to the address of the acquirer.
[0055] In one embodiment, Figure 4 As shown, the game script content to be processed is parsed to obtain an abstract syntax tree set corresponding to the game script content to be processed, including:
[0056] Step 402, calling the target operating system file, where the target operating system file is written according to preset grammar rules of the target operating system.
[0057] Step 404, obtaining a plurality of game script statements to be executed after screening from each game script statement to be executed according to the target operating system file.
[0058] Step 406, convert the filtered multiple to-be-executed game script statements into corresponding tag sequences, call a matching callback function, and convert each tag sequence into an abstract syntax tree set through the callback function.
[0059] The target operating system here refers to the ohm system, which is a library that helps developers define their own domain-specific language DSL. After designing their own DSL, the omh system will write their own ohm file according to the preset grammar rules. The ohm file is the target operating system file.
[0060] Specifically, the target operating system file, that is, the ohm file, is called, and the game script statements to be executed in the game script content to be processed are screened according to the target operating system file, and the game script statements to be executed that meet the rules are converted to obtain the corresponding tag sequence. Then, by calling the callback function matching the tag sequence, each tag sequence is converted to the corresponding abstract syntax tree through the callback function to form an abstract syntax tree set.
[0061] For example, when parsing the content of the game script to be processed, the ohm file is called, token parsing is performed on the game script statements to be executed that meet the rules, and then the corresponding DSL callback function is called to convert the token into AST in the callback function.
[0062] In one embodiment, Figure 5 As shown, the rendering engine reads each abstract syntax tree in the abstract syntax tree set one by one, and calls the rendering component matching the read abstract syntax tree for rendering, including:
[0063] Step 502: read the current abstract syntax tree through the rendering engine, where the current abstract syntax tree is any one in the abstract syntax tree set.
[0064] Step 504, when the target game script statement corresponding to the current abstract syntax tree is a game script instruction statement, determine the current rendering component that matches the current abstract syntax tree according to the abstract syntax tree description information of the current abstract syntax tree, and render the current abstract syntax tree through the current rendering component.
[0065] The rendering engine reads each abstract syntax tree in the abstract syntax tree set one by one, and can determine an abstract syntax tree from the abstract syntax tree set as the current abstract syntax tree. Since the abstract syntax tree is a tree-like representation of the abstract syntax structure of the corresponding game script statement to be executed, and the game script statement to be executed is described using a domain-specific language DSL. The DSL may include but is not limited to game script instruction statements and game script logic statements. Specifically, it can be as follows Figure 5A As shown, Figure 5A A schematic diagram showing the structure of the game script content in one embodiment is shown. Figure 5A The game script content in may include multiple game script statements, which may be game script instruction statements or game script logic statements. The DSL of game script instruction statements may include player name="xxx" file="xxx", sound name="xxx" file="xxx", etc. The DSL of game script logic statements may include:
[0066] #if XXX / / do something
[0067] #else / / do something
[0068] #end.
[0069] Specifically, when parsing the current abstract syntax tree, it is possible to determine whether it is necessary to call a matching current rendering component by using the script statement type of the target game script statement corresponding to the current abstract syntax tree, wherein the target game script statement may be one or more. If the target game script statement corresponding to the current abstract syntax tree is a game script instruction statement, the matching current rendering component is determined based on the abstract syntax tree description information of the current abstract syntax tree. The abstract syntax tree description information of the current abstract syntax tree includes the current rendering component identifier, the current rendering content, etc. Therefore, after determining the current rendering component, the current rendering content of the current abstract syntax tree is rendered by the current rendering component.
[0070] In one embodiment, Figure 6 As shown, the rendering engine reads each abstract syntax tree in the abstract syntax tree set one by one, and calls a rendering component matching the read abstract syntax tree for rendering, and also includes:
[0071] Step 602, when the target game script statement corresponding to the current abstract syntax tree is a game script logic statement, and the target game script statement is a game script judgment statement, determine whether the preset judgment condition is met according to the description information of the current abstract syntax tree, wherein the game script logic statement includes a game script judgment statement and a game script loop statement.
[0072] Step 604: if satisfied, obtain the current game script statement corresponding to the current abstract syntax tree, where the current game script statement is any one of the multiple target game script statements corresponding to the current abstract syntax tree.
[0073] Step 606, determining whether the current game script statement is a game script instruction statement to determine whether it is necessary to call the current rendering component matching the current game script statement for rendering.
[0074] Specifically, when parsing the current abstract syntax tree, if the target game script statement corresponding to the current abstract syntax tree is a game script logic statement, since the game script logic statement includes but is not limited to a game script judgment statement and a game script loop statement, wherein the game script judgment statement is a game script statement used for judgment, and the game script loop statement is a game script statement used for loop operations, it is detected whether the target game script statement is a game script judgment statement. When the target game script statement is a game script judgment statement, it is determined whether the preset judgment conditions are met based on the description information of the current abstract syntax tree.
[0075] If the conditions are met, the current game script statement corresponding to the current abstract syntax tree is obtained, and the current game script statement is any one of the multiple target game script statements corresponding to the current abstract syntax tree. Further, it is determined whether the current game script statement is a game script instruction statement to determine whether it is necessary to call the current rendering component matching the current game script statement for rendering, because only when the current game script statement is a game script instruction statement, it is necessary to call the matching current rendering component for rendering.
[0076] If the type of the current abstract syntax tree is a logic script, it is necessary to determine whether the current abstract syntax tree is a judgment branch or a loop branch in the logic script. If it is a judgment branch, it is determined whether the preset condition is met according to the description information of the current abstract syntax tree. If it is a loop branch, loop processing is performed according to the description information of the current abstract syntax tree. The preset condition can be determined based on actual business needs, actual product needs, or actual application scenarios.
[0077] In one embodiment, judging whether the current game script statement is a game script instruction statement to determine whether it is necessary to call a matching current rendering component for rendering includes: when the current game script statement is a game script instruction statement, determining a matching current rendering component according to the script statement description information of the current game script statement, and rendering the current game script statement through the current rendering component.
[0078] Specifically, it is judged whether the current game script statement is a game script instruction statement to determine whether it is necessary to call the matching current rendering component for rendering. Specifically, when it is determined that the current game script statement is a game script instruction statement, the matching current rendering component can be determined according to the description information of the current game script statement, and the current game script statement can be rendered through the current rendering component.
[0079] For example, the rendering engine will read the AST one by one. When encountering the AST of the instruction script, it will call the corresponding rendering component for rendering. When encountering the AST of the logic script, it will perform logical processing based on the information provided by the AST. If it is an AST of a judgment statement, it will first determine whether the conditions are met. If the conditions are met, then based on the game script statements in the AST, it may be a game script logic statement or a game script instruction statement. If it is a game script instruction statement, the corresponding rendering component will be called for rendering, etc. Otherwise, if the conditions are not met, the next AST will be read.
[0080] For example, the target game script statement corresponding to the current abstract syntax tree is:
[0081] #if x>10 / / do player name="xxx" file="xxx"
[0082] #end.
[0083] Among them, when it is detected that the target game script statement is a game script judgment statement, it is judged that the description information of the current abstract syntax tree meets the preset condition x>10, then the current game script statement corresponding to the current abstract syntax tree is obtained as playername="xxx"file="xxx", and since the current game script statement is a game script instruction statement, the matching video rendering component is called for rendering.
[0084] In another embodiment, if it is determined that the description information of the current abstract syntax tree does not meet the preset condition, the next abstract syntax tree is obtained and determined as the current abstract syntax tree for determination.
[0085] In one embodiment, Figure 7 As shown, the rendering engine reads each abstract syntax tree in the abstract syntax tree set one by one, and calls the rendering component matching the read abstract syntax tree for rendering, including:
[0086] Step 702: Read each abstract syntax tree in the abstract syntax tree set one by one through the rendering engine, and determine a target rendering component that matches the read abstract syntax tree from the rendering components registered with the onion model.
[0087] Step 704: The target rendering component determines whether the rendering context needs to be rendered.
[0088] Step 706: If rendering is required, the read abstract syntax tree is rendered through the target rendering component.
[0089] Among them, the onion model here is a plug-in mechanism that decouples each rendering component so that each rendering component is loosely coupled. Specifically, the rendering engine reads each abstract syntax tree in the abstract syntax tree set one by one, and determines the target rendering component from the rendering components registered with the onion model according to the abstract syntax tree currently being read. Specifically, it can be determined according to the description information of the abstract syntax tree being read. Furthermore, the rendering context is judged by the target rendering component to determine whether it needs to be rendered, because some target rendering components no longer need to be rendered or other factors cause them to no longer need to be rendered. Therefore, it is necessary to judge the rendering context through the target rendering component to determine whether it needs to be rendered. If rendering is required, the read abstract syntax tree is rendered through the target rendering component.
[0090] In one embodiment, the client can have a corresponding version of a general rendering engine built in. First, the correspondence table between the game script content and the game resources is downloaded. When reading the current game script content corresponding to the general rendering engine, the corresponding current game resources are obtained according to the correspondence table. The current game resources are rendered by the general rendering engine built in the client to generate the current game. Among them, all game resources can be uploaded to the CDN network in advance when the game is released. When reading the current game script content, the corresponding current game resources can be obtained from the corresponding CDN network. The correspondence table records the CDN address where the current game resources are located.
[0091] Among them, separating the game script content from the game resources and from the rendering engine can ensure the purity of the code core, facilitate maintenance and management, and facilitate version iteration; when publishing a project, only the script file needs to be published, and the corresponding resources are downloaded from the CDN at an accelerated speed, which greatly improves the project publishing and running speed.
[0092] In a specific embodiment, a game script processing method is provided, which specifically includes the following steps:
[0093] 1. Obtain the game script content to be processed, which includes multiple game script statements to be executed. The game script statements to be executed are described in a domain-specific language.
[0094] 1-1. Obtain the game script content edited by the editor and upload the game script content to the content distribution network.
[0095] 1-2. Send a request to obtain the game script content to be processed from the content distribution network according to the request.
[0096] 2. Parse the game script content to be processed to obtain an abstract syntax tree set corresponding to the game script content to be processed. The abstract syntax tree set includes multiple abstract syntax trees, which are tree-like representations of the abstract syntax structure of the corresponding game script statements to be executed.
[0097] 2-1. Call the target operating system file, which is written according to the preset grammar rules of the target operating system.
[0098] 2-2. Obtain multiple game script statements to be executed after screening from each game script statement to be executed according to the target operating system file.
[0099] 2-3. Convert the filtered multiple to-be-executed game script statements into corresponding tag sequences, call the matching callback function, and convert each tag sequence into an abstract syntax tree set through the callback function.
[0100] 3. The rendering engine reads each abstract syntax tree in the abstract syntax tree set one by one, and calls the rendering component that matches the read abstract syntax tree for rendering.
[0101] 3-1-1. Read the current abstract syntax tree through the rendering engine. The current abstract syntax tree is any one in the abstract syntax tree set.
[0102] 3-1-2. When the target game script statement corresponding to the current abstract syntax tree is a game script instruction statement, the current rendering component that matches the current abstract syntax tree is determined according to the abstract syntax tree description information of the current abstract syntax tree, and the current abstract syntax tree is rendered through the current rendering component.
[0103] 3-1-3. When the target game script statement corresponding to the current abstract syntax tree is a game script logic statement, and the target game script statement is a game script judgment statement, determine whether the preset judgment condition is met based on the description information of the current abstract syntax tree.
[0104] 3-1-4. If satisfied, obtain the current game script statement corresponding to the current abstract syntax tree, where the current game script statement is any one of the multiple target game script statements corresponding to the current abstract syntax tree.
[0105] 3-1-5. Determine whether the current game script statement is a game script instruction statement to determine whether it is necessary to call the current rendering component that matches the current game script statement for rendering.
[0106] When the current game script statement is a game script instruction statement, a matching current rendering component is determined according to the script statement description information of the current game script statement, and the current game script statement is rendered by the current rendering component.
[0107] 3-2-1. The rendering engine reads each abstract syntax tree in the abstract syntax tree set one by one, and determines the target rendering component that matches the read abstract syntax tree from the rendering components registered with the onion model.
[0108] 3-2-2. The target rendering component determines whether the rendering context needs to be rendered.
[0109] 3-2-3. If rendering is required, the read abstract syntax tree is rendered through the target rendering component.
[0110] It should be understood that, although the various steps in the above-mentioned flow chart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the above-mentioned flow chart may include a plurality of sub-steps or a plurality of stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0111] In one embodiment, Figure 8 As shown, a game script processing device 800 is provided, including: an acquisition module 802, a parsing module 804 and a rendering module 806, wherein:
[0112] The acquisition module 802 is used to acquire the game script content to be processed, where the game script content to be processed includes a plurality of game script statements to be executed, and the game script statements to be executed are described in a domain specific language.
[0113] The parsing module 804 is used to parse the game script content to be processed to obtain an abstract syntax tree set corresponding to the game script content to be processed. The abstract syntax tree set includes multiple abstract syntax trees, and the abstract syntax tree is a tree-like representation of the abstract syntax structure of the corresponding game script statement to be executed.
[0114] The rendering module 806 is used to read each abstract syntax tree in the abstract syntax tree set one by one through a rendering engine, and call a rendering component matching the read abstract syntax tree to perform rendering.
[0115] In one embodiment, the acquisition module 802 acquires the game script content edited by the editor, uploads the game script content to the content distribution network, sends an acquisition request, and pulls the game script content to be processed from the content distribution network according to the acquisition request.
[0116] In one embodiment, the parsing module 804 calls the target operating system file, which is written according to the preset grammar rules of the target operating system, obtains multiple filtered game script statements to be executed from each game script statement to be executed according to the target operating system file, converts the multiple filtered game script statements to be executed into corresponding tag sequences, calls a matching callback function, and converts each tag sequence through the callback function to obtain an abstract syntax tree set.
[0117] In one embodiment, the rendering module 806 reads the current abstract syntax tree through the rendering engine. The current abstract syntax tree is any one in the abstract syntax tree set. When the target game script statement corresponding to the current abstract syntax tree is a game script instruction statement, the current rendering component matching the current abstract syntax tree is determined according to the abstract syntax tree description information of the current abstract syntax tree, and the current abstract syntax tree is rendered through the current rendering component.
[0118] In one embodiment, when the target game script statement corresponding to the current abstract syntax tree is a game script logic statement and the target game script statement is a game script judgment statement, the rendering module 806 determines whether a preset judgment condition is met according to the description information of the current abstract syntax tree. If so, the current game script statement corresponding to the current abstract syntax tree is obtained, where the current game script statement is any one of multiple target game script statements corresponding to the current abstract syntax tree, and whether the current game script statement is a game script instruction statement is determined to determine whether it is necessary to call the current rendering component matching the current game script statement for rendering.
[0119] In one embodiment, when the current game script statement is a game script instruction statement, the rendering module 806 determines a matching current rendering component according to the script statement description information of the current game script statement, and renders the current game script statement through the current rendering component.
[0120] In one embodiment, the rendering module 806 reads each abstract syntax tree in the abstract syntax tree set one by one through the rendering engine, determines the target rendering component that matches the read abstract syntax tree from the rendering components registered with the onion model, and determines whether the rendering context itself needs to be rendered through the target rendering component. If rendering is required, the read abstract syntax tree is rendered through the target rendering component.
[0121] For the specific definition of the game script processing device, please refer to the definition of the game script processing method above, which will not be repeated here. Each module in the above-mentioned game script processing device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0122] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig. 9As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store game script content. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a game script processing method is implemented.
[0123] Those skilled in the art will understand that Fig. 9 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0124] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented: obtaining game script content to be processed, the game script content to be processed includes multiple game script statements to be executed, the game script statements to be executed are described in a domain-specific language, parsing the game script content to be processed to obtain an abstract syntax tree set corresponding to the game script content to be processed, the abstract syntax tree set includes multiple abstract syntax trees, the abstract syntax tree is a tree-like representation of an abstract syntax structure of the corresponding game script statement to be executed, reading each abstract syntax tree in the abstract syntax tree set one by one through a rendering engine, and calling a rendering component matching the read abstract syntax tree for rendering.
[0125] In one embodiment, when the processor executes the computer program, it also implements the following steps: obtaining the game script content edited by the editor, uploading the game script content to the content distribution network, sending an acquisition request, and pulling the game script content to be processed from the content distribution network according to the acquisition request.
[0126] In one embodiment, when the processor executes the computer program, the following steps are also implemented: calling the target operating system file, the target operating system file is written according to the preset grammar rules of the target operating system, obtaining multiple filtered game script statements to be executed from each game script statement to be executed according to the target operating system file, converting the multiple filtered game script statements to be executed into corresponding tag sequences, calling a matching callback function, and converting each tag sequence through the callback function to obtain an abstract syntax tree set.
[0127] In one embodiment, the processor further implements the following steps when executing the computer program: reading the current abstract syntax tree through the rendering engine, where the current abstract syntax tree is any one in the abstract syntax tree set; when the target game script statement corresponding to the current abstract syntax tree is a game script instruction statement, determining the current rendering component that matches the current abstract syntax tree according to the abstract syntax tree description information of the current abstract syntax tree, and rendering the current abstract syntax tree through the current rendering component.
[0128] In one embodiment, the processor further implements the following steps when executing the computer program: when the target game script statement corresponding to the current abstract syntax tree is a game script logic statement, and the target game script statement is a game script judgment statement, determine whether a preset judgment condition is met according to the description information of the current abstract syntax tree; if so, obtain the current game script statement corresponding to the current abstract syntax tree, where the current game script statement is any one of multiple target game script statements corresponding to the current abstract syntax tree; determine whether the current game script statement is a game script instruction statement to determine whether it is necessary to call a current rendering component matching the current game script statement for rendering.
[0129] In one embodiment, when the processor executes the computer program, the following steps are also implemented: determining whether the current game script statement is a game script instruction statement to determine whether it is necessary to call a matching current rendering component for rendering, including: when the current game script statement is a game script instruction statement, determining a matching current rendering component based on the script statement description information of the current game script statement, and rendering the current game script statement through the current rendering component.
[0130] In one embodiment, when the processor executes the computer program, the following steps are also implemented: reading each abstract syntax tree in the abstract syntax tree set one by one through the rendering engine, determining a target rendering component that matches the read abstract syntax tree from the rendering components registered with the onion model, judging the rendering context through the target rendering component to determine whether it needs to be rendered, and if rendering is required, rendering the read abstract syntax tree through the target rendering component.
[0131] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: obtaining game script content to be processed, the game script content to be processed includes multiple game script statements to be executed, and the game script statements to be executed are described in a domain-specific language; parsing the game script content to be processed to obtain an abstract syntax tree set corresponding to the game script content to be processed, the abstract syntax tree set includes multiple abstract syntax trees, and the abstract syntax tree is a tree-like representation of an abstract syntax structure of the corresponding game script statement to be executed; reading each abstract syntax tree in the abstract syntax tree set one by one through a rendering engine, and calling a rendering component matching the read abstract syntax tree for rendering.
[0132] In one embodiment, when the processor executes the computer program, it also implements the following steps: obtaining the game script content edited by the editor, uploading the game script content to the content distribution network, sending an acquisition request, and pulling the game script content to be processed from the content distribution network according to the acquisition request.
[0133] In one embodiment, when the processor executes the computer program, the following steps are also implemented: calling the target operating system file, the target operating system file is written according to the preset grammar rules of the target operating system, obtaining multiple filtered game script statements to be executed from each game script statement to be executed according to the target operating system file, converting the multiple filtered game script statements to be executed into corresponding tag sequences, calling a matching callback function, and converting each tag sequence through the callback function to obtain an abstract syntax tree set.
[0134] In one embodiment, the processor further implements the following steps when executing the computer program: reading the current abstract syntax tree through the rendering engine, where the current abstract syntax tree is any one in the abstract syntax tree set; when the target game script statement corresponding to the current abstract syntax tree is a game script instruction statement, determining the current rendering component that matches the current abstract syntax tree according to the abstract syntax tree description information of the current abstract syntax tree, and rendering the current abstract syntax tree through the current rendering component.
[0135] In one embodiment, the processor further implements the following steps when executing the computer program: when the target game script statement corresponding to the current abstract syntax tree is a game script logic statement, and the target game script statement is a game script judgment statement, determine whether a preset judgment condition is met according to the description information of the current abstract syntax tree; if so, obtain the current game script statement corresponding to the current abstract syntax tree, where the current game script statement is any one of multiple target game script statements corresponding to the current abstract syntax tree; determine whether the current game script statement is a game script instruction statement to determine whether it is necessary to call a current rendering component matching the current game script statement for rendering.
[0136] In one embodiment, when the processor executes the computer program, the following steps are also implemented: determining whether the current game script statement is a game script instruction statement to determine whether it is necessary to call a matching current rendering component for rendering, including: when the current game script statement is a game script instruction statement, determining a matching current rendering component based on the script statement description information of the current game script statement, and rendering the current game script statement through the current rendering component.
[0137] In one embodiment, when the processor executes the computer program, the following steps are also implemented: reading each abstract syntax tree in the abstract syntax tree set one by one through the rendering engine, determining a target rendering component that matches the read abstract syntax tree from the rendering components registered with the onion model, judging the rendering context through the target rendering component to determine whether it needs to be rendered, and if rendering is required, rendering the read abstract syntax tree through the target rendering component.
[0138] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0139] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0140] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A game script processing method, the method include: Obtaining game script content to be processed, wherein the game script content to be processed includes a plurality of game script statements to be executed, wherein the game script statements to be executed are described in a domain specific language; the domain specific language is DSL; the game script content to be processed is the game script content that is waiting to be processed; The game script content is used to control the game application; Parsing the game script content to be processed to obtain an abstract syntax tree set corresponding to the game script content to be processed, wherein the abstract syntax tree set includes multiple abstract syntax trees, and the abstract syntax tree is a tree representation of an abstract syntax structure of a corresponding game script statement to be executed; Reading each of the abstract syntax trees in the abstract syntax tree set one by one through a rendering engine, and calling a rendering component matching the read abstract syntax tree to perform rendering; The step of reading each of the abstract syntax trees in the abstract syntax tree set one by one through a rendering engine and calling a rendering component matching the read abstract syntax tree for rendering includes: Reading each of the abstract syntax trees in the abstract syntax tree set one by one through a rendering engine, and determining a target rendering component matching the read abstract syntax tree from rendering components registered with the onion model; The target rendering component determines whether the rendering context needs to be rendered. If rendering is required, the read abstract syntax tree is rendered through the target rendering component.
2. The method according to claim 1, It is characterized in that The obtaining of the game script content to be processed includes: Obtaining game script content edited by an editor, and uploading the game script content to a content distribution network; Send an acquisition request, and pull the to-be-processed game script content from the content distribution network according to the acquisition request.
3. The method according to claim 1, It is characterized in that The step of parsing the game script content to be processed to obtain an abstract syntax tree set corresponding to the game script content to be processed includes: Calling a target operating system file, wherein the target operating system file is written according to a preset grammar rule of the target operating system; Obtaining a plurality of filtered game script statements to be executed from each of the game script statements to be executed according to the target operating system file; The filtered multiple to-be-executed game script statements are converted into corresponding tag sequences, a matching callback function is called, and each of the tag sequences is converted by the callback function to obtain an abstract syntax tree set.
4. The method according to claim 1, It is characterized in that The step of reading each of the abstract syntax trees in the abstract syntax tree set one by one through a rendering engine, and calling a rendering component matching the read abstract syntax tree for rendering includes: Reading a current abstract syntax tree through a rendering engine, wherein the current abstract syntax tree is any one of the abstract syntax tree sets; When the target game script statement corresponding to the current abstract syntax tree is a game script instruction statement, a current rendering component matching the current abstract syntax tree is determined according to the abstract syntax tree description information of the current abstract syntax tree, and the current abstract syntax tree is rendered by the current rendering component.
5. The method according to claim 4, It is characterized in that The method further comprises: When the target game script statement corresponding to the current abstract syntax tree is a game script logic statement, and the target game script statement is a game script judgment statement, judging whether a preset judgment condition is met according to the description information of the current abstract syntax tree, wherein the game script logic statement includes a game script judgment statement and a game script loop statement; If satisfied, obtain a current game script statement corresponding to the current abstract syntax tree, where the current game script statement is any one of a plurality of target game script statements corresponding to the current abstract syntax tree; It is determined whether the current game script statement is a game script instruction statement to determine whether a current rendering component matching the current game script statement needs to be called for rendering.
6. The method according to claim 5, It is characterized in that The step of judging whether the current game script statement is a game script instruction statement to determine whether a matching current rendering component needs to be called for rendering includes: When the current game script statement is a game script instruction statement, a matching current rendering component is determined according to the script statement description information of the current game script statement, and the current game script statement is rendered by the current rendering component.
7. A game script processing device, It is characterized in that The device comprises: An acquisition module is used to acquire game script content to be processed, wherein the game script content to be processed includes a plurality of game script statements to be executed, and the game script statements to be executed are described in a domain specific language; the domain specific language is DSL; the game script content to be processed is the game script content waiting to be processed; the game script content is used to control the game application; A parsing module, used to parse the game script content to be processed to obtain an abstract syntax tree set corresponding to the game script content to be processed, wherein the abstract syntax tree set includes multiple abstract syntax trees, and the abstract syntax tree is a tree representation of an abstract syntax structure of a corresponding game script statement to be executed; A rendering module, configured to read each of the abstract syntax trees in the abstract syntax tree set one by one through a rendering engine, and call a rendering component matching the read abstract syntax tree for rendering; wherein, the step of reading each of the abstract syntax trees in the abstract syntax tree set one by one through a rendering engine, and calling a rendering component matching the read abstract syntax tree for rendering comprises: Reading each of the abstract syntax trees in the abstract syntax tree set one by one through a rendering engine, and determining a target rendering component matching the read abstract syntax tree from rendering components registered with the onion model; The target rendering component determines whether the rendering context needs to be rendered. If rendering is required, the read abstract syntax tree is rendered through the target rendering component.
8. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
