From aba3c270bbdaec1f3108e738a318ee7720db4241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sat, 30 Sep 2017 23:57:38 +0200 Subject: [PATCH] Game actions fixes --- src/openrct2/actions/GameAction.cpp | 4 +++- src/openrct2/actions/GameAction.h | 9 +++----- .../actions/PlaceParkEntranceAction.hpp | 15 +++++------- src/openrct2/actions/RideCreateAction.hpp | 23 ++++++++----------- src/openrct2/actions/RideDemolishAction.hpp | 22 ++++++++---------- src/openrct2/actions/RideSetName.hpp | 16 +++++-------- src/openrct2/actions/RideSetStatus.hpp | 17 ++++++-------- 7 files changed, 44 insertions(+), 62 deletions(-) diff --git a/src/openrct2/actions/GameAction.cpp b/src/openrct2/actions/GameAction.cpp index b43bc6543b..6641c4a63e 100644 --- a/src/openrct2/actions/GameAction.cpp +++ b/src/openrct2/actions/GameAction.cpp @@ -176,8 +176,10 @@ namespace GameActions uint32 playerId = action->GetPlayer(); network_set_player_last_action(network_get_player_index(playerId), action->GetType()); - if(result->Cost != 0) + if (result->Cost != 0) + { network_add_player_money_spent(playerId, result->Cost); + } } } diff --git a/src/openrct2/actions/GameAction.h b/src/openrct2/actions/GameAction.h index f95fd994bd..7995249ea3 100644 --- a/src/openrct2/actions/GameAction.h +++ b/src/openrct2/actions/GameAction.h @@ -23,11 +23,8 @@ #include "../core/DataSerialiser.h" #include "../core/IStream.hpp" -extern "C" -{ - #include "../game.h" - #include "../world/map.h" -} +#include "../game.h" +#include "../world/map.h" /** * Common error codes for game actions. @@ -123,7 +120,7 @@ public: virtual uint16 GetActionFlags() const { // Make sure we execute some things only on the client. - if ((GetFlags() & GAME_COMMAND_FLAG_GHOST) != 0 || + if ((GetFlags() & GAME_COMMAND_FLAG_GHOST) != 0 || (GetFlags() & GAME_COMMAND_FLAG_5) != 0) { return GA_FLAGS::CLIENT_ONLY; diff --git a/src/openrct2/actions/PlaceParkEntranceAction.hpp b/src/openrct2/actions/PlaceParkEntranceAction.hpp index 2965083a3d..1e932d70e1 100644 --- a/src/openrct2/actions/PlaceParkEntranceAction.hpp +++ b/src/openrct2/actions/PlaceParkEntranceAction.hpp @@ -14,20 +14,17 @@ *****************************************************************************/ #pragma endregion +#pragma once + #include "../core/MemoryStream.h" #include "../localisation/string_ids.h" #include "../OpenRCT2.h" #include "GameAction.h" -#pragma once - -extern "C" -{ - #include "../cheats.h" - #include "../world/entrance.h" - #include "../world/park.h" - #include "../world/footpath.h" -} +#include "../cheats.h" +#include "../world/entrance.h" +#include "../world/park.h" +#include "../world/footpath.h" struct PlaceParkEntranceGameActionResult : public GameActionResult { diff --git a/src/openrct2/actions/RideCreateAction.hpp b/src/openrct2/actions/RideCreateAction.hpp index aae4a54dfb..19347e736c 100644 --- a/src/openrct2/actions/RideCreateAction.hpp +++ b/src/openrct2/actions/RideCreateAction.hpp @@ -21,17 +21,14 @@ #include "../localisation/string_ids.h" #include "GameAction.h" -extern "C" -{ - #include "../localisation/date.h" - #include "../cheats.h" - #include "../interface/window.h" - #include "../world/park.h" - #include "../rct1.h" - #include "../ride/ride_data.h" - #include "../ride/ride.h" - #include "../ride/station.h" -} +#include "../localisation/date.h" +#include "../cheats.h" +#include "../interface/window.h" +#include "../world/park.h" +#include "../rct1.h" +#include "../ride/ride_data.h" +#include "../ride/ride.h" +#include "../ride/station.h" struct RideCreateGameActionResult : public GameActionResult { @@ -308,5 +305,5 @@ public: res->Position.x = (uint16)0x8000; return std::move(res); - } -}; \ No newline at end of file + } +}; diff --git a/src/openrct2/actions/RideDemolishAction.hpp b/src/openrct2/actions/RideDemolishAction.hpp index 69476347d2..2ffd1f4564 100644 --- a/src/openrct2/actions/RideDemolishAction.hpp +++ b/src/openrct2/actions/RideDemolishAction.hpp @@ -19,19 +19,16 @@ #include "../core/MemoryStream.h" #include "GameAction.h" -extern "C" -{ - #include "../cheats.h" - #include "../interface/window.h" - #include "../localisation/localisation.h" - #include "../ride/ride.h" - #include "../world/park.h" -} +#include "../cheats.h" +#include "../interface/window.h" +#include "../localisation/localisation.h" +#include "../ride/ride.h" +#include "../world/park.h" struct RideDemolishAction : public GameActionBase { private: - sint32 _rideIndex; + sint32 _rideIndex = -1; public: RideDemolishAction() {} @@ -91,7 +88,7 @@ public: for (sint32 i = 0; i < MAX_BANNERS; i++) { rct_banner *banner = &gBanners[i]; - if (banner->type != BANNER_NULL && + if (banner->type != BANNER_NULL && banner->flags & BANNER_FLAG_LINKED_TO_RIDE && banner->colour == _rideIndex) { @@ -125,7 +122,7 @@ public: // 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 && + if (peep->voucher_type == VOUCHER_TYPE_RIDE_FREE && peep->voucher_arguments == _rideIndex) { peep->item_standard_flags &= ~(PEEP_ITEM_VOUCHER); @@ -198,7 +195,7 @@ public: res->Position = { x, y, z }; } - + window_close_by_number(WC_RIDE_CONSTRUCTION, _rideIndex); window_close_by_number(WC_RIDE, _rideIndex); window_close_by_number(WC_DEMOLISH_RIDE_PROMPT, _rideIndex); @@ -209,4 +206,3 @@ public: return res; } }; - diff --git a/src/openrct2/actions/RideSetName.hpp b/src/openrct2/actions/RideSetName.hpp index bebad4fb20..4309735738 100644 --- a/src/openrct2/actions/RideSetName.hpp +++ b/src/openrct2/actions/RideSetName.hpp @@ -20,23 +20,20 @@ #include "../localisation/string_ids.h" #include "GameAction.h" -extern "C" -{ - #include "../cheats.h" - #include "../interface/window.h" - #include "../localisation/localisation.h" - #include "../world/park.h" -} +#include "../cheats.h" +#include "../interface/window.h" +#include "../localisation/localisation.h" +#include "../world/park.h" struct RideSetNameAction : public GameActionBase { private: - sint32 _rideIndex; + sint32 _rideIndex = -1; std::string _name; public: RideSetNameAction() {} - RideSetNameAction(sint32 rideIndex, const std::string& name) + RideSetNameAction(sint32 rideIndex, const std::string& name) : _rideIndex(rideIndex), _name(name) { @@ -108,4 +105,3 @@ public: return res; } }; - diff --git a/src/openrct2/actions/RideSetStatus.hpp b/src/openrct2/actions/RideSetStatus.hpp index bf9edc1e82..cc140abb69 100644 --- a/src/openrct2/actions/RideSetStatus.hpp +++ b/src/openrct2/actions/RideSetStatus.hpp @@ -20,19 +20,16 @@ #include "../localisation/string_ids.h" #include "GameAction.h" -extern "C" -{ - #include "../cheats.h" - #include "../interface/window.h" - #include "../world/park.h" - #include "../ride/ride.h" -} +#include "../cheats.h" +#include "../interface/window.h" +#include "../world/park.h" +#include "../ride/ride.h" struct RideSetStatusAction : public GameActionBase { private: - uint8 _rideIndex; - uint8 _status; + sint32 _rideIndex = -1; + uint8 _status = RIDE_STATUS_CLOSED; public: RideSetStatusAction() {} @@ -56,7 +53,7 @@ public: GameActionResult::Ptr Query() const override { - if (_rideIndex >= MAX_RIDES) + if (_rideIndex >= MAX_RIDES || _rideIndex < 0) { log_warning("Invalid game command for ride %u", _rideIndex); return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_INVALID_SELECTION_OF_OBJECTS);