clang-format game actions

This commit is contained in:
clang-format authored and Hielke Morsink committed 2018-07-23 15:58:01 +02:00
1 parent 42fa1b0f63
commit 90f1a328ab
21 files changed
+726 -703

No files matched your search

+9 -7
View File
@@ -15,9 +15,9 @@
#include "../localisation/Localisation.h"
#include "../localisation/StringIds.h"
#include "../ui/UiContext.h"
#include "../world/Sprite.h"
#include "../world/Banner.h"
#include "../windows/Intent.h"
#include "../world/Banner.h"
#include "../world/Sprite.h"
#include "GameAction.h"
struct BannerSetNameAction : public GameActionBase<GAME_COMMAND_SET_BANNER_NAME, GameActionResult>
@@ -27,10 +27,12 @@ private:
std::string _name;
public:
BannerSetNameAction() {}
BannerSetNameAction()
{
}
BannerSetNameAction(BannerIndex bannerIndex, const std::string& name)
: _bannerIndex(bannerIndex),
_name(name)
: _bannerIndex(bannerIndex)
, _name(name)
{
}
@@ -71,8 +73,8 @@ public:
{
rct_banner* banner = &gBanners[_bannerIndex];
utf8 *buffer = gCommonStringFormatBuffer;
utf8 *dst = buffer;
utf8* buffer = gCommonStringFormatBuffer;
utf8* dst = buffer;
dst = utf8_write_codepoint(dst, FORMAT_COLOUR_CODE_START + banner->text_colour);
String::Set(dst, sizeof(gCommonStringFormatBuffer) - (dst - buffer), _name.c_str(), _name.size());
+24 -20
View File
@@ -7,7 +7,8 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include <algorithm>
#include "GameAction.h"
#include "../Context.h"
#include "../core/Guard.hpp"
#include "../core/Memory.hpp"
@@ -18,7 +19,8 @@
#include "../platform/platform.h"
#include "../scenario/Scenario.h"
#include "../world/Park.h"
#include "GameAction.h"
#include <algorithm>
GameActionResult::GameActionResult(GA_ERROR error, rct_string_id message)
{
@@ -33,7 +35,7 @@ GameActionResult::GameActionResult(GA_ERROR error, rct_string_id title, rct_stri
ErrorMessage = message;
}
GameActionResult::GameActionResult(GA_ERROR error, rct_string_id title, rct_string_id message, uint8_t * args)
GameActionResult::GameActionResult(GA_ERROR error, rct_string_id title, rct_string_id message, uint8_t* args)
{
Error = error;
ErrorTitle = title;
@@ -69,7 +71,7 @@ namespace GameActions
{
Initialize();
GameAction * result = nullptr;
GameAction* result = nullptr;
if (id < Util::CountOf(_actions))
{
GameActionFactory factory = _actions[id];
@@ -84,21 +86,27 @@ namespace GameActions
static bool CheckActionInPausedMode(uint32_t actionFlags)
{
if (gGamePaused == 0) return true;
if (gCheatsBuildInPauseMode) return true;
if (actionFlags & GA_FLAGS::ALLOW_WHILE_PAUSED) return true;
if (gGamePaused == 0)
return true;
if (gCheatsBuildInPauseMode)
return true;
if (actionFlags & GA_FLAGS::ALLOW_WHILE_PAUSED)
return true;
return false;
}
static bool CheckActionAffordability(const GameActionResult * result)
static bool CheckActionAffordability(const GameActionResult* result)
{
if (gParkFlags & PARK_FLAGS_NO_MONEY) return true;
if (result->Cost <= 0) return true;
if (result->Cost <= gCash) return true;
if (gParkFlags & PARK_FLAGS_NO_MONEY)
return true;
if (result->Cost <= 0)
return true;
if (result->Cost <= gCash)
return true;
return false;
}
GameActionResult::Ptr Query(const GameAction * action)
GameActionResult::Ptr Query(const GameAction* action)
{
Guard::ArgumentNotNull(action);
@@ -131,7 +139,7 @@ namespace GameActions
return result;
}
GameActionResult::Ptr Execute(const GameAction * action)
GameActionResult::Ptr Execute(const GameAction* action)
{
Guard::ArgumentNotNull(action);
@@ -177,10 +185,8 @@ namespace GameActions
gCommandPosition.z = result->Position.z;
// Update money balance
if (!(gParkFlags & PARK_FLAGS_NO_MONEY) &&
!(flags & GAME_COMMAND_FLAG_GHOST) &&
!(flags & GAME_COMMAND_FLAG_5) &&
result->Cost != 0)
if (!(gParkFlags & PARK_FLAGS_NO_MONEY) && !(flags & GAME_COMMAND_FLAG_GHOST) && !(flags & GAME_COMMAND_FLAG_5)
&& result->Cost != 0)
{
finance_payment(result->Cost, result->ExpenditureType);
money_effect_create(result->Cost);
@@ -214,9 +220,7 @@ namespace GameActions
cb(action, result.get());
}
if (result->Error != GA_ERROR::OK &&
!(flags & GAME_COMMAND_FLAG_GHOST) &&
!(flags & GAME_COMMAND_FLAG_5))
if (result->Error != GA_ERROR::OK && !(flags & GAME_COMMAND_FLAG_GHOST) && !(flags & GAME_COMMAND_FLAG_5))
{
// Show the error box
std::copy(result->ErrorMessageArgs.begin(), result->ErrorMessageArgs.end(), gCommonFormatArgs);
+48 -57
View File
@@ -9,19 +9,18 @@
#pragma once
#include "../Game.h"
#include "../common.h"
#include "../core/DataSerialiser.h"
#include "../core/IStream.hpp"
#include "../localisation/StringIds.h"
#include "../world/Map.h"
#include <array>
#include <functional>
#include <memory>
#include <utility>
#include "../common.h"
#include "../core/DataSerialiser.h"
#include "../core/IStream.hpp"
#include "../Game.h"
#include "../localisation/StringIds.h"
#include "../world/Map.h"
/**
* Common error codes for game actions.
*/
@@ -48,9 +47,9 @@ enum class GA_ERROR : uint16_t
namespace GA_FLAGS
{
constexpr uint16_t ALLOW_WHILE_PAUSED = 1 << 0;
constexpr uint16_t CLIENT_ONLY = 1 << 1;
constexpr uint16_t EDITOR_ONLY = 1 << 2;
}
constexpr uint16_t CLIENT_ONLY = 1 << 1;
constexpr uint16_t EDITOR_ONLY = 1 << 2;
} // namespace GA_FLAGS
#ifdef __WARN_SUGGEST_FINAL_METHODS__
#pragma GCC diagnostic push
@@ -66,34 +65,34 @@ class GameActionResult
public:
using Ptr = std::unique_ptr<GameActionResult>;
GA_ERROR Error = GA_ERROR::OK;
rct_string_id ErrorTitle = STR_NONE;
rct_string_id ErrorMessage = STR_NONE;
std::array<uint8_t, 12> ErrorMessageArgs;
CoordsXYZ Position = {};
money32 Cost = 0;
uint16_t ExpenditureType = 0;
GA_ERROR Error = GA_ERROR::OK;
rct_string_id ErrorTitle = STR_NONE;
rct_string_id ErrorMessage = STR_NONE;
std::array<uint8_t, 12> ErrorMessageArgs;
CoordsXYZ Position = {};
money32 Cost = 0;
uint16_t ExpenditureType = 0;
GameActionResult() = default;
GameActionResult(GA_ERROR error, rct_string_id message);
GameActionResult(GA_ERROR error, rct_string_id title, rct_string_id message);
GameActionResult(GA_ERROR error, rct_string_id title, rct_string_id message, uint8_t * args);
GameActionResult(GA_ERROR error, rct_string_id title, rct_string_id message, uint8_t* args);
GameActionResult(const GameActionResult&) = delete;
virtual ~GameActionResult() {};
virtual ~GameActionResult(){};
};
struct GameAction
{
public:
using Ptr = std::unique_ptr<GameAction>;
using Callback_t = std::function<void(const struct GameAction *, const GameActionResult *)>;
using Ptr = std::unique_ptr<GameAction>;
using Callback_t = std::function<void(const struct GameAction*, const GameActionResult*)>;
private:
uint32_t const _type;
uint32_t _playerId = 0; // Callee
uint32_t _flags = 0; // GAME_COMMAND_FLAGS
uint32_t _networkId = 0;
uint32_t _playerId = 0; // Callee
uint32_t _flags = 0; // GAME_COMMAND_FLAGS
uint32_t _networkId = 0;
Callback_t _callback;
public:
@@ -115,13 +114,12 @@ public:
}
/**
* Gets the GA_FLAGS flags that are enabled for this game action.
*/
* Gets the GA_FLAGS flags that are enabled for this game action.
*/
virtual uint16_t GetActionFlags() const
{
// Make sure we execute some things only on the client.
if ((GetFlags() & GAME_COMMAND_FLAG_GHOST) != 0 ||
(GetFlags() & GAME_COMMAND_FLAG_5) != 0)
if ((GetFlags() & GAME_COMMAND_FLAG_GHOST) != 0 || (GetFlags() & GAME_COMMAND_FLAG_5) != 0)
{
return GA_FLAGS::CLIENT_ONLY;
}
@@ -130,8 +128,8 @@ public:
}
/**
* Currently used for GAME_COMMAND_FLAGS, needs refactoring once everything is replaced.
*/
* Currently used for GAME_COMMAND_FLAGS, needs refactoring once everything is replaced.
*/
uint32_t GetFlags() const
{
return _flags;
@@ -152,7 +150,7 @@ public:
_callback = cb;
}
const Callback_t & GetCallback() const
const Callback_t& GetCallback() const
{
return _callback;
}
@@ -181,13 +179,13 @@ public:
}
/**
* Query the result of the game action without changing the game state.
*/
* Query the result of the game action without changing the game state.
*/
virtual GameActionResult::Ptr Query() const abstract;
/**
* Apply the game action and change the game state.
*/
* Apply the game action and change the game state.
*/
virtual GameActionResult::Ptr Execute() const abstract;
};
@@ -195,8 +193,7 @@ public:
#pragma GCC diagnostic pop
#endif
template<uint32_t TType, typename TResultType>
struct GameActionBase : GameAction
template<uint32_t TType, typename TResultType> struct GameActionBase : GameAction
{
public:
using Result = TResultType;
@@ -208,40 +205,34 @@ public:
{
}
void SetCallback(std::function<void(const struct GameAction *, const TResultType *)> typedCallback)
void SetCallback(std::function<void(const struct GameAction*, const TResultType*)> typedCallback)
{
GameAction::SetCallback([typedCallback](const GameAction * ga, const GameActionResult * result)
{
typedCallback(ga, static_cast<const TResultType *>(result));
GameAction::SetCallback([typedCallback](const GameAction* ga, const GameActionResult* result) {
typedCallback(ga, static_cast<const TResultType*>(result));
});
}
protected:
template<class... TTypes>
static constexpr std::unique_ptr<TResultType> MakeResult(TTypes&&... args)
template<class... TTypes> static constexpr std::unique_ptr<TResultType> MakeResult(TTypes&&... args)
{
return std::make_unique<TResultType>(std::forward<TTypes>(args)...);
}
};
using GameActionFactory = GameAction *(*)();
using GameActionFactory = GameAction* (*)();
namespace GameActions
{
void Initialize();
void Register();
GameAction::Ptr Create(uint32_t id);
GameActionResult::Ptr Query(const GameAction * action);
GameActionResult::Ptr Execute(const GameAction * action);
GameActionFactory Register(uint32_t id, GameActionFactory action);
void Initialize();
void Register();
GameAction::Ptr Create(uint32_t id);
GameActionResult::Ptr Query(const GameAction* action);
GameActionResult::Ptr Execute(const GameAction* action);
GameActionFactory Register(uint32_t id, GameActionFactory action);
template<typename T>
static GameActionFactory Register()
template<typename T> static GameActionFactory Register()
{
GameActionFactory factory = []() -> GameAction *
{
return new T();
};
GameActionFactory factory = []() -> GameAction* { return new T(); };
Register(T::TYPE, factory);
return factory;
}
+267 -260
View File
@@ -9,332 +9,339 @@
#include "GameAction.h"
#include "GuestSetNameAction.hpp"
#include "MazeSetTrackAction.hpp"
#include "PlaceParkEntranceAction.hpp"
#include "PlacePeepSpawnAction.hpp"
#include "RideCreateAction.hpp"
#include "RideDemolishAction.hpp"
#include "RideSetName.hpp"
#include "RideSetStatus.hpp"
#include "SetParkEntranceFeeAction.hpp"
#include "StaffSetNameAction.hpp"
#include "RideCreateAction.hpp"
#include "RideSetStatus.hpp"
#include "RideSetName.hpp"
#include "RideDemolishAction.hpp"
#include "PlacePeepSpawnAction.hpp"
#include "MazeSetTrackAction.hpp"
#include "WallRemoveAction.hpp"
#pragma region PlaceParkEntranceAction
money32 place_park_entrance(int16_t x, int16_t y, int16_t z, uint8_t direction)
money32 place_park_entrance(int16_t x, int16_t y, int16_t z, uint8_t direction)
{
auto gameAction = PlaceParkEntranceAction(x, y, z, direction);
auto result = GameActions::Execute(&gameAction);
if (result->Error == GA_ERROR::OK)
{
auto gameAction = PlaceParkEntranceAction(x, y, z, direction);
auto result = GameActions::Execute(&gameAction);
if (result->Error == GA_ERROR::OK)
{
return 0;
}
else
{
return MONEY32_UNDEFINED;
}
return 0;
}
/**
*
* rct2: 0x006666E7
*/
void game_command_place_park_entrance(
[[maybe_unused]] int32_t * eax,
[[maybe_unused]] int32_t * ebx,
[[maybe_unused]] int32_t * ecx,
[[maybe_unused]] int32_t * edx,
[[maybe_unused]] int32_t * esi,
[[maybe_unused]] int32_t * edi,
[[maybe_unused]] int32_t * ebp)
else
{
Guard::Assert(false, "GAME_COMMAND_PLACE_PARK_ENTRANCE DEPRECATED");
return MONEY32_UNDEFINED;
}
}
/**
*
* rct2: 0x00666F4E
*/
money32 park_entrance_place_ghost(int32_t x, int32_t y, int32_t z, int32_t direction)
/**
*
* rct2: 0x006666E7
*/
void game_command_place_park_entrance(
[[maybe_unused]] int32_t* eax,
[[maybe_unused]] int32_t* ebx,
[[maybe_unused]] int32_t* ecx,
[[maybe_unused]] int32_t* edx,
[[maybe_unused]] int32_t* esi,
[[maybe_unused]] int32_t* edi,
[[maybe_unused]] int32_t* ebp)
{
Guard::Assert(false, "GAME_COMMAND_PLACE_PARK_ENTRANCE DEPRECATED");
}
/**
*
* rct2: 0x00666F4E
*/
money32 park_entrance_place_ghost(int32_t x, int32_t y, int32_t z, int32_t direction)
{
park_entrance_remove_ghost();
auto gameAction = PlaceParkEntranceAction(x, y, z, direction);
gameAction.SetFlags(GAME_COMMAND_FLAG_GHOST);
auto result = GameActions::Execute(&gameAction);
if (result->Error == GA_ERROR::OK)
{
park_entrance_remove_ghost();
auto gameAction = PlaceParkEntranceAction(x, y, z, direction);
gameAction.SetFlags(GAME_COMMAND_FLAG_GHOST);
auto result = GameActions::Execute(&gameAction);
if (result->Error == GA_ERROR::OK)
{
gParkEntranceGhostPosition.x = x;
gParkEntranceGhostPosition.y = y;
gParkEntranceGhostPosition.z = z;
gParkEntranceGhostDirection = direction;
gParkEntranceGhostExists = true;
}
return result->Cost;
gParkEntranceGhostPosition.x = x;
gParkEntranceGhostPosition.y = y;
gParkEntranceGhostPosition.z = z;
gParkEntranceGhostDirection = direction;
gParkEntranceGhostExists = true;
}
return result->Cost;
}
#pragma endregion
#pragma region SetParkEntranceFeeAction
void park_set_entrance_fee(money32 fee)
{
auto gameAction = SetParkEntranceFeeAction((money16)fee);
GameActions::Execute(&gameAction);
}
void park_set_entrance_fee(money32 fee)
{
auto gameAction = SetParkEntranceFeeAction((money16)fee);
GameActions::Execute(&gameAction);
}
void game_command_set_park_entrance_fee(
[[maybe_unused]] int * eax,
[[maybe_unused]] int * ebx,
[[maybe_unused]] int * ecx,
[[maybe_unused]] int * edx,
[[maybe_unused]] int * esi,
int * edi,
[[maybe_unused]] int * ebp)
{
money16 fee = (money16)(*edi & 0xFFFF);
auto gameAction = SetParkEntranceFeeAction(fee);
GameActions::Execute(&gameAction);
}
void game_command_set_park_entrance_fee(
[[maybe_unused]] int* eax,
[[maybe_unused]] int* ebx,
[[maybe_unused]] int* ecx,
[[maybe_unused]] int* edx,
[[maybe_unused]] int* esi,
int* edi,
[[maybe_unused]] int* ebp)
{
money16 fee = (money16)(*edi & 0xFFFF);
auto gameAction = SetParkEntranceFeeAction(fee);
GameActions::Execute(&gameAction);
}
#pragma endregion
#pragma region RideCreateAction
/**
*
* rct2: 0x006B4800
*/
void ride_construct_new(ride_list_item listItem)
{
int32_t rideEntryIndex = ride_get_entry_index(listItem.type, listItem.entry_index);
int32_t colour1 = ride_get_random_colour_preset_index(listItem.type);
int32_t colour2 = ride_get_unused_preset_vehicle_colour(rideEntryIndex);
/**
*
* rct2: 0x006B4800
*/
void ride_construct_new(ride_list_item listItem)
{
int32_t rideEntryIndex = ride_get_entry_index(listItem.type, listItem.entry_index);
int32_t colour1 = ride_get_random_colour_preset_index(listItem.type);
int32_t colour2 = ride_get_unused_preset_vehicle_colour(rideEntryIndex);
auto gameAction = RideCreateAction(listItem.type, listItem.entry_index, colour1, colour2);
auto gameAction = RideCreateAction(listItem.type, listItem.entry_index, colour1, colour2);
gameAction.SetCallback([](const GameAction *ga, const RideCreateGameActionResult * result)
{
if (result->Error != GA_ERROR::OK)
return;
gameAction.SetCallback([](const GameAction* ga, const RideCreateGameActionResult* result) {
if (result->Error != GA_ERROR::OK)
return;
ride_construct(result->rideIndex);
});
ride_construct(result->rideIndex);
});
GameActions::Execute(&gameAction);
}
GameActions::Execute(&gameAction);
}
money32 ride_create_command(int32_t type, int32_t subType, int32_t flags, uint8_t *outRideIndex, uint8_t *outRideColour)
{
int32_t rideEntryIndex = ride_get_entry_index(type, subType);
int32_t colour1 = ride_get_random_colour_preset_index(type);
int32_t colour2 = ride_get_unused_preset_vehicle_colour(rideEntryIndex);
money32 ride_create_command(int32_t type, int32_t subType, int32_t flags, uint8_t* outRideIndex, uint8_t* outRideColour)
{
int32_t rideEntryIndex = ride_get_entry_index(type, subType);
int32_t colour1 = ride_get_random_colour_preset_index(type);
int32_t colour2 = ride_get_unused_preset_vehicle_colour(rideEntryIndex);
auto gameAction = RideCreateAction(type, subType, colour1, colour2);
gameAction.SetFlags(flags);
auto gameAction = RideCreateAction(type, subType, colour1, colour2);
gameAction.SetFlags(flags);
auto r = GameActions::Execute(&gameAction);
const RideCreateGameActionResult *res = static_cast<RideCreateGameActionResult*>(r.get());
auto r = GameActions::Execute(&gameAction);
const RideCreateGameActionResult* res = static_cast<RideCreateGameActionResult*>(r.get());
*outRideIndex = res->rideIndex;
*outRideColour = colour1;
*outRideIndex = res->rideIndex;
*outRideColour = colour1;
return res->Cost;
}
return res->Cost;
}
/**
*
* rct2: 0x006B3F0F
*/
void game_command_create_ride(
[[maybe_unused]] int32_t * eax,
[[maybe_unused]] int32_t * ebx,
[[maybe_unused]] int32_t * ecx,
[[maybe_unused]] int32_t * edx,
[[maybe_unused]] int32_t * esi,
[[maybe_unused]] int32_t * edi,
[[maybe_unused]] int32_t * ebp)
{
Guard::Assert(false, "GAME_COMMAND_CREATE_RIDE DEPRECATED");
}
/**
*
* rct2: 0x006B3F0F
*/
void game_command_create_ride(
[[maybe_unused]] int32_t* eax,
[[maybe_unused]] int32_t* ebx,
[[maybe_unused]] int32_t* ecx,
[[maybe_unused]] int32_t* edx,
[[maybe_unused]] int32_t* esi,
[[maybe_unused]] int32_t* edi,
[[maybe_unused]] int32_t* ebp)
{
Guard::Assert(false, "GAME_COMMAND_CREATE_RIDE DEPRECATED");
}
#pragma endregion
#pragma region RideSetStatusAction
void ride_set_status(int32_t rideIndex, int32_t status)
{
auto gameAction = RideSetStatusAction(rideIndex, status);
GameActions::Execute(&gameAction);
}
void ride_set_status(int32_t rideIndex, int32_t status)
{
auto gameAction = RideSetStatusAction(rideIndex, status);
GameActions::Execute(&gameAction);
}
/**
*
* rct2: 0x006B4EA6
*/
void game_command_set_ride_status(
[[maybe_unused]] int32_t * eax,
[[maybe_unused]] int32_t * ebx,
[[maybe_unused]] int32_t * ecx,
[[maybe_unused]] int32_t * edx,
[[maybe_unused]] int32_t * esi,
[[maybe_unused]] int32_t * edi,
[[maybe_unused]] int32_t * ebp)
{
Guard::Assert(false, "GAME_COMMAND_SET_RIDE_STATUS DEPRECATED");
}
/**
*
* rct2: 0x006B4EA6
*/
void game_command_set_ride_status(
[[maybe_unused]] int32_t* eax,
[[maybe_unused]] int32_t* ebx,
[[maybe_unused]] int32_t* ecx,
[[maybe_unused]] int32_t* edx,
[[maybe_unused]] int32_t* esi,
[[maybe_unused]] int32_t* edi,
[[maybe_unused]] int32_t* ebp)
{
Guard::Assert(false, "GAME_COMMAND_SET_RIDE_STATUS DEPRECATED");
}
#pragma endregion
#pragma region RideSetNameAction
void ride_set_name(int32_t rideIndex, const char *name)
{
auto gameAction = RideSetNameAction(rideIndex, name);
GameActions::Execute(&gameAction);
}
void ride_set_name(int32_t rideIndex, const char* name)
{
auto gameAction = RideSetNameAction(rideIndex, name);
GameActions::Execute(&gameAction);
}
/**
*
* rct2: 0x006B578B
*/
void game_command_set_ride_name(
[[maybe_unused]] int32_t * eax,
[[maybe_unused]] int32_t * ebx,
[[maybe_unused]] int32_t * ecx,
[[maybe_unused]] int32_t * edx,
[[maybe_unused]] int32_t * esi,
[[maybe_unused]] int32_t * edi,
[[maybe_unused]] int32_t * ebp)
{
Guard::Assert(false, "GAME_COMMAND_SET_RIDE_NAME DEPRECATED");
}
/**
*
* rct2: 0x006B578B
*/
void game_command_set_ride_name(
[[maybe_unused]] int32_t* eax,
[[maybe_unused]] int32_t* ebx,
[[maybe_unused]] int32_t* ecx,
[[maybe_unused]] int32_t* edx,
[[maybe_unused]] int32_t* esi,
[[maybe_unused]] int32_t* edi,
[[maybe_unused]] int32_t* ebp)
{
Guard::Assert(false, "GAME_COMMAND_SET_RIDE_NAME DEPRECATED");
}
#pragma endregion
#pragma region RideModifyAction
void ride_action_modify(int32_t rideIndex, int32_t modifyType, int32_t flags)
{
auto gameAction = RideDemolishAction(rideIndex, modifyType);
gameAction.SetFlags(flags);
void ride_action_modify(int32_t rideIndex, int32_t modifyType, int32_t flags)
{
auto gameAction = RideDemolishAction(rideIndex, modifyType);
gameAction.SetFlags(flags);
GameActions::Execute(&gameAction);
}
GameActions::Execute(&gameAction);
}
/**
*
* rct2: 0x006B49D9
*/
void game_command_demolish_ride(
[[maybe_unused]] int32_t * eax,
[[maybe_unused]] int32_t * ebx,
[[maybe_unused]] int32_t * ecx,
[[maybe_unused]] int32_t * edx,
[[maybe_unused]] int32_t * esi,
[[maybe_unused]] int32_t * edi,
[[maybe_unused]] int32_t * ebp)
{
Guard::Assert(false, "GAME_COMMAND_DEMOLISH_RIDE DEPRECATED");
}
/**
*
* rct2: 0x006B49D9
*/
void game_command_demolish_ride(
[[maybe_unused]] int32_t* eax,
[[maybe_unused]] int32_t* ebx,
[[maybe_unused]] int32_t* ecx,
[[maybe_unused]] int32_t* edx,
[[maybe_unused]] int32_t* esi,
[[maybe_unused]] int32_t* edi,
[[maybe_unused]] int32_t* ebp)
{
Guard::Assert(false, "GAME_COMMAND_DEMOLISH_RIDE DEPRECATED");
}
#pragma endregion
#pragma region GuestSetName
void guest_set_name(uint16_t spriteIndex, const char * name)
{
auto gameAction = GuestSetNameAction(spriteIndex, name);
GameActions::Execute(&gameAction);
}
void guest_set_name(uint16_t spriteIndex, const char* name)
{
auto gameAction = GuestSetNameAction(spriteIndex, name);
GameActions::Execute(&gameAction);
}
/**
*
* rct2: 0x00698D6C
*/
void game_command_set_guest_name(
[[maybe_unused]] int32_t * eax,
[[maybe_unused]] int32_t * ebx,
[[maybe_unused]] int32_t * ecx,
[[maybe_unused]] int32_t * edx,
[[maybe_unused]] int32_t * esi,
[[maybe_unused]] int32_t * edi,
[[maybe_unused]] int32_t * ebp)
{
Guard::Assert(false, "GAME_COMMAND_SET_GUEST_NAME DEPRECATED");
}
/**
*
* rct2: 0x00698D6C
*/
void game_command_set_guest_name(
[[maybe_unused]] int32_t* eax,
[[maybe_unused]] int32_t* ebx,
[[maybe_unused]] int32_t* ecx,
[[maybe_unused]] int32_t* edx,
[[maybe_unused]] int32_t* esi,
[[maybe_unused]] int32_t* edi,
[[maybe_unused]] int32_t* ebp)
{
Guard::Assert(false, "GAME_COMMAND_SET_GUEST_NAME DEPRECATED");
}
#pragma endregion
#pragma region StaffSetName
void staff_set_name(uint16_t spriteIndex, const char * name)
{
auto gameAction = StaffSetNameAction(spriteIndex, name);
GameActions::Execute(&gameAction);
}
void staff_set_name(uint16_t spriteIndex, const char* name)
{
auto gameAction = StaffSetNameAction(spriteIndex, name);
GameActions::Execute(&gameAction);
}
void game_command_set_staff_name(
[[maybe_unused]] int32_t * eax,
[[maybe_unused]] int32_t * ebx,
[[maybe_unused]] int32_t * ecx,
[[maybe_unused]] int32_t * edx,
[[maybe_unused]] int32_t * esi,
[[maybe_unused]] int32_t * edi,
[[maybe_unused]] int32_t * ebp)
{
Guard::Assert(false, "GAME_COMMAND_SET_STAFF_NAME DEPRECATED");
}
void game_command_set_staff_name(
[[maybe_unused]] int32_t* eax,
[[maybe_unused]] int32_t* ebx,
[[maybe_unused]] int32_t* ecx,
[[maybe_unused]] int32_t* edx,
[[maybe_unused]] int32_t* esi,
[[maybe_unused]] int32_t* edi,
[[maybe_unused]] int32_t* ebp)
{
Guard::Assert(false, "GAME_COMMAND_SET_STAFF_NAME DEPRECATED");
}
#pragma endregion
#pragma region PlacePeepSpawn
bool place_peep_spawn(CoordsXYZD location)
bool place_peep_spawn(CoordsXYZD location)
{
auto gameAction = PlacePeepSpawnAction(location);
auto result = GameActions::Execute(&gameAction);
if (result->Error == GA_ERROR::OK)
{
auto gameAction = PlacePeepSpawnAction(location);
auto result = GameActions::Execute(&gameAction);
if (result->Error == GA_ERROR::OK)
{
return true;
}
else
{
return false;
}
return true;
}
else
{
return false;
}
}
#pragma endregion
#pragma region MazeSetTrack
money32 maze_set_track(uint16_t x, uint16_t y, uint16_t z, uint8_t flags, bool initialPlacement, uint8_t direction, uint8_t rideIndex, uint8_t mode)
money32 maze_set_track(
uint16_t x,
uint16_t y,
uint16_t z,
uint8_t flags,
bool initialPlacement,
uint8_t direction,
uint8_t rideIndex,
uint8_t mode)
{
auto gameAction = MazeSetTrackAction(x, y, z, initialPlacement, direction, rideIndex, mode);
gameAction.SetFlags(flags);
GameActionResult::Ptr res;
if (!(flags & GAME_COMMAND_FLAG_APPLY))
res = GameActions::Query(&gameAction);
else
res = GameActions::Execute(&gameAction);
// NOTE: ride_construction_tooldown_construct requires them to be set.
// Refactor result type once theres no C code referencing this function.
gGameCommandErrorText = res->ErrorMessage;
gGameCommandErrorTitle = res->ErrorTitle;
if (res->Error != GA_ERROR::OK)
{
auto gameAction = MazeSetTrackAction(x, y, z, initialPlacement, direction, rideIndex, mode);
gameAction.SetFlags(flags);
GameActionResult::Ptr res;
if (!(flags & GAME_COMMAND_FLAG_APPLY))
res = GameActions::Query(&gameAction);
else
res = GameActions::Execute(&gameAction);
// NOTE: ride_construction_tooldown_construct requires them to be set.
// Refactor result type once theres no C code referencing this function.
gGameCommandErrorText = res->ErrorMessage;
gGameCommandErrorTitle = res->ErrorTitle;
if (res->Error != GA_ERROR::OK)
{
return MONEY32_UNDEFINED;
}
return res->Cost;
return MONEY32_UNDEFINED;
}
/**
*
* rct2: 0x006CD8CE
*/
void game_command_set_maze_track(
[[maybe_unused]] int32_t * eax,
[[maybe_unused]] int32_t * ebx,
[[maybe_unused]] int32_t * ecx,
[[maybe_unused]] int32_t * edx,
[[maybe_unused]] int32_t * esi,
[[maybe_unused]] int32_t * edi,
[[maybe_unused]] int32_t * ebp)
{
Guard::Assert(false, "GAME_COMMAND_SET_MAZE_TRACK DEPRECATED");
}
return res->Cost;
}
/**
*
* rct2: 0x006CD8CE
*/
void game_command_set_maze_track(
[[maybe_unused]] int32_t* eax,
[[maybe_unused]] int32_t* ebx,
[[maybe_unused]] int32_t* ecx,
[[maybe_unused]] int32_t* edx,
[[maybe_unused]] int32_t* esi,
[[maybe_unused]] int32_t* edi,
[[maybe_unused]] int32_t* ebp)
{
Guard::Assert(false, "GAME_COMMAND_SET_MAZE_TRACK DEPRECATED");
}
#pragma endregion
+11 -11
View File
@@ -7,24 +7,24 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include "BannerSetNameAction.hpp"
#include "GameAction.h"
#include "GuestSetNameAction.hpp"
#include "ParkSetLoanAction.hpp"
#include "ParkSetResearchFundingAction.hpp"
#include "MazeSetTrackAction.hpp"
#include "ParkMarketingAction.hpp"
#include "ParkSetLoanAction.hpp"
#include "ParkSetNameAction.hpp"
#include "ParkSetResearchFundingAction.hpp"
#include "PlaceParkEntranceAction.hpp"
#include "PlacePeepSpawnAction.hpp"
#include "RideCreateAction.hpp"
#include "RideDemolishAction.hpp"
#include "RideSetName.hpp"
#include "RideSetStatus.hpp"
#include "SetParkEntranceFeeAction.hpp"
#include "SignSetNameAction.hpp"
#include "StaffSetColourAction.hpp"
#include "StaffSetNameAction.hpp"
#include "RideCreateAction.hpp"
#include "RideSetStatus.hpp"
#include "RideSetName.hpp"
#include "RideDemolishAction.hpp"
#include "PlacePeepSpawnAction.hpp"
#include "MazeSetTrackAction.hpp"
#include "SignSetNameAction.hpp"
#include "ParkSetNameAction.hpp"
#include "BannerSetNameAction.hpp"
#include "WallRemoveAction.hpp"
namespace GameActions
+18 -15
View File
@@ -9,18 +9,17 @@
#pragma once
#include "../core/MemoryStream.h"
#include "../localisation/StringIds.h"
#include "GameAction.h"
#include "../Cheats.h"
#include "../Context.h"
#include "../core/MemoryStream.h"
#include "../drawing/Drawing.h"
#include "../interface/Window.h"
#include "../localisation/Localisation.h"
#include "../localisation/StringIds.h"
#include "../windows/Intent.h"
#include "../world/Park.h"
#include "../world/Sprite.h"
#include "GameAction.h"
struct GuestSetNameAction : public GameActionBase<GAME_COMMAND_SET_GUEST_NAME, GameActionResult>
{
@@ -29,10 +28,12 @@ private:
std::string _name;
public:
GuestSetNameAction() {}
GuestSetNameAction()
{
}
GuestSetNameAction(uint16_t spriteIndex, const std::string& name)
: _spriteIndex(spriteIndex),
_name(name)
: _spriteIndex(spriteIndex)
, _name(name)
{
}
@@ -50,7 +51,6 @@ public:
GameActionResult::Ptr Query() const override
{
if (_spriteIndex >= MAX_SPRITES)
{
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_NAME_GUEST, STR_NONE);
@@ -58,17 +58,19 @@ public:
if (_name.empty())
{
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_NAME_GUEST, STR_ERR_INVALID_NAME_FOR_GUEST);
return std::make_unique<GameActionResult>(
GA_ERROR::INVALID_PARAMETERS, STR_CANT_NAME_GUEST, STR_ERR_INVALID_NAME_FOR_GUEST);
}
rct_peep * peep = GET_PEEP(_spriteIndex);
rct_peep* peep = GET_PEEP(_spriteIndex);
if (peep->type != PEEP_TYPE_GUEST)
{
log_warning("Invalid game command for sprite %u", _spriteIndex);
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_NAME_GUEST, STR_NONE);
}
rct_string_id newUserStringId = user_string_allocate(USER_STRING_HIGH_ID_NUMBER | USER_STRING_DUPLICATION_PERMITTED, _name.c_str());
rct_string_id newUserStringId
= user_string_allocate(USER_STRING_HIGH_ID_NUMBER | USER_STRING_DUPLICATION_PERMITTED, _name.c_str());
if (newUserStringId == 0)
{
// TODO: Probably exhausted, introduce new error.
@@ -81,14 +83,15 @@ public:
GameActionResult::Ptr Execute() const override
{
rct_string_id newUserStringId = user_string_allocate(USER_STRING_HIGH_ID_NUMBER | USER_STRING_DUPLICATION_PERMITTED, _name.c_str());
rct_string_id newUserStringId
= user_string_allocate(USER_STRING_HIGH_ID_NUMBER | USER_STRING_DUPLICATION_PERMITTED, _name.c_str());
if (newUserStringId == 0)
{
// TODO: Probably exhausted, introduce new error.
return std::make_unique<GameActionResult>(GA_ERROR::UNKNOWN, STR_CANT_NAME_GUEST, gGameCommandErrorText);
}
rct_peep * peep = GET_PEEP(_spriteIndex);
rct_peep* peep = GET_PEEP(_spriteIndex);
if (peep->type != PEEP_TYPE_GUEST)
{
log_warning("Invalid game command for sprite %u", _spriteIndex);
@@ -96,7 +99,7 @@ public:
}
set_format_arg(0, uint32_t, peep->id);
utf8 * curName = gCommonStringFormatBuffer;
utf8* curName = gCommonStringFormatBuffer;
rct_string_id curId = peep->name_string_idx;
format_string(curName, 256, curId, gCommonFormatArgs);
+93 -114
View File
@@ -9,41 +9,28 @@
#pragma once
#include "../core/MemoryStream.h"
#include "../localisation/StringIds.h"
#include "GameAction.h"
#include "../Cheats.h"
#include "../core/MemoryStream.h"
#include "../interface/Window.h"
#include "../localisation/Localisation.h"
#include "../localisation/StringIds.h"
#include "../management/Finance.h"
#include "../ride/Track.h"
#include "../ride/TrackData.h"
#include "../world/Footpath.h"
#include "../world/Park.h"
#include "GameAction.h"
/** rct2: 0x00993CE9 */
static constexpr const uint8_t byte_993CE9[] =
{
0xFF, 0xE0, 0xFF,
14, 0, 1, 2,
6, 2, 4, 5,
9, 10, 6, 8,
12, 13, 14, 10,
static constexpr const uint8_t byte_993CE9[] = {
0xFF, 0xE0, 0xFF, 14, 0, 1, 2, 6, 2, 4, 5, 9, 10, 6, 8, 12, 13, 14, 10,
};
/** rct2: 0x00993CFC */
static constexpr const uint8_t byte_993CFC[] =
{
5, 12, 0xFF, 0xFF, 9, 0, 0xFF, 0xFF, 13, 4, 0xFF, 0xFF, 1, 8, 0xFF, 0xFF
};
static constexpr const uint8_t byte_993CFC[] = { 5, 12, 0xFF, 0xFF, 9, 0, 0xFF, 0xFF, 13, 4, 0xFF, 0xFF, 1, 8, 0xFF, 0xFF };
/** rct2: 0x00993D0C */
static constexpr const uint8_t byte_993D0C[] =
{
3, 0, 0xFF, 0xFF, 0, 1, 0xFF, 0xFF, 1, 2, 0xFF, 0xFF, 2, 3, 0xFF, 0xFF
};
static constexpr const uint8_t byte_993D0C[] = { 3, 0, 0xFF, 0xFF, 0, 1, 0xFF, 0xFF, 1, 2, 0xFF, 0xFF, 2, 3, 0xFF, 0xFF };
struct MazeSetTrackAction : public GameActionBase<GAME_COMMAND_SET_MAZE_TRACK, GameActionResult>
{
@@ -57,15 +44,18 @@ private:
uint8_t _mode;
public:
MazeSetTrackAction() {}
MazeSetTrackAction(uint16_t x, uint16_t y, uint16_t z, bool initialPlacement, uint8_t direction, uint8_t rideIndex, uint8_t mode)
: _x(x),
_y(y),
_z(z),
_initialPlacement(initialPlacement),
_direction(direction),
_rideIndex(rideIndex),
_mode(mode)
MazeSetTrackAction()
{
}
MazeSetTrackAction(
uint16_t x, uint16_t y, uint16_t z, bool initialPlacement, uint8_t direction, uint8_t rideIndex, uint8_t mode)
: _x(x)
, _y(y)
, _z(z)
, _initialPlacement(initialPlacement)
, _direction(direction)
, _rideIndex(rideIndex)
, _mode(mode)
{
}
@@ -112,7 +102,7 @@ public:
return res;
}
rct_tile_element * tileElement = map_get_surface_element_at(_x / 32, _y / 32);
rct_tile_element* tileElement = map_get_surface_element_at(_x / 32, _y / 32);
if (tileElement == nullptr)
{
res->Error = GA_ERROR::UNKNOWN;
@@ -167,7 +157,7 @@ public:
return res;
}
Ride * ride = get_ride(_rideIndex);
Ride* ride = get_ride(_rideIndex);
if (ride == nullptr || ride->type == RIDE_CRASH_TYPE_NONE)
{
res->Error = GA_ERROR::NO_CLEARANCE;
@@ -211,10 +201,11 @@ public:
uint8_t baseHeight = _z >> 3;
uint8_t clearanceHeight = (_z + 32) >> 3;
rct_tile_element * tileElement = map_get_track_element_at_of_type_from_ride(_x, _y, baseHeight, TRACK_ELEM_MAZE, _rideIndex);
rct_tile_element* tileElement
= map_get_track_element_at_of_type_from_ride(_x, _y, baseHeight, TRACK_ELEM_MAZE, _rideIndex);
if (tileElement == nullptr)
{
Ride * ride = get_ride(_rideIndex);
Ride* ride = get_ride(_rideIndex);
openrct2_assert(ride != nullptr, "Invalid ride index: %d\n", _rideIndex);
money32 price = (((RideTrackCosts[ride->type].track_price * TrackPricing[TRACK_ELEM_MAZE]) >> 16));
@@ -253,110 +244,98 @@ public:
switch (_mode)
{
case GC_SET_MAZE_TRACK_BUILD:
{
uint8_t segmentOffset = MazeGetSegmentBit(_x, _y);
tileElement->properties.track.maze_entry &= ~(1 << segmentOffset);
if (!_initialPlacement)
case GC_SET_MAZE_TRACK_BUILD:
{
segmentOffset = byte_993CE9[(_direction + segmentOffset)];
uint8_t segmentOffset = MazeGetSegmentBit(_x, _y);
tileElement->properties.track.maze_entry &= ~(1 << segmentOffset);
uint8_t temp_edx = byte_993CFC[segmentOffset];
if (temp_edx != 0xFF)
if (!_initialPlacement)
{
uint16_t previousElementX = floor2(_x, 32) - CoordsDirectionDelta[_direction].x;
uint16_t previousElementY = floor2(_y, 32) - CoordsDirectionDelta[_direction].y;
segmentOffset = byte_993CE9[(_direction + segmentOffset)];
tileElement->properties.track.maze_entry &= ~(1 << segmentOffset);
rct_tile_element * previousTileElement = map_get_track_element_at_of_type_from_ride(
previousElementX,
previousElementY,
baseHeight,
TRACK_ELEM_MAZE,
_rideIndex);
uint8_t temp_edx = byte_993CFC[segmentOffset];
if (temp_edx != 0xFF)
{
uint16_t previousElementX = floor2(_x, 32) - CoordsDirectionDelta[_direction].x;
uint16_t previousElementY = floor2(_y, 32) - CoordsDirectionDelta[_direction].y;
if (previousTileElement != nullptr)
{
previousTileElement->properties.track.maze_entry &= ~(1 << temp_edx);
}
else
{
tileElement->properties.track.maze_entry |= (1 << segmentOffset);
rct_tile_element* previousTileElement = map_get_track_element_at_of_type_from_ride(
previousElementX, previousElementY, baseHeight, TRACK_ELEM_MAZE, _rideIndex);
if (previousTileElement != nullptr)
{
previousTileElement->properties.track.maze_entry &= ~(1 << temp_edx);
}
else
{
tileElement->properties.track.maze_entry |= (1 << segmentOffset);
}
}
}
break;
}
break;
}
case GC_SET_MAZE_TRACK_MOVE:
break;
case GC_SET_MAZE_TRACK_MOVE:
break;
case GC_SET_MAZE_TRACK_FILL:
if (!_initialPlacement)
{
uint16_t previousSegmentX = _x - CoordsDirectionDelta[_direction].x / 2;
uint16_t previousSegmentY = _y - CoordsDirectionDelta[_direction].y / 2;
tileElement = map_get_track_element_at_of_type_from_ride(
previousSegmentX,
previousSegmentY,
baseHeight,
TRACK_ELEM_MAZE,
_rideIndex);
map_invalidate_tile_full(floor2(previousSegmentX, 32), floor2(previousSegmentY, 32));
if (tileElement == nullptr)
case GC_SET_MAZE_TRACK_FILL:
if (!_initialPlacement)
{
log_error("No surface found\n");
res->Error = GA_ERROR::UNKNOWN;
res->ErrorMessage = STR_NONE;
return res;
}
uint16_t previousSegmentX = _x - CoordsDirectionDelta[_direction].x / 2;
uint16_t previousSegmentY = _y - CoordsDirectionDelta[_direction].y / 2;
uint32_t segmentBit = MazeGetSegmentBit(previousSegmentX, previousSegmentY);
tileElement = map_get_track_element_at_of_type_from_ride(
previousSegmentX, previousSegmentY, baseHeight, TRACK_ELEM_MAZE, _rideIndex);
tileElement->properties.track.maze_entry |= (1 << segmentBit);
segmentBit--;
tileElement->properties.track.maze_entry |= (1 << segmentBit);
segmentBit = (segmentBit - 4) & 0x0F;
tileElement->properties.track.maze_entry |= (1 << segmentBit);
segmentBit = (segmentBit + 3) & 0x0F;
map_invalidate_tile_full(floor2(previousSegmentX, 32), floor2(previousSegmentY, 32));
if (tileElement == nullptr)
{
log_error("No surface found\n");
res->Error = GA_ERROR::UNKNOWN;
res->ErrorMessage = STR_NONE;
return res;
}
uint32_t segmentBit = MazeGetSegmentBit(previousSegmentX, previousSegmentY);
do
{
tileElement->properties.track.maze_entry |= (1 << segmentBit);
uint32_t direction1 = byte_993D0C[segmentBit];
uint16_t nextElementX = floor2(previousSegmentX, 32) + CoordsDirectionDelta[direction1].x;
uint16_t nextElementY = floor2(previousSegmentY, 32) + CoordsDirectionDelta[direction1].y;
rct_tile_element * tmp_tileElement = map_get_track_element_at_of_type_from_ride(
nextElementX,
nextElementY,
baseHeight,
TRACK_ELEM_MAZE,
_rideIndex);
if (tmp_tileElement != nullptr)
{
uint8_t edx11 = byte_993CFC[segmentBit];
tmp_tileElement->properties.track.maze_entry |= 1 << (edx11);
}
segmentBit--;
} while ((segmentBit & 0x3) != 0x3);
}
break;
tileElement->properties.track.maze_entry |= (1 << segmentBit);
segmentBit = (segmentBit - 4) & 0x0F;
tileElement->properties.track.maze_entry |= (1 << segmentBit);
segmentBit = (segmentBit + 3) & 0x0F;
do
{
tileElement->properties.track.maze_entry |= (1 << segmentBit);
uint32_t direction1 = byte_993D0C[segmentBit];
uint16_t nextElementX = floor2(previousSegmentX, 32) + CoordsDirectionDelta[direction1].x;
uint16_t nextElementY = floor2(previousSegmentY, 32) + CoordsDirectionDelta[direction1].y;
rct_tile_element* tmp_tileElement = map_get_track_element_at_of_type_from_ride(
nextElementX, nextElementY, baseHeight, TRACK_ELEM_MAZE, _rideIndex);
if (tmp_tileElement != nullptr)
{
uint8_t edx11 = byte_993CFC[segmentBit];
tmp_tileElement->properties.track.maze_entry |= 1 << (edx11);
}
segmentBit--;
} while ((segmentBit & 0x3) != 0x3);
}
break;
}
map_invalidate_tile(floor2(_x, 32), floor2(_y, 32), tileElement->base_height * 8, tileElement->clearance_height * 8);
if ((tileElement->properties.track.maze_entry & 0x8888) == 0x8888)
{
Ride * ride = get_ride(_rideIndex);
Ride* ride = get_ride(_rideIndex);
tile_element_remove(tileElement);
sub_6CB945(_rideIndex);
ride->maze_tiles--;
+10 -8
View File
@@ -29,11 +29,13 @@ private:
int32_t _numWeeks;
public:
ParkMarketingAction() {}
ParkMarketingAction()
{
}
ParkMarketingAction(int32_t type, int32_t item, int32_t numWeeks)
: _type(type),
_item(item),
_numWeeks(numWeeks)
: _type(type)
, _item(item)
, _numWeeks(numWeeks)
{
}
@@ -50,14 +52,14 @@ public:
GameActionResult::Ptr Query() const override
{
if ((size_t)_type >= Util::CountOf(AdvertisingCampaignPricePerWeek) ||
_numWeeks >= 256)
if ((size_t)_type >= Util::CountOf(AdvertisingCampaignPricePerWeek) || _numWeeks >= 256)
{
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_START_MARKETING_CAMPAIGN);
}
if (gParkFlags & PARK_FLAGS_FORBID_MARKETING_CAMPAIGN)
{
return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_START_MARKETING_CAMPAIGN, STR_MARKETING_CAMPAIGNS_FORBIDDEN_BY_LOCAL_AUTHORITY);
return MakeResult(
GA_ERROR::DISALLOWED, STR_CANT_START_MARKETING_CAMPAIGN, STR_MARKETING_CAMPAIGNS_FORBIDDEN_BY_LOCAL_AUTHORITY);
}
return CreateResult();
@@ -65,7 +67,7 @@ public:
GameActionResult::Ptr Execute() const override
{
gMarketingCampaignDaysLeft[_type] = _numWeeks | CAMPAIGN_ACTIVE_FLAG;
gMarketingCampaignDaysLeft[_type] = _numWeeks | CAMPAIGN_ACTIVE_FLAG;
gMarketingCampaignRideIndex[_type] = _item;
// We are only interested in invalidating the finances (marketing) window
+4 -2
View File
@@ -24,7 +24,9 @@ private:
money32 _value;
public:
ParkSetLoanAction() {}
ParkSetLoanAction()
{
}
ParkSetLoanAction(money32 value)
: _value(value)
{
@@ -43,7 +45,7 @@ public:
GameActionResult::Ptr Query() const override
{
auto currentLoan = gBankLoan;
auto currentLoan = gBankLoan;
auto loanDifference = currentLoan - _value;
if (_value > currentLoan)
{
+8 -10
View File
@@ -28,7 +28,9 @@ private:
std::string _name;
public:
ParkSetNameAction() {}
ParkSetNameAction()
{
}
ParkSetNameAction(const std::string& name)
: _name(name)
{
@@ -84,8 +86,8 @@ public:
gParkName = newNameId;
// Log park rename command if we are in multiplayer and logging is enabled
if ((network_get_mode() == NETWORK_MODE_CLIENT ||
network_get_mode() == NETWORK_MODE_SERVER) && gConfigNetwork.log_server_actions)
if ((network_get_mode() == NETWORK_MODE_CLIENT || network_get_mode() == NETWORK_MODE_SERVER)
&& gConfigNetwork.log_server_actions)
{
LogAction(oldName);
}
@@ -102,19 +104,15 @@ private:
return buffer;
}
void LogAction(const std::string &oldName) const
void LogAction(const std::string& oldName) const
{
// Get player name
auto playerIndex = network_get_player_index(game_command_playerid);
auto playerName = network_get_player_name(playerIndex);
char logMessage[256];
const char * args[3] = {
playerName,
oldName.c_str(),
_name.c_str()
};
format_string(logMessage, sizeof(logMessage), STR_LOG_PARK_NAME, (void *)args);
const char* args[3] = { playerName, oldName.c_str(), _name.c_str() };
format_string(logMessage, sizeof(logMessage), STR_LOG_PARK_NAME, (void*)args);
network_append_server_log(logMessage);
}
};
@@ -26,10 +26,12 @@ private:
uint8_t _fundingAmount;
public:
ParkSetResearchFundingAction() {}
ParkSetResearchFundingAction()
{
}
ParkSetResearchFundingAction(uint32_t priorities, uint8_t fundingAmount)
: _priorities(priorities),
_fundingAmount(fundingAmount)
: _priorities(priorities)
, _fundingAmount(fundingAmount)
{
}
@@ -9,18 +9,17 @@
#pragma once
#include "../Cheats.h"
#include "../OpenRCT2.h"
#include "../core/MemoryStream.h"
#include "../localisation/StringIds.h"
#include "../OpenRCT2.h"
#include "GameAction.h"
#include "../Cheats.h"
#include "../management/Finance.h"
#include "../world/Entrance.h"
#include "../world/Park.h"
#include "../world/Footpath.h"
#include "../world/MapAnimation.h"
#include "../world/Park.h"
#include "../world/Sprite.h"
#include "GameAction.h"
struct PlaceParkEntranceAction : public GameActionBase<GAME_COMMAND_PLACE_PARK_ENTRANCE, GameActionResult>
{
@@ -31,12 +30,14 @@ private:
uint8_t _direction;
public:
PlaceParkEntranceAction() {}
PlaceParkEntranceAction(int16_t x, int16_t y, int16_t z, int16_t direction) :
_x(x),
_y(y),
_z(z),
_direction(direction)
PlaceParkEntranceAction()
{
}
PlaceParkEntranceAction(int16_t x, int16_t y, int16_t z, int16_t direction)
: _x(x)
, _y(y)
, _z(z)
, _direction(direction)
{
}
@@ -56,7 +57,8 @@ public:
{
if (!(gScreenFlags & SCREEN_FLAGS_EDITOR) && !gCheatsSandboxMode)
{
return std::make_unique<GameActionResult>(GA_ERROR::NOT_IN_EDITOR_MODE, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_NONE);
return std::make_unique<GameActionResult>(
GA_ERROR::NOT_IN_EDITOR_MODE, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_NONE);
}
gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LAND_PURCHASE;
@@ -72,7 +74,8 @@ public:
if (_x <= 32 || _y <= 32 || _x >= (gMapSizeUnits - 32) || _y >= (gMapSizeUnits - 32))
{
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_TOO_CLOSE_TO_EDGE_OF_MAP);
return std::make_unique<GameActionResult>(
GA_ERROR::INVALID_PARAMETERS, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_TOO_CLOSE_TO_EDGE_OF_MAP);
}
int8_t entranceNum = -1;
@@ -87,7 +90,8 @@ public:
if (entranceNum == -1)
{
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_ERR_TOO_MANY_PARK_ENTRANCES);
return std::make_unique<GameActionResult>(
GA_ERROR::INVALID_PARAMETERS, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_ERR_TOO_MANY_PARK_ENTRANCES);
}
int8_t zLow = _z * 2;
@@ -110,7 +114,8 @@ public:
{
if (!map_can_construct_at(entranceLoc.x, entranceLoc.y, zLow, zHigh, 0xF))
{
return std::make_unique<GameActionResult>(GA_ERROR::NO_CLEARANCE, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_NONE);
return std::make_unique<GameActionResult>(
GA_ERROR::NO_CLEARANCE, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_NONE);
}
}
@@ -118,7 +123,8 @@ public:
rct_tile_element* entranceElement = map_get_park_entrance_element_at(entranceLoc.x, entranceLoc.y, zLow, false);
if (entranceElement != nullptr)
{
return std::make_unique<GameActionResult>(GA_ERROR::ITEM_ALREADY_PLACED, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_NONE);
return std::make_unique<GameActionResult>(
GA_ERROR::ITEM_ALREADY_PLACED, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_NONE);
}
}
@@ -195,10 +201,10 @@ public:
}
update_park_fences(entranceLoc);
update_park_fences({entranceLoc.x - 32, entranceLoc.y});
update_park_fences({entranceLoc.x + 32, entranceLoc.y});
update_park_fences({entranceLoc.x, entranceLoc.y - 32});
update_park_fences({entranceLoc.x, entranceLoc.y + 32});
update_park_fences({ entranceLoc.x - 32, entranceLoc.y });
update_park_fences({ entranceLoc.x + 32, entranceLoc.y });
update_park_fences({ entranceLoc.x, entranceLoc.y - 32 });
update_park_fences({ entranceLoc.x, entranceLoc.y + 32 });
map_invalidate_tile(entranceLoc.x, entranceLoc.y, newElement->base_height * 8, newElement->clearance_height * 8);
+29 -18
View File
@@ -9,15 +9,14 @@
#pragma once
#include "../Cheats.h"
#include "../OpenRCT2.h"
#include "../core/MemoryStream.h"
#include "../localisation/StringIds.h"
#include "../OpenRCT2.h"
#include "GameAction.h"
#include "../Cheats.h"
#include "../management/Finance.h"
#include "../world/Park.h"
#include "../world/Footpath.h"
#include "../world/Park.h"
#include "GameAction.h"
static int32_t _nextPeepSpawnIndex = 0;
@@ -27,9 +26,11 @@ private:
CoordsXYZD _location;
public:
PlacePeepSpawnAction() {}
PlacePeepSpawnAction(CoordsXYZD location) :
_location(location)
PlacePeepSpawnAction()
{
}
PlacePeepSpawnAction(CoordsXYZD location)
: _location(location)
{
}
@@ -49,7 +50,8 @@ public:
{
if (!(gScreenFlags & SCREEN_FLAGS_EDITOR) && !gCheatsSandboxMode)
{
return std::make_unique<GameActionResult>(GA_ERROR::NOT_IN_EDITOR_MODE, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_NONE);
return std::make_unique<GameActionResult>(
GA_ERROR::NOT_IN_EDITOR_MODE, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_NONE);
}
gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LAND_PURCHASE;
@@ -63,25 +65,32 @@ public:
return std::make_unique<GameActionResult>(GA_ERROR::NO_FREE_ELEMENTS, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_NONE);
}
if (_location.x <= 16 || _location.y <= 16 || _location.x >= (gMapSizeUnits - 16) || _location.y >= (gMapSizeUnits - 16))
if (_location.x <= 16 || _location.y <= 16 || _location.x >= (gMapSizeUnits - 16)
|| _location.y >= (gMapSizeUnits - 16))
{
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_OFF_EDGE_OF_MAP);
return std::make_unique<GameActionResult>(
GA_ERROR::INVALID_PARAMETERS, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_OFF_EDGE_OF_MAP);
}
rct_tile_element *mapElement, *surfaceMapElement;
// Verify footpath exists at location, and retrieve coordinates
mapElement = map_get_path_element_at(_location.x >> 5, _location.y >> 5, _location.z / 8);
if (mapElement == nullptr) {
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_CAN_ONLY_BE_BUILT_ACROSS_PATHS);
if (mapElement == nullptr)
{
return std::make_unique<GameActionResult>(
GA_ERROR::INVALID_PARAMETERS, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_CAN_ONLY_BE_BUILT_ACROSS_PATHS);
}
// Verify location is unowned
surfaceMapElement = map_get_surface_element_at(_location.x >> 5, _location.y >> 5);
if (surfaceMapElement == nullptr) {
if (surfaceMapElement == nullptr)
{
return std::make_unique<GameActionResult>(GA_ERROR::UNKNOWN, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_NONE);
}
if (surfaceMapElement->properties.surface.ownership & 0xF0) {
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_ERR_MUST_BE_OUTSIDE_PARK_BOUNDARIES);
if (surfaceMapElement->properties.surface.ownership & 0xF0)
{
return std::make_unique<GameActionResult>(
GA_ERROR::INVALID_PARAMETERS, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_ERR_MUST_BE_OUTSIDE_PARK_BOUNDARIES);
}
return std::make_unique<GameActionResult>();
@@ -97,8 +106,10 @@ public:
// Find empty or next appropriate peep spawn to use
int32_t peepSpawnIndex = -1;
for (int32_t i = 0; i < MAX_PEEP_SPAWNS; i++) {
if (gPeepSpawns[i].x == PEEP_SPAWN_UNDEFINED) {
for (int32_t i = 0; i < MAX_PEEP_SPAWNS; i++)
{
if (gPeepSpawns[i].x == PEEP_SPAWN_UNDEFINED)
{
peepSpawnIndex = i;
break;
}
+33 -29
View File
@@ -9,28 +9,34 @@
#pragma once
#include <algorithm>
#include "../Cheats.h"
#include "../core/Memory.hpp"
#include "../core/MemoryStream.h"
#include "../localisation/StringIds.h"
#include "GameAction.h"
#include "../localisation/Date.h"
#include "../Cheats.h"
#include "../interface/Window.h"
#include "../world/Park.h"
#include "../localisation/Date.h"
#include "../localisation/StringIds.h"
#include "../rct1/RCT1.h"
#include "../ride/RideData.h"
#include "../ride/Ride.h"
#include "../ride/RideData.h"
#include "../ride/ShopItem.h"
#include "../ride/Station.h"
#include "../scenario/Scenario.h"
#include "../world/Park.h"
#include "GameAction.h"
#include <algorithm>
class RideCreateGameActionResult final : public GameActionResult
{
public:
RideCreateGameActionResult() : GameActionResult(GA_ERROR::OK, 0) {}
RideCreateGameActionResult(GA_ERROR error, rct_string_id message) : GameActionResult(error, message) {}
RideCreateGameActionResult()
: GameActionResult(GA_ERROR::OK, 0)
{
}
RideCreateGameActionResult(GA_ERROR error, rct_string_id message)
: GameActionResult(error, message)
{
}
int32_t rideIndex = -1;
};
@@ -44,18 +50,21 @@ private:
uint8_t _colour2;
public:
RideCreateAction() {}
RideCreateAction(int32_t rideType, int32_t subType, int32_t colour1, int32_t colour2) :
_rideType(rideType),
_subType(subType),
_colour1(colour1),
_colour2(colour2)
RideCreateAction()
{
}
RideCreateAction(int32_t rideType, int32_t subType, int32_t colour1, int32_t colour2)
: _rideType(rideType)
, _subType(subType)
, _colour1(colour1)
, _colour2(colour2)
{
}
uint16_t GetActionFlags() const override
{
return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED;;
return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED;
;
}
void Serialise(DataSerialiser& stream) override
@@ -85,18 +94,16 @@ public:
return std::make_unique<RideCreateGameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_INVALID_RIDE_TYPE);
}
const track_colour_preset_list *colourPresets = &RideColourPresets[_rideType];
const track_colour_preset_list* colourPresets = &RideColourPresets[_rideType];
if (_colour1 >= colourPresets->count)
{
// FIXME: Add new error string.
return std::make_unique<RideCreateGameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_INVALID_RIDE_TYPE);
}
rct_ride_entry *rideEntry = get_ride_entry(rideEntryIndex);
vehicle_colour_preset_list *presetList = rideEntry->vehicle_preset_list;
if ((presetList->count > 0 && presetList->count != 255) &&
_colour2 >= presetList->count)
rct_ride_entry* rideEntry = get_ride_entry(rideEntryIndex);
vehicle_colour_preset_list* presetList = rideEntry->vehicle_preset_list;
if ((presetList->count > 0 && presetList->count != 255) && _colour2 >= presetList->count)
{
// FIXME: Add new error string.
return std::make_unique<RideCreateGameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_INVALID_RIDE_TYPE);
@@ -107,7 +114,7 @@ public:
GameActionResult::Ptr Execute() const override
{
rct_ride_entry * rideEntry;
rct_ride_entry* rideEntry;
auto res = std::make_unique<RideCreateGameActionResult>();
int32_t rideEntryIndex = ride_get_entry_index(_rideType, _subType);
@@ -149,7 +156,7 @@ public:
ride->queue_time[i] = 0;
}
for (auto &vehicle : ride->vehicles)
for (auto& vehicle : ride->vehicles)
{
vehicle = SPRITE_INDEX_NULL;
}
@@ -258,10 +265,7 @@ public:
}
}
std::fill(
std::begin(ride->num_customers),
std::end(ride->num_customers),
0);
std::fill(std::begin(ride->num_customers), std::end(ride->num_customers), 0);
ride->value = 0xFFFF;
ride->satisfaction = 255;
ride->satisfaction_time_out = 0;
+36 -37
View File
@@ -11,8 +11,8 @@
#include "../Cheats.h"
#include "../Context.h"
#include "../core/MemoryStream.h"
#include "../GameState.h"
#include "../core/MemoryStream.h"
#include "../interface/Window.h"
#include "../localisation/Localisation.h"
#include "../management/NewsItem.h"
@@ -20,8 +20,8 @@
#include "../ui/UiContext.h"
#include "../ui/WindowManager.h"
#include "../world/Banner.h"
#include "../world/Sprite.h"
#include "../world/Park.h"
#include "../world/Sprite.h"
#include "GameAction.h"
#include "MazeSetTrackAction.hpp"
@@ -34,10 +34,12 @@ private:
uint8_t _modifyType = RIDE_MODIFY_DEMOLISH;
public:
RideDemolishAction() {}
RideDemolishAction(int32_t rideIndex, uint8_t modifyType) :
_rideIndex(rideIndex),
_modifyType(modifyType)
RideDemolishAction()
{
}
RideDemolishAction(int32_t rideIndex, uint8_t modifyType)
: _rideIndex(rideIndex)
, _modifyType(modifyType)
{
}
@@ -55,7 +57,7 @@ public:
GameActionResult::Ptr Query() const override
{
Ride *ride = get_ride(_rideIndex);
Ride* ride = get_ride(_rideIndex);
if (ride->type == RIDE_TYPE_NULL)
{
log_warning("Invalid game command for ride %u", _rideIndex);
@@ -64,7 +66,9 @@ public:
if (ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE && _modifyType == RIDE_MODIFY_DEMOLISH)
{
return std::make_unique<GameActionResult>(GA_ERROR::NO_CLEARANCE, STR_CANT_DEMOLISH_RIDE,
return std::make_unique<GameActionResult>(
GA_ERROR::NO_CLEARANCE,
STR_CANT_DEMOLISH_RIDE,
STR_LOCAL_AUTHORITY_FORBIDS_DEMOLITION_OR_MODIFICATIONS_TO_THIS_RIDE);
}
@@ -74,20 +78,20 @@ public:
{
if (ride->status != RIDE_STATUS_CLOSED)
{
return std::make_unique<GameActionResult>(GA_ERROR::DISALLOWED, STR_CANT_REFURBISH_RIDE,
STR_MUST_BE_CLOSED_FIRST);
return std::make_unique<GameActionResult>(
GA_ERROR::DISALLOWED, STR_CANT_REFURBISH_RIDE, STR_MUST_BE_CLOSED_FIRST);
}
if (ride->num_riders > 0)
{
return std::make_unique<GameActionResult>(GA_ERROR::DISALLOWED, STR_CANT_REFURBISH_RIDE,
STR_RIDE_NOT_YET_EMPTY);
return std::make_unique<GameActionResult>(
GA_ERROR::DISALLOWED, STR_CANT_REFURBISH_RIDE, STR_RIDE_NOT_YET_EMPTY);
}
if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_EVER_BEEN_OPENED) || RideAvailableBreakdowns[ride->type] == 0)
{
return std::make_unique<GameActionResult>(GA_ERROR::DISALLOWED, STR_CANT_REFURBISH_RIDE,
STR_CANT_REFURBISH_NOT_NEEDED);
return std::make_unique<GameActionResult>(
GA_ERROR::DISALLOWED, STR_CANT_REFURBISH_RIDE, STR_CANT_REFURBISH_NOT_NEEDED);
}
result->ErrorTitle = STR_CANT_REFURBISH_RIDE;
@@ -99,26 +103,26 @@ public:
GameActionResult::Ptr Execute() const override
{
Ride *ride = get_ride(_rideIndex);
Ride* ride = get_ride(_rideIndex);
if (ride->type == RIDE_TYPE_NULL)
{
log_warning("Invalid game command for ride %u", _rideIndex);
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_DEMOLISH_RIDE, STR_NONE);
}
switch (_modifyType) {
case RIDE_MODIFY_DEMOLISH:
return DemolishRide(ride);
case RIDE_MODIFY_RENEW:
return RefurbishRide(ride);
switch (_modifyType)
{
case RIDE_MODIFY_DEMOLISH:
return DemolishRide(ride);
case RIDE_MODIFY_RENEW:
return RefurbishRide(ride);
}
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_DO_THIS);
}
private:
GameActionResult::Ptr DemolishRide(Ride * ride) const
GameActionResult::Ptr DemolishRide(Ride* ride) const
{
money32 refundPrice = DemolishTracks();
@@ -129,11 +133,9 @@ private:
sub_6CB945(_rideIndex);
news_item_disable_news(NEWS_ITEM_RIDE, _rideIndex);
for (auto &banner : gBanners)
for (auto& banner : gBanners)
{
if (banner.type != BANNER_NULL &&
banner.flags & BANNER_FLAG_LINKED_TO_RIDE &&
banner.ride_index == _rideIndex)
if (banner.type != BANNER_NULL && banner.flags & BANNER_FLAG_LINKED_TO_RIDE && banner.ride_index == _rideIndex)
{
banner.flags &= 0xFB;
banner.string_idx = STR_DEFAULT_SIGN;
@@ -141,8 +143,8 @@ private:
}
uint16_t spriteIndex;
rct_peep *peep;
FOR_ALL_GUESTS(spriteIndex, peep)
rct_peep* peep;
FOR_ALL_GUESTS (spriteIndex, peep)
{
uint8_t ride_id_bit = _rideIndex % 8;
uint8_t ride_id_offset = _rideIndex / 8;
@@ -165,8 +167,7 @@ private:
// remove any free voucher for this ride from peep
if (peep->item_standard_flags & PEEP_ITEM_VOUCHER)
{
if (peep->voucher_type == VOUCHER_TYPE_RIDE_FREE &&
peep->voucher_arguments == _rideIndex)
if (peep->voucher_type == VOUCHER_TYPE_RIDE_FREE && peep->voucher_arguments == _rideIndex)
{
peep->item_standard_flags &= ~(PEEP_ITEM_VOUCHER);
}
@@ -213,14 +214,13 @@ private:
for (int32_t i = 0; i < PEEP_MAX_THOUGHTS; i++)
{
if (peep->thoughts[i].type != PEEP_THOUGHT_TYPE_NONE &&
peep->thoughts[i].item == _rideIndex)
if (peep->thoughts[i].type != PEEP_THOUGHT_TYPE_NONE && peep->thoughts[i].item == _rideIndex)
{
// Clear top thought, push others up
memmove(&peep->thoughts[i], &peep->thoughts[i + 1], sizeof(rct_peep_thought)*(PEEP_MAX_THOUGHTS - i - 1));
memmove(&peep->thoughts[i], &peep->thoughts[i + 1], sizeof(rct_peep_thought) * (PEEP_MAX_THOUGHTS - i - 1));
peep->thoughts[PEEP_MAX_THOUGHTS - 1].type = PEEP_THOUGHT_TYPE_NONE;
peep->thoughts[PEEP_MAX_THOUGHTS - 1].item = PEEP_THOUGHT_ITEM_NONE;
//Next iteration, check the new thought at this index
// Next iteration, check the new thought at this index
i--;
}
}
@@ -322,8 +322,7 @@ private:
continue;
}
static constexpr const LocationXY16 DirOffsets[] =
{
static constexpr const LocationXY16 DirOffsets[] = {
{ 0, 0 },
{ 0, 16 },
{ 16, 16 },
@@ -347,7 +346,7 @@ private:
return refundPrice;
}
GameActionResult::Ptr RefurbishRide(Ride * ride) const
GameActionResult::Ptr RefurbishRide(Ride* ride) const
{
auto res = std::make_unique<GameActionResult>();
res->ExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION;
+13 -8
View File
@@ -29,10 +29,12 @@ private:
std::string _name;
public:
RideSetNameAction() {}
RideSetNameAction()
{
}
RideSetNameAction(int32_t rideIndex, const std::string& name)
: _rideIndex(rideIndex),
_name(name)
: _rideIndex(rideIndex)
, _name(name)
{
}
@@ -50,7 +52,7 @@ public:
GameActionResult::Ptr Query() const override
{
Ride *ride = get_ride(_rideIndex);
Ride* ride = get_ride(_rideIndex);
if (ride->type == RIDE_TYPE_NULL)
{
log_warning("Invalid game command for ride %u", _rideIndex);
@@ -59,10 +61,12 @@ public:
if (_name.empty())
{
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_RENAME_RIDE_ATTRACTION, STR_INVALID_RIDE_ATTRACTION_NAME);
return std::make_unique<GameActionResult>(
GA_ERROR::INVALID_PARAMETERS, STR_CANT_RENAME_RIDE_ATTRACTION, STR_INVALID_RIDE_ATTRACTION_NAME);
}
rct_string_id newUserStringId = user_string_allocate(USER_STRING_HIGH_ID_NUMBER | USER_STRING_DUPLICATION_PERMITTED, _name.c_str());
rct_string_id newUserStringId
= user_string_allocate(USER_STRING_HIGH_ID_NUMBER | USER_STRING_DUPLICATION_PERMITTED, _name.c_str());
if (newUserStringId == 0)
{
// TODO: Probably exhausted, introduce new error.
@@ -75,9 +79,10 @@ public:
GameActionResult::Ptr Execute() const override
{
rct_string_id newUserStringId = user_string_allocate(USER_STRING_HIGH_ID_NUMBER | USER_STRING_DUPLICATION_PERMITTED, _name.c_str());
rct_string_id newUserStringId
= user_string_allocate(USER_STRING_HIGH_ID_NUMBER | USER_STRING_DUPLICATION_PERMITTED, _name.c_str());
Ride *ride = get_ride(_rideIndex);
Ride* ride = get_ride(_rideIndex);
if (ride->type == RIDE_TYPE_NULL)
{
log_warning("Invalid game command for ride %u", _rideIndex);
+39 -41
View File
@@ -9,25 +9,19 @@
#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 "GameAction.h"
#include "../Cheats.h"
#include "../interface/Window.h"
#include "../management/Finance.h"
#include "../ride/Ride.h"
#include "../world/Park.h"
#include "../world/Sprite.h"
#include "../ride/Ride.h"
#include "GameAction.h"
static rct_string_id _StatusErrorTitles[] =
{
STR_CANT_CLOSE,
STR_CANT_OPEN,
STR_CANT_TEST
};
static rct_string_id _StatusErrorTitles[] = { STR_CANT_CLOSE, STR_CANT_OPEN, STR_CANT_TEST };
struct RideSetStatusAction : public GameActionBase<GAME_COMMAND_SET_RIDE_STATUS, GameActionResult>
{
@@ -36,10 +30,12 @@ private:
uint8_t _status = RIDE_STATUS_CLOSED;
public:
RideSetStatusAction() {}
RideSetStatusAction(uint8_t rideIndex, uint8_t status) :
_rideIndex(rideIndex),
_status(status)
RideSetStatusAction()
{
}
RideSetStatusAction(uint8_t rideIndex, uint8_t status)
: _rideIndex(rideIndex)
, _status(status)
{
}
@@ -58,7 +54,7 @@ public:
GameActionResult::Ptr Query() const override
{
GameActionResult::Ptr res = std::make_unique<GameActionResult>();
Ride *ride = get_ride(_rideIndex);
Ride* ride = get_ride(_rideIndex);
res->ErrorTitle = _StatusErrorTitles[_status];
set_format_arg_on(res->ErrorMessageArgs.data(), 6, rct_string_id, ride->name);
set_format_arg_on(res->ErrorMessageArgs.data(), 8, uint32_t, ride->name_arguments);
@@ -82,7 +78,8 @@ public:
return res;
}
}
else if (_status == RIDE_STATUS_OPEN) {
else if (_status == RIDE_STATUS_OPEN)
{
if (!ride_is_valid_for_open(_rideIndex, _status == RIDE_STATUS_OPEN, 0))
{
res->Error = GA_ERROR::UNKNOWN;
@@ -99,10 +96,10 @@ public:
GameActionResult::Ptr res = std::make_unique<GameActionResult>();
res->ExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_RUNNING_COSTS;
Ride *ride = get_ride(_rideIndex);
Ride* ride = get_ride(_rideIndex);
res->ErrorTitle = _StatusErrorTitles[_status];
set_format_arg_on(res->ErrorMessageArgs.data(), 6, rct_string_id, ride->name);
set_format_arg_on(res->ErrorMessageArgs.data(), 8,uint32_t, ride->name_arguments);
set_format_arg_on(res->ErrorMessageArgs.data(), 8, uint32_t, ride->name_arguments);
if (ride->type == RIDE_TYPE_NULL)
{
@@ -112,33 +109,34 @@ public:
return res;
}
if (ride->overall_view.xy != RCT_XY8_UNDEFINED)
if (ride->overall_view.xy != RCT_XY8_UNDEFINED)
{
res->Position.x = ride->overall_view.x * 32 + 16;
res->Position.y = ride->overall_view.y * 32 + 16;
res->Position.z = tile_element_height(res->Position.x, res->Position.y);
}
switch (_status) {
case RIDE_STATUS_CLOSED:
if (ride->status == _status)
{
if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN))
switch (_status)
{
case RIDE_STATUS_CLOSED:
if (ride->status == _status)
{
ride->lifecycle_flags &= ~RIDE_LIFECYCLE_CRASHED;
ride_clear_for_construction(_rideIndex);
ride_remove_peeps(_rideIndex);
if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN))
{
ride->lifecycle_flags &= ~RIDE_LIFECYCLE_CRASHED;
ride_clear_for_construction(_rideIndex);
ride_remove_peeps(_rideIndex);
}
}
}
ride->status = RIDE_STATUS_CLOSED;
ride->lifecycle_flags &= ~RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING;
ride->race_winner = SPRITE_INDEX_NULL;
ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAIN | RIDE_INVALIDATE_RIDE_LIST;
window_invalidate_by_number(WC_RIDE, _rideIndex);
break;
case RIDE_STATUS_TESTING:
case RIDE_STATUS_OPEN:
ride->status = RIDE_STATUS_CLOSED;
ride->lifecycle_flags &= ~RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING;
ride->race_winner = SPRITE_INDEX_NULL;
ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAIN | RIDE_INVALIDATE_RIDE_LIST;
window_invalidate_by_number(WC_RIDE, _rideIndex);
break;
case RIDE_STATUS_TESTING:
case RIDE_STATUS_OPEN:
{
if (ride->status == _status)
{
@@ -147,7 +145,7 @@ public:
// Fix #3183: Make sure we close the construction window so the ride finishes any editing code before opening
// otherwise vehicles get added to the ride incorrectly (such as to a ghost station)
rct_window *constructionWindow = window_find_by_number(WC_RIDE_CONSTRUCTION, _rideIndex);
rct_window* constructionWindow = window_find_by_number(WC_RIDE_CONSTRUCTION, _rideIndex);
if (constructionWindow != nullptr)
{
window_close(constructionWindow);
@@ -176,9 +174,9 @@ public:
window_invalidate_by_number(WC_RIDE, _rideIndex);
break;
}
default:
Guard::Assert(false, "Invalid status passed: %u", _status);
break;
default:
Guard::Assert(false, "Invalid status passed: %u", _status);
break;
}
return res;
}
@@ -9,13 +9,12 @@
#pragma once
#include "../core/MemoryStream.h"
#include "../localisation/StringIds.h"
#include "GameAction.h"
#include "../Cheats.h"
#include "../core/MemoryStream.h"
#include "../interface/Window.h"
#include "../localisation/StringIds.h"
#include "../world/Park.h"
#include "GameAction.h"
struct SetParkEntranceFeeAction : public GameActionBase<GAME_COMMAND_SET_PARK_ENTRANCE_FEE, GameActionResult>
{
@@ -23,8 +22,10 @@ private:
money16 _fee;
public:
SetParkEntranceFeeAction() {}
SetParkEntranceFeeAction(money16 fee)
SetParkEntranceFeeAction()
{
}
SetParkEntranceFeeAction(money16 fee)
: _fee(fee)
{
}
@@ -63,4 +64,3 @@ public:
return std::make_unique<GameActionResult>();
}
};
@@ -27,10 +27,12 @@ private:
uint8_t _colour;
public:
StaffSetColourAction() {}
StaffSetColourAction()
{
}
StaffSetColourAction(uint8_t staffType, uint8_t colour)
: _staffType(staffType),
_colour(colour)
: _staffType(staffType)
, _colour(colour)
{
}
@@ -47,9 +49,7 @@ public:
GameActionResult::Ptr Query() const override
{
if (_staffType != STAFF_TYPE_HANDYMAN &&
_staffType != STAFF_TYPE_MECHANIC &&
_staffType != STAFF_TYPE_SECURITY)
if (_staffType != STAFF_TYPE_HANDYMAN && _staffType != STAFF_TYPE_MECHANIC && _staffType != STAFF_TYPE_SECURITY)
{
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
}
@@ -66,8 +66,8 @@ public:
// Update each staff member's uniform
int32_t spriteIndex;
rct_peep * peep;
FOR_ALL_PEEPS(spriteIndex, peep)
rct_peep* peep;
FOR_ALL_PEEPS (spriteIndex, peep)
{
if (peep->type == PEEP_TYPE_STAFF && peep->staff_type == _staffType)
{
+26 -18
View File
@@ -9,19 +9,18 @@
#pragma once
#include "../core/MemoryStream.h"
#include "../localisation/StringIds.h"
#include "GameAction.h"
#include "../Cheats.h"
#include "../Context.h"
#include "../core/MemoryStream.h"
#include "../drawing/Drawing.h"
#include "../peep/Staff.h"
#include "../interface/Window.h"
#include "../localisation/Localisation.h"
#include "../localisation/StringIds.h"
#include "../peep/Staff.h"
#include "../windows/Intent.h"
#include "../world/Park.h"
#include "../world/Sprite.h"
#include "GameAction.h"
struct StaffSetNameAction : public GameActionBase<GAME_COMMAND_SET_STAFF_NAME, GameActionResult>
{
@@ -30,10 +29,12 @@ private:
std::string _name;
public:
StaffSetNameAction() {}
StaffSetNameAction()
{
}
StaffSetNameAction(uint16_t spriteIndex, const std::string& name)
: _spriteIndex(spriteIndex),
_name(name)
: _spriteIndex(spriteIndex)
, _name(name)
{
}
@@ -53,7 +54,8 @@ public:
{
if (_spriteIndex >= MAX_SPRITES)
{
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, STR_NONE);
return std::make_unique<GameActionResult>(
GA_ERROR::INVALID_PARAMETERS, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, STR_NONE);
}
if (_name.empty())
@@ -61,18 +63,21 @@ public:
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER);
}
rct_peep * peep = GET_PEEP(_spriteIndex);
rct_peep* peep = GET_PEEP(_spriteIndex);
if (peep->type != PEEP_TYPE_STAFF)
{
log_warning("Invalid game command for sprite %u", _spriteIndex);
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, STR_NONE);
return std::make_unique<GameActionResult>(
GA_ERROR::INVALID_PARAMETERS, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, STR_NONE);
}
rct_string_id newUserStringId = user_string_allocate(USER_STRING_HIGH_ID_NUMBER | USER_STRING_DUPLICATION_PERMITTED, _name.c_str());
rct_string_id newUserStringId
= user_string_allocate(USER_STRING_HIGH_ID_NUMBER | USER_STRING_DUPLICATION_PERMITTED, _name.c_str());
if (newUserStringId == 0)
{
// TODO: Probably exhausted, introduce new error.
return std::make_unique<GameActionResult>(GA_ERROR::UNKNOWN, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, gGameCommandErrorText);
return std::make_unique<GameActionResult>(
GA_ERROR::UNKNOWN, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, gGameCommandErrorText);
}
user_string_free(newUserStringId);
@@ -81,22 +86,25 @@ public:
GameActionResult::Ptr Execute() const override
{
rct_string_id newUserStringId = user_string_allocate(USER_STRING_HIGH_ID_NUMBER | USER_STRING_DUPLICATION_PERMITTED, _name.c_str());
rct_string_id newUserStringId
= user_string_allocate(USER_STRING_HIGH_ID_NUMBER | USER_STRING_DUPLICATION_PERMITTED, _name.c_str());
if (newUserStringId == 0)
{
// TODO: Probably exhausted, introduce new error.
return std::make_unique<GameActionResult>(GA_ERROR::UNKNOWN, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, gGameCommandErrorText);
return std::make_unique<GameActionResult>(
GA_ERROR::UNKNOWN, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, gGameCommandErrorText);
}
rct_peep * peep = GET_PEEP(_spriteIndex);
rct_peep* peep = GET_PEEP(_spriteIndex);
if (peep->type != PEEP_TYPE_STAFF)
{
log_warning("Invalid game command for sprite %u", _spriteIndex);
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, STR_NONE);
return std::make_unique<GameActionResult>(
GA_ERROR::INVALID_PARAMETERS, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, STR_NONE);
}
set_format_arg(0, uint32_t, peep->id);
utf8 * curName = gCommonStringFormatBuffer;
utf8* curName = gCommonStringFormatBuffer;
rct_string_id curId = peep->name_string_idx;
format_string(curName, 256, curId, gCommonFormatArgs);
+12 -10
View File
@@ -49,16 +49,15 @@ public:
res->Cost = 0;
res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING;
if (!map_is_location_valid({_location.x << 5, _location.y << 5}))
if (!map_is_location_valid({ _location.x << 5, _location.y << 5 }))
{
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS);
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;
if (!isGhost &&
!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) &&
!gCheatsSandboxMode &&
!map_is_location_owned(_location.x << 5, _location.y << 5, _location.z << 3))
if (!isGhost && !(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode
&& !map_is_location_owned(_location.x << 5, _location.y << 5, _location.z << 3))
{
return std::make_unique<GameActionResult>(GA_ERROR::NOT_OWNED, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK);
}
@@ -66,7 +65,8 @@ public:
rct_tile_element* wallElement = GetFirstWallElementAt(_location, isGhost);
if (wallElement == nullptr)
{
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS);
return std::make_unique<GameActionResult>(
GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS);
}
res->Cost = 0;
@@ -81,10 +81,11 @@ public:
const bool isGhost = GetFlags() & GAME_COMMAND_FLAG_GHOST;
rct_tile_element * wallElement = GetFirstWallElementAt(_location, isGhost);
rct_tile_element* wallElement = GetFirstWallElementAt(_location, isGhost);
if (wallElement == nullptr)
{
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS);
return std::make_unique<GameActionResult>(
GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS);
}
res->Position.x = (_location.x << 5) + 16;
@@ -92,7 +93,8 @@ public:
res->Position.z = tile_element_height(res->Position.x, res->Position.y);
tile_element_remove_banner_entry(wallElement);
map_invalidate_tile_zoom1(_location.x << 5, _location.y << 5, wallElement->base_height * 8, (wallElement->base_height * 8) + 72);
map_invalidate_tile_zoom1(
_location.x << 5, _location.y << 5, wallElement->base_height * 8, (wallElement->base_height * 8) + 72);
tile_element_remove(wallElement);
return res;