CN112473128B - Method, apparatus, electronic device and storage medium for isolating game logic - Google Patents
Method, apparatus, electronic device and storage medium for isolating game logic Download PDFInfo
- Publication number
- CN112473128B CN112473128B CN202011326134.4A CN202011326134A CN112473128B CN 112473128 B CN112473128 B CN 112473128B CN 202011326134 A CN202011326134 A CN 202011326134A CN 112473128 B CN112473128 B CN 112473128B
- Authority
- CN
- China
- Prior art keywords
- player
- game logic
- isolating
- game
- preset number
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 56
- 238000013507 mapping Methods 0.000 claims abstract description 16
- 238000004590 computer program Methods 0.000 claims description 11
- 230000007246 mechanism Effects 0.000 claims description 10
- 238000002955 isolation Methods 0.000 abstract description 12
- 230000002159 abnormal effect Effects 0.000 abstract description 6
- 230000015556 catabolic process Effects 0.000 abstract description 4
- 238000011161 development Methods 0.000 abstract description 4
- 230000008569 process Effects 0.000 description 11
- 238000004891 communication Methods 0.000 description 8
- 238000010586 diagram Methods 0.000 description 5
- 238000005516 engineering process Methods 0.000 description 5
- 230000008901 benefit Effects 0.000 description 4
- 230000006870 function Effects 0.000 description 4
- 238000012545 processing Methods 0.000 description 3
- 238000004364 calculation method Methods 0.000 description 2
- 238000004519 manufacturing process Methods 0.000 description 2
- 230000002093 peripheral effect Effects 0.000 description 2
- 239000007787 solid Substances 0.000 description 2
- 230000001360 synchronised effect Effects 0.000 description 2
- 230000001133 acceleration Effects 0.000 description 1
- 230000001419 dependent effect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000000802 evaporation-induced self-assembly Methods 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000000926 separation method Methods 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
Classifications
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F13/00—Video games, i.e. games using an electronically generated display having two or more dimensions
- A63F13/30—Interconnection arrangements between game servers and game devices; Interconnection arrangements between game devices; Interconnection arrangements between game servers
- A63F13/35—Details of game servers
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F13/00—Video games, i.e. games using an electronically generated display having two or more dimensions
- A63F13/70—Game security or game management aspects
- A63F13/77—Game security or game management aspects involving data related to game devices or game servers, e.g. configuration data, software version or amount of memory
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F2300/00—Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
- A63F2300/50—Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game characterized by details of game servers
- A63F2300/53—Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game characterized by details of game servers details of basic data processing
- A63F2300/538—Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game characterized by details of game servers details of basic data processing for performing operations on behalf of the game client, e.g. rendering
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F2300/00—Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
- A63F2300/50—Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game characterized by details of game servers
- A63F2300/55—Details of game data or player data management
- A63F2300/5526—Game data structure
- A63F2300/5533—Game data structure using program state or machine event data, e.g. server keeps track of the state of multiple players on in a multiple player game
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Business, Economics & Management (AREA)
- Computer Security & Cryptography (AREA)
- General Business, Economics & Management (AREA)
- Debugging And Monitoring (AREA)
- Stored Programmes (AREA)
Abstract
The application relates to a method, a device, an electronic device and a storage medium for isolating game logic, which belong to the field of game development, wherein the method comprises the following steps: pre-creating an object pool, wherein the object pool comprises a preset number of idle objects, and each idle object comprises a player unique identifier and a template class array; pre-creating a preset number of threads, wherein the threads are provided with numbers; when a player is online, selecting an object from the idle objects, assigning a player unique identifier of the selected object by using a player ID of the player, and mapping the player ID to a thread with a corresponding number; when a request for entering game logic is received, acquiring an object corresponding to the player ID through a thread corresponding to the player ID, and searching the game logic corresponding to the request from a template class array of the object; and executing the searched game logic. The method realizes inter-player isolation, play isolation and inter-thread isolation, and effectively solves the problem of how to avoid abnormal or breakdown of data of other players caused by triggering the BUG.
Description
Technical Field
The present application relates to the field of game development technologies, and in particular, to a method, an apparatus, an electronic device, and a storage medium for isolating game logic.
Background
In the game development process, the interactive playing method between players is considered, and the own single-machine logic playing method of the players is also considered. Thus, during the course of a game, different players may have different play. However, according to the current implementation of game logic, if the BUG is triggered during the game, other players are likely to be affected. For example, for stand-alone logic play, it can be cumbersome to trigger a BUG during play to cause other players to have data anomalies or process crashes.
At present, no effective solution is proposed for how to avoid abnormal data or process breakdown of other players caused by triggering the BUG in the related technology.
Disclosure of Invention
The embodiment of the application provides a method, a device, electronic equipment and a storage medium for isolating game logic, which at least solve the problem of how to avoid abnormal data or process crash of other players caused by triggering BUG in the related technology.
In a first aspect, an embodiment of the present application provides a method for isolating game logic, applied to a server, where the method includes: pre-creating an object pool, wherein the object pool comprises a preset number of idle objects, each idle object comprises a player unique identifier and a template class array, and the template class array supports a preset number of game logics; pre-creating a preset number of threads, wherein the threads with numbers are provided with the preset number; when a player is online, selecting an object from the idle objects, assigning a player unique identifier of the selected object by using a player ID of the player, and mapping the player ID to a thread with a corresponding number; when a request for entering game logic is received, acquiring an object corresponding to the player ID from the object pool through a thread corresponding to the player ID, and searching the game logic corresponding to the request from the template class array of the object; and executing the searched game logic.
In some of these embodiments, the number of objects is configured according to a maximum value carried by the server.
In some embodiments, the predetermined number of free objects is located in an array.
In some of these embodiments, an error capture mechanism is provided in each of the game logic for deciding whether to force a kick player to go offline.
In some of these embodiments, the error trapping mechanism is implemented by try in the C language, try-catch in the Python language, or xpcal in the Lua language.
In some of these embodiments, the error capture mechanism comprises: if the following logic is illegal: when the memory is read or written, the memory is read or written to the wrong memory, or the array subscript crosses the boundary, or the divisor is 0, the player is forced to kick off the line.
In some of these embodiments, the method of isolating game logic further comprises: and releasing the selected object after the player gets off line, so that the object is restored to an idle state.
In a second aspect, an embodiment of the present application provides an apparatus for isolating game logic, including an object pool creation module, a thread creation module, a mapping module, a lookup module, and an execution module, where the object pool creation module is configured to pre-create an object pool, where the object pool includes a preset number of idle objects, each of the idle objects includes a player unique identifier and a template class array, and the template class array supports the preset number of game logic; the thread creation module is used for pre-creating a preset number of threads, and the threads with the preset number are numbered; the mapping module is used for selecting an object from the idle objects when a player is online, assigning the player unique identification of the selected object by using the player ID of the player, and mapping the player ID to a thread with a corresponding number; the searching module is used for acquiring an object corresponding to the player ID from the object pool through a thread corresponding to the player ID when a request for entering the game logic is received, and searching the game logic corresponding to the request from the template class array of the object; the execution module is used for executing the searched game logic.
In a third aspect, embodiments of the present application provide an electronic device comprising a processor and a storage medium storing a computer program that when executed by the processor implements a method of isolating game logic as described in any one of the preceding claims.
In a fourth aspect, embodiments of the present application provide a computer readable storage medium having a computer program stored thereon, wherein the computer program when executed by a processor implements a method of isolating game logic as described in any of the above.
According to the above, the method for isolating game logic in the embodiment of the application includes: pre-creating an object pool, wherein the object pool comprises a preset number of idle objects, each idle object comprises a player unique identifier and a template class array, and the template class array supports a preset number of game logics; presetting a preset number of threads, wherein the threads with numbers are preset; when a player is online, selecting an object from the idle objects, assigning a player unique identifier of the selected object by using a player ID of the player, and mapping the player ID to a thread with a corresponding number; when a request for entering game logic is received, an object corresponding to the player ID is obtained from an object pool through a thread corresponding to the player ID, and the game logic corresponding to the request is searched from a template class array of the object; and executing the searched game logic. According to the embodiment of the application, inter-player isolation, inter-play (namely game logic) isolation and inter-thread isolation are realized, and the problem of how to avoid abnormal data or process breakdown of other players caused by triggering the BUG is effectively solved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and together with the description serve to explain the application and do not constitute an undue limitation to the application. In the drawings:
FIG. 1 is a flow chart of a method of isolating game logic according to an embodiment of the present application;
FIG. 2 is a schematic flow diagram of server execution when a player comes online in accordance with an embodiment of the present application;
FIG. 3 is a block diagram of an apparatus for isolating game logic according to an embodiment of the present application;
fig. 4 is a block diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described and illustrated below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden on the person of ordinary skill in the art based on the embodiments provided herein, are intended to be within the scope of the present application.
It is apparent that the drawings in the following description are only some examples or embodiments of the present application, and it is possible for those of ordinary skill in the art to apply the present application to other similar situations according to these drawings without inventive effort. Moreover, it should be appreciated that while such a development effort might be complex and lengthy, it would nevertheless be a routine undertaking of design, fabrication, or manufacture for those of ordinary skill having the benefit of this disclosure, and thus should not be construed as having the benefit of this disclosure.
Reference in the specification to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is to be expressly and implicitly understood by those of ordinary skill in the art that the embodiments described herein can be combined with other embodiments without conflict.
Unless defined otherwise, technical or scientific terms used herein should be given the ordinary meaning as understood by one of ordinary skill in the art to which this application belongs. Reference to "a," "an," "the," and similar terms herein do not denote a limitation of quantity, but rather denote the singular or plural. The terms "comprising," "including," "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, article, or apparatus that comprises a list of steps or modules (elements) is not limited to only those steps or elements but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus. The terms "connected," "coupled," and the like in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The term "plurality" as used herein refers to two or more. "and/or" describes an association relationship of an association object, meaning that there may be three relationships, e.g., "a and/or B" may mean: a exists alone, A and B exist together, and B exists alone. The character "/" generally indicates that the context-dependent object is an "or" relationship. The terms "first," "second," "third," and the like, as used herein, are merely distinguishing between similar objects and not representing a particular ordering of objects.
In order to solve the problem of abnormal data or process crash of other players caused by triggering the BUG, the embodiment of the present application provides a method for isolating game logic, and fig. 1 is a flowchart of a method for isolating game logic according to an embodiment of the present application, as shown in fig. 1, where the method includes:
s100: pre-creating an object pool, wherein the object pool comprises a preset number of idle objects, each idle object comprises a player unique identifier and a template class array, and the template class array supports a preset number of game logics;
s200: presetting a preset number of threads, wherein the threads with numbers are preset;
s300: when a player is online, selecting an object from the idle objects, assigning a player unique identifier of the selected object by using a player ID of the player, and mapping the player ID to a thread with a corresponding number;
s400: when a request for entering game logic is received, an object corresponding to the player ID is obtained from an object pool through a thread corresponding to the player ID, and the game logic corresponding to the request is searched from a template class array of the object;
s500: and executing the searched game logic.
It should be noted that, steps S100 and S200 may be sequential or simultaneous.
According to the content, the isolation among players is realized, namely, different players cannot influence each other; the playing methods are isolated, namely, different playing methods cannot be mutually influenced; and inter-thread isolation, namely different threads cannot be mutually influenced, so that the problem that data of other players are abnormal or a process is crashed due to triggering of the BUG can be effectively solved.
In order to describe the method of isolating game logic in the embodiments of the present application in detail, specific examples are set forth below.
Each player is represented by a class, the general structure is as follows:
class PlayerData{
int m_iPlayerid;
T**m_pkLogic;
};
where m_iPrayerid represents the player unique identifier and m_pkLogic represents the actual logical drive class object for this player. Preferably, m_pkLogic is a template class array, and can support different game logics (the number of the game logics can be preset), so that isolation between different playing methods (namely, the game logics) can be realized, and the process breakdown of one playing method can not affect other playing methods. The template class array can be regarded as a set of a plurality of game logics, different game logic implementations are mainly embodied on interfaces, and the same interfaces complete different logic functions through different game logic implementations, for example, the logic of combat is implemented by combat classes, the logic of maze is implemented by maze classes, and the logic of scenario is implemented by scenario classes.
An object pool is pre-created at the time of server startup, the object pool containing X free objects (i.e., playerData) each containing the player unique identifier and template class array. As an example, the value of X takes 8, as shown in table 1:
table 1 is the initial state of 8 objects in the object pool
| Object(s) | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| Status of | Free | Free | Free | Free | Free | Free | Free | Free |
。
The value of X may be preset, and may be configured according to the maximum value of the server bearer, for example, the default value of X is 1000 when the server is started, and if the server cannot be loaded, the value of X is adjusted to a smaller value such as 900 or 600 to adapt to the server bearer. Preferably, the X objects are placed in an array.
When a player comes online, selecting an object from the idle objects in the object pool. For example, when a player comes online, an object is selected from the object pool, and the objects in the object pool are shown in table 2:
table 2 states 8 objects in the object pool
| Object(s) | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| Status of | Used | Free | Free | Free | Free | Free | Free | Free |
。
At this time, the player ID of the player is used to assign the m_iplayerid in the selected object, and at the same time, variables used by some running logic may be set as initial values by default.
Thereafter, the player's game logic is implemented with the object, which is released after the player comes off-line, causing the object to resume the idle state.
In the above procedure, Y threads are also pre-created, each thread having a number, so that the player ID of the player can be mapped to the corresponding numbered thread. As an example, there are 4 threads, numbered 1, 2, 3, and 4, respectively, and the player ID of one player is 1009, then according to the preset mapping rule (the mapping rule may be set or changed according to the actual requirement), it is mapped to thread 1009mod 4=1, and since the object and the thread are two dimensions and do not affect each other, each thread searches the object from the object pool, so that the inter-thread player cannot affect each other. Preferably, different player IDs are mapped to different numbered threads.
When the uplink protocol information of the player is sent to the server through the client, wherein the protocol information refers to data transmitted to the server by the client, the request of the player for entering the game logic is acquired through the network message, at the moment, the server acquires an object corresponding to the player ID from the object pool through a thread corresponding to the player ID, searches the game logic corresponding to the request from the template class array of the object, and executes the searched game logic. For example, the client side tells the server that I want to enter a battle, the server can judge whether the request is legal, and if so, the server enters calculation of battle logic.
For further isolation, an error capture mechanism is provided in each game logic for determining whether to force a kick player to go offline, which can be implemented by some characteristics of the language itself, such as try of the C language, try-catch of the Python language, xpcal of the Lua language. Specifically, the error capturing mechanism detects through the running environment, and if the running logic is illegal, the player is forced to kick off the line. For example, when the following occurs: when the memory is read or written to the wrong memory during the reading and writing of the memory, or the subscript of the array crosses the boundary, or the divisor is 0, etc., the player is forced to kick off the line to avoid larger loss, and the damage can be timely stopped after the player makes an error.
Based on the foregoing, fig. 2 is a schematic flow chart executed by a server when a player is online, as shown in fig. 2, when the player sends a request for entering game logic to the server through a client, a process is started, the server finds a thread corresponding to the player, then finds m_pklogic (i.e., a logic class) corresponding to the player, and then finds game logic (i.e., a logic function) corresponding to the request, where implementation of the logic function provides an error capturing mechanism, and timely loss stopping can be achieved after the player makes an error.
The embodiment of the application further provides a device for isolating game logic, and fig. 3 is a structural block diagram of the device for isolating game logic according to the embodiment of the application, and as shown in fig. 3, the device comprises an object pool creation module 1, a thread creation module 2, a mapping module 3, a search module 4 and an execution module 5, wherein the object pool creation module 1 is used for pre-creating an object pool, the object pool comprises a preset number of idle objects, each idle object comprises a player unique identifier and a template class array, and the template class array supports the preset number of game logic; the thread creation module 2 is used for pre-creating a preset number of threads, and the threads with the preset number are numbered; the mapping module 3 is used for selecting an object from the idle objects when the player is online, assigning a player unique identifier of the selected object by using a player ID of the player, and mapping the player ID to a thread with a corresponding number; the searching module 4 is used for acquiring an object corresponding to the player ID from the object pool through a thread corresponding to the player ID when receiving a request for entering the game logic, and searching the game logic corresponding to the request from a template class array of the object; the execution module 5 is used for executing the searched game logic.
In summary, the method for isolating game logic according to the embodiments of the present application has the following advantages:
(1) PlayerData (objects) corresponding to different players are found from the object pool, and then logic function calculation is carried out, so that isolation among players is realized, and different players cannot influence each other;
(2) m_pkLogic is a template class array, can support different game logics, and realizes the separation between playing methods, so that different playing methods cannot be mutually influenced;
(3) By mapping player IDs of different players to threads with different numbers, inter-thread isolation is realized, so that different threads cannot be mutually influenced;
(4) According to the error capturing mechanism, when the running logic is illegal, the player is forced to kick off the line to avoid larger loss, and the loss can be timely stopped after the player makes an error.
In addition, the method for isolating game logic of the embodiment of the application can be realized by the electronic equipment. Fig. 4 is a block diagram of an electronic device according to an embodiment of the present application, which may include a processor 81 and a memory 82 storing computer program instructions, as shown in fig. 4.
In particular, the processor 81 may include a Central Processing Unit (CPU), or an application specific integrated circuit (Application Specific Integrated Circuit, abbreviated as ASIC), or may be configured to implement one or more integrated circuits of embodiments of the present application.
Memory 82 may include, among other things, mass storage for data or instructions. By way of example, and not limitation, memory 82 may comprise a Hard Disk Drive (HDD), floppy Disk Drive, solid state Drive (Solid State Drive, SSD), flash memory, optical Disk, magneto-optical Disk, tape, or universal serial bus (Universal Serial Bus, USB) Drive, or a combination of two or more of the foregoing. The memory 82 may include removable or non-removable (or fixed) media, where appropriate. The memory 82 may be internal or external to the data processing apparatus, where appropriate. In a particular embodiment, the memory 82 is a Non-Volatile (Non-Volatile) memory. In a particular embodiment, the Memory 82 includes Read-Only Memory (ROM) and random access Memory (Random Access Memory, RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (PROM for short), an erasable PROM (Erasable Programmable Read-Only Memory for short), an electrically erasable PROM (Electrically Erasable Programmable Read-Only Memory for short EEPROM), an electrically rewritable ROM (Electrically Alterable Read-Only Memory for short EAROM) or a FLASH Memory (FLASH) or a combination of two or more of these. The RAM may be Static Random-Access Memory (SRAM) or dynamic Random-Access Memory (Dynamic Random Access Memory DRAM), where the DRAM may be a fast page mode dynamic Random-Access Memory (Fast Page Mode Dynamic Random Access Memory FPMDRAM), extended data output dynamic Random-Access Memory (Extended Date Out Dynamic Random Access Memory EDODRAM), synchronous dynamic Random-Access Memory (Synchronous Dynamic Random-Access Memory SDRAM), or the like, as appropriate.
Memory 82 may be used to store or cache various data files that need to be processed and/or communicated, as well as possible computer program instructions for execution by processor 81.
The processor 81 implements any of the methods of isolating game logic of the above embodiments by reading and executing computer program instructions stored in the memory 82.
In some of these embodiments, the electronic device may also include a communication interface 83 and a bus 80. As shown in fig. 4, the processor 81, the memory 82, and the communication interface 83 are connected to each other through the bus 80 and perform communication with each other.
The communication interface 83 is used to implement communications between various modules, devices, units, and/or units in embodiments of the present application. The communication interface 83 may also enable communication with other components such as: and the external equipment, the image/data acquisition equipment, the database, the external storage, the image/data processing workstation and the like are used for data communication.
Bus 80 includes hardware, software, or both that couple components of the electronic device to one another. Bus 80 includes, but is not limited to, at least one of: data Bus (Data Bus), address Bus (Address Bus), control Bus (Control Bus), expansion Bus (Expansion Bus), local Bus (Local Bus). By way of example, and not limitation, bus 80 may include a graphics acceleration interface (Accelerated Graphics Port), abbreviated AGP, or other graphics Bus, an enhanced industry standard architecture (Extended Industry Standard Architecture, abbreviated EISA) Bus, a Front Side Bus (FSB), a HyperTransport (HT) interconnect, an industry standard architecture (Industry Standard Architecture, ISA) Bus, a wireless bandwidth (InfiniBand) interconnect, a Low Pin Count (LPC) Bus, a memory Bus, a micro channel architecture (Micro Channel Architecture, abbreviated MCa) Bus, a peripheral component interconnect (Peripheral Component Interconnect, abbreviated PCI) Bus, a PCI-Express (PCI-X) Bus, a serial advanced technology attachment (Serial Advanced Technology Attachment, abbreviated SATA) Bus, a video electronics standards association local (Video Electronics Standards Association Local Bus, abbreviated VLB) Bus, or other suitable Bus, or a combination of two or more of the foregoing. Bus 80 may include one or more buses, where appropriate. Although embodiments of the present application describe and illustrate a particular bus, the present application contemplates any suitable bus or interconnect.
In addition, in connection with the method of isolating game logic in the above embodiments, embodiments of the present application may be implemented by providing a computer readable storage medium. The computer readable storage medium has stored thereon computer program instructions; the computer program instructions, when executed by a processor, implement a method of isolating game logic in any of the above embodiments.
The technical features of the above-described embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above-described embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples merely represent a few embodiments of the present application, which are described in more detail and are not to be construed as limiting the scope of the invention. It should be noted that it would be apparent to those skilled in the art that various modifications and improvements could be made without departing from the spirit of the present application, which would be within the scope of the present application. Accordingly, the scope of protection of the present application is to be determined by the claims appended hereto.
Claims (10)
1. A method of isolating game logic for use with a server, the method comprising:
pre-creating an object pool, wherein the object pool comprises a preset number of idle objects, each idle object comprises a player unique identifier and a template class array, and the template class array supports a preset number of game logics;
pre-creating a preset number of threads, wherein the threads with numbers are provided with the preset number;
when a player is online, selecting an object from the idle objects, assigning a player unique identifier of the selected object by using a player ID of the player, and mapping the player ID to a thread with a corresponding number;
when a request for entering game logic is received, acquiring an object corresponding to the player ID from the object pool through a thread corresponding to the player ID, and searching the game logic corresponding to the request from the template class array of the object;
and executing the searched game logic.
2. The method of isolating game logic of claim 1, wherein the number of objects is configured according to a maximum value carried by the server.
3. The method of isolating game logic of claim 1, wherein the predetermined number of free objects are located in an array.
4. The method of isolating game logic according to claim 1, wherein an error capture mechanism is provided in each of said game logic for determining whether to force a kick player to go offline.
5. The method of isolating game logic of claim 4, wherein the error trapping mechanism is implemented by try in C language, try-catch in Python language, or xpcal in Lua language.
6. The method of isolating game logic of claim 4, wherein the error capture mechanism comprises:
if the following logic is illegal: when the memory is read or written, the memory is read or written to the wrong memory, or the array subscript crosses the boundary, or the divisor is 0, the player is forced to kick off the line.
7. The method of isolating game logic of claim 1, further comprising:
and releasing the selected object after the player gets off line, so that the object is restored to an idle state.
8. An apparatus for isolating game logic, comprising:
the system comprises an object pool creation module, a template class array and a game logic management module, wherein the object pool creation module is used for pre-creating an object pool, the object pool comprises a preset number of idle objects, each idle object comprises a player unique identifier and the template class array, and the template class array supports a preset number of game logics;
the thread creating module is used for pre-creating a preset number of threads, and the threads with the preset number are numbered;
the mapping module is used for selecting an object from the idle objects when a player is online, assigning the player unique identification of the selected object by using the player ID of the player, and mapping the player ID to a thread with a corresponding number;
the searching module is used for acquiring an object corresponding to the player ID from the object pool through a thread corresponding to the player ID when a request for entering game logic is received, and searching the game logic corresponding to the request from the template class array of the object;
and the execution module is used for executing the searched game logic.
9. An electronic device comprising a processor and a storage medium storing a computer program, wherein the computer program when executed by the processor implements a method of isolating game logic as claimed in any one of claims 1 to 7.
10. A computer readable storage medium having stored thereon a computer program, which when executed by a processor implements a method of isolating game logic according to any of claims 1 to 7.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202011326134.4A CN112473128B (en) | 2020-11-24 | 2020-11-24 | Method, apparatus, electronic device and storage medium for isolating game logic |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202011326134.4A CN112473128B (en) | 2020-11-24 | 2020-11-24 | Method, apparatus, electronic device and storage medium for isolating game logic |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN112473128A CN112473128A (en) | 2021-03-12 |
| CN112473128B true CN112473128B (en) | 2023-12-26 |
Family
ID=74933299
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202011326134.4A Active CN112473128B (en) | 2020-11-24 | 2020-11-24 | Method, apparatus, electronic device and storage medium for isolating game logic |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN112473128B (en) |
Families Citing this family (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN115445198B (en) * | 2022-09-15 | 2025-01-07 | 网易(杭州)网络有限公司 | Number generation method and device for game objects, computer equipment and storage medium |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US9569281B1 (en) * | 2015-08-13 | 2017-02-14 | International Business Machines Corporation | Dynamic synchronization object pool management |
| CN110058859A (en) * | 2018-01-18 | 2019-07-26 | 阿里巴巴集团控股有限公司 | Implementation method, device, equipment and the medium of program operation and virtual machine instance |
| CN111111215A (en) * | 2019-12-24 | 2020-05-08 | 北京像素软件科技股份有限公司 | Game matching method, device, server and readable storage medium |
| CN111273968A (en) * | 2020-01-17 | 2020-06-12 | 上海米哈游天命科技有限公司 | Object calling method, device, equipment and medium |
| CN111917852A (en) * | 2020-07-23 | 2020-11-10 | 上海珀立信息科技有限公司 | Multi-person network synchronization system based on Unity and development method |
Family Cites Families (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CA2302959A1 (en) * | 2000-03-23 | 2001-09-23 | Ibm Canada Limited-Ibm Canada Limitee | Priority resource allocation in programming environments |
-
2020
- 2020-11-24 CN CN202011326134.4A patent/CN112473128B/en active Active
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US9569281B1 (en) * | 2015-08-13 | 2017-02-14 | International Business Machines Corporation | Dynamic synchronization object pool management |
| CN110058859A (en) * | 2018-01-18 | 2019-07-26 | 阿里巴巴集团控股有限公司 | Implementation method, device, equipment and the medium of program operation and virtual machine instance |
| CN111111215A (en) * | 2019-12-24 | 2020-05-08 | 北京像素软件科技股份有限公司 | Game matching method, device, server and readable storage medium |
| CN111273968A (en) * | 2020-01-17 | 2020-06-12 | 上海米哈游天命科技有限公司 | Object calling method, device, equipment and medium |
| CN111917852A (en) * | 2020-07-23 | 2020-11-10 | 上海珀立信息科技有限公司 | Multi-person network synchronization system based on Unity and development method |
Also Published As
| Publication number | Publication date |
|---|---|
| CN112473128A (en) | 2021-03-12 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US20190163364A1 (en) | System and method for tcp offload for nvme over tcp-ip | |
| US9104813B2 (en) | Software installation method, apparatus and program product | |
| CN111258965B (en) | Data acquisition method and device, electronic equipment and storage medium | |
| US8347052B2 (en) | Initializing of a memory area | |
| KR102254159B1 (en) | Method for detecting real-time error in operating system kernel memory | |
| US11256444B2 (en) | Method for processing read/write data, apparatus, and computer readable storage medium thereof | |
| CN109416664B (en) | Systems, devices, and methods for enhanced address space layout randomization | |
| CN112473128B (en) | Method, apparatus, electronic device and storage medium for isolating game logic | |
| CN109446147B (en) | Data interaction method of network storage device and pcie device | |
| US20250199822A1 (en) | Asset loading accuracy through automatic correction of asset file paths | |
| JP4726915B2 (en) | Method and system for determining device criticality in a computer configuration | |
| US20200371882A1 (en) | Method, Apparatus, Device and Medium for Starting Virtual Machine | |
| CN110765125B (en) | Method and device for storing data | |
| US11868620B2 (en) | Read-write method and apparatus, electronic device, and readable memory medium | |
| CN111371818B (en) | Data request verification method, device and equipment | |
| US20190347194A1 (en) | Flash data compression decompression method and apparatus | |
| CN114116544A (en) | Method, device and equipment for acquiring slot information and storage medium | |
| CN112163242A (en) | Method for verifying disk data | |
| CN108052296B (en) | Data reading method and device and computer storage medium | |
| CN113553202B (en) | Verification method, device and storage medium for combined message sequence | |
| CN113703855B (en) | Random offset value storage method and device | |
| CN115037589A (en) | Configuration issuing method and device | |
| CN110213314B (en) | Method, device and server for determining storage node | |
| CN113535338A (en) | Interaction method, system, storage medium and electronic device for data access | |
| CN112328423A (en) | A processing method, device and storage medium for searching service loopholes |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |