2016-05-04 19:24:41 +02:00
/*****************************************************************************
2020-07-21 15:04:34 +02:00
* Copyright (c) 2014-2020 OpenRCT2 developers
2016-05-04 19:24:41 +02:00
*
2018-06-15 14:07:34 +02:00
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
2016-05-04 19:24:41 +02:00
*
2018-06-15 14:07:34 +02:00
* OpenRCT2 is licensed under the GNU General Public License version 3.
2016-05-04 19:24:41 +02:00
*****************************************************************************/
2018-06-22 22:59:46 +02:00
#include "InteractiveConsole.h"
2018-03-11 18:15:44 +00:00
2017-03-25 17:42:14 +00:00
#include "../Context.h"
2018-06-22 22:59:46 +02:00
#include "../EditorObjectSelectionSession.h"
#include "../Game.h"
#include "../OpenRCT2.h"
2020-03-31 23:12:35 +02:00
#include "../PlatformEnvironment.h"
2018-12-06 06:34:27 +01:00
#include "../ReplayManager.h"
2018-06-22 22:59:46 +02:00
#include "../Version.h"
2020-12-09 23:39:10 -07:00
#include "../actions/ClimateSetAction.h"
#include "../actions/RideSetPriceAction.h"
#include "../actions/RideSetSettingAction.h"
#include "../actions/SetCheatAction.h"
#include "../actions/StaffSetCostumeAction.h"
2018-06-22 22:59:46 +02:00
#include "../config/Config.h"
2021-05-09 19:11:04 +01:00
#include "../core/Console.hpp"
2018-03-13 13:14:02 +01:00
#include "../core/Guard.hpp"
2020-03-31 23:12:35 +02:00
#include "../core/Path.hpp"
2018-01-19 20:26:08 +01:00
#include "../core/String.hpp"
2018-01-05 21:17:33 +00:00
#include "../drawing/Drawing.h"
2018-01-06 18:32:25 +01:00
#include "../drawing/Font.h"
2018-11-19 04:38:55 +09:00
#include "../interface/Chat.h"
2018-01-21 03:07:56 +01:00
#include "../interface/Colour.h"
2019-06-15 17:01:41 +02:00
#include "../interface/Window_internal.h"
2018-01-06 18:32:25 +01:00
#include "../localisation/Localisation.h"
2017-10-06 22:37:06 +02:00
#include "../management/Finance.h"
2020-04-16 16:27:48 +02:00
#include "../management/NewsItem.h"
2017-10-05 16:22:37 +02:00
#include "../management/Research.h"
2016-10-24 13:11:36 -04:00
#include "../network/network.h"
2018-01-02 20:36:42 +01:00
#include "../object/Object.h"
2018-02-08 20:44:24 +01:00
#include "../object/ObjectList.h"
2016-07-05 19:33:12 +01:00
#include "../object/ObjectManager.h"
2016-07-02 21:52:17 +01:00
#include "../object/ObjectRepository.h"
2017-10-13 10:06:36 +02:00
#include "../peep/Staff.h"
2020-04-16 16:36:00 +02:00
#include "../platform/platform.h"
2017-12-31 13:21:34 +01:00
#include "../ride/Ride.h"
2018-01-10 00:00:09 +01:00
#include "../ride/RideData.h"
2021-05-29 06:01:32 +01:00
#include "../ride/Vehicle.h"
2017-12-13 13:02:24 +01:00
#include "../util/Util.h"
2017-10-19 10:01:05 +02:00
#include "../windows/Intent.h"
2017-03-11 11:24:18 +00:00
#include "../world/Climate.h"
2021-02-23 10:49:41 +01:00
#include "../world/EntityList.h"
2017-12-31 21:40:00 +01:00
#include "../world/Park.h"
2018-01-11 10:59:26 +01:00
#include "../world/Scenery.h"
2018-03-19 23:34:37 +01:00
#include "../world/Sprite.h"
2018-01-05 23:45:53 +00:00
#include "Viewport.h"
2015-05-19 03:53:37 +01:00
2018-06-22 22:59:46 +02:00
#include <algorithm>
#include <cmath>
#include <cstdarg>
2018-11-17 00:26:27 +01:00
#include <cstdlib>
2018-06-22 22:59:46 +02:00
#include <deque>
2018-11-17 00:26:27 +01:00
#include <exception>
2018-06-22 22:59:46 +02:00
#include <string>
#include <thread>
2019-01-24 16:12:49 +01:00
#include <vector>
2018-06-22 22:59:46 +02:00
2017-10-13 18:07:02 +02:00
#ifndef NO_TTF
2018-07-21 16:17:06 +02:00
# include "../drawing/TTF.h"
2017-10-13 18:07:02 +02:00
#endif
2019-01-24 16:12:49 +01:00
using arguments_t = std :: vector < std :: string > ;
static constexpr const char * ClimateNames [] = {
2018-11-07 23:12:05 +01:00
"cool_and_wet" ,
"warm" ,
"hot_and_dry" ,
"cold" ,
};
2019-01-24 16:12:49 +01:00
static int32_t console_parse_int ( const std :: string & src , bool * valid );
static double console_parse_double ( const std :: string & src , bool * valid );
2015-05-19 03:53:37 +01:00
2019-01-24 16:12:49 +01:00
static void console_write_all_commands ( InteractiveConsole & console );
static int32_t cc_variables ( InteractiveConsole & console , const arguments_t & argv );
static int32_t cc_windows ( InteractiveConsole & console , const arguments_t & argv );
static int32_t cc_help ( InteractiveConsole & console , const arguments_t & argv );
2015-05-19 13:46:05 -04:00
2018-06-22 22:59:46 +02:00
static bool invalidArguments ( bool * invalid , bool arguments );
2015-06-19 10:51:54 -04:00
2018-06-22 22:59:46 +02:00
#define SET_FLAG(variable, flag, value) \
{ \
if (value) \
variable |= flag; \
else \
variable &= ~(flag); \
}
2015-05-19 21:12:09 -04:00
2019-01-24 16:12:49 +01:00
static int32_t console_parse_int ( const std :: string & src , bool * valid )
2018-06-22 22:59:46 +02:00
{
utf8 * end ;
2018-06-20 17:28:51 +02:00
int32_t value ;
2019-01-24 16:12:49 +01:00
value = static_cast < int32_t > ( strtol ( src . c_str (), & end , 10 ));
2018-06-22 22:59:46 +02:00
* valid = ( * end == '\0' );
2017-06-06 23:24:18 +02:00
return value ;
2015-05-19 21:12:09 -04:00
}
2019-01-24 16:12:49 +01:00
static double console_parse_double ( const std :: string & src , bool * valid )
2018-06-22 22:59:46 +02:00
{
utf8 * end ;
2017-06-06 23:24:18 +02:00
double value ;
2019-01-24 16:12:49 +01:00
value = strtod ( src . c_str (), & end );
2018-06-22 22:59:46 +02:00
* valid = ( * end == '\0' );
2017-06-06 23:24:18 +02:00
return value ;
2015-05-19 21:12:09 -04:00
}
2019-01-24 16:12:49 +01:00
static int32_t cc_clear ( InteractiveConsole & console , [[maybe_unused]] const arguments_t & argv )
2015-05-19 03:53:37 +01:00
{
2018-03-11 19:46:03 +00:00
console . Clear ();
2017-06-06 23:24:18 +02:00
return 0 ;
2015-05-19 03:53:37 +01:00
}
2019-01-24 16:12:49 +01:00
static int32_t cc_close ( InteractiveConsole & console , [[maybe_unused]] const arguments_t & argv )
2015-06-01 02:33:56 +01:00
{
2018-03-11 21:21:27 +00:00
console . Close ();
2017-06-06 23:24:18 +02:00
return 0 ;
2015-06-01 02:33:56 +01:00
}
2019-01-24 16:12:49 +01:00
static int32_t cc_hide ( InteractiveConsole & console , [[maybe_unused]] const arguments_t & argv )
2018-03-22 20:29:41 +00:00
{
console . Hide ();
return 0 ;
}
2019-01-24 16:12:49 +01:00
static int32_t cc_echo ( InteractiveConsole & console , const arguments_t & argv )
2015-05-19 03:53:37 +01:00
{
2019-01-24 16:12:49 +01:00
if ( ! argv . empty ())
2018-03-11 19:46:03 +00:00
console . WriteLine ( argv [ 0 ]);
2017-06-06 23:24:18 +02:00
return 0 ;
2015-05-19 03:53:37 +01:00
}
2019-01-24 16:12:49 +01:00
static int32_t cc_rides ( InteractiveConsole & console , const arguments_t & argv )
2016-04-20 13:37:31 +02:00
{
2019-01-24 16:12:49 +01:00
if ( ! argv . empty ())
2018-06-22 22:59:46 +02:00
{
2019-01-24 16:12:49 +01:00
if ( argv [ 0 ] == "list" )
2018-06-22 22:59:46 +02:00
{
2019-08-04 14:45:17 +01:00
for ( const auto & ride : GetRideManager ())
2018-06-22 22:59:46 +02:00
{
2019-08-04 14:45:17 +01:00
auto name = ride . GetName ();
2018-06-22 22:59:46 +02:00
console . WriteFormatLine (
2019-08-04 14:45:17 +01:00
"ride: %03d type: %02u subtype %03u operating mode: %02u name: %s" , ride . id , ride . type , ride . subtype ,
ride . mode , name . c_str ());
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "set" )
2018-06-22 22:59:46 +02:00
{
2019-01-24 16:12:49 +01:00
if ( argv . size () < 4 )
2018-06-22 22:59:46 +02:00
{
2019-01-24 16:12:49 +01:00
if ( argv . size () > 1 && argv [ 1 ] == "mode" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "Ride modes are specified using integer IDs as given below:" );
2020-09-28 15:09:59 +02:00
for ( int32_t i = 0 ; i < static_cast < uint8_t > ( RideMode :: Count ); i ++ )
2018-06-22 22:59:46 +02:00
{
2017-06-06 23:24:18 +02:00
char mode_name [ 128 ] = { 0 };
rct_string_id mode_string_id = RideModeNames [ i ];
2018-01-07 21:43:07 +01:00
format_string ( mode_name , 128 , mode_string_id , nullptr );
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "%02d - %s" , i , mode_name );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
}
else
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "rides set type <ride id> <ride type>" );
console . WriteFormatLine ( "rides set mode [<ride id> <operating mode>]" );
console . WriteFormatLine ( "rides set mass <ride id> <mass value>" );
console . WriteFormatLine ( "rides set excitement <ride id> <excitement value>" );
console . WriteFormatLine ( "rides set intensity <ride id> <intensity value>" );
console . WriteFormatLine ( "rides set nausea <ride id> <nausea value>" );
2019-03-20 18:48:01 +00:00
console . WriteFormatLine ( "rides set price <ride id / all [type]> <price>" );
2017-06-06 23:24:18 +02:00
}
return 0 ;
}
2019-01-24 16:12:49 +01:00
if ( argv [ 1 ] == "type" )
2018-06-22 22:59:46 +02:00
{
2019-01-24 16:12:49 +01:00
bool int_valid [ 2 ] = { false };
2018-06-20 17:28:51 +02:00
int32_t ride_index = console_parse_int ( argv [ 2 ], & int_valid [ 0 ]);
int32_t type = console_parse_int ( argv [ 3 ], & int_valid [ 1 ]);
2018-06-22 22:59:46 +02:00
if ( ! int_valid [ 0 ] || ! int_valid [ 1 ])
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "This command expects integer arguments" );
2018-06-22 22:59:46 +02:00
}
else if ( ride_index < 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "Ride index must not be negative" );
2018-06-22 22:59:46 +02:00
}
else
{
2021-08-02 07:24:52 +03:00
int32_t res = set_operating_setting ( static_cast < ride_id_t > ( ride_index ), RideSetSetting :: RideType , type );
2018-06-22 22:59:46 +02:00
if ( res == MONEY32_UNDEFINED )
{
2021-05-11 01:27:39 -10:00
if ( ! gCheatsAllowArbitraryRideTypeChanges )
{
console . WriteFormatLine (
"That didn't work. Try enabling the 'Allow arbitrary ride type changes' cheat" );
}
else
{
console . WriteFormatLine ( "That didn't work" );
}
2017-06-06 23:24:18 +02:00
}
}
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 1 ] == "mode" )
2018-06-22 22:59:46 +02:00
{
2019-01-24 16:12:49 +01:00
bool int_valid [ 2 ] = { false };
2018-06-20 17:28:51 +02:00
int32_t ride_index = console_parse_int ( argv [ 2 ], & int_valid [ 0 ]);
int32_t mode = console_parse_int ( argv [ 3 ], & int_valid [ 1 ]);
2018-06-22 22:59:46 +02:00
if ( ! int_valid [ 0 ] || ! int_valid [ 1 ])
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "This command expects integer arguments" );
2018-06-22 22:59:46 +02:00
}
else if ( ride_index < 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "Ride index must not be negative" );
2018-06-22 22:59:46 +02:00
}
else
{
2021-08-02 07:24:52 +03:00
auto ride = get_ride ( static_cast < ride_id_t > ( ride_index ));
2020-09-28 15:09:59 +02:00
if ( mode >= static_cast < uint8_t > ( RideMode :: Count ))
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "Invalid ride mode." );
2017-06-06 23:24:18 +02:00
}
2019-08-04 14:45:17 +01:00
else if ( ride == nullptr )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "No ride found with index %d" , ride_index );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else
{
2020-09-28 15:09:59 +02:00
ride -> mode = static_cast < RideMode > ( mode & 0xFF );
2019-01-18 10:46:18 +00:00
invalidate_test_results ( ride );
2017-06-06 23:24:18 +02:00
}
}
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 1 ] == "mass" )
2018-06-22 22:59:46 +02:00
{
2019-01-24 16:12:49 +01:00
bool int_valid [ 2 ] = { false };
2018-06-20 17:28:51 +02:00
int32_t ride_index = console_parse_int ( argv [ 2 ], & int_valid [ 0 ]);
int32_t mass = console_parse_int ( argv [ 3 ], & int_valid [ 1 ]);
2017-02-24 20:48:04 +00:00
2018-06-22 22:59:46 +02:00
if ( ride_index < 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "Ride index must not be negative" );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( ! int_valid [ 0 ] || ! int_valid [ 1 ])
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "This command expects integer arguments" );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else
{
2021-08-02 07:24:52 +03:00
auto ride = get_ride ( static_cast < ride_id_t > ( ride_index ));
2018-06-22 22:59:46 +02:00
if ( mass <= 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "Friction value must be strictly positive" );
2017-06-06 23:24:18 +02:00
}
2019-08-04 14:45:17 +01:00
else if ( ride == nullptr )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "No ride found with index %d" , ride_index );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else
{
2020-07-31 07:48:27 +01:00
for ( int32_t i = 0 ; i < ride -> num_vehicles ; ++ i )
2018-06-22 22:59:46 +02:00
{
2020-07-31 07:48:27 +01:00
for ( Vehicle * vehicle = GetEntity < Vehicle > ( ride -> vehicles [ i ]); vehicle != nullptr ;
vehicle = GetEntity < Vehicle > ( vehicle -> next_vehicle_on_train ))
2018-06-22 22:59:46 +02:00
{
2017-12-17 18:00:42 +01:00
vehicle -> mass = mass ;
2017-06-06 23:24:18 +02:00
}
}
}
}
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 1 ] == "excitement" )
2018-06-22 22:59:46 +02:00
{
2019-01-24 16:12:49 +01:00
bool int_valid [ 2 ] = { false };
2018-06-20 17:28:51 +02:00
int32_t ride_index = console_parse_int ( argv [ 2 ], & int_valid [ 0 ]);
2017-06-06 23:24:18 +02:00
ride_rating excitement = console_parse_int ( argv [ 3 ], & int_valid [ 1 ]);
2017-02-24 20:48:04 +00:00
2018-06-22 22:59:46 +02:00
if ( ride_index < 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "Ride index must not be negative" );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( ! int_valid [ 0 ] || ! int_valid [ 1 ])
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "This command expects integer arguments" );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else
{
2021-08-02 07:24:52 +03:00
auto ride = get_ride ( static_cast < ride_id_t > ( ride_index ));
2018-06-22 22:59:46 +02:00
if ( excitement <= 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "Excitement value must be strictly positive" );
2017-06-06 23:24:18 +02:00
}
2019-08-04 14:45:17 +01:00
else if ( ride == nullptr )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "No ride found with index %d" , ride_index );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else
{
2017-06-06 23:24:18 +02:00
ride -> excitement = excitement ;
}
}
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 1 ] == "intensity" )
2018-06-22 22:59:46 +02:00
{
2019-01-24 16:12:49 +01:00
bool int_valid [ 2 ] = { false };
2018-06-20 17:28:51 +02:00
int32_t ride_index = console_parse_int ( argv [ 2 ], & int_valid [ 0 ]);
2017-06-06 23:24:18 +02:00
ride_rating intensity = console_parse_int ( argv [ 3 ], & int_valid [ 1 ]);
2017-02-24 20:48:04 +00:00
2018-06-22 22:59:46 +02:00
if ( ride_index < 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "Ride index must not be negative" );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( ! int_valid [ 0 ] || ! int_valid [ 1 ])
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "This command expects integer arguments" );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else
{
2021-08-02 07:24:52 +03:00
auto ride = get_ride ( static_cast < ride_id_t > ( ride_index ));
2018-06-22 22:59:46 +02:00
if ( intensity <= 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "Intensity value must be strictly positive" );
2017-06-06 23:24:18 +02:00
}
2019-08-04 14:45:17 +01:00
else if ( ride == nullptr )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "No ride found with index %d" , ride_index );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else
{
2017-06-06 23:24:18 +02:00
ride -> intensity = intensity ;
}
}
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 1 ] == "nausea" )
2018-06-22 22:59:46 +02:00
{
2019-01-24 16:12:49 +01:00
bool int_valid [ 2 ] = { false };
2018-06-20 17:28:51 +02:00
int32_t ride_index = console_parse_int ( argv [ 2 ], & int_valid [ 0 ]);
2017-06-06 23:24:18 +02:00
ride_rating nausea = console_parse_int ( argv [ 3 ], & int_valid [ 1 ]);
2018-06-22 22:59:46 +02:00
if ( ride_index < 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "Ride index must not be negative" );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( ! int_valid [ 0 ] || ! int_valid [ 1 ])
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "This command expects integer arguments" );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else
{
2021-08-02 07:24:52 +03:00
auto ride = get_ride ( static_cast < ride_id_t > ( ride_index ));
2018-06-22 22:59:46 +02:00
if ( nausea <= 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "Nausea value must be strictly positive" );
2017-06-06 23:24:18 +02:00
}
2019-08-04 14:45:17 +01:00
else if ( ride == nullptr )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "No ride found with index %d" , ride_index );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else
{
2017-06-06 23:24:18 +02:00
ride -> nausea = nausea ;
}
}
}
2019-03-18 21:38:48 +00:00
else if ( argv [ 1 ] == "price" )
{
bool int_valid [ 2 ] = { false };
if ( argv [ 2 ] == "all" )
{
auto arg1 = console_parse_int ( argv [ 3 ], & int_valid [ 0 ]);
if ( argv . size () <= 4 )
{
auto price = arg1 ;
if ( int_valid [ 0 ])
{
2019-08-04 16:00:15 +01:00
for ( const auto & ride : GetRideManager ())
2019-03-18 21:38:48 +00:00
{
2019-08-04 16:00:15 +01:00
auto rideSetPrice = RideSetPriceAction ( ride . id , price , true );
2019-03-18 21:38:48 +00:00
GameActions :: Execute ( & rideSetPrice );
}
}
else
{
console . WriteFormatLine ( "This command expects one or two integer arguments" );
}
}
else
{
auto rideType = arg1 ;
auto price = console_parse_int ( argv [ 4 ], & int_valid [ 1 ]);
if ( int_valid [ 0 ] && int_valid [ 1 ])
{
2019-08-04 14:45:17 +01:00
for ( const auto & ride : GetRideManager ())
2019-03-18 21:38:48 +00:00
{
2019-08-04 14:45:17 +01:00
if ( ride . type == rideType )
2019-03-18 21:38:48 +00:00
{
2019-08-04 14:45:17 +01:00
auto rideSetPrice = RideSetPriceAction ( ride . id , price , true );
2019-03-18 21:38:48 +00:00
GameActions :: Execute ( & rideSetPrice );
}
}
}
else
{
console . WriteFormatLine ( "This command expects one or two integer arguments" );
}
}
}
else
{
int32_t rideId = console_parse_int ( argv [ 2 ], & int_valid [ 0 ]);
money16 price = console_parse_int ( argv [ 3 ], & int_valid [ 1 ]);
if ( ! int_valid [ 0 ] || ! int_valid [ 1 ])
{
console . WriteFormatLine ( "This command expects the string all or two integer arguments" );
}
2019-03-18 21:50:29 +00:00
else
{
2021-08-02 07:24:52 +03:00
auto rideSetPrice = RideSetPriceAction ( static_cast < ride_id_t > ( rideId ), price , true );
2019-03-18 21:50:29 +00:00
GameActions :: Execute ( & rideSetPrice );
}
2019-03-18 21:38:48 +00:00
}
}
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
}
else
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "subcommands: list, set" );
2017-06-06 23:24:18 +02:00
}
return 0 ;
2016-04-20 13:37:31 +02:00
}
2019-01-24 16:12:49 +01:00
static int32_t cc_staff ( InteractiveConsole & console , const arguments_t & argv )
2016-05-19 21:30:32 +01:00
{
2019-01-24 16:12:49 +01:00
if ( ! argv . empty ())
2018-06-22 22:59:46 +02:00
{
2019-01-24 16:12:49 +01:00
if ( argv [ 0 ] == "list" )
2018-06-22 22:59:46 +02:00
{
2021-03-16 11:18:06 +00:00
for ( auto peep : EntityList < Staff > ())
2018-06-22 22:59:46 +02:00
{
2019-07-21 20:44:19 +01:00
auto name = peep -> GetName ();
2018-06-22 22:59:46 +02:00
console . WriteFormatLine (
2020-08-16 18:20:00 -04:00
"staff id %03d type: %02u energy %03u name %s" , peep -> sprite_index , peep -> AssignedStaffType , peep -> Energy ,
2020-06-10 17:54:34 +01:00
name . c_str ());
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "set" )
2018-06-22 22:59:46 +02:00
{
2019-01-24 16:12:49 +01:00
if ( argv . size () < 4 )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "staff set energy <staff id> <value 0-255>" );
console . WriteFormatLine ( "staff set costume <staff id> <costume id>" );
2020-09-08 15:29:18 -04:00
for ( int32_t i = 0 ; i < static_cast < uint8_t > ( EntertainerCostume :: Count ); i ++ )
2018-06-22 22:59:46 +02:00
{
2017-06-06 23:24:18 +02:00
char costume_name [ 128 ] = { 0 };
rct_string_id costume = StaffCostumeNames [ i ];
format_string ( costume_name , 128 , STR_DROPDOWN_MENU_LABEL , & costume );
// That's a terrible hack here. Costume names include inline sprites
// that don't work well with the console, so manually skip past them.
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( " costume %i: %s" , i , costume_name + 7 );
2017-06-06 23:24:18 +02:00
}
return 0 ;
}
2019-01-24 16:12:49 +01:00
if ( argv [ 1 ] == "energy" )
2018-06-22 22:59:46 +02:00
{
2018-06-20 17:28:51 +02:00
int32_t int_val [ 3 ];
2019-01-24 16:12:49 +01:00
bool int_valid [ 3 ] = { false };
2017-06-06 23:24:18 +02:00
int_val [ 0 ] = console_parse_int ( argv [ 2 ], & int_valid [ 0 ]);
int_val [ 1 ] = console_parse_int ( argv [ 3 ], & int_valid [ 1 ]);
2016-11-13 20:17:49 +01:00
2020-07-26 17:42:02 +01:00
if ( int_valid [ 0 ] && int_valid [ 1 ])
2018-06-22 22:59:46 +02:00
{
2020-07-26 17:42:02 +01:00
Peep * peep = GetEntity < Peep > ( int_val [ 0 ]);
if ( peep != nullptr )
{
peep -> Energy = int_val [ 1 ];
peep -> EnergyTarget = int_val [ 1 ];
}
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 1 ] == "costume" )
2018-06-22 22:59:46 +02:00
{
2018-06-20 17:28:51 +02:00
int32_t int_val [ 2 ];
2019-01-24 16:12:49 +01:00
bool int_valid [ 2 ] = { false };
2017-06-06 23:24:18 +02:00
int_val [ 0 ] = console_parse_int ( argv [ 2 ], & int_valid [ 0 ]);
int_val [ 1 ] = console_parse_int ( argv [ 3 ], & int_valid [ 1 ]);
2018-06-22 22:59:46 +02:00
if ( ! int_valid [ 0 ])
{
2018-03-11 19:46:03 +00:00
console . WriteLineError ( "Invalid staff ID" );
2017-06-06 23:24:18 +02:00
return 1 ;
}
2020-07-26 17:42:02 +01:00
auto staff = GetEntity < Staff > ( int_val [ 0 ]);
if ( staff == nullptr )
{
console . WriteLineError ( "Invalid staff ID" );
return 1 ;
}
2020-08-16 18:25:32 -04:00
if ( staff -> AssignedStaffType != StaffType :: Entertainer )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteLineError ( "Specified staff is not entertainer" );
2017-06-06 23:24:18 +02:00
return 1 ;
}
2020-09-08 15:29:18 -04:00
if ( ! int_valid [ 1 ] || int_val [ 1 ] < 0 || int_val [ 1 ] >= static_cast < uint8_t > ( EntertainerCostume :: Count ))
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteLineError ( "Invalid costume ID" );
2017-06-06 23:24:18 +02:00
return 1 ;
}
2016-12-28 14:06:24 +01:00
2020-09-08 15:29:18 -04:00
EntertainerCostume costume = static_cast < EntertainerCostume > ( int_val [ 1 ]);
2019-02-05 07:36:39 +00:00
auto staffSetCostumeAction = StaffSetCostumeAction ( int_val [ 0 ], costume );
2019-02-24 18:10:07 +00:00
GameActions :: Execute ( & staffSetCostumeAction );
2017-06-06 23:24:18 +02:00
}
}
2018-06-22 22:59:46 +02:00
}
else
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "subcommands: list, set" );
2017-06-06 23:24:18 +02:00
}
return 0 ;
2016-05-19 21:30:32 +01:00
}
2019-01-24 16:12:49 +01:00
static int32_t cc_get ( InteractiveConsole & console , const arguments_t & argv )
2015-05-19 03:53:37 +01:00
{
2019-01-24 16:12:49 +01:00
if ( ! argv . empty ())
2018-06-22 22:59:46 +02:00
{
2019-01-24 16:12:49 +01:00
if ( argv [ 0 ] == "park_rating" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "park_rating %d" , gParkRating );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "park_value" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "park_value %d" , gParkValue / 10 );
2018-01-07 06:00:29 +09:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "company_value" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "company_value %d" , gCompanyValue / 10 );
2018-01-07 06:00:29 +09:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "money" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "money %d.%d0" , gCash / 10 , gCash % 10 );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "scenario_initial_cash" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "scenario_initial_cash %d" , gInitialCash / 10 );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "current_loan" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "current_loan %d" , gBankLoan / 10 );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "max_loan" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "max_loan %d" , gMaxBankLoan / 10 );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "guest_initial_cash" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "guest_initial_cash %d.%d0" , gGuestInitialCash / 10 , gGuestInitialCash % 10 );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "guest_initial_happiness" )
2018-06-22 22:59:46 +02:00
{
2018-06-20 17:28:51 +02:00
uint32_t current_happiness = gGuestInitialHappiness ;
2018-06-22 22:59:46 +02:00
for ( int32_t i = 15 ; i <= 99 ; i ++ )
{
if ( i == 99 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "guest_initial_happiness %d%% (%d)" , 15 , gGuestInitialHappiness );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( current_happiness == calculate_guest_initial_happiness ( i ))
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "guest_initial_happiness %d%% (%d)" , i , gGuestInitialHappiness );
2017-06-06 23:24:18 +02:00
break ;
}
}
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "guest_initial_hunger" )
2018-06-22 22:59:46 +02:00
{
console . WriteFormatLine (
"guest_initial_hunger %d%% (%d)" , (( 255 - gGuestInitialHunger ) * 100 ) / 255 , gGuestInitialHunger );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "guest_initial_thirst" )
2018-06-22 22:59:46 +02:00
{
console . WriteFormatLine (
"guest_initial_thirst %d%% (%d)" , (( 255 - gGuestInitialThirst ) * 100 ) / 255 , gGuestInitialThirst );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "guest_prefer_less_intense_rides" )
2018-06-22 22:59:46 +02:00
{
console . WriteFormatLine (
"guest_prefer_less_intense_rides %d" , ( gParkFlags & PARK_FLAGS_PREF_LESS_INTENSE_RIDES ) != 0 );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "guest_prefer_more_intense_rides" )
2018-06-22 22:59:46 +02:00
{
console . WriteFormatLine (
"guest_prefer_more_intense_rides %d" , ( gParkFlags & PARK_FLAGS_PREF_MORE_INTENSE_RIDES ) != 0 );
2017-06-06 23:24:18 +02:00
}
2019-02-16 20:39:41 +00:00
else if ( argv [ 0 ] == "forbid_marketing_campaigns" )
2018-06-22 22:59:46 +02:00
{
2019-02-16 20:39:41 +00:00
console . WriteFormatLine ( "forbid_marketing_campaigns %d" , ( gParkFlags & PARK_FLAGS_FORBID_MARKETING_CAMPAIGN ) != 0 );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "forbid_landscape_changes" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "forbid_landscape_changes %d" , ( gParkFlags & PARK_FLAGS_FORBID_LANDSCAPE_CHANGES ) != 0 );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "forbid_tree_removal" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "forbid_tree_removal %d" , ( gParkFlags & PARK_FLAGS_FORBID_TREE_REMOVAL ) != 0 );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "forbid_high_construction" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "forbid_high_construction %d" , ( gParkFlags & PARK_FLAGS_FORBID_HIGH_CONSTRUCTION ) != 0 );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "pay_for_rides" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "pay_for_rides %d" , ( gParkFlags & PARK_FLAGS_PARK_FREE_ENTRY ) != 0 );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "no_money" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "no_money %d" , ( gParkFlags & PARK_FLAGS_NO_MONEY ) != 0 );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "difficult_park_rating" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "difficult_park_rating %d" , ( gParkFlags & PARK_FLAGS_DIFFICULT_PARK_RATING ) != 0 );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "difficult_guest_generation" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "difficult_guest_generation %d" , ( gParkFlags & PARK_FLAGS_DIFFICULT_GUEST_GENERATION ) != 0 );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "park_open" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "park_open %d" , ( gParkFlags & PARK_FLAGS_PARK_OPEN ) != 0 );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "land_rights_cost" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "land_rights_cost %d.%d0" , gLandPrice / 10 , gLandPrice % 10 );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "construction_rights_cost" )
2018-06-22 22:59:46 +02:00
{
console . WriteFormatLine (
"construction_rights_cost %d.%d0" , gConstructionRightsPrice / 10 , gConstructionRightsPrice % 10 );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "climate" )
2018-06-22 22:59:46 +02:00
{
2020-08-21 10:43:57 +02:00
console . WriteFormatLine (
"climate %s (%d)" , ClimateNames [ static_cast < uint8_t > ( gClimate )], static_cast < uint8_t > ( gClimate ));
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "game_speed" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "game_speed %d" , gGameSpeed );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "console_small_font" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "console_small_font %d" , gConfigInterface . console_small_font );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "location" )
2018-06-22 22:59:46 +02:00
{
rct_window * w = window_get_main ();
if ( w != nullptr )
{
rct_viewport * viewport = window_get_viewport ( w );
2020-08-02 08:32:59 +01:00
auto info = get_map_coordinates_from_pos (
2021-02-10 01:06:18 +00:00
{ viewport -> view_width / 2 , viewport -> view_height / 2 }, EnumsToFlags ( ViewportInteractionItem :: Terrain ));
2020-03-07 21:07:18 +01:00
2020-08-02 08:32:59 +01:00
auto tileMapCoord = TileCoordsXY ( info . Loc );
2020-03-07 21:07:18 +01:00
console . WriteFormatLine ( "location %d %d" , tileMapCoord . x , tileMapCoord . y );
2017-06-06 23:24:18 +02:00
}
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "window_scale" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "window_scale %.3f" , gConfigGeneral . window_scale );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "window_limit" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "window_limit %d" , gConfigGeneral . window_limit );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "render_weather_effects" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "render_weather_effects %d" , gConfigGeneral . render_weather_effects );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "render_weather_gloom" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "render_weather_gloom %d" , gConfigGeneral . render_weather_gloom );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "cheat_sandbox_mode" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "cheat_sandbox_mode %d" , gCheatsSandboxMode );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "cheat_disable_clearance_checks" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "cheat_disable_clearance_checks %d" , gCheatsDisableClearanceChecks );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "cheat_disable_support_limits" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "cheat_disable_support_limits %d" , gCheatsDisableSupportLimits );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "current_rotation" )
2018-10-14 22:44:45 +01:00
{
console . WriteFormatLine ( "current_rotation %d" , get_current_rotation ());
}
2021-01-19 19:44:36 +02:00
else if ( argv [ 0 ] == "host_timescale" )
{
console . WriteFormatLine ( "host_timescale %.02f" , OpenRCT2 :: GetContext () -> GetTimeScale ());
}
2017-10-13 18:07:02 +02:00
#ifndef NO_TTF
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "enable_hinting" )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "enable_hinting %d" , gConfigFonts . enable_hinting );
2017-10-13 18:07:02 +02:00
}
#endif
2018-06-22 22:59:46 +02:00
else
{
2018-03-11 19:46:03 +00:00
console . WriteLineWarning ( "Invalid variable." );
2017-06-06 23:24:18 +02:00
}
}
return 0 ;
2015-05-19 21:12:09 -04:00
}
2019-01-24 16:12:49 +01:00
static int32_t cc_set ( InteractiveConsole & console , const arguments_t & argv )
2015-05-19 21:12:09 -04:00
{
2019-01-24 16:12:49 +01:00
uint32_t i ;
if ( argv . size () > 1 )
2018-06-22 22:59:46 +02:00
{
2018-06-20 17:28:51 +02:00
int32_t int_val [ 4 ];
2017-06-06 23:24:18 +02:00
bool int_valid [ 4 ];
double double_val [ 4 ];
bool double_valid [ 4 ];
bool invalidArgs = false ;
2015-05-19 21:12:09 -04:00
2018-06-22 22:59:46 +02:00
for ( i = 0 ; i < 4 ; i ++ )
{
2019-01-24 16:12:49 +01:00
if ( i + 1 < argv . size ())
2018-06-22 22:59:46 +02:00
{
2017-06-06 23:24:18 +02:00
int_val [ i ] = console_parse_int ( argv [ i + 1 ], & int_valid [ i ]);
double_val [ i ] = console_parse_double ( argv [ i + 1 ], & double_valid [ i ]);
}
2018-06-22 22:59:46 +02:00
else
{
int_val [ i ] = 0 ;
int_valid [ i ] = false ;
double_val [ i ] = 0 ;
double_valid [ i ] = false ;
2017-06-06 23:24:18 +02:00
}
}
2015-05-19 21:12:09 -04:00
2019-01-24 16:12:49 +01:00
if ( argv [ 0 ] == "money" && invalidArguments ( & invalidArgs , double_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2020-06-07 23:18:11 +02:00
money32 money = MONEY ( static_cast < int32_t > ( double_val [ 0 ]), ( static_cast < int32_t > ( double_val [ 0 ] * 100 )) % 100 );
2018-06-22 22:59:46 +02:00
if ( gCash != money )
{
2019-05-04 15:28:38 +02:00
auto setCheatAction = SetCheatAction ( CheatType :: SetMoney , money );
2020-10-15 04:04:39 +03:00
setCheatAction . SetCallback ([ & console ]( const GameAction * , const GameActions :: Result * res ) {
if ( res -> Error != GameActions :: Status :: Ok )
2019-05-04 15:28:38 +02:00
console . WriteLineError ( "Network error: Permission denied!" );
else
console . Execute ( "get money" );
});
GameActions :: Execute ( & setCheatAction );
2017-06-06 23:24:18 +02:00
}
2019-05-04 15:28:38 +02:00
else
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
console . Execute ( "get money" );
2017-06-06 23:24:18 +02:00
}
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "scenario_initial_cash" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2018-08-12 12:50:40 +01:00
gInitialCash = std :: clamp ( MONEY ( int_val [ 0 ], 0 ), MONEY ( 0 , 0 ), MONEY ( 1000000 , 00 ));
2018-03-11 19:46:03 +00:00
console . Execute ( "get scenario_initial_cash" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "current_loan" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2021-04-10 16:00:50 +01:00
gBankLoan = std :: clamp < money64 > ( MONEY ( int_val [ 0 ] - ( int_val [ 0 ] % 1000 ), 0 ), MONEY ( 0 , 0 ), gMaxBankLoan );
2018-03-11 19:46:03 +00:00
console . Execute ( "get current_loan" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "max_loan" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2018-08-12 12:50:40 +01:00
gMaxBankLoan = std :: clamp ( MONEY ( int_val [ 0 ] - ( int_val [ 0 ] % 1000 ), 0 ), MONEY ( 0 , 0 ), MONEY ( 5000000 , 0 ));
2018-03-11 19:46:03 +00:00
console . Execute ( "get max_loan" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "guest_initial_cash" && invalidArguments ( & invalidArgs , double_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2018-08-12 12:50:40 +01:00
gGuestInitialCash = std :: clamp (
2020-06-07 23:18:11 +02:00
MONEY ( static_cast < int32_t > ( double_val [ 0 ]), ( static_cast < int32_t > ( double_val [ 0 ] * 100 )) % 100 ), MONEY ( 0 , 0 ),
MONEY ( 1000 , 0 ));
2018-03-11 19:46:03 +00:00
console . Execute ( "get guest_initial_cash" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "guest_initial_happiness" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2020-04-22 17:09:29 +02:00
gGuestInitialHappiness = calculate_guest_initial_happiness ( static_cast < uint8_t > ( int_val [ 0 ]));
2018-03-11 19:46:03 +00:00
console . Execute ( "get guest_initial_happiness" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "guest_initial_hunger" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2018-08-12 12:50:40 +01:00
gGuestInitialHunger = ( std :: clamp ( int_val [ 0 ], 1 , 84 ) * 255 / 100 - 255 ) * - 1 ;
2018-03-11 19:46:03 +00:00
console . Execute ( "get guest_initial_hunger" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "guest_initial_thirst" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2018-08-12 12:50:40 +01:00
gGuestInitialThirst = ( std :: clamp ( int_val [ 0 ], 1 , 84 ) * 255 / 100 - 255 ) * - 1 ;
2018-03-11 19:46:03 +00:00
console . Execute ( "get guest_initial_thirst" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "guest_prefer_less_intense_rides" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2017-06-06 23:24:18 +02:00
SET_FLAG ( gParkFlags , PARK_FLAGS_PREF_LESS_INTENSE_RIDES , int_val [ 0 ]);
2018-03-11 19:46:03 +00:00
console . Execute ( "get guest_prefer_less_intense_rides" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "guest_prefer_more_intense_rides" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2017-06-06 23:24:18 +02:00
SET_FLAG ( gParkFlags , PARK_FLAGS_PREF_MORE_INTENSE_RIDES , int_val [ 0 ]);
2018-03-11 19:46:03 +00:00
console . Execute ( "get guest_prefer_more_intense_rides" );
2017-06-06 23:24:18 +02:00
}
2019-02-16 20:39:41 +00:00
else if ( argv [ 0 ] == "forbid_marketing_campaigns" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2017-06-06 23:24:18 +02:00
SET_FLAG ( gParkFlags , PARK_FLAGS_FORBID_MARKETING_CAMPAIGN , int_val [ 0 ]);
2019-02-16 20:39:41 +00:00
console . Execute ( "get forbid_marketing_campaigns" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "forbid_landscape_changes" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2017-06-06 23:24:18 +02:00
SET_FLAG ( gParkFlags , PARK_FLAGS_FORBID_LANDSCAPE_CHANGES , int_val [ 0 ]);
2018-03-11 19:46:03 +00:00
console . Execute ( "get forbid_landscape_changes" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "forbid_tree_removal" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2017-06-06 23:24:18 +02:00
SET_FLAG ( gParkFlags , PARK_FLAGS_FORBID_TREE_REMOVAL , int_val [ 0 ]);
2018-03-11 19:46:03 +00:00
console . Execute ( "get forbid_tree_removal" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "forbid_high_construction" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2017-06-06 23:24:18 +02:00
SET_FLAG ( gParkFlags , PARK_FLAGS_FORBID_HIGH_CONSTRUCTION , int_val [ 0 ]);
2018-03-11 19:46:03 +00:00
console . Execute ( "get forbid_high_construction" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "pay_for_rides" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2017-06-06 23:24:18 +02:00
SET_FLAG ( gParkFlags , PARK_FLAGS_PARK_FREE_ENTRY , int_val [ 0 ]);
2018-03-11 19:46:03 +00:00
console . Execute ( "get pay_for_rides" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "no_money" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2017-06-06 23:24:18 +02:00
SET_FLAG ( gParkFlags , PARK_FLAGS_NO_MONEY , int_val [ 0 ]);
2018-03-11 19:46:03 +00:00
console . Execute ( "get no_money" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "difficult_park_rating" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2017-06-06 23:24:18 +02:00
SET_FLAG ( gParkFlags , PARK_FLAGS_DIFFICULT_PARK_RATING , int_val [ 0 ]);
2018-03-11 19:46:03 +00:00
console . Execute ( "get difficult_park_rating" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "difficult_guest_generation" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2017-06-06 23:24:18 +02:00
SET_FLAG ( gParkFlags , PARK_FLAGS_DIFFICULT_GUEST_GENERATION , int_val [ 0 ]);
2018-03-11 19:46:03 +00:00
console . Execute ( "get difficult_guest_generation" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "park_open" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2017-06-06 23:24:18 +02:00
SET_FLAG ( gParkFlags , PARK_FLAGS_PARK_OPEN , int_val [ 0 ]);
2018-03-11 19:46:03 +00:00
console . Execute ( "get park_open" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "land_rights_cost" && invalidArguments ( & invalidArgs , double_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2018-08-12 12:50:40 +01:00
gLandPrice = std :: clamp (
2020-06-07 23:18:11 +02:00
MONEY ( static_cast < int32_t > ( double_val [ 0 ]), ( static_cast < int32_t > ( double_val [ 0 ] * 100 )) % 100 ), MONEY ( 0 , 0 ),
MONEY ( 200 , 0 ));
2018-03-11 19:46:03 +00:00
console . Execute ( "get land_rights_cost" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "construction_rights_cost" && invalidArguments ( & invalidArgs , double_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2018-08-12 12:50:40 +01:00
gConstructionRightsPrice = std :: clamp (
2020-06-07 23:18:11 +02:00
MONEY ( static_cast < int32_t > ( double_val [ 0 ]), ( static_cast < int32_t > ( double_val [ 0 ] * 100 )) % 100 ), MONEY ( 0 , 0 ),
MONEY ( 200 , 0 ));
2018-03-11 19:46:03 +00:00
console . Execute ( "get construction_rights_cost" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "climate" )
2018-06-22 22:59:46 +02:00
{
2020-08-21 10:43:57 +02:00
uint8_t newClimate = static_cast < uint8_t > ( ClimateType :: Count );
invalidArgs = true ;
2018-06-22 22:59:46 +02:00
if ( int_valid [ 0 ])
{
2020-08-21 10:43:57 +02:00
newClimate = static_cast < uint8_t > ( int_val [ 0 ]);
invalidArgs = false ;
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else
{
2020-08-21 10:43:57 +02:00
for ( newClimate = 0 ; newClimate < static_cast < uint8_t > ( ClimateType :: Count ); newClimate ++ )
2018-06-22 22:59:46 +02:00
{
2020-08-21 10:43:57 +02:00
if ( argv [ 1 ] == ClimateNames [ newClimate ])
2018-06-22 22:59:46 +02:00
{
2020-08-21 10:43:57 +02:00
invalidArgs = false ;
2017-06-06 23:24:18 +02:00
break ;
}
}
}
2018-11-07 23:12:05 +01:00
2020-08-21 10:43:57 +02:00
if ( invalidArgs )
{
console . WriteLine ( language_get_string ( STR_INVALID_CLIMATE_ID ));
}
2017-06-06 23:24:18 +02:00
else
2020-08-21 10:43:57 +02:00
{
auto gameAction = ClimateSetAction ( ClimateType { newClimate });
GameActions :: Execute ( & gameAction );
2018-06-22 22:59:46 +02:00
console . Execute ( "get climate" );
2020-08-21 10:43:57 +02:00
}
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "game_speed" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2018-08-12 12:50:40 +01:00
gGameSpeed = std :: clamp ( int_val [ 0 ], 1 , 8 );
2018-03-11 19:46:03 +00:00
console . Execute ( "get game_speed" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "console_small_font" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2017-06-06 23:24:18 +02:00
gConfigInterface . console_small_font = ( int_val [ 0 ] != 0 );
config_save_default ();
2018-03-11 19:46:03 +00:00
console . Execute ( "get console_small_font" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "location" && invalidArguments ( & invalidArgs , int_valid [ 0 ] && int_valid [ 1 ]))
2018-06-22 22:59:46 +02:00
{
rct_window * w = window_get_main ();
if ( w != nullptr )
{
2020-03-01 23:18:59 +01:00
auto location = TileCoordsXYZ ( int_val [ 0 ], int_val [ 1 ], 0 ). ToCoordsXYZ (). ToTileCentre ();
location . z = tile_element_height ( location );
2020-07-16 17:01:42 -04:00
w -> SetLocation ( location );
2017-06-06 23:24:18 +02:00
viewport_update_position ( w );
2018-03-11 19:46:03 +00:00
console . Execute ( "get location" );
2017-06-06 23:24:18 +02:00
}
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "window_scale" && invalidArguments ( & invalidArgs , double_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2020-04-22 17:09:29 +02:00
float newScale = static_cast < float > ( 0.001 * std :: trunc ( 1000 * double_val [ 0 ]));
2018-08-12 12:50:40 +01:00
gConfigGeneral . window_scale = std :: clamp ( newScale , 0.5f , 5.0f );
2017-06-06 23:24:18 +02:00
config_save_default ();
gfx_invalidate_screen ();
context_trigger_resize ();
2017-12-09 17:08:38 +01:00
context_update_cursor_scale ();
2018-03-11 19:46:03 +00:00
console . Execute ( "get window_scale" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "window_limit" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2017-06-06 23:24:18 +02:00
window_set_window_limit ( int_val [ 0 ]);
2018-03-11 19:46:03 +00:00
console . Execute ( "get window_limit" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "render_weather_effects" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2017-06-06 23:24:18 +02:00
gConfigGeneral . render_weather_effects = ( int_val [ 0 ] != 0 );
config_save_default ();
2018-03-11 19:46:03 +00:00
console . Execute ( "get render_weather_effects" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "render_weather_gloom" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2017-06-06 23:24:18 +02:00
gConfigGeneral . render_weather_gloom = ( int_val [ 0 ] != 0 );
config_save_default ();
2018-03-11 19:46:03 +00:00
console . Execute ( "get render_weather_gloom" );
2017-06-06 23:24:18 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "cheat_sandbox_mode" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
if ( gCheatsSandboxMode != ( int_val [ 0 ] != 0 ))
{
2019-05-04 15:28:38 +02:00
auto setCheatAction = SetCheatAction ( CheatType :: SandboxMode , int_val [ 0 ] != 0 );
2020-10-15 04:04:39 +03:00
setCheatAction . SetCallback ([ & console ]( const GameAction * , const GameActions :: Result * res ) {
if ( res -> Error != GameActions :: Status :: Ok )
2019-05-04 15:28:38 +02:00
console . WriteLineError ( "Network error: Permission denied!" );
else
console . Execute ( "get cheat_sandbox_mode" );
});
GameActions :: Execute ( & setCheatAction );
}
else
{
console . Execute ( "get cheat_sandbox_mode" );
2017-06-06 23:24:18 +02:00
}
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "cheat_disable_clearance_checks" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
if ( gCheatsDisableClearanceChecks != ( int_val [ 0 ] != 0 ))
{
2019-05-04 15:28:38 +02:00
auto setCheatAction = SetCheatAction ( CheatType :: DisableClearanceChecks , int_val [ 0 ] != 0 );
2020-10-15 04:04:39 +03:00
setCheatAction . SetCallback ([ & console ]( const GameAction * , const GameActions :: Result * res ) {
if ( res -> Error != GameActions :: Status :: Ok )
2019-05-04 15:28:38 +02:00
console . WriteLineError ( "Network error: Permission denied!" );
else
console . Execute ( "get cheat_disable_clearance_checks" );
});
GameActions :: Execute ( & setCheatAction );
}
else
{
console . Execute ( "get cheat_disable_clearance_checks" );
2017-06-06 23:24:18 +02:00
}
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "cheat_disable_support_limits" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
if ( gCheatsDisableSupportLimits != ( int_val [ 0 ] != 0 ))
{
2019-05-04 15:28:38 +02:00
auto setCheatAction = SetCheatAction ( CheatType :: DisableSupportLimits , int_val [ 0 ] != 0 );
2020-10-15 04:04:39 +03:00
setCheatAction . SetCallback ([ & console ]( const GameAction * , const GameActions :: Result * res ) {
if ( res -> Error != GameActions :: Status :: Ok )
2019-05-04 15:28:38 +02:00
console . WriteLineError ( "Network error: Permission denied!" );
else
console . Execute ( "get cheat_disable_support_limits" );
});
GameActions :: Execute ( & setCheatAction );
}
else
{
console . Execute ( "get cheat_disable_support_limits" );
2017-06-06 23:24:18 +02:00
}
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "current_rotation" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-10-14 22:44:45 +01:00
{
uint8_t currentRotation = get_current_rotation ();
rct_window * mainWindow = window_get_main ();
int32_t newRotation = int_val [ 0 ];
if ( newRotation < 0 || newRotation > 3 )
{
console . WriteLineError ( "Invalid argument. Valid rotations are 0-3." );
}
else if ( newRotation != currentRotation && mainWindow != nullptr )
{
window_rotate_camera ( mainWindow , newRotation - currentRotation );
}
console . Execute ( "get current_rotation" );
}
2021-01-19 19:44:36 +02:00
else if ( argv [ 0 ] == "host_timescale" && invalidArguments ( & invalidArgs , double_valid [ 0 ]))
{
float newScale = static_cast < float > ( double_val [ 0 ]);
OpenRCT2 :: GetContext () -> SetTimeScale ( newScale );
console . Execute ( "get host_timescale" );
}
2017-10-13 18:07:02 +02:00
#ifndef NO_TTF
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "enable_hinting" && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
2018-06-22 22:59:46 +02:00
{
2017-10-13 18:07:02 +02:00
gConfigFonts . enable_hinting = ( int_val [ 0 ] != 0 );
config_save_default ();
2018-03-11 19:46:03 +00:00
console . Execute ( "get enable_hinting" );
2017-10-13 22:57:36 +02:00
ttf_toggle_hinting ();
2017-10-13 18:07:02 +02:00
}
#endif
2018-06-22 22:59:46 +02:00
else if ( invalidArgs )
{
2018-03-11 19:46:03 +00:00
console . WriteLineError ( "Invalid arguments." );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else
{
2018-03-11 19:46:03 +00:00
console . WriteLineError ( "Invalid variable." );
2017-06-06 23:24:18 +02:00
}
2015-05-20 02:37:44 +01:00
2017-06-06 23:24:18 +02:00
gfx_invalidate_screen ();
}
2018-06-22 22:59:46 +02:00
else
{
2018-03-11 19:46:03 +00:00
console . WriteLineError ( "Value required." );
2017-06-06 23:24:18 +02:00
}
return 0 ;
2015-05-19 03:53:37 +01:00
}
2018-04-20 13:56:37 +02:00
2019-01-24 16:12:49 +01:00
static int32_t cc_load_object ( InteractiveConsole & console , const arguments_t & argv )
2018-06-22 22:59:46 +02:00
{
2019-01-24 16:12:49 +01:00
if ( ! argv . empty ())
2018-06-22 22:59:46 +02:00
{
2017-06-06 23:24:18 +02:00
char name [ 9 ] = { 0 };
2018-12-15 22:23:31 +01:00
std :: fill_n ( name , 8 , ' ' );
2018-06-20 17:28:51 +02:00
int32_t i = 0 ;
2019-01-24 16:12:49 +01:00
for ( const char * ch = argv [ 0 ]. c_str (); * ch != '\0' && i < 8 ; ch ++ )
2018-06-22 22:59:46 +02:00
{
2017-06-06 23:24:18 +02:00
name [ i ++ ] = * ch ;
}
2016-07-02 21:52:17 +01:00
2018-06-22 22:59:46 +02:00
const ObjectRepositoryItem * ori = object_repository_find_object_by_name ( name );
if ( ori == nullptr )
{
2018-03-11 19:46:03 +00:00
console . WriteLineError ( "Could not find the object." );
2017-06-06 23:24:18 +02:00
return 1 ;
}
2016-07-02 21:52:17 +01:00
2018-06-22 22:59:46 +02:00
const rct_object_entry * entry = & ori -> ObjectEntry ;
2021-03-27 13:48:27 +01:00
const auto * loadedObject = object_manager_get_loaded_object ( ObjectEntryDescriptor ( * ori ));
2018-06-22 22:59:46 +02:00
if ( loadedObject != nullptr )
{
2018-03-11 19:46:03 +00:00
console . WriteLineError ( "Object is already in scenario." );
2017-06-06 23:24:18 +02:00
return 1 ;
}
2016-07-02 21:52:17 +01:00
2017-06-06 23:24:18 +02:00
loadedObject = object_manager_load_object ( entry );
2018-06-22 22:59:46 +02:00
if ( loadedObject == nullptr )
{
2018-03-11 19:46:03 +00:00
console . WriteLineError ( "Unable to load object." );
2017-06-06 23:24:18 +02:00
return 1 ;
}
2020-03-18 21:27:53 +01:00
auto groupIndex = object_manager_get_loaded_object_entry_index ( loadedObject );
2016-07-02 21:52:17 +01:00
2020-11-09 11:53:29 +01:00
ObjectType objectType = entry -> GetType ();
2020-11-09 10:36:37 +01:00
if ( objectType == ObjectType :: Ride )
2018-06-22 22:59:46 +02:00
{
2017-06-06 23:24:18 +02:00
// Automatically research the ride so it's supported by the game.
2018-06-22 22:59:46 +02:00
rct_ride_entry * rideEntry ;
2018-06-20 17:28:51 +02:00
int32_t rideType ;
2016-07-02 21:52:17 +01:00
2017-06-06 23:24:18 +02:00
rideEntry = get_ride_entry ( groupIndex );
2016-07-02 21:52:17 +01:00
2018-06-22 22:59:46 +02:00
for ( int32_t j = 0 ; j < MAX_RIDE_TYPES_PER_RIDE_ENTRY ; j ++ )
{
2017-06-06 23:24:18 +02:00
rideType = rideEntry -> ride_type [ j ];
2020-04-30 13:58:48 +02:00
if ( rideType != RIDE_TYPE_NULL )
{
2021-02-26 10:01:00 +01:00
ResearchCategory category = GetRideTypeDescriptor ( rideType ). GetResearchCategory ();
2020-04-30 13:58:48 +02:00
research_insert_ride_entry ( rideType , groupIndex , category , true );
}
2017-06-06 23:24:18 +02:00
}
2016-07-02 21:52:17 +01:00
2017-06-06 23:24:18 +02:00
gSilentResearch = true ;
research_reset_current_item ();
gSilentResearch = false ;
}
2020-11-09 10:36:37 +01:00
else if ( objectType == ObjectType :: SceneryGroup )
2018-06-22 22:59:46 +02:00
{
2020-01-26 15:17:37 +01:00
research_insert_scenery_group_entry ( groupIndex , true );
2016-07-02 21:52:17 +01:00
2017-06-06 23:24:18 +02:00
gSilentResearch = true ;
research_reset_current_item ();
gSilentResearch = false ;
}
scenery_set_default_placement_configuration ();
2017-10-07 01:28:00 +02:00
2018-02-05 22:59:44 +01:00
auto intent = Intent ( INTENT_ACTION_REFRESH_NEW_RIDES );
context_broadcast_intent ( & intent );
2016-07-02 21:52:17 +01:00
2017-06-06 23:24:18 +02:00
gWindowUpdateTicks = 0 ;
gfx_invalidate_screen ();
2018-03-11 19:46:03 +00:00
console . WriteLine ( "Object file loaded." );
2017-06-06 23:24:18 +02:00
}
2015-05-23 14:56:54 -04:00
2017-06-06 23:24:18 +02:00
return 0 ;
2015-05-23 14:56:54 -04:00
}
2015-08-16 15:31:59 +02:00
2019-01-24 16:12:49 +01:00
static int32_t cc_object_count ( InteractiveConsole & console , [[maybe_unused]] const arguments_t & argv )
2018-04-20 13:56:37 +02:00
{
2018-06-25 23:54:31 +02:00
const utf8 * object_type_names [] = {
"Rides" , "Small scenery" , "Large scenery" , "Walls" , "Banners" ,
"Paths" , "Path Additions" , "Scenery groups" , "Park entrances" , "Water" ,
};
2020-11-11 10:51:10 +01:00
for ( ObjectType i = ObjectType :: Ride ; i < ObjectType :: ScenarioText ; i ++ )
2018-06-22 22:59:46 +02:00
{
2018-06-20 17:28:51 +02:00
int32_t entryGroupIndex = 0 ;
2020-11-11 10:51:10 +01:00
for (; entryGroupIndex < object_entry_group_counts [ EnumValue ( i )]; entryGroupIndex ++ )
2018-06-22 22:59:46 +02:00
{
2020-11-11 10:51:10 +01:00
if ( object_entry_get_chunk ( i , entryGroupIndex ) == nullptr )
2018-02-11 18:56:09 +00:00
{
2017-06-06 23:24:18 +02:00
break ;
}
}
2020-11-11 10:51:10 +01:00
console . WriteFormatLine (
"%s: %d/%d" , object_type_names [ EnumValue ( i )], entryGroupIndex , object_entry_group_counts [ EnumValue ( i )]);
2017-06-06 23:24:18 +02:00
}
2015-05-23 14:56:54 -04:00
2017-06-06 23:24:18 +02:00
return 0 ;
2015-05-23 14:56:54 -04:00
}
2015-08-16 15:31:59 +02:00
2019-01-24 16:12:49 +01:00
static int32_t cc_open ( InteractiveConsole & console , const arguments_t & argv )
2018-06-22 22:59:46 +02:00
{
2019-01-24 16:12:49 +01:00
if ( ! argv . empty ())
2018-06-22 22:59:46 +02:00
{
2017-06-06 23:24:18 +02:00
bool title = ( gScreenFlags & SCREEN_FLAGS_TITLE_DEMO ) != 0 ;
bool invalidTitle = false ;
2019-01-24 16:12:49 +01:00
if ( argv [ 0 ] == "object_selection" && invalidArguments ( & invalidTitle , ! title ))
2018-06-22 22:59:46 +02:00
{
2021-08-19 00:04:49 -10:00
if ( network_get_mode () != NETWORK_MODE_NONE )
{
console . WriteLineError ( "Cannot open this window in multiplayer mode." );
}
else
{
// Only this window should be open for safety reasons
window_close_all ();
context_open_window ( WC_EDITOR_OBJECT_SELECTION );
}
2018-06-22 22:59:46 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "inventions_list" && invalidArguments ( & invalidTitle , ! title ))
2018-06-22 22:59:46 +02:00
{
2021-08-19 00:04:49 -10:00
if ( network_get_mode () != NETWORK_MODE_NONE )
{
console . WriteLineError ( "Cannot open this window in multiplayer mode." );
}
else
{
context_open_window ( WC_EDITOR_INVENTION_LIST );
}
2018-06-22 22:59:46 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "scenario_options" && invalidArguments ( & invalidTitle , ! title ))
2018-06-22 22:59:46 +02:00
{
2017-08-12 23:06:12 +02:00
context_open_window ( WC_EDITOR_SCENARIO_OPTIONS );
2018-06-22 22:59:46 +02:00
}
2020-09-28 02:53:31 +02:00
else if ( argv [ 0 ] == "objective_options" && invalidArguments ( & invalidTitle , ! title ))
{
2021-08-19 00:04:49 -10:00
if ( network_get_mode () != NETWORK_MODE_NONE )
{
console . WriteLineError ( "Cannot open this window in multiplayer mode." );
}
else
{
context_open_window ( WC_EDITOR_OBJECTIVE_OPTIONS );
}
2020-09-28 02:53:31 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "options" )
2018-06-22 22:59:46 +02:00
{
2017-08-06 05:22:00 +02:00
context_open_window ( WC_OPTIONS );
2018-06-22 22:59:46 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "themes" )
2018-06-22 22:59:46 +02:00
{
2017-08-06 05:22:00 +02:00
context_open_window ( WC_THEMES );
2018-06-22 22:59:46 +02:00
}
2019-01-24 16:12:49 +01:00
else if ( argv [ 0 ] == "title_sequences" )
2018-06-22 22:59:46 +02:00
{
2017-09-10 11:02:16 +02:00
context_open_window ( WC_TITLE_EDITOR );
2018-06-22 22:59:46 +02:00
}
else if ( invalidTitle )
{
2018-03-11 19:46:03 +00:00
console . WriteLineError ( "Cannot open this window in the title screen." );
2018-06-22 22:59:46 +02:00
}
else
{
2018-03-11 19:46:03 +00:00
console . WriteLineError ( "Invalid window." );
2017-06-06 23:24:18 +02:00
}
}
return 0 ;
2015-05-23 14:56:54 -04:00
}
2015-05-19 03:53:37 +01:00
2019-01-24 16:12:49 +01:00
static int32_t cc_remove_unused_objects ( InteractiveConsole & console , [[maybe_unused]] const arguments_t & argv )
2017-09-29 16:32:30 +02:00
{
2018-06-20 17:28:51 +02:00
int32_t result = editor_remove_unused_objects ();
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "%d unused object entries have been removed." , result );
2017-09-29 16:32:30 +02:00
return 0 ;
}
2020-03-16 09:48:26 +01:00
static int32_t cc_remove_floating_objects ( InteractiveConsole & console , const arguments_t & argv )
{
uint16_t result = remove_floating_sprites ();
console . WriteFormatLine ( "Removed %d flying objects" , result );
return 0 ;
}
2019-01-24 16:12:49 +01:00
static int32_t cc_remove_park_fences ( InteractiveConsole & console , [[maybe_unused]] const arguments_t & argv )
2017-10-08 09:12:00 +01:00
{
2017-10-31 12:57:40 +01:00
tile_element_iterator it ;
tile_element_iterator_begin ( & it );
2017-10-08 09:12:00 +01:00
do
{
2018-05-02 19:27:04 +02:00
if ( it . element -> GetType () == TILE_ELEMENT_TYPE_SURFACE )
2017-10-08 09:12:00 +01:00
{
// Remove all park fence flags
2018-09-16 21:53:12 +02:00
it . element -> AsSurface () -> SetParkFences ( 0 );
2017-10-08 09:12:00 +01:00
}
2018-06-22 22:59:46 +02:00
} while ( tile_element_iterator_next ( & it ));
2017-10-08 09:12:00 +01:00
2019-08-23 21:01:08 +02:00
gfx_invalidate_screen ();
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "Park fences have been removed." );
2017-10-08 09:12:00 +01:00
return 0 ;
}
2019-01-24 16:12:49 +01:00
static int32_t cc_show_limits ( InteractiveConsole & console , [[maybe_unused]] const arguments_t & argv )
2017-10-05 10:00:32 +02:00
{
2021-04-09 02:09:08 +01:00
const auto & tileElements = GetTileElements ();
2021-05-30 09:09:47 +01:00
const auto tileElementCount = tileElements . size ();
2017-10-05 10:00:32 +02:00
2019-08-03 17:27:50 +01:00
int32_t rideCount = ride_get_count ();
2018-06-20 17:28:51 +02:00
int32_t spriteCount = 0 ;
2021-03-16 11:18:06 +00:00
for ( int32_t i = 0 ; i < static_cast < uint8_t > ( EntityType :: Count ); ++ i )
2017-10-05 10:00:32 +02:00
{
2021-03-16 11:18:06 +00:00
spriteCount += GetEntityListCount ( EntityType ( i ));
2017-10-05 10:00:32 +02:00
}
2021-03-16 11:18:06 +00:00
int32_t staffCount = GetEntityListCount ( EntityType :: Staff );
2017-10-05 10:00:32 +02:00
2021-07-27 10:25:58 +01:00
auto bannerCount = GetNumBanners ();
2017-10-05 10:00:32 +02:00
2021-02-24 23:34:34 +01:00
console . WriteFormatLine ( "Sprites: %d/%d" , spriteCount , MAX_ENTITIES );
2021-05-30 09:09:47 +01:00
console . WriteFormatLine ( "Map Elements: %zu/%d" , tileElementCount , MAX_TILE_ELEMENTS );
2018-10-31 12:51:06 +01:00
console . WriteFormatLine ( "Banners: %d/%zu" , bannerCount , MAX_BANNERS );
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "Rides: %d/%d" , rideCount , MAX_RIDES );
console . WriteFormatLine ( "Staff: %d/%d" , staffCount , STAFF_MAX_COUNT );
2019-08-26 12:28:37 +01:00
console . WriteFormatLine ( "Images: %zu/%zu" , ImageListGetUsedCount (), ImageListGetMaximum ());
2017-10-05 10:00:32 +02:00
return 0 ;
}
2019-01-24 16:12:49 +01:00
static int32_t cc_for_date ( [[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t & argv )
2018-01-07 12:57:59 +01:00
{
2018-06-20 17:28:51 +02:00
int32_t year = 0 ;
int32_t month = 0 ;
int32_t day = 0 ;
2019-01-24 16:12:49 +01:00
if ( argv . size () < 1 || argv . size () > 3 )
2018-01-07 12:57:59 +01:00
{
return - 1 ;
}
// All cases involve providing a year, so grab that first
2019-01-24 16:12:49 +01:00
year = atoi ( argv [ 0 ]. c_str ());
2019-12-30 16:03:51 +01:00
if ( year < 1 || year > MAX_YEAR )
2018-01-07 12:57:59 +01:00
{
return - 1 ;
}
// YYYY (no month provided, preserve existing month)
2019-01-24 16:12:49 +01:00
if ( argv . size () == 1 )
2018-01-07 12:57:59 +01:00
{
month = gDateMonthsElapsed % MONTH_COUNT + 1 ;
}
// YYYY MM or YYYY MM DD (month provided)
2019-01-24 16:12:49 +01:00
if ( argv . size () >= 2 )
2018-01-07 12:57:59 +01:00
{
2019-01-24 16:12:49 +01:00
month = atoi ( argv [ 1 ]. c_str ());
2018-01-07 12:57:59 +01:00
month -= 2 ;
if ( month < 1 || month > MONTH_COUNT )
{
return - 1 ;
}
}
// YYYY OR YYYY MM (no day provided, preserve existing day)
2019-01-24 16:12:49 +01:00
if ( argv . size () <= 2 )
2018-01-07 12:57:59 +01:00
{
2020-04-22 17:09:29 +02:00
day = std :: clamp (
2020-10-21 02:05:27 +02:00
gDateMonthTicks / ( TICKS_PER_MONTH / days_in_month [ month - 1 ]) + 1 , 1 , static_cast < int > ( days_in_month [ month - 1 ]));
2018-01-07 12:57:59 +01:00
}
// YYYY MM DD (year, month, and day provided)
2019-01-24 16:12:49 +01:00
if ( argv . size () == 3 )
2018-01-07 12:57:59 +01:00
{
2019-01-24 16:12:49 +01:00
day = atoi ( argv [ 2 ]. c_str ());
2018-06-22 22:59:46 +02:00
if ( day < 1 || day > days_in_month [ month - 1 ])
2018-01-07 12:57:59 +01:00
{
return - 1 ;
}
}
date_set ( year , month , day );
window_invalidate_by_class ( WC_BOTTOM_TOOLBAR );
return 1 ;
}
2020-04-16 16:36:00 +02:00
static int32_t cc_load_park ( [[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t & argv )
{
if ( argv . size () < 1 )
{
console . WriteLine ( "Parameters required <filename>" );
return 0 ;
}
char savePath [ MAX_PATH ];
if ( String :: IndexOf ( argv [ 0 ]. c_str (), '/' ) == SIZE_MAX && String :: IndexOf ( argv [ 0 ]. c_str (), '\\' ) == SIZE_MAX )
{
// no / or \ was included. File should be in save dir.
platform_get_user_directory ( savePath , "save" , sizeof ( savePath ));
safe_strcat_path ( savePath , argv [ 0 ]. c_str (), sizeof ( savePath ));
}
else
{
safe_strcpy ( savePath , argv [ 0 ]. c_str (), sizeof ( savePath ));
}
if ( ! String :: EndsWith ( savePath , ".sv6" , true ) && ! String :: EndsWith ( savePath , ".sc6" , true ))
{
path_append_extension ( savePath , ".sv6" , sizeof ( savePath ));
}
if ( context_load_park_from_file ( savePath ))
{
console . WriteFormatLine ( "Park %s was loaded successfully" , savePath );
}
else
{
console . WriteFormatLine ( "Loading Park %s failed" , savePath );
}
return 1 ;
}
2019-01-24 16:12:49 +01:00
static int32_t cc_save_park ( [[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t & argv )
2018-10-14 22:36:41 +02:00
{
2019-01-24 16:12:49 +01:00
if ( argv . size () < 1 )
2018-10-14 22:36:41 +02:00
{
save_game_cmd ();
}
else
{
2019-01-24 16:12:49 +01:00
save_game_cmd ( argv [ 0 ]. c_str ());
2018-10-14 22:36:41 +02:00
}
return 1 ;
}
2019-01-24 16:12:49 +01:00
static int32_t cc_say ( InteractiveConsole & console , const arguments_t & argv )
2018-11-19 04:38:55 +09:00
{
if ( network_get_mode () == NETWORK_MODE_NONE || network_get_status () != NETWORK_STATUS_CONNECTED
2020-09-04 15:40:12 -03:00
|| network_get_authstatus () != NetworkAuth :: Ok )
2018-11-19 04:38:55 +09:00
{
console . WriteFormatLine ( "This command only works in multiplayer mode." );
return 0 ;
}
else
{
2019-01-24 16:12:49 +01:00
if ( ! argv . empty ())
2018-11-19 04:38:55 +09:00
{
2019-01-24 16:12:49 +01:00
network_send_chat ( argv [ 0 ]. c_str ());
2018-11-19 04:38:55 +09:00
return 1 ;
}
else
{
console . WriteFormatLine ( "Input your message" );
return 0 ;
}
}
}
2019-01-24 16:12:49 +01:00
static int32_t cc_replay_startrecord ( InteractiveConsole & console , const arguments_t & argv )
2018-12-06 06:34:27 +01:00
{
if ( network_get_mode () != NETWORK_MODE_NONE )
{
console . WriteFormatLine ( "This command is currently not supported in multiplayer mode." );
return 0 ;
}
2019-01-24 16:12:49 +01:00
if ( argv . size () < 1 )
2018-12-06 06:34:27 +01:00
{
console . WriteFormatLine ( "Parameters required <replay_name> [<max_ticks = 0xFFFFFFFF>]" );
return 0 ;
}
std :: string name = argv [ 0 ];
2018-12-28 20:31:07 +01:00
2020-03-31 23:12:35 +02:00
if ( ! String :: EndsWith ( name , ".sv6r" , true ))
{
name += ".sv6r" ;
}
std :: string outPath = OpenRCT2 :: GetContext () -> GetPlatformEnvironment () -> GetDirectoryPath (
OpenRCT2 :: DIRBASE :: USER , OpenRCT2 :: DIRID :: REPLAY );
name = Path :: Combine ( outPath , name );
2018-12-28 20:31:07 +01:00
// If ticks are specified by user use that otherwise maximum ticks specified by const.
uint32_t maxTicks = OpenRCT2 :: k_MaxReplayTicks ;
2019-01-24 16:12:49 +01:00
if ( argv . size () >= 2 )
2018-12-06 06:34:27 +01:00
{
2019-01-24 16:12:49 +01:00
maxTicks = atol ( argv [ 1 ]. c_str ());
2018-12-06 06:34:27 +01:00
}
auto * replayManager = OpenRCT2 :: GetContext () -> GetReplayManager ();
2018-12-28 20:31:07 +01:00
if ( replayManager -> StartRecording ( name , maxTicks ))
2018-12-06 06:34:27 +01:00
{
2019-01-02 05:20:10 +01:00
OpenRCT2 :: ReplayRecordInfo info ;
replayManager -> GetCurrentReplayInfo ( info );
const char * logFmt = "Replay recording started: (%s) %s" ;
console . WriteFormatLine ( logFmt , info . Name . c_str (), info . FilePath . c_str ());
2021-05-09 19:11:04 +01:00
Console :: WriteLine ( logFmt , info . Name . c_str (), info . FilePath . c_str ());
2019-01-02 05:20:10 +01:00
2018-12-28 20:31:07 +01:00
return 1 ;
2018-12-06 06:34:27 +01:00
}
return 0 ;
}
2019-01-24 16:12:49 +01:00
static int32_t cc_replay_stoprecord ( InteractiveConsole & console , const arguments_t & argv )
2018-12-06 06:34:27 +01:00
{
if ( network_get_mode () != NETWORK_MODE_NONE )
{
console . WriteFormatLine ( "This command is currently not supported in multiplayer mode." );
return 0 ;
}
auto * replayManager = OpenRCT2 :: GetContext () -> GetReplayManager ();
2019-05-10 22:00:38 +02:00
if ( ! replayManager -> IsRecording () && ! replayManager -> IsNormalising ())
2019-01-02 05:20:10 +01:00
{
console . WriteFormatLine ( "Replay currently not recording" );
return 0 ;
}
OpenRCT2 :: ReplayRecordInfo info ;
replayManager -> GetCurrentReplayInfo ( info );
2018-12-28 20:31:07 +01:00
if ( replayManager -> StopRecording ())
2018-12-06 06:34:27 +01:00
{
2019-01-02 05:20:10 +01:00
const char * logFmt = "Replay recording stopped: (%s) %s \n "
" Ticks: %u \n "
" Commands: %u \n "
" Checksums: %u" ;
console . WriteFormatLine (
logFmt , info . Name . c_str (), info . FilePath . c_str (), info . Ticks , info . NumCommands , info . NumChecksums );
2021-05-09 19:11:04 +01:00
Console :: WriteLine ( logFmt , info . Name . c_str (), info . FilePath . c_str (), info . Ticks , info . NumCommands , info . NumChecksums );
2019-01-02 05:20:10 +01:00
2018-12-28 20:31:07 +01:00
return 1 ;
2018-12-06 06:34:27 +01:00
}
return 0 ;
}
2019-01-24 16:12:49 +01:00
static int32_t cc_replay_start ( InteractiveConsole & console , const arguments_t & argv )
2018-12-06 06:34:27 +01:00
{
if ( network_get_mode () != NETWORK_MODE_NONE )
{
console . WriteFormatLine ( "This command is currently not supported in multiplayer mode." );
return 0 ;
}
2019-01-24 16:12:49 +01:00
if ( argv . size () < 1 )
2018-12-06 06:34:27 +01:00
{
console . WriteFormatLine ( "Parameters required <replay_name>" );
return 0 ;
}
std :: string name = argv [ 0 ];
auto * replayManager = OpenRCT2 :: GetContext () -> GetReplayManager ();
2018-12-28 20:31:07 +01:00
if ( replayManager -> StartPlayback ( name ))
2018-12-06 06:34:27 +01:00
{
2019-01-02 05:20:10 +01:00
OpenRCT2 :: ReplayRecordInfo info ;
replayManager -> GetCurrentReplayInfo ( info );
std :: time_t ts = info . TimeRecorded ;
2019-01-02 05:35:57 +01:00
char recordingDate [ 128 ] = {};
std :: strftime ( recordingDate , sizeof ( recordingDate ), "%c" , std :: localtime ( & ts ));
2019-01-02 05:20:10 +01:00
const char * logFmt = "Replay playback started: %s \n "
2019-01-02 05:35:57 +01:00
" Date Recorded: %s \n "
2019-01-02 05:20:10 +01:00
" Ticks: %u \n "
" Commands: %u \n "
" Checksums: %u" ;
2019-01-02 05:35:57 +01:00
console . WriteFormatLine ( logFmt , info . FilePath . c_str (), recordingDate , info . Ticks , info . NumCommands , info . NumChecksums );
2021-05-09 19:11:04 +01:00
Console :: WriteLine ( logFmt , info . FilePath . c_str (), recordingDate , info . Ticks , info . NumCommands , info . NumChecksums );
2019-01-02 05:20:10 +01:00
2018-12-28 20:31:07 +01:00
return 1 ;
2018-12-06 06:34:27 +01:00
}
return 0 ;
}
2019-01-24 16:12:49 +01:00
static int32_t cc_replay_stop ( InteractiveConsole & console , const arguments_t & argv )
2018-12-06 06:34:27 +01:00
{
if ( network_get_mode () != NETWORK_MODE_NONE )
{
console . WriteFormatLine ( "This command is currently not supported in multiplayer mode." );
return 0 ;
}
auto * replayManager = OpenRCT2 :: GetContext () -> GetReplayManager ();
2018-12-28 20:31:07 +01:00
if ( replayManager -> StopPlayback ())
2018-12-06 06:34:27 +01:00
{
2018-12-28 20:31:07 +01:00
console . WriteFormatLine ( "Stopped replay" );
return 1 ;
2018-12-06 06:34:27 +01:00
}
return 0 ;
}
2019-01-24 16:12:49 +01:00
static int32_t cc_replay_normalise ( InteractiveConsole & console , const arguments_t & argv )
2018-12-11 08:13:47 +01:00
{
if ( network_get_mode () != NETWORK_MODE_NONE )
{
console . WriteFormatLine ( "This command is currently not supported in multiplayer mode." );
return 0 ;
}
2019-01-24 16:12:49 +01:00
if ( argv . size () < 2 )
2018-12-11 08:13:47 +01:00
{
console . WriteFormatLine ( "Parameters required <replay_input> <replay_output>" );
return 0 ;
}
std :: string inputFile = argv [ 0 ];
std :: string outputFile = argv [ 1 ];
2020-04-10 07:55:52 +01:00
if ( ! String :: EndsWith ( outputFile , ".sv6r" , true ))
{
outputFile += ".sv6r" ;
}
std :: string outPath = OpenRCT2 :: GetContext () -> GetPlatformEnvironment () -> GetDirectoryPath (
OpenRCT2 :: DIRBASE :: USER , OpenRCT2 :: DIRID :: REPLAY );
outputFile = Path :: Combine ( outPath , outputFile );
2018-12-11 08:13:47 +01:00
auto * replayManager = OpenRCT2 :: GetContext () -> GetReplayManager ();
2018-12-28 20:31:07 +01:00
if ( replayManager -> NormaliseReplay ( inputFile , outputFile ))
2018-12-11 08:13:47 +01:00
{
2018-12-28 20:31:07 +01:00
console . WriteFormatLine ( "Stopped replay" );
return 1 ;
2018-12-11 08:13:47 +01:00
}
return 0 ;
}
2019-05-11 21:31:34 +02:00
static int32_t cc_mp_desync ( InteractiveConsole & console , const arguments_t & argv )
{
int32_t desyncType = 0 ;
if ( argv . size () >= 1 )
{
desyncType = atoi ( argv [ 0 ]. c_str ());
}
2021-03-25 08:08:26 +00:00
std :: vector < Guest *> guests ;
2019-05-11 21:31:34 +02:00
2021-03-25 08:08:26 +00:00
for ( auto * guest : EntityList < Guest > ())
2019-05-11 21:31:34 +02:00
{
2021-03-25 08:08:26 +00:00
guests . push_back ( guest );
2019-05-11 21:31:34 +02:00
}
switch ( desyncType )
{
2021-03-25 08:08:26 +00:00
case 0 : // Guest t-shirts.
2019-05-11 21:31:34 +02:00
{
2021-03-25 08:08:26 +00:00
if ( guests . empty ())
2019-05-11 21:31:34 +02:00
{
2021-03-25 08:08:26 +00:00
console . WriteFormatLine ( "No guests" );
2019-05-11 21:31:34 +02:00
}
else
{
2021-03-25 08:08:26 +00:00
auto * guest = guests [ 0 ];
if ( guests . size () > 1 )
guest = guests [ util_rand () % guests . size () - 1 ];
guest -> TshirtColour = util_rand () & 0xFF ;
guest -> Invalidate ();
2019-05-11 21:31:34 +02:00
}
break ;
}
2021-03-25 08:08:26 +00:00
case 1 : // Remove random guest.
2019-05-11 21:31:34 +02:00
{
2021-03-25 08:08:26 +00:00
if ( guests . empty ())
2019-05-11 21:31:34 +02:00
{
2021-03-25 08:08:26 +00:00
console . WriteFormatLine ( "No guest removed" );
2019-05-11 21:31:34 +02:00
}
else
{
2021-03-25 08:08:26 +00:00
auto * guest = guests [ 0 ];
if ( guests . size () > 1 )
guest = guests [ util_rand () % guests . size () - 1 ];
guest -> Remove ();
2019-05-11 21:31:34 +02:00
}
break ;
}
}
return 0 ;
}
2018-11-17 00:26:27 +01:00
#pragma warning(push)
#pragma warning(disable : 4702) // unreachable code
2019-01-24 16:12:49 +01:00
static int32_t cc_abort ( [[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t & argv )
2018-11-17 00:26:27 +01:00
{
std :: abort ();
return 0 ;
}
2019-01-24 16:12:49 +01:00
static int32_t cc_dereference ( [[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t & argv )
2018-11-29 21:02:56 +01:00
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnull-dereference"
// Dereference a nullptr to induce a crash to be caught by crash handler, on supported platforms
uint8_t * myptr = nullptr ;
* myptr = 42 ;
return 0 ;
#pragma GCC diagnostic pop
}
2019-01-24 16:12:49 +01:00
static int32_t cc_terminate ( [[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t & argv )
2018-11-17 00:26:27 +01:00
{
std :: terminate ();
return 0 ;
}
#pragma warning(pop)
2020-01-13 19:22:45 +01:00
static int32_t cc_assert ( [[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t & argv )
{
if ( ! argv . empty ())
Guard :: Assert ( false , "%s" , argv [ 0 ]. c_str ());
else
Guard :: Assert ( false );
return 0 ;
}
2020-04-16 16:27:48 +02:00
static int32_t cc_add_news_item ( [[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t & argv )
{
2020-09-28 12:28:31 +01:00
if ( argv . size () < 2 )
2020-04-16 16:27:48 +02:00
{
console . WriteLineWarning ( "Too few arguments" );
2020-07-26 02:46:22 -06:00
static_assert ( News :: ItemTypeCount == 10 , "News::ItemType::Count changed, update console command!" );
2020-09-28 12:28:31 +01:00
console . WriteLine ( "add_news_item <type> <message> [assoc]" );
2020-04-16 16:27:48 +02:00
console . WriteLine ( "type is one of:" );
2020-07-26 02:46:22 -06:00
console . WriteLine ( " 0 (News::ItemType::Null)" );
console . WriteLine ( " 1 (News::ItemType::Ride)" );
console . WriteLine ( " 2 (News::ItemType::PeepOnRide)" );
console . WriteLine ( " 3 (News::ItemType::Peep)" );
console . WriteLine ( " 4 (News::ItemType::Money)" );
console . WriteLine ( " 5 (News::ItemType::Blank)" );
console . WriteLine ( " 6 (News::ItemType::Research)" );
console . WriteLine ( " 7 (News::ItemType::Peeps)" );
console . WriteLine ( " 8 (News::ItemType::Award)" );
console . WriteLine ( " 9 (News::ItemType::Graph)" );
2020-04-16 16:27:48 +02:00
console . WriteLine ( "message is the message to display, wrapped in quotes for multiple words" );
2020-09-28 12:28:31 +01:00
console . WriteLine ( "assoc is the associated id of ride/peep/tile/etc. If the selected ItemType doesn't need an assoc "
"(Null, Money, Award, Graph), you can leave this field blank" );
2020-04-16 16:27:48 +02:00
return 1 ;
}
2020-09-28 12:28:31 +01:00
2020-04-16 16:27:48 +02:00
auto type = atoi ( argv [ 0 ]. c_str ());
auto msg = argv [ 1 ]. c_str ();
2020-09-28 12:28:31 +01:00
auto assoc = 0 ;
News :: ItemType itemType = static_cast < News :: ItemType > ( type );
if ( argv . size () == 3 ) // 3 arguments passed, set assoc
{
assoc = atoi ( argv [ 2 ]. c_str ());
}
else
{
if ( News :: CheckIfItemRequiresAssoc ( itemType ))
{
console . WriteLine ( "Selected ItemType requires an assoc" );
return 0 ;
}
}
News :: AddItemToQueue ( itemType , msg , assoc );
console . WriteLine ( "Successfully added News Item" );
2020-04-16 16:27:48 +02:00
return 0 ;
}
2019-01-24 16:12:49 +01:00
using console_command_func = int32_t ( * )( InteractiveConsole & console , const arguments_t & argv );
2018-06-22 22:59:46 +02:00
struct console_command
{
const utf8 * command ;
2017-06-06 23:24:18 +02:00
console_command_func func ;
2018-06-22 22:59:46 +02:00
const utf8 * help ;
const utf8 * usage ;
2018-02-14 09:42:26 +01:00
};
2015-05-19 03:53:37 +01:00
2018-05-16 20:41:29 +02:00
// clang-format off
2018-01-11 23:14:31 +01:00
static constexpr const utf8 * console_variable_table [] = {
2017-06-06 23:24:18 +02:00
"park_rating" ,
2018-01-07 06:00:29 +09:00
"park_value" ,
"company_value" ,
2017-06-06 23:24:18 +02:00
"money" ,
"scenario_initial_cash" ,
"current_loan" ,
"max_loan" ,
"guest_initial_cash" ,
"guest_initial_happiness" ,
"guest_initial_hunger" ,
"guest_initial_thirst" ,
"guest_prefer_less_intense_rides" ,
"guest_prefer_more_intense_rides" ,
2019-02-18 12:09:22 +00:00
"forbid_marketing_campaigns" ,
2017-06-06 23:24:18 +02:00
"forbid_landscape_changes" ,
"forbid_tree_removal" ,
"forbid_high_construction" ,
"pay_for_rides" ,
"no_money" ,
"difficult_park_rating" ,
"difficult_guest_generation" ,
"land_rights_cost" ,
"construction_rights_cost" ,
"park_open" ,
"climate" ,
"game_speed" ,
"console_small_font" ,
"location" ,
"window_scale" ,
"window_limit" ,
"render_weather_effects" ,
"render_weather_gloom" ,
"cheat_sandbox_mode" ,
"cheat_disable_clearance_checks" ,
"cheat_disable_support_limits" ,
2018-10-14 22:44:45 +01:00
"current_rotation" ,
2015-05-19 21:12:09 -04:00
};
2018-01-11 23:14:31 +01:00
static constexpr const utf8 * console_window_table [] = {
2017-06-06 23:24:18 +02:00
"object_selection" ,
"inventions_list" ,
"scenario_options" ,
2020-09-28 02:53:31 +02:00
"objective_options" ,
2017-06-06 23:24:18 +02:00
"options" ,
"themes" ,
"title_sequences"
2015-05-19 03:53:37 +01:00
};
2018-01-11 23:14:31 +01:00
static constexpr const console_command console_command_table [] = {
2018-11-17 00:26:27 +01:00
{ "abort" , cc_abort , "Calls std::abort(), for testing purposes only." , "abort" },
2020-04-16 16:27:48 +02:00
{ "add_news_item" , cc_add_news_item , "Inserts a news item" , "add_news_item [<type> <message> <assoc>]" },
2020-01-13 19:22:45 +01:00
{ "assert" , cc_assert , "Triggers assertion failure, for testing purposes only" , "assert" },
2018-11-19 04:38:55 +09:00
{ "clear" , cc_clear , "Clears the console." , "clear" },
{ "close" , cc_close , "Closes the console." , "close" },
{ "date" , cc_for_date , "Sets the date to a given date." , "Format <year>[ <month>[ <day>]]." },
2018-11-29 21:02:56 +01:00
{ "dereference" , cc_dereference , "Dereferences a nullptr, for testing purposes only" , "dereference" },
2017-06-06 23:24:18 +02:00
{ "echo" , cc_echo , "Echoes the text to the console." , "echo <text>" },
2018-11-19 04:38:55 +09:00
{ "exit" , cc_close , "Closes the console." , "exit" },
2017-06-06 23:24:18 +02:00
{ "get" , cc_get , "Gets the value of the specified variable." , "get <variable>" },
2018-11-17 00:26:27 +01:00
{ "help" , cc_help , "Lists commands or info about a command." , "help [command]" },
2018-11-19 04:38:55 +09:00
{ "hide" , cc_hide , "Hides the console." , "hide" },
2017-06-06 23:24:18 +02:00
{ "load_object" , cc_load_object , "Loads the object file into the scenario. \n "
"Loading a scenery group will not load its associated objects. \n "
"This is a safer method opposed to \" open object_selection \" ." ,
"load_object <objectfilenodat>" },
2020-04-16 16:36:00 +02:00
{ "load_park" , cc_load_park , "Load park from save directory or by absolute path" , "load_park <filename>" },
2017-06-06 23:24:18 +02:00
{ "object_count" , cc_object_count , "Shows the number of objects of each type in the scenario." , "object_count" },
2018-11-17 00:26:27 +01:00
{ "open" , cc_open , "Opens the window with the give name." , "open <window>." },
2018-11-19 04:38:55 +09:00
{ "quit" , cc_close , "Closes the console." , "quit" },
{ "remove_park_fences" , cc_remove_park_fences , "Removes all park fences from the surface" , "remove_park_fences" },
2018-11-17 00:26:27 +01:00
{ "remove_unused_objects" , cc_remove_unused_objects , "Removes all the unused objects from the object selection." , "remove_unused_objects" },
2020-03-16 09:48:26 +01:00
{ "remove_floating_objects" , cc_remove_floating_objects , "Removes floating objects" , "remove_floating_objects" },
2017-06-06 23:24:18 +02:00
{ "rides" , cc_rides , "Ride management." , "rides <subcommand>" },
2018-11-19 04:38:55 +09:00
{ "save_park" , cc_save_park , "Save current state of park. If no name specified default path will be used." , "save_park [name]" },
{ "say" , cc_say , "Say to other players." , "say <message>" },
2018-11-17 00:26:27 +01:00
{ "set" , cc_set , "Sets the variable to the specified value." , "set <variable> <value>" },
{ "show_limits" , cc_show_limits , "Shows the map data counts and limits." , "show_limits" },
2018-11-19 04:38:55 +09:00
{ "staff" , cc_staff , "Staff management." , "staff <subcommand>" },
2018-11-17 00:26:27 +01:00
{ "terminate" , cc_terminate , "Calls std::terminate(), for testing purposes only." , "terminate" },
{ "variables" , cc_variables , "Lists all the variables that can be used with get and sometimes set." , "variables" },
{ "windows" , cc_windows , "Lists all the windows that can be opened." , "windows" },
2018-12-06 06:34:27 +01:00
{ "replay_startrecord" , cc_replay_startrecord , "Starts recording a new replay." , "replay_startrecord <name> [max_ticks]" },
{ "replay_stoprecord" , cc_replay_stoprecord , "Stops recording a new replay." , "replay_stoprecord" },
{ "replay_start" , cc_replay_start , "Starts a replay" , "replay_start <name>" },
{ "replay_stop" , cc_replay_stop , "Stops the replay" , "replay_stop" },
2018-12-11 08:13:47 +01:00
{ "replay_normalise" , cc_replay_normalise , "Normalises the replay to remove all gaps" , "replay_normalise <input file> <output file>" },
2021-03-25 08:08:26 +00:00
{ "mp_desync" , cc_mp_desync , "Forces a multiplayer desync" , "cc_mp_desync [desync_type, 0 = Random t-shirt color on random guest, 1 = Remove random guest ]" },
2019-11-24 10:04:32 -03:00
2015-05-23 14:56:54 -04:00
};
2018-05-16 20:41:29 +02:00
// clang-format on
2015-05-23 14:56:54 -04:00
2019-01-24 16:12:49 +01:00
static int32_t cc_windows ( InteractiveConsole & console , [[maybe_unused]] const arguments_t & argv )
2018-04-20 13:56:37 +02:00
{
2018-01-05 23:28:04 +00:00
for ( auto s : console_window_table )
{
2018-03-11 19:46:03 +00:00
console . WriteLine ( s );
2018-01-05 23:28:04 +00:00
}
2017-06-06 23:24:18 +02:00
return 0 ;
2015-05-23 14:56:54 -04:00
}
2018-04-20 13:56:37 +02:00
2019-01-24 16:12:49 +01:00
static int32_t cc_variables ( InteractiveConsole & console , [[maybe_unused]] const arguments_t & argv )
2015-05-19 21:12:09 -04:00
{
2018-01-05 23:28:04 +00:00
for ( auto s : console_variable_table )
{
2018-03-11 19:46:03 +00:00
console . WriteLine ( s );
2018-01-05 23:28:04 +00:00
}
2017-06-06 23:24:18 +02:00
return 0 ;
2015-05-19 21:12:09 -04:00
}
2019-01-24 16:12:49 +01:00
static int32_t cc_help ( InteractiveConsole & console , const arguments_t & argv )
2015-05-19 13:46:05 -04:00
{
2019-01-24 16:12:49 +01:00
if ( ! argv . empty ())
2018-01-05 23:28:04 +00:00
{
2018-06-22 22:59:46 +02:00
for ( const auto & c : console_command_table )
2018-01-05 23:28:04 +00:00
{
2019-01-24 16:12:49 +01:00
if ( argv [ 0 ] == c . command )
2018-01-05 23:28:04 +00:00
{
2018-03-11 19:46:03 +00:00
console . WriteLine ( c . help );
console . WriteFormatLine ( " \n Usage: %s" , c . usage );
2017-06-06 23:24:18 +02:00
}
}
}
2018-01-05 23:28:04 +00:00
else
{
2018-03-11 19:46:03 +00:00
console_write_all_commands ( console );
2017-06-06 23:24:18 +02:00
}
return 0 ;
2015-05-19 13:46:05 -04:00
}
2018-06-22 22:59:46 +02:00
static void console_write_all_commands ( InteractiveConsole & console )
2015-05-19 03:53:37 +01:00
{
2018-06-22 22:59:46 +02:00
for ( const auto & c : console_command_table )
2018-01-05 23:28:04 +00:00
{
2018-03-11 19:46:03 +00:00
console . WriteLine ( c . command );
2018-01-05 23:28:04 +00:00
}
2015-05-19 03:53:37 +01:00
}
2018-06-22 22:59:46 +02:00
static bool invalidArguments ( bool * invalid , bool arguments )
2015-05-19 03:53:37 +01:00
{
2018-06-22 22:59:46 +02:00
if ( ! arguments )
{
2018-03-11 19:46:03 +00:00
* invalid = true ;
return false ;
}
return true ;
2015-05-19 21:12:09 -04:00
}
2018-06-22 22:59:46 +02:00
void InteractiveConsole :: Execute ( const std :: string & s )
2015-05-19 21:12:09 -04:00
{
2019-01-24 16:12:49 +01:00
arguments_t argv ;
argv . reserve ( 8 );
2018-06-22 22:59:46 +02:00
const utf8 * start = s . c_str ();
const utf8 * end ;
2017-06-06 23:24:18 +02:00
bool inQuotes = false ;
2018-06-22 22:59:46 +02:00
do
{
2017-06-06 23:24:18 +02:00
while ( * start == ' ' )
start ++ ;
2015-05-19 03:53:37 +01:00
2018-06-22 22:59:46 +02:00
if ( * start == '"' )
{
2017-06-06 23:24:18 +02:00
inQuotes = true ;
start ++ ;
}
2018-06-22 22:59:46 +02:00
else
{
2017-06-06 23:24:18 +02:00
inQuotes = false ;
}
2015-05-19 03:53:37 +01:00
2017-06-06 23:24:18 +02:00
end = start ;
2018-06-22 22:59:46 +02:00
while ( * end != 0 )
{
2017-06-06 23:24:18 +02:00
if ( * end == ' ' && ! inQuotes )
break ;
if ( * end == '"' && inQuotes )
break ;
end ++ ;
}
size_t length = end - start ;
2015-05-19 21:12:09 -04:00
2018-06-22 22:59:46 +02:00
if ( length > 0 )
{
2019-01-24 16:12:49 +01:00
argv . emplace_back ( start , length );
2017-06-06 23:24:18 +02:00
}
2015-05-19 03:53:37 +01:00
2017-06-06 23:24:18 +02:00
start = end ;
} while ( * end != 0 );
2015-05-19 03:53:37 +01:00
2019-01-24 16:12:49 +01:00
if ( argv . empty ())
return ;
2017-06-06 23:24:18 +02:00
bool validCommand = false ;
2019-01-22 00:03:12 +01:00
2019-01-24 16:12:49 +01:00
for ( const auto & c : console_command_table )
2018-01-05 23:28:04 +00:00
{
2019-01-24 16:12:49 +01:00
if ( argv [ 0 ] == c . command )
2018-01-05 23:28:04 +00:00
{
2019-01-24 16:12:49 +01:00
argv . erase ( argv . begin ());
c . func ( * this , argv );
validCommand = true ;
break ;
2017-06-06 23:24:18 +02:00
}
}
2015-05-19 03:53:37 +01:00
2019-01-24 16:12:49 +01:00
if ( ! validCommand )
2018-06-22 22:59:46 +02:00
{
2018-03-11 19:46:03 +00:00
WriteLineError ( "Unknown command. Type help to list available commands." );
2017-06-06 23:24:18 +02:00
}
2015-06-19 10:51:54 -04:00
}
2018-06-22 22:59:46 +02:00
void InteractiveConsole :: WriteLine ( const std :: string & s )
2015-06-19 10:51:54 -04:00
{
2020-10-16 00:13:52 +01:00
WriteLine ( s , FormatToken :: ColourWindow2 );
2018-03-11 19:46:03 +00:00
}
2018-06-22 22:59:46 +02:00
void InteractiveConsole :: WriteLineError ( const std :: string & s )
2018-03-11 19:46:03 +00:00
{
2020-10-16 00:13:52 +01:00
WriteLine ( s , FormatToken :: ColourRed );
2018-03-11 19:46:03 +00:00
}
2018-06-22 22:59:46 +02:00
void InteractiveConsole :: WriteLineWarning ( const std :: string & s )
2018-03-11 19:46:03 +00:00
{
2020-10-16 00:13:52 +01:00
WriteLine ( s , FormatToken :: ColourYellow );
2018-03-11 19:46:03 +00:00
}
2018-06-22 22:59:46 +02:00
void InteractiveConsole :: WriteFormatLine ( const char * format , ...)
2018-03-11 19:46:03 +00:00
{
va_list list ;
va_start ( list , format );
2018-03-12 17:39:58 +00:00
auto buffer = String :: Format_VA ( format , list );
2018-03-11 19:46:03 +00:00
va_end ( list );
auto s = std :: string ( buffer );
std :: free ( buffer );
WriteLine ( s );
}