mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 19:13:07 +01:00
Use game action directly when used from different game command/action.
This commit is contained in:
committed by
Aaron van Geffen
parent
70ee22bbfa
commit
8cb76cd969
@@ -16,6 +16,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../core/MemoryStream.h"
|
||||
#include "../localisation/StringIds.h"
|
||||
#include "GameAction.h"
|
||||
@@ -62,9 +63,7 @@ public:
|
||||
|
||||
if (!map_is_location_valid(_x, _y))
|
||||
{
|
||||
res->Error = GA_ERROR::INVALID_PARAMETERS;
|
||||
res->ErrorMessage = STR_INVALID_SELECTION_OF_OBJECTS;
|
||||
return res;
|
||||
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS);
|
||||
}
|
||||
|
||||
const bool isGhost = GetFlags() & GAME_COMMAND_FLAG_GHOST;
|
||||
@@ -73,19 +72,13 @@ public:
|
||||
!gCheatsSandboxMode &&
|
||||
!map_is_location_owned(_x, _y, _baseHeight * 8))
|
||||
{
|
||||
res->Error = GA_ERROR::NOT_OWNED;
|
||||
res->ErrorMessage = STR_CANT_REMOVE_THIS;
|
||||
return res;
|
||||
return std::make_unique<GameActionResult>(GA_ERROR::NOT_OWNED, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK);
|
||||
}
|
||||
|
||||
rct_tile_element * wallElement = GetFirstWallElementAt(_x, _y, _baseHeight, _direction, isGhost);
|
||||
if (wallElement == nullptr)
|
||||
{
|
||||
// NOTE: There seems to be some oddities with calling code currently trying to
|
||||
// delete the same thing multiple times.
|
||||
res->Error = GA_ERROR::INVALID_PARAMETERS;
|
||||
res->ErrorMessage = STR_NONE;
|
||||
return res;
|
||||
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS);
|
||||
}
|
||||
|
||||
res->Cost = 0;
|
||||
@@ -103,9 +96,7 @@ public:
|
||||
rct_tile_element * wallElement = GetFirstWallElementAt(_x, _y, _baseHeight, _direction, isGhost);
|
||||
if (wallElement == nullptr)
|
||||
{
|
||||
res->Error = GA_ERROR::INVALID_PARAMETERS;
|
||||
res->ErrorMessage = STR_INVALID_SELECTION_OF_OBJECTS;
|
||||
return res;
|
||||
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS);
|
||||
}
|
||||
|
||||
res->Position.x = _x + 16;
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "../scenario/Scenario.h"
|
||||
#include "../util/Util.h"
|
||||
#include "../windows/Intent.h"
|
||||
#include "../actions/WallRemoveAction.hpp"
|
||||
#include "Banner.h"
|
||||
#include "Climate.h"
|
||||
#include "Footpath.h"
|
||||
@@ -1123,22 +1124,18 @@ restart_from_beginning:
|
||||
|
||||
} break;
|
||||
case TILE_ELEMENT_TYPE_WALL:
|
||||
if (clear & (1 << 0)) {
|
||||
cost = wall_remove(x * 32, y * 32, tileElement->base_height, tile_element_get_direction(tileElement), flags);
|
||||
if (cost == MONEY32_UNDEFINED)
|
||||
return MONEY32_UNDEFINED;
|
||||
|
||||
totalCost += cost;
|
||||
|
||||
// NOTE (12/10/2017): This will get us stuck in an infinite loop because game actions are queued
|
||||
// it seems to be trying to remove the same thing over and over.
|
||||
// Leaving this here for reference.
|
||||
/*
|
||||
if (flags & 1)
|
||||
goto restart_from_beginning;
|
||||
*/
|
||||
|
||||
} break;
|
||||
if (clear & (1 << 0))
|
||||
{
|
||||
// NOTE: We execute the game action directly as this function is already called from such.
|
||||
auto wallRemoveAction = WallRemoveAction(x * 32, y * 32, tileElement->base_height, tile_element_get_direction(tileElement));
|
||||
wallRemoveAction.SetFlags(flags);
|
||||
auto res = ((flags & GAME_COMMAND_FLAG_APPLY) ? wallRemoveAction.Execute() : wallRemoveAction.Query());
|
||||
if (res->Error == GA_ERROR::OK)
|
||||
{
|
||||
totalCost += res->Cost;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TILE_ELEMENT_TYPE_LARGE_SCENERY:
|
||||
if (clear & (1 << 1)) {
|
||||
sint32 eax = x * 32;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "../object/ObjectList.h"
|
||||
#include "../object/ObjectManager.h"
|
||||
#include "../scenario/Scenario.h"
|
||||
#include "../actions/WallRemoveAction.hpp"
|
||||
#include "Climate.h"
|
||||
#include "Footpath.h"
|
||||
#include "Fountain.h"
|
||||
@@ -243,10 +244,13 @@ void scenery_remove_ghost_tool_placement(){
|
||||
} while (!tile_element_is_last_for_tile(tile_element++));
|
||||
}
|
||||
|
||||
if (gSceneryGhostType & SCENERY_ENTRY_FLAG_2){
|
||||
if (gSceneryGhostType & SCENERY_ENTRY_FLAG_2)
|
||||
{
|
||||
gSceneryGhostType &= ~SCENERY_ENTRY_FLAG_2;
|
||||
const sint32 flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_PATH_SCENERY;
|
||||
wall_remove(x, y, gSceneryGhostWallRotation, z, flags);
|
||||
|
||||
auto wallRemoveAction = WallRemoveAction(x, y, z, gSceneryGhostWallRotation);
|
||||
wallRemoveAction.SetFlags(GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_PATH_SCENERY);
|
||||
wallRemoveAction.Execute();
|
||||
}
|
||||
|
||||
if (gSceneryGhostType & SCENERY_ENTRY_FLAG_3){
|
||||
|
||||
Reference in New Issue
Block a user