diff --git a/Converting-Game-Commands-to-Game-Actions.md b/Converting-Game-Commands-to-Game-Actions.md index 787adba..3878871 100644 --- a/Converting-Game-Commands-to-Game-Actions.md +++ b/Converting-Game-Commands-to-Game-Actions.md @@ -39,7 +39,7 @@ public: GameActionResult::Ptr Execute() const override { - + } }; ``` @@ -54,12 +54,12 @@ Register(); ## Work out the Parameters Have a look at the game command and make a list of all of the parameters. -1. int32_t x0, -2. int32_t y0, -3. int32_t x1, -4. int32_t y1, -5. uint8_t surfaceStyle, -6. uint8_t edgeStyle, +1. int32_t x0, +2. int32_t y0, +3. int32_t x1, +4. int32_t y1, +5. uint8_t surfaceStyle, +6. uint8_t edgeStyle, 7. uint8_t flags Parameter 1-4 is a map range and should use `struct MapRange`. Parameter 5-6 are the styles that are set, both are required in our action. Parameter 7 is the flags, this is no longer passed directly into the function and is therefore not required. @@ -114,7 +114,7 @@ I like to create the query function by copying and pasting the game command dire gCommandPosition.x = xMid; gCommandPosition.y = yMid; - gCommandPosition.z = heightMid; + gCommandPosition.z = heightMid; // This section defines where command took place it will be placed in the result. ``` New code. @@ -218,18 +218,18 @@ The rest of the function is hard to follow if broken up so consider it as a whol { for (int32_t y = y0; y <= y1; y += 32) { - if (x > 0x1FFF) // This should never happen as range is already verified and normalised + if (x > 0x1FFF) // This should never happen as range is already verified and normalised continue; if (y > 0x1FFF) continue; if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode) { - if (!map_is_location_in_park({ x, y })) + if (!map_is_location_in_park({ x, y })) continue; // This function actually checks the range again just to be really sure } - auto surfaceElement = map_get_surface_element_at({ x, y })->AsSurface(); + auto surfaceElement = map_get_surface_element_at({ x, y })->AsSurface(); // This is dangerous potential null deref. Except we have triple checked range is valid. if (surfaceElement == nullptr) { @@ -389,7 +389,7 @@ We can then go into the main for loop. for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += 32) { auto tileElement = map_get_surface_element_at({ x, y }); - if (tileElement == nullptr) // Nullptr checks should always be kept + if (tileElement == nullptr) // Nullptr checks should always be kept { continue; }