1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-02-01 11:15:13 +01:00

Formatting

Margen67
2021-04-20 14:17:48 -10:00
parent d2a0826eaa
commit b11e6ae459

@@ -1,15 +1,12 @@
Game Actions are the replacement for [[Game Commands]]. Each game command has its own class. The action can then be issued by using either an Execute or a Query.
```
auto gameAction = PlaceParkEntranceAction(x, y, z, direction);
auto result = GameActions::Execute(&gameAction);
```
```
auto gameAction = PlaceParkEntranceAction(x, y, z, direction);
auto result = GameActions::Query(&gameAction);
```
The result of an Execute or Query is the same a `GameActionResult::Ptr`. This carries information such as success : `Error`, cost : `Cost`, location : `Position`.
When you call `GameActions::Execute` it works the same as a game command it will first Query the GameAction to confirm that it is possible before calling the Execute.
@@ -19,20 +16,15 @@ Flags can be passed into the GameAction with the `SetFlags` command. This is use
When a GameAction (or Game Command) needs to call into a GameAction this is called nesting. Instead of using the standard calls you need to use `QueryNested` or `ExecuteNested`. This is to prevent multiple game actions being issued on the network. A nested call will only be executed locally.
## GameAction Class
Below is an example GameAction class.
```
DEFINE_GAME_ACTION(ParkSetLoanAction, GAME_COMMAND_SET_CURRENT_LOAN, GameActionResult)
{
```
All GameActions use the `DEFINE_GAME_ACTION` macro to setup the class. The first parameter is the class name. The second is the GAME_COMMAND. The GAME_COMMAND is used to serialise and deserialise when sending over the network. The final parameter is the return class of the two main functions (Query and Execute). GameActionResult can be subclassed to return additional information.
```
private:
money32 _value;
```
All of the parameters for calling this GameAction have an internal class member.
```
@@ -53,7 +45,6 @@ A default constructor is required as networked versions of the GameAction pass i
}
```
To prevent duplicate code some flags such as `ALLOW_WHILE_PAUSED` and `EDITOR_ONLY` can be set here. This allows for much simpler structure of the Query and Execute.
```
void Serialise(DataSerialiser & stream) override
{