Fix #3832: Track piece colour scheme paint not network-safe

This commit is contained in:
Michael Steenbeek 2018-12-11 22:17:52 +01:00 committed by GitHub
parent 23dc14b286
commit cf44ea7e24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 86 additions and 4 deletions

View File

@ -3721,6 +3721,7 @@ STR_6270 :Terrain Surfaces
STR_6271 :Terrain Edges
STR_6272 :Stations
STR_6273 :Music
STR_6274 :Can't set colour scheme...
#############
# Scenarios #

View File

@ -15,6 +15,7 @@
- Feature: [#8259] Add say command to in-game console.
- Change: [#7961] Add new object types: station, terrain surface, and terrain edge.
- Change: [#8222] The climate setting has been moved from objective options to scenario options.
- Fix: [#3832] Changing the colour scheme of track pieces does not work in multiplayer.
- Fix: [#6191] OpenRCT2 fails to run when the path has an emoji in it.
- Fix: [#7439] Placement messages have mixed strings
- Fix: [#7473] Disabling sound effects also disables "Disable audio on focus loss".

View File

@ -22,6 +22,8 @@
#include <openrct2/Game.h>
#include <openrct2/Input.h>
#include <openrct2/OpenRCT2.h>
#include <openrct2/actions/GameAction.h>
#include <openrct2/actions/RideSetColourScheme.hpp>
#include <openrct2/audio/audio.h>
#include <openrct2/config/Config.h>
#include <openrct2/localisation/Date.h>
@ -4286,7 +4288,8 @@ static void window_ride_set_track_colour_scheme(rct_window* w, int32_t x, int32_
z = tileElement->base_height * 8;
direction = tileElement->GetDirection();
sub_6C683D(&x, &y, &z, direction, tileElement->AsTrack()->GetTrackType(), newColourScheme, nullptr, 4);
auto gameAction = RideSetColourSchemeAction(x, y, z, direction, tileElement->AsTrack()->GetTrackType(), newColourScheme);
GameActions::Execute(&gameAction);
}
/**

View File

@ -88,8 +88,9 @@ enum GAME_COMMAND
GAME_COMMAND_BALLOON_PRESS,
GAME_COMMAND_MODIFY_TILE,
GAME_COMMAND_EDIT_SCENARIO_OPTIONS,
GAME_COMMAND_PLACE_PEEP_SPAWN, // GA, TODO: refactor to separate array for just game actions
GAME_COMMAND_SET_CLIMATE, // GA
GAME_COMMAND_PLACE_PEEP_SPAWN, // GA, TODO: refactor to separate array for just game actions
GAME_COMMAND_SET_CLIMATE, // GA
GAME_COMMAND_SET_COLOUR_SCHEME, // GA
GAME_COMMAND_COUNT,
};

View File

@ -21,6 +21,7 @@
#include "PlacePeepSpawnAction.hpp"
#include "RideCreateAction.hpp"
#include "RideDemolishAction.hpp"
#include "RideSetColourScheme.hpp"
#include "RideSetName.hpp"
#include "RideSetStatus.hpp"
#include "SetParkEntranceFeeAction.hpp"
@ -46,6 +47,7 @@ namespace GameActions
Register<PlacePeepSpawnAction>();
Register<RideCreateAction>();
Register<RideDemolishAction>();
Register<RideSetColourSchemeAction>();
Register<RideSetNameAction>();
Register<RideSetStatusAction>();
Register<SetParkEntranceFeeAction>();

View File

@ -0,0 +1,71 @@
/*****************************************************************************
* Copyright (c) 2014-2018 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 "../Cheats.h"
#include "../common.h"
#include "../core/MemoryStream.h"
#include "../interface/Window.h"
#include "../localisation/Localisation.h"
#include "../localisation/StringIds.h"
#include "../management/Finance.h"
#include "../ride/Ride.h"
#include "../world/Park.h"
#include "../world/Sprite.h"
#include "GameAction.h"
struct RideSetColourSchemeAction : public GameActionBase<GAME_COMMAND_SET_COLOUR_SCHEME, GameActionResult>
{
private:
int32_t _x = 0, _y = 0, _z = 0, _direction = 0, _trackType = 0;
uint16_t _newColourScheme = 0;
public:
RideSetColourSchemeAction() = default;
RideSetColourSchemeAction(int32_t x, int32_t y, int32_t z, int32_t direction, int32_t trackType, uint16_t newColourScheme)
: _x(x)
, _y(y)
, _z(z)
, _direction(direction)
, _trackType(trackType)
, _newColourScheme(newColourScheme)
{
}
uint16_t GetActionFlags() const override
{
return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED;
}
void Serialise(DataSerialiser& stream) override
{
GameAction::Serialise(stream);
stream << DS_TAG(_x) << DS_TAG(_y) << DS_TAG(_z) << DS_TAG(_direction) << DS_TAG(_trackType)
<< DS_TAG(_newColourScheme);
}
GameActionResult::Ptr Query() const override
{
return std::make_unique<GameActionResult>();
}
GameActionResult::Ptr Execute() const override
{
GameActionResult::Ptr res = std::make_unique<GameActionResult>();
res->ExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION;
res->ErrorTitle = STR_CANT_SET_COLOUR_SCHEME;
int32_t x = _x, y = _y, z = _z;
sub_6C683D(&x, &y, &z, _direction, _trackType, _newColourScheme, nullptr, 4);
return res;
}
};

View File

@ -3891,6 +3891,8 @@ enum
STR_OBJECT_SELECTION_STATIONS = 6272,
STR_OBJECT_SELECTION_MUSIC = 6273,
STR_CANT_SET_COLOUR_SCHEME = 6274,
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working
STR_COUNT = 32768
};

View File

@ -30,7 +30,7 @@
// This string specifies which version of network stream current build uses.
// It is used for making sure only compatible builds get connected, even within
// single OpenRCT2 version.
#define NETWORK_STREAM_VERSION "12"
#define NETWORK_STREAM_VERSION "13"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
static rct_peep* _pickup_peep = nullptr;

View File

@ -120,6 +120,7 @@ const std::vector<NetworkAction> NetworkActions::Actions = {
GAME_COMMAND_SET_RIDE_SETTING,
GAME_COMMAND_SET_RIDE_PRICE,
GAME_COMMAND_SET_BRAKES_SPEED,
GAME_COMMAND_SET_COLOUR_SCHEME,
},
},
{