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

Implement wall set colour action

This commit is contained in:
duncanspumpkin
2019-04-06 19:36:44 +01:00
parent 8fc1d70239
commit 8ef5afe2ce
7 changed files with 173 additions and 67 deletions

View File

@@ -36,6 +36,7 @@
#include <openrct2/actions/SmallScenerySetColourAction.hpp>
#include <openrct2/actions/SurfaceSetStyleAction.hpp>
#include <openrct2/actions/WallPlaceAction.hpp>
#include <openrct2/actions/WallSetColourAction.hpp>
#include <openrct2/actions/WaterLowerAction.hpp>
#include <openrct2/actions/WaterRaiseAction.hpp>
#include <openrct2/audio/audio.h>
@@ -1026,11 +1027,11 @@ static void repaint_scenery_tool_down(int16_t x, int16_t y, rct_widgetindex widg
if (!(scenery_entry->wall.flags & (WALL_SCENERY_HAS_PRIMARY_COLOUR | WALL_SCENERY_HAS_GLASS)))
return;
gGameCommandErrorTitle = STR_CANT_REPAINT_THIS;
game_do_command(
grid_x, 1 | (gWindowSceneryPrimaryColour << 8), grid_y,
tile_element->GetDirection() | (tile_element->base_height << 8), GAME_COMMAND_SET_WALL_COLOUR, 0,
gWindowScenerySecondaryColour | (gWindowSceneryTertiaryColour << 8));
auto repaintScenery = WallSetColourAction(
{ grid_x, grid_y, tile_element->base_height * 8, tile_element->GetDirection() }, gWindowSceneryPrimaryColour,
gWindowScenerySecondaryColour, gWindowSceneryTertiaryColour);
GameActions::Execute(&repaintScenery);
break;
}
case VIEWPORT_INTERACTION_ITEM_LARGE_SCENERY:

View File

@@ -644,8 +644,8 @@ void game_log_multiplayer_command(int command, const int* eax, const int* ebx, c
network_append_server_log(log_msg);
}
else if (
command == GAME_COMMAND_SET_WALL_COLOUR || command == GAME_COMMAND_SET_LARGE_SCENERY_COLOUR
|| command == GAME_COMMAND_SET_BANNER_COLOUR || command == GAME_COMMAND_SET_BANNER_STYLE)
command == GAME_COMMAND_SET_LARGE_SCENERY_COLOUR || command == GAME_COMMAND_SET_BANNER_COLOUR
|| command == GAME_COMMAND_SET_BANNER_STYLE)
{
// Log editing scenery
char* args[1] = {
@@ -1292,7 +1292,7 @@ GAME_COMMAND_POINTER* new_game_command_table[GAME_COMMAND_COUNT] = {
game_command_place_banner,
game_command_remove_banner,
nullptr,
game_command_set_wall_colour,
nullptr,
game_command_set_large_scenery_colour,
game_command_set_banner_colour,
game_command_set_land_ownership,

View File

@@ -72,7 +72,7 @@ enum GAME_COMMAND
GAME_COMMAND_PLACE_BANNER,
GAME_COMMAND_REMOVE_BANNER,
GAME_COMMAND_SET_SCENERY_COLOUR, // GA
GAME_COMMAND_SET_WALL_COLOUR,
GAME_COMMAND_SET_WALL_COLOUR, // GA
GAME_COMMAND_SET_LARGE_SCENERY_COLOUR,
GAME_COMMAND_SET_BANNER_COLOUR,
GAME_COMMAND_SET_LAND_OWNERSHIP,

View File

@@ -65,6 +65,7 @@
#include "TrackSetBrakeSpeedAction.hpp"
#include "WallPlaceAction.hpp"
#include "WallRemoveAction.hpp"
#include "WallSetColourAction.hpp"
#include "WaterLowerAction.hpp"
#include "WaterRaiseAction.hpp"
#include "WaterSetHeightAction.hpp"
@@ -114,6 +115,7 @@ namespace GameActions
Register<SurfaceSetStyleAction>();
Register<WallPlaceAction>();
Register<WallRemoveAction>();
Register<WallSetColourAction>();
Register<SmallSceneryPlaceAction>();
Register<SmallSceneryRemoveAction>();
Register<SmallScenerySetColourAction>();

View File

@@ -0,0 +1,161 @@
/*****************************************************************************
* Copyright (c) 2014-2019 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#pragma once
#include "../OpenRCT2.h"
#include "../management/Finance.h"
#include "../ride/RideGroupManager.h"
#include "../ride/Track.h"
#include "../ride/TrackData.h"
#include "../world/Banner.h"
#include "../world/LargeScenery.h"
#include "../world/MapAnimation.h"
#include "../world/Scenery.h"
#include "../world/SmallScenery.h"
#include "../world/Surface.h"
#include "GameAction.h"
DEFINE_GAME_ACTION(WallSetColourAction, GAME_COMMAND_SET_WALL_COLOUR, GameActionResult)
{
private:
CoordsXYZD _loc;
int32_t _primaryColour;
int32_t _secondaryColour;
int32_t _tertiaryColour;
public:
WallSetColourAction()
{
}
WallSetColourAction(CoordsXYZD loc, int32_t primaryColour, int32_t secondaryColour, int32_t tertiaryColour)
: _loc(loc)
, _primaryColour(primaryColour)
, _secondaryColour(secondaryColour)
, _tertiaryColour(tertiaryColour)
{
}
uint16_t GetActionFlags() const override
{
return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED;
}
void Serialise(DataSerialiser & stream) override
{
GameAction::Serialise(stream);
stream << DS_TAG(_loc) << DS_TAG(_primaryColour) << DS_TAG(_secondaryColour) << DS_TAG(_tertiaryColour);
}
GameActionResult::Ptr Query() const override
{
auto res = MakeResult();
res->ErrorTitle = STR_CANT_REPAINT_THIS;
res->Position.x = _loc.x + 16;
res->Position.y = _loc.y + 16;
res->Position.z = _loc.z;
res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING;
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !map_is_location_in_park({ _loc.x, _loc.y })
&& !gCheatsSandboxMode)
{
return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK);
}
auto wallElement = map_get_wall_element_at(_loc.x, _loc.y, _loc.z / 8, _loc.direction);
if (wallElement == nullptr)
{
log_error(
"Could not find wall element at: x = %d, y = %d, z = %d, direction = %u", _loc.x, _loc.y, _loc.z,
_loc.direction);
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REPAINT_THIS);
}
if ((GetFlags() & GAME_COMMAND_FLAG_GHOST) && !(wallElement->IsGhost()))
{
return res;
}
rct_scenery_entry* sceneryEntry = wallElement->GetEntry();
if (sceneryEntry == nullptr)
{
log_error("Could not find wall object");
return MakeResult(GA_ERROR::UNKNOWN, STR_CANT_REPAINT_THIS);
}
if (_primaryColour > 31)
{
log_error("Primary colour invalid: colour = %d", _primaryColour);
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REPAINT_THIS);
}
if (_secondaryColour > 31)
{
log_error("Secondary colour invalid: colour = %d", _secondaryColour);
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REPAINT_THIS);
}
if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR)
{
if (_tertiaryColour > 31)
{
log_error("Tertiary colour invalid: colour = %d", _tertiaryColour);
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REPAINT_THIS);
}
}
return res;
}
GameActionResult::Ptr Execute() const override
{
auto res = MakeResult();
res->ErrorTitle = STR_CANT_REPAINT_THIS;
res->Position.x = _loc.x + 16;
res->Position.y = _loc.y + 16;
res->Position.z = _loc.z;
res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING;
auto wallElement = map_get_wall_element_at(_loc.x, _loc.y, _loc.z / 8, _loc.direction);
if (wallElement == nullptr)
{
log_error(
"Could not find wall element at: x = %d, y = %d, z = %d, direction = %u", _loc.x, _loc.y, _loc.z,
_loc.direction);
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REPAINT_THIS);
}
if ((GetFlags() & GAME_COMMAND_FLAG_GHOST) && !(wallElement->IsGhost()))
{
return res;
}
rct_scenery_entry* sceneryEntry = wallElement->GetEntry();
if (sceneryEntry == nullptr)
{
log_error("Could not find wall object");
return MakeResult(GA_ERROR::UNKNOWN, STR_CANT_REPAINT_THIS);
}
wallElement->SetPrimaryColour(_primaryColour);
wallElement->SetSecondaryColour(_secondaryColour);
if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR)
{
wallElement->SetTertiaryColour(_tertiaryColour);
}
map_invalidate_tile_zoom1(_loc.x, _loc.y, _loc.z, _loc.z + 72);
return res;
}
private:
};

View File

@@ -191,8 +191,6 @@ void game_command_set_land_ownership(
int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp);
void game_command_remove_banner(
int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp);
void game_command_set_wall_colour(
int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp);
void game_command_set_large_scenery_colour(
int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp);
void game_command_set_banner_colour(

View File

@@ -29,49 +29,6 @@
#include "Surface.h"
#include "Wall.h"
static money32 WallSetColour(
int16_t x, int16_t y, uint8_t baseHeight, uint8_t direction, uint8_t primaryColour, uint8_t secondaryColour,
uint8_t tertiaryColour, uint8_t flags)
{
gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING;
int32_t z = baseHeight * 8;
gCommandPosition.x = x + 16;
gCommandPosition.y = y + 16;
gCommandPosition.z = z;
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !map_is_location_in_park({ x, y }) && !gCheatsSandboxMode)
{
return MONEY32_UNDEFINED;
}
auto wallElement = map_get_wall_element_at(x, y, baseHeight, direction);
if (wallElement == nullptr)
{
return 0;
}
if ((flags & GAME_COMMAND_FLAG_GHOST) && !(wallElement->IsGhost()))
{
return 0;
}
if (flags & GAME_COMMAND_FLAG_APPLY)
{
rct_scenery_entry* scenery_entry = wallElement->GetEntry();
wallElement->SetPrimaryColour(primaryColour);
wallElement->SetSecondaryColour(secondaryColour);
if (scenery_entry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR)
{
wallElement->SetTertiaryColour(tertiaryColour);
}
map_invalidate_tile_zoom1(x, y, z, z + 72);
}
return 0;
}
/**
*
* rct2: 0x006E588E
@@ -136,19 +93,6 @@ void wall_remove_intersecting_walls(int32_t x, int32_t y, int32_t z0, int32_t z1
} while (!(tileElement++)->IsLastForTile());
}
/**
*
* rct2: 0x006E56B5
*/
void game_command_set_wall_colour(
int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, [[maybe_unused]] int32_t* esi, [[maybe_unused]] int32_t* edi,
int32_t* ebp)
{
*ebx = WallSetColour(
*eax & 0xFFFF, *ecx & 0xFFFF, (*edx >> 8) & 0xFF, *edx & 0xFF, (*ebx >> 8) & 0xFF, *ebp & 0xFF, (*ebp >> 8) & 0xFF,
*ebx & 0xFF);
}
uint8_t WallElement::GetSlope() const
{
return (type & TILE_ELEMENT_QUADRANT_MASK) >> 6;