2016-05-04 19:24:41 +02:00
/*****************************************************************************
2018-06-15 14:07:34 +02:00
* Copyright (c) 2014-2018 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"
#include "../Version.h"
2018-11-07 23:12:05 +01:00
#include "../actions/ClimateSetAction.hpp"
2018-06-22 22:59:46 +02:00
#include "../config/Config.h"
2018-03-13 13:14:02 +01:00
#include "../core/Guard.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-01-21 03:07:56 +01:00
#include "../interface/Colour.h"
2018-01-06 18:32:25 +01:00
#include "../localisation/Localisation.h"
#include "../localisation/User.h"
2017-10-06 22:37:06 +02:00
#include "../management/Finance.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"
2017-12-31 13:21:34 +01:00
#include "../ride/Ride.h"
2018-01-10 00:00:09 +01:00
#include "../ride/RideData.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"
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>
#include <deque>
#include <string>
#include <thread>
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
2018-11-07 23:12:05 +01:00
static constexpr const utf8 * ClimateNames [] = {
"cool_and_wet" ,
"warm" ,
"hot_and_dry" ,
"cold" ,
};
2018-06-22 22:59:46 +02:00
static void console_write_all_commands ( InteractiveConsole & console );
static int32_t console_parse_int ( const utf8 * src , bool * valid );
static double console_parse_double ( const utf8 * src , bool * valid );
2015-05-19 03:53:37 +01:00
2018-06-22 22:59:46 +02:00
static int32_t cc_variables ( InteractiveConsole & console , const utf8 ** argv , int32_t argc );
static int32_t cc_windows ( InteractiveConsole & console , const utf8 ** argv , int32_t argc );
static int32_t cc_help ( InteractiveConsole & console , const utf8 ** argv , int32_t argc );
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
2018-06-22 22:59:46 +02:00
int32_t console_parse_int ( const utf8 * src , bool * valid )
{
utf8 * end ;
2018-06-20 17:28:51 +02:00
int32_t value ;
2018-06-22 22:59:46 +02:00
value = strtol ( src , & end , 10 );
* valid = ( * end == '\0' );
2017-06-06 23:24:18 +02:00
return value ;
2015-05-19 21:12:09 -04:00
}
2018-06-22 22:59:46 +02:00
double console_parse_double ( const utf8 * src , bool * valid )
{
utf8 * end ;
2017-06-06 23:24:18 +02:00
double value ;
2018-06-22 22:59:46 +02:00
value = strtod ( src , & end );
* valid = ( * end == '\0' );
2017-06-06 23:24:18 +02:00
return value ;
2015-05-19 21:12:09 -04:00
}
2018-06-22 22:59:46 +02:00
static int32_t cc_clear ( InteractiveConsole & console , [[maybe_unused]] const utf8** argv, [[maybe_unused]] int32_t argc )
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
}
2018-06-22 22:59:46 +02:00
static int32_t cc_close ( InteractiveConsole & console , [[maybe_unused]] const utf8** argv, [[maybe_unused]] int32_t argc )
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
}
2018-06-22 22:59:46 +02:00
static int32_t cc_hide ( InteractiveConsole & console , [[maybe_unused]] const utf8** argv, [[maybe_unused]] int32_t argc )
2018-03-22 20:29:41 +00:00
{
console . Hide ();
return 0 ;
}
2018-06-22 22:59:46 +02:00
static int32_t cc_echo ( InteractiveConsole & console , const utf8 ** argv , int32_t argc )
2015-05-19 03:53:37 +01:00
{
2017-06-06 23:24:18 +02:00
if ( argc > 0 )
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
}
2018-06-22 22:59:46 +02:00
static int32_t cc_rides ( InteractiveConsole & console , const utf8 ** argv , int32_t argc )
2016-04-20 13:37:31 +02:00
{
2018-06-22 22:59:46 +02:00
if ( argc > 0 )
{
if ( strcmp ( argv [ 0 ], "list" ) == 0 )
{
Ride * ride ;
2018-06-20 17:28:51 +02:00
int32_t i ;
2018-06-22 22:59:46 +02:00
FOR_ALL_RIDES ( i , ride )
{
2017-06-06 23:24:18 +02:00
char name [ 128 ];
format_string ( name , 128 , ride -> name , & ride -> name_arguments );
2018-06-22 22:59:46 +02:00
console . WriteFormatLine (
2018-07-21 13:51:54 +02:00
"ride: %03d type: %02u subtype %03u operating mode: %02u name: %s" , i , ride -> type , ride -> subtype ,
ride -> mode , name );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
}
else if ( strcmp ( argv [ 0 ], "set" ) == 0 )
{
if ( argc < 4 )
{
if ( argc > 1 && strcmp ( argv [ 1 ], "mode" ) == 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "Ride modes are specified using integer IDs as given below:" );
2018-06-22 22:59:46 +02:00
for ( int32_t i = 0 ; i < RIDE_MODE_COUNT ; i ++ )
{
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>" );
2017-06-06 23:24:18 +02:00
}
return 0 ;
}
2018-06-22 22:59:46 +02:00
if ( strcmp ( argv [ 1 ], "type" ) == 0 )
{
2017-06-06 23:24:18 +02:00
bool int_valid [ 2 ] = { 0 };
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
{
2017-06-06 23:24:18 +02:00
gGameCommandErrorTitle = STR_CANT_CHANGE_OPERATING_MODE ;
2018-06-22 22:59:46 +02:00
int32_t res = game_do_command (
0 , ( type << 8 ) | 1 , 0 , ( RIDE_SETTING_RIDE_TYPE << 8 ) | ride_index , GAME_COMMAND_SET_RIDE_SETTING , 0 , 0 );
if ( res == MONEY32_UNDEFINED )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "That didn't work" );
2017-06-06 23:24:18 +02:00
}
}
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 1 ], "mode" ) == 0 )
{
2017-06-06 23:24:18 +02:00
bool int_valid [ 2 ] = { 0 };
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
{
Ride * ride = get_ride ( ride_index );
if ( mode <= 0 || mode > ( RIDE_MODE_COUNT - 1 ))
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "Invalid ride mode." );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( ride == nullptr || ride -> type == RIDE_TYPE_NULL )
{
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 -> mode = mode ;
invalidate_test_results ( ride_index );
}
}
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 1 ], "mass" ) == 0 )
{
2017-06-06 23:24:18 +02:00
bool int_valid [ 2 ] = { 0 };
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
{
Ride * ride = get_ride ( ride_index );
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
}
2018-06-22 22:59:46 +02:00
else if ( ride -> type == RIDE_TYPE_NULL )
{
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
{
for ( int32_t i = 0 ; i < ride -> num_vehicles ; i ++ )
{
2018-06-20 17:28:51 +02:00
uint16_t vehicle_index = ride -> vehicles [ i ];
2018-06-22 22:59:46 +02:00
while ( vehicle_index != SPRITE_INDEX_NULL )
{
rct_vehicle * vehicle = GET_VEHICLE ( vehicle_index );
2017-12-17 18:00:42 +01:00
vehicle -> mass = mass ;
2017-06-06 23:24:18 +02:00
vehicle_index = vehicle -> next_vehicle_on_train ;
}
}
}
}
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 1 ], "excitement" ) == 0 )
{
2017-06-06 23:24:18 +02:00
bool int_valid [ 2 ] = { 0 };
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
{
Ride * ride = get_ride ( ride_index );
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
}
2018-06-22 22:59:46 +02:00
else if ( ride -> type == RIDE_TYPE_NULL )
{
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 ;
}
}
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 1 ], "intensity" ) == 0 )
{
2017-06-06 23:24:18 +02:00
bool int_valid [ 2 ] = { 0 };
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
{
Ride * ride = get_ride ( ride_index );
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
}
2018-06-22 22:59:46 +02:00
else if ( ride -> type == RIDE_TYPE_NULL )
{
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 ;
}
}
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 1 ], "nausea" ) == 0 )
{
2017-06-06 23:24:18 +02:00
bool int_valid [ 2 ] = { 0 };
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
{
Ride * ride = get_ride ( ride_index );
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
}
2018-06-22 22:59:46 +02:00
else if ( ride -> type == RIDE_TYPE_NULL )
{
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 ;
}
}
}
}
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
}
2018-06-22 22:59:46 +02:00
static int32_t cc_staff ( InteractiveConsole & console , const utf8 ** argv , int32_t argc )
2016-05-19 21:30:32 +01:00
{
2018-06-22 22:59:46 +02:00
if ( argc > 0 )
{
if ( strcmp ( argv [ 0 ], "list" ) == 0 )
{
rct_peep * peep ;
2018-06-20 17:28:51 +02:00
int32_t i ;
2018-06-22 22:59:46 +02:00
FOR_ALL_STAFF ( i , peep )
{
2017-06-06 23:24:18 +02:00
char name [ 128 ];
format_string ( name , 128 , peep -> name_string_idx , & peep -> id );
2018-06-22 22:59:46 +02:00
console . WriteFormatLine (
"staff id %03d type: %02u energy %03u name %s" , i , peep -> staff_type , peep -> energy , name );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
}
else if ( strcmp ( argv [ 0 ], "set" ) == 0 )
{
if ( argc < 4 )
{
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>" );
2018-06-22 22:59:46 +02:00
for ( int32_t i = 0 ; i < ENTERTAINER_COSTUME_COUNT ; i ++ )
{
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 ;
}
2018-06-22 22:59:46 +02:00
if ( strcmp ( argv [ 1 ], "energy" ) == 0 )
{
2018-06-20 17:28:51 +02:00
int32_t int_val [ 3 ];
2017-06-06 23:24:18 +02:00
bool int_valid [ 3 ] = { 0 };
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
2018-06-22 22:59:46 +02:00
if ( int_valid [ 0 ] && int_valid [ 1 ] && (( GET_PEEP ( int_val [ 0 ])) != nullptr ))
{
rct_peep * peep = GET_PEEP ( int_val [ 0 ]);
2016-05-19 21:30:32 +01:00
2017-06-06 23:24:18 +02:00
peep -> energy = int_val [ 1 ];
2017-07-26 15:23:24 +02:00
peep -> energy_target = int_val [ 1 ];
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
}
else if ( strcmp ( argv [ 1 ], "costume" ) == 0 )
{
2018-06-20 17:28:51 +02:00
int32_t int_val [ 2 ];
2017-06-06 23:24:18 +02:00
bool int_valid [ 2 ] = { 0 };
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
rct_peep * peep = nullptr ;
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 ;
}
peep = GET_PEEP ( int_val [ 0 ]);
2018-07-21 11:50:45 +02:00
bool is_entertainer = peep != nullptr && peep -> type == PEEP_TYPE_STAFF
&& peep -> staff_type == STAFF_TYPE_ENTERTAINER ;
2018-06-22 22:59:46 +02:00
if ( ! is_entertainer )
{
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 ;
}
2018-06-22 22:59:46 +02:00
if ( ! int_valid [ 1 ] || int_val [ 1 ] < 0 || int_val [ 1 ] >= ENTERTAINER_COSTUME_COUNT )
{
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
2018-06-20 17:28:51 +02:00
int32_t costume = int_val [ 1 ] | 0x80 ;
2017-06-06 23:24:18 +02:00
game_do_command ( peep -> x , ( costume << 8 ) | 1 , peep -> y , int_val [ 0 ], GAME_COMMAND_SET_STAFF_ORDER , 0 , 0 );
}
}
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
}
2018-06-22 22:59:46 +02:00
static int32_t cc_get ( InteractiveConsole & console , const utf8 ** argv , int32_t argc )
2015-05-19 03:53:37 +01:00
{
2018-06-22 22:59:46 +02:00
if ( argc > 0 )
{
if ( strcmp ( argv [ 0 ], "park_rating" ) == 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "park_rating %d" , gParkRating );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "park_value" ) == 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "park_value %d" , gParkValue / 10 );
2018-01-07 06:00:29 +09:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "company_value" ) == 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "company_value %d" , gCompanyValue / 10 );
2018-01-07 06:00:29 +09:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "money" ) == 0 )
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "scenario_initial_cash" ) == 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "scenario_initial_cash %d" , gInitialCash / 10 );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "current_loan" ) == 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "current_loan %d" , gBankLoan / 10 );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "max_loan" ) == 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "max_loan %d" , gMaxBankLoan / 10 );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "guest_initial_cash" ) == 0 )
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "guest_initial_happiness" ) == 0 )
{
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 ;
}
}
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "guest_initial_hunger" ) == 0 )
{
console . WriteFormatLine (
"guest_initial_hunger %d%% (%d)" , (( 255 - gGuestInitialHunger ) * 100 ) / 255 , gGuestInitialHunger );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "guest_initial_thirst" ) == 0 )
{
console . WriteFormatLine (
"guest_initial_thirst %d%% (%d)" , (( 255 - gGuestInitialThirst ) * 100 ) / 255 , gGuestInitialThirst );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "guest_prefer_less_intense_rides" ) == 0 )
{
console . WriteFormatLine (
"guest_prefer_less_intense_rides %d" , ( gParkFlags & PARK_FLAGS_PREF_LESS_INTENSE_RIDES ) != 0 );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "guest_prefer_more_intense_rides" ) == 0 )
{
console . WriteFormatLine (
"guest_prefer_more_intense_rides %d" , ( gParkFlags & PARK_FLAGS_PREF_MORE_INTENSE_RIDES ) != 0 );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "forbid_marketing_campagns" ) == 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "forbid_marketing_campagns %d" , ( gParkFlags & PARK_FLAGS_FORBID_MARKETING_CAMPAIGN ) != 0 );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "forbid_landscape_changes" ) == 0 )
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "forbid_tree_removal" ) == 0 )
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "forbid_high_construction" ) == 0 )
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "pay_for_rides" ) == 0 )
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "no_money" ) == 0 )
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "difficult_park_rating" ) == 0 )
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "difficult_guest_generation" ) == 0 )
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "park_open" ) == 0 )
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "land_rights_cost" ) == 0 )
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "construction_rights_cost" ) == 0 )
{
console . WriteFormatLine (
"construction_rights_cost %d.%d0" , gConstructionRightsPrice / 10 , gConstructionRightsPrice % 10 );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "climate" ) == 0 )
{
2018-11-07 23:12:05 +01:00
console . WriteFormatLine ( "climate %s (%d)" , ClimateNames [ gClimate ], gClimate );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "game_speed" ) == 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "game_speed %d" , gGameSpeed );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "console_small_font" ) == 0 )
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "test_unfinished_tracks" ) == 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "test_unfinished_tracks %d" , gConfigGeneral . test_unfinished_tracks );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "no_test_crashes" ) == 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "no_test_crashes %d" , gConfigGeneral . no_test_crashes );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "location" ) == 0 )
{
rct_window * w = window_get_main ();
if ( w != nullptr )
{
2018-06-20 17:28:51 +02:00
int32_t interactionType ;
2018-11-01 13:53:50 +01:00
TileElement * tileElement ;
2018-06-04 19:50:46 +02:00
LocationXY16 mapCoord = {};
2018-06-22 22:59:46 +02:00
rct_viewport * viewport = window_get_viewport ( w );
get_map_coordinates_from_pos (
2018-07-21 13:51:54 +02:00
viewport -> view_width / 2 , viewport -> view_height / 2 , VIEWPORT_INTERACTION_MASK_TERRAIN , & mapCoord . x ,
& mapCoord . y , & interactionType , & tileElement , nullptr );
2017-06-06 23:24:18 +02:00
mapCoord . x -= 16 ;
mapCoord . x /= 32 ;
mapCoord . y -= 16 ;
mapCoord . y /= 32 ;
mapCoord . x ++ ;
mapCoord . y ++ ;
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "location %d %d" , mapCoord . x , mapCoord . y );
2017-06-06 23:24:18 +02:00
}
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "window_scale" ) == 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "window_scale %.3f" , gConfigGeneral . window_scale );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "window_limit" ) == 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "window_limit %d" , gConfigGeneral . window_limit );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "render_weather_effects" ) == 0 )
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "render_weather_gloom" ) == 0 )
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "cheat_sandbox_mode" ) == 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "cheat_sandbox_mode %d" , gCheatsSandboxMode );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "cheat_disable_clearance_checks" ) == 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "cheat_disable_clearance_checks %d" , gCheatsDisableClearanceChecks );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "cheat_disable_support_limits" ) == 0 )
{
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "cheat_disable_support_limits %d" , gCheatsDisableSupportLimits );
2017-06-06 23:24:18 +02:00
}
2018-10-14 22:44:45 +01:00
else if ( strcmp ( argv [ 0 ], "current_rotation" ) == 0 )
{
console . WriteFormatLine ( "current_rotation %d" , get_current_rotation ());
}
2017-10-13 18:07:02 +02:00
#ifndef NO_TTF
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "enable_hinting" ) == 0 )
{
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
}
2018-06-22 22:59:46 +02:00
static int32_t cc_set ( InteractiveConsole & console , const utf8 ** argv , int32_t argc )
2015-05-19 21:12:09 -04:00
{
2018-06-20 17:28:51 +02:00
int32_t i ;
2018-06-22 22:59:46 +02:00
if ( argc > 1 )
{
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 ++ )
{
if ( i + 1 < argc )
{
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
2018-06-22 22:59:46 +02:00
if ( strcmp ( argv [ 0 ], "money" ) == 0 && invalidArguments ( & invalidArgs , double_valid [ 0 ]))
{
2018-06-20 17:28:51 +02:00
money32 money = MONEY (( int32_t ) double_val [ 0 ], (( int32_t )( double_val [ 0 ] * 100 )) % 100 );
2017-06-06 23:24:18 +02:00
bool run_get_money = true ;
2018-06-22 22:59:46 +02:00
if ( gCash != money )
{
if ( game_do_command ( 0 , GAME_COMMAND_FLAG_APPLY , CHEAT_SETMONEY , money , GAME_COMMAND_CHEAT , 0 , 0 )
!= MONEY32_UNDEFINED )
{
2018-03-11 19:46:03 +00:00
// When in networked client mode, console.Execute("get money")
2017-06-06 23:24:18 +02:00
// does not print value accurately. Instead, print the argument.
2018-06-22 22:59:46 +02:00
if ( network_get_mode () == NETWORK_MODE_CLIENT )
{
2017-06-06 23:24:18 +02:00
run_get_money = false ;
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "money %d.%d0" , money / 10 , money % 10 );
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 ( "Network error: Permission denied!" );
2017-06-06 23:24:18 +02:00
}
}
2018-06-22 22:59:46 +02:00
if ( run_get_money )
{
2018-03-11 19:46:03 +00:00
console . Execute ( "get money" );
2017-06-06 23:24:18 +02:00
}
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "scenario_initial_cash" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "current_loan" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
2018-08-12 12:50:40 +01:00
gBankLoan = std :: clamp ( 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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "max_loan" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "guest_initial_cash" ) == 0 && invalidArguments ( & invalidArgs , double_valid [ 0 ]))
{
2018-08-12 12:50:40 +01:00
gGuestInitialCash = std :: clamp (
MONEY (( int32_t ) double_val [ 0 ], (( 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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "guest_initial_happiness" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
2018-06-20 17:28:51 +02:00
gGuestInitialHappiness = calculate_guest_initial_happiness (( 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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "guest_initial_hunger" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "guest_initial_thirst" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "guest_prefer_less_intense_rides" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "guest_prefer_more_intense_rides" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "forbid_marketing_campagns" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
2017-06-06 23:24:18 +02:00
SET_FLAG ( gParkFlags , PARK_FLAGS_FORBID_MARKETING_CAMPAIGN , int_val [ 0 ]);
2018-03-11 19:46:03 +00:00
console . Execute ( "get forbid_marketing_campagns" );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "forbid_landscape_changes" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "forbid_tree_removal" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "forbid_high_construction" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "pay_for_rides" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "no_money" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "difficult_park_rating" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "difficult_guest_generation" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "park_open" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "land_rights_cost" ) == 0 && invalidArguments ( & invalidArgs , double_valid [ 0 ]))
{
2018-08-12 12:50:40 +01:00
gLandPrice = std :: clamp (
MONEY (( int32_t ) double_val [ 0 ], (( 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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "construction_rights_cost" ) == 0 && invalidArguments ( & invalidArgs , double_valid [ 0 ]))
{
2018-08-12 12:50:40 +01:00
gConstructionRightsPrice = std :: clamp (
MONEY (( int32_t ) double_val [ 0 ], (( 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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "climate" ) == 0 )
{
if ( int_valid [ 0 ])
{
2018-11-07 23:12:05 +01:00
const auto newClimate = int_val [ 0 ];
if ( newClimate < 0 || newClimate >= CLIMATE_COUNT )
{
console . WriteLine ( language_get_string ( STR_INVALID_CLIMATE_ID ));
}
else
{
auto gameAction = ClimateSetAction ( newClimate );
GameActions :: Execute ( & gameAction );
}
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else
{
2018-11-07 23:12:05 +01:00
for ( i = 0 ; i < CLIMATE_COUNT ; i ++ )
2018-06-22 22:59:46 +02:00
{
2018-11-07 23:12:05 +01:00
if ( strcmp ( argv [ 1 ], ClimateNames [ i ]) == 0 )
2018-06-22 22:59:46 +02:00
{
2017-06-06 23:24:18 +02:00
gClimate = i ;
break ;
}
}
}
2018-11-07 23:12:05 +01:00
if ( i == CLIMATE_COUNT )
2017-06-06 23:24:18 +02:00
invalidArgs = true ;
else
2018-06-22 22:59:46 +02:00
console . Execute ( "get climate" );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "game_speed" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "console_small_font" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "test_unfinished_tracks" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
2017-06-06 23:24:18 +02:00
gConfigGeneral . test_unfinished_tracks = ( int_val [ 0 ] != 0 );
config_save_default ();
2018-03-11 19:46:03 +00:00
console . Execute ( "get test_unfinished_tracks" );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "no_test_crashes" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
2017-06-06 23:24:18 +02:00
gConfigGeneral . no_test_crashes = ( int_val [ 0 ] != 0 );
config_save_default ();
2018-03-11 19:46:03 +00:00
console . Execute ( "get no_test_crashes" );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "location" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ] && int_valid [ 1 ]))
{
rct_window * w = window_get_main ();
if ( w != nullptr )
{
2018-06-20 17:28:51 +02:00
int32_t x = ( int16_t )( int_val [ 0 ] * 32 + 16 );
int32_t y = ( int16_t )( int_val [ 1 ] * 32 + 16 );
int32_t z = tile_element_height ( x , y );
2017-06-06 23:24:18 +02:00
window_set_location ( w , x , y , z );
viewport_update_position ( w );
2018-03-11 19:46:03 +00:00
console . Execute ( "get location" );
2017-06-06 23:24:18 +02:00
}
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "window_scale" ) == 0 && invalidArguments ( & invalidArgs , double_valid [ 0 ]))
{
float newScale = ( 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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "window_limit" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "render_weather_effects" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "render_weather_gloom" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
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
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "cheat_sandbox_mode" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
if ( gCheatsSandboxMode != ( int_val [ 0 ] != 0 ))
{
if ( game_do_command ( 0 , GAME_COMMAND_FLAG_APPLY , CHEAT_SANDBOXMODE , ( int_val [ 0 ] != 0 ), GAME_COMMAND_CHEAT , 0 , 0 )
!= MONEY32_UNDEFINED )
{
2017-06-06 23:24:18 +02:00
// Change it locally so it shows the accurate value in the
2018-03-11 19:46:03 +00:00
// "console.Execute("get cheat_sandbox_mode")" line when in networked client mode
2017-06-06 23:24:18 +02:00
gCheatsSandboxMode = ( int_val [ 0 ] != 0 );
}
2018-06-22 22:59:46 +02:00
else
{
2018-03-11 19:46:03 +00:00
console . WriteLineError ( "Network error: Permission denied!" );
2017-06-06 23:24:18 +02:00
}
}
2018-03-11 19:46:03 +00:00
console . Execute ( "get cheat_sandbox_mode" );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "cheat_disable_clearance_checks" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
if ( gCheatsDisableClearanceChecks != ( int_val [ 0 ] != 0 ))
{
if ( game_do_command (
0 , GAME_COMMAND_FLAG_APPLY , CHEAT_DISABLECLEARANCECHECKS , ( int_val [ 0 ] != 0 ), GAME_COMMAND_CHEAT , 0 , 0 )
!= MONEY32_UNDEFINED )
{
2017-06-06 23:24:18 +02:00
// Change it locally so it shows the accurate value in the
2018-03-11 19:46:03 +00:00
// "console.Execute("get cheat_disable_clearance_checks")" line when in networked client mode
2017-06-06 23:24:18 +02:00
gCheatsDisableClearanceChecks = ( int_val [ 0 ] != 0 );
}
2018-06-22 22:59:46 +02:00
else
{
2018-03-11 19:46:03 +00:00
console . WriteLineError ( "Network error: Permission denied!" );
2017-06-06 23:24:18 +02:00
}
}
2018-03-11 19:46:03 +00:00
console . Execute ( "get cheat_disable_clearance_checks" );
2017-06-06 23:24:18 +02:00
}
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "cheat_disable_support_limits" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
if ( gCheatsDisableSupportLimits != ( int_val [ 0 ] != 0 ))
{
if ( game_do_command (
0 , GAME_COMMAND_FLAG_APPLY , CHEAT_DISABLESUPPORTLIMITS , ( int_val [ 0 ] != 0 ), GAME_COMMAND_CHEAT , 0 , 0 )
!= MONEY32_UNDEFINED )
{
2017-06-06 23:24:18 +02:00
// Change it locally so it shows the accurate value in the
2018-03-11 19:46:03 +00:00
// "console.Execute("get cheat_disable_support_limits")" line when in networked client mode
2017-06-06 23:24:18 +02:00
gCheatsDisableSupportLimits = ( int_val [ 0 ] != 0 );
}
2018-06-22 22:59:46 +02:00
else
{
2018-03-11 19:46:03 +00:00
console . WriteLineError ( "Network error: Permission denied!" );
2017-06-06 23:24:18 +02:00
}
}
2018-03-11 19:46:03 +00:00
console . Execute ( "get cheat_disable_support_limits" );
2017-06-06 23:24:18 +02:00
}
2018-10-14 22:44:45 +01:00
else if ( strcmp ( argv [ 0 ], "current_rotation" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
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" );
}
2017-10-13 18:07:02 +02:00
#ifndef NO_TTF
2018-06-22 22:59:46 +02:00
else if ( strcmp ( argv [ 0 ], "enable_hinting" ) == 0 && invalidArguments ( & invalidArgs , int_valid [ 0 ]))
{
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
2018-07-21 11:50:45 +02:00
static int32_t cc_twitch (
[[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const utf8** argv, [[maybe_unused]] int32_t argc )
2015-05-25 20:36:40 +01:00
{
#ifdef DISABLE_TWITCH
2018-03-11 19:46:03 +00:00
console . WriteLineError ( "OpenRCT2 build not compiled with Twitch integration." );
2015-05-25 20:36:40 +01:00
#else
2017-06-06 23:24:18 +02:00
// TODO: Add some twitch commands
2018-06-04 23:57:59 +02:00
// Display a message to the player for now
console . WriteLine ( "To be implemented" );
2015-05-25 20:36:40 +01:00
#endif
2017-06-06 23:24:18 +02:00
return 0 ;
2015-05-25 20:36:40 +01:00
}
2015-08-02 11:25:26 +01:00
2018-06-22 22:59:46 +02:00
static int32_t cc_load_object ( InteractiveConsole & console , const utf8 ** argv , int32_t argc )
{
if ( argc > 0 )
{
2017-06-06 23:24:18 +02:00
char name [ 9 ] = { 0 };
memset ( name , ' ' , 8 );
2018-06-20 17:28:51 +02:00
int32_t i = 0 ;
2018-06-22 22:59:46 +02:00
for ( const char * ch = argv [ 0 ]; * ch != '\0' && i < 8 ; ch ++ )
{
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 ;
void * loadedObject = object_manager_get_loaded_object ( entry );
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 ;
}
2018-06-20 17:28:51 +02:00
int32_t groupIndex = object_manager_get_loaded_object_entry_index ( loadedObject );
2016-07-02 21:52:17 +01:00
2018-06-20 17:28:51 +02:00
uint8_t objectType = object_entry_get_type ( entry );
2018-06-22 22:59:46 +02:00
if ( objectType == OBJECT_TYPE_RIDE )
{
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 ];
2017-06-14 15:08:56 +02:00
if ( rideType != RIDE_TYPE_NULL )
2018-01-28 16:14:00 +01:00
research_insert ( true , RESEARCH_ENTRY_RIDE_MASK | ( rideType << 8 ) | groupIndex , rideEntry -> category [ 0 ]);
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 ;
}
2018-06-22 22:59:46 +02:00
else if ( objectType == OBJECT_TYPE_SCENERY_GROUP )
{
2018-01-28 16:14:00 +01:00
research_insert ( true , groupIndex , RESEARCH_CATEGORY_SCENERY_GROUP );
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
2018-06-22 22:59:46 +02:00
static int32_t cc_object_count ( InteractiveConsole & console , [[maybe_unused]] const utf8** argv, [[maybe_unused]] int32_t argc )
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" ,
};
2018-06-22 22:59:46 +02:00
for ( int32_t i = 0 ; i < 10 ; i ++ )
{
2018-06-20 17:28:51 +02:00
int32_t entryGroupIndex = 0 ;
2018-06-22 22:59:46 +02:00
for (; entryGroupIndex < object_entry_group_counts [ i ]; entryGroupIndex ++ )
{
2018-02-11 18:56:09 +00:00
if ( object_entry_get_chunk ( i , entryGroupIndex ) == nullptr )
{
2017-06-06 23:24:18 +02:00
break ;
}
}
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "%s: %d/%d" , object_type_names [ i ], entryGroupIndex , object_entry_group_counts [ 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
2018-06-20 17:28:51 +02:00
static int32_t cc_reset_user_strings (
2018-06-22 22:59:46 +02:00
[[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const utf8** argv, [[maybe_unused]] int32_t argc )
2015-08-16 15:31:59 +02:00
{
2017-06-06 23:24:18 +02:00
reset_user_strings ();
return 0 ;
2015-08-16 15:31:59 +02:00
}
2018-06-22 22:59:46 +02:00
static int32_t cc_open ( InteractiveConsole & console , const utf8 ** argv , int32_t argc )
{
if ( argc > 0 )
{
2017-06-06 23:24:18 +02:00
bool title = ( gScreenFlags & SCREEN_FLAGS_TITLE_DEMO ) != 0 ;
bool invalidTitle = false ;
2018-06-22 22:59:46 +02:00
if ( strcmp ( argv [ 0 ], "object_selection" ) == 0 && invalidArguments ( & invalidTitle , ! title ))
{
2017-06-06 23:24:18 +02:00
// Only this window should be open for safety reasons
window_close_all ();
2017-11-23 09:03:56 +01:00
context_open_window ( WC_EDITOR_OBJECT_SELECTION );
2018-06-22 22:59:46 +02:00
}
else if ( strcmp ( argv [ 0 ], "inventions_list" ) == 0 && invalidArguments ( & invalidTitle , ! title ))
{
2017-08-12 23:06:12 +02:00
context_open_window ( WC_EDITOR_INVENTION_LIST );
2018-06-22 22:59:46 +02:00
}
else if ( strcmp ( argv [ 0 ], "scenario_options" ) == 0 && invalidArguments ( & invalidTitle , ! title ))
{
2017-08-12 23:06:12 +02:00
context_open_window ( WC_EDITOR_SCENARIO_OPTIONS );
2018-06-22 22:59:46 +02:00
}
else if ( strcmp ( argv [ 0 ], "options" ) == 0 )
{
2017-08-06 05:22:00 +02:00
context_open_window ( WC_OPTIONS );
2018-06-22 22:59:46 +02:00
}
else if ( strcmp ( argv [ 0 ], "themes" ) == 0 )
{
2017-08-06 05:22:00 +02:00
context_open_window ( WC_THEMES );
2018-06-22 22:59:46 +02:00
}
else if ( strcmp ( argv [ 0 ], "title_sequences" ) == 0 )
{
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
2018-07-21 11:50:45 +02:00
static int32_t cc_remove_unused_objects (
InteractiveConsole & console , [[maybe_unused]] const utf8** argv, [[maybe_unused]] int32_t argc )
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 ;
}
2018-07-21 11:50:45 +02:00
static int32_t cc_remove_park_fences (
InteractiveConsole & console , [[maybe_unused]] const utf8** argv, [[maybe_unused]] int32_t argc )
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
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 ;
}
2018-06-22 22:59:46 +02:00
static int32_t cc_show_limits ( InteractiveConsole & console , [[maybe_unused]] const utf8** argv, [[maybe_unused]] int32_t argc )
2017-10-05 10:00:32 +02:00
{
map_reorganise_elements ();
2018-06-20 17:28:51 +02:00
int32_t tileElementCount = gNextFreeTileElement - gTileElements - 1 ;
2017-10-05 10:00:32 +02:00
2018-06-20 17:28:51 +02:00
int32_t rideCount = 0 ;
for ( int32_t i = 0 ; i < MAX_RIDES ; ++ i )
2017-10-05 10:00:32 +02:00
{
2018-06-22 22:59:46 +02:00
Ride * ride = get_ride ( i );
if ( ride -> type != RIDE_TYPE_NULL )
2017-10-05 10:00:32 +02:00
{
rideCount ++ ;
}
}
2018-06-20 17:28:51 +02:00
int32_t spriteCount = 0 ;
for ( int32_t i = 1 ; i < NUM_SPRITE_LISTS ; ++ i )
2017-10-05 10:00:32 +02:00
{
spriteCount += gSpriteListCount [ i ];
}
2018-06-20 17:28:51 +02:00
int32_t staffCount = 0 ;
for ( int32_t i = 0 ; i < STAFF_MAX_COUNT ; ++ i )
2017-10-05 10:00:32 +02:00
{
if ( gStaffModes [ i ] & 1 )
{
staffCount ++ ;
}
}
2018-06-20 17:28:51 +02:00
int32_t bannerCount = 0 ;
2018-06-12 21:18:13 +01:00
for ( BannerIndex i = 0 ; i < MAX_BANNERS ; ++ i )
2017-10-05 10:00:32 +02:00
{
if ( gBanners [ i ]. type != BANNER_NULL )
{
bannerCount ++ ;
}
}
2018-03-11 19:46:03 +00:00
console . WriteFormatLine ( "Sprites: %d/%d" , spriteCount , MAX_SPRITES );
console . WriteFormatLine ( "Map Elements: %d/%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 );
2017-10-05 10:00:32 +02:00
return 0 ;
}
2018-07-21 11:50:45 +02:00
static int32_t cc_for_date (
[[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const utf8** argv, [[maybe_unused]] int32_t argc )
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 ;
2018-01-07 12:57:59 +01:00
if ( argc < 1 || argc > 3 )
{
return - 1 ;
}
// All cases involve providing a year, so grab that first
year = atoi ( argv [ 0 ]);
if ( year < 1 || year > 8192 )
{
return - 1 ;
}
// YYYY (no month provided, preserve existing month)
if ( argc == 1 )
{
month = gDateMonthsElapsed % MONTH_COUNT + 1 ;
}
// YYYY MM or YYYY MM DD (month provided)
if ( argc >= 2 )
{
month = atoi ( argv [ 1 ]);
month -= 2 ;
if ( month < 1 || month > MONTH_COUNT )
{
return - 1 ;
}
}
// YYYY OR YYYY MM (no day provided, preserve existing day)
if ( argc <= 2 )
{
2018-08-12 12:50:40 +01:00
day = std :: clamp ( gDateMonthTicks / ( 0x10000 / days_in_month [ month - 1 ]) + 1 , 1 , ( int ) days_in_month [ month - 1 ]);
2018-01-07 12:57:59 +01:00
}
// YYYY MM DD (year, month, and day provided)
if ( argc == 3 )
{
day = atoi ( argv [ 2 ]);
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 ;
}
2018-10-14 22:36:41 +02:00
static int32_t cc_save_park (
[[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const utf8** argv, [[maybe_unused]] int32_t argc )
{
if ( argc < 1 )
{
save_game_cmd ();
}
else
{
save_game_cmd ( argv [ 0 ]);
}
return 1 ;
}
2018-06-22 22:59:46 +02:00
using console_command_func = int32_t ( * )( InteractiveConsole & console , const utf8 ** argv , int32_t argc );
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" ,
"forbid_marketing_campagn" ,
"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" ,
"test_unfinished_tracks" ,
"no_test_crashes" ,
"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" ,
"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 [] = {
2017-06-06 23:24:18 +02:00
{ "clear" , cc_clear , "Clears the console." , "clear" },
2018-03-22 20:29:41 +00:00
{ "close" , cc_close , "Closes the console." , "close" },
{ "exit" , cc_close , "Closes the console." , "exit" },
{ "quit" , cc_close , "Closes the console." , "quit" },
2017-06-06 23:24:18 +02:00
{ "hide" , cc_hide , "Hides the console." , "hide" },
{ "echo" , cc_echo , "Echoes the text to the console." , "echo <text>" },
{ "help" , cc_help , "Lists commands or info about a command." , "help [command]" },
{ "get" , cc_get , "Gets the value of the specified variable." , "get <variable>" },
{ "set" , cc_set , "Sets the variable to the specified value." , "set <variable> <value>" },
{ "open" , cc_open , "Opens the window with the give name." , "open <window>." },
{ "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" },
{ "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>" },
{ "object_count" , cc_object_count , "Shows the number of objects of each type in the scenario." , "object_count" },
2018-06-04 23:57:59 +02:00
{ "twitch" , cc_twitch , "Twitch API" , "twitch" },
2017-06-06 23:24:18 +02:00
{ "reset_user_strings" , cc_reset_user_strings , "Resets all user-defined strings, to fix incorrectly occurring 'Chosen name in use already' errors." , "reset_user_strings" },
{ "rides" , cc_rides , "Ride management." , "rides <subcommand>" },
{ "staff" , cc_staff , "Staff management." , "staff <subcommand>" },
2017-09-29 16:32:30 +02:00
{ "remove_unused_objects" , cc_remove_unused_objects , "Removes all the unused objects from the object selection." , "remove_unused_objects" },
2017-10-08 09:12:00 +01:00
{ "remove_park_fences" , cc_remove_park_fences , "Removes all park fences from the surface" , "remove_park_fences" },
2017-10-05 10:00:32 +02:00
{ "show_limits" , cc_show_limits , "Shows the map data counts and limits." , "show_limits" },
2018-10-14 22:36:41 +02:00
{ "date" , cc_for_date , "Sets the date to a given date." , "Format <year>[ <month>[ <day>]]." },
{ "save_park" , cc_save_park , "Save current state of park. If no name specified default path will be used." , "save_park [name]" },
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
2018-06-22 22:59:46 +02:00
static int32_t cc_windows ( InteractiveConsole & console , [[maybe_unused]] const utf8** argv, [[maybe_unused]] int32_t argc )
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
2018-06-22 22:59:46 +02:00
static int32_t cc_variables ( InteractiveConsole & console , [[maybe_unused]] const utf8** argv, [[maybe_unused]] int32_t argc )
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
}
2018-06-22 22:59:46 +02:00
static int32_t cc_help ( InteractiveConsole & console , const utf8 ** argv , int32_t argc )
2015-05-19 13:46:05 -04:00
{
2018-01-05 23:28:04 +00:00
if ( argc > 0 )
{
2018-06-22 22:59:46 +02:00
for ( const auto & c : console_command_table )
2018-01-05 23:28:04 +00:00
{
if ( strcmp ( c . command , argv [ 0 ]) == 0 )
{
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
{
2018-06-20 17:28:51 +02:00
int32_t argc = 0 ;
int32_t argvCapacity = 8 ;
2018-06-22 22:59:46 +02:00
utf8 ** argv = ( utf8 ** ) malloc ( argvCapacity * sizeof ( utf8 * ));
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 )
{
utf8 * arg = ( utf8 * ) malloc ( length + 1 );
2017-06-06 23:24:18 +02:00
memcpy ( arg , start , length );
arg [ length ] = 0 ;
2015-05-19 03:53:37 +01:00
2018-06-22 22:59:46 +02:00
if ( argc >= argvCapacity )
{
2017-06-06 23:24:18 +02:00
argvCapacity *= 2 ;
2018-06-22 22:59:46 +02:00
argv = ( utf8 ** ) realloc ( argv , argvCapacity * sizeof ( utf8 * ));
2017-06-06 23:24:18 +02:00
}
argv [ argc ] = arg ;
argc ++ ;
}
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
2017-06-06 23:24:18 +02:00
if ( argc == 0 )
return ;
2015-05-19 03:53:37 +01:00
2017-06-06 23:24:18 +02:00
bool validCommand = false ;
2018-06-22 22:59:46 +02:00
for ( const auto & c : console_command_table )
2018-01-05 23:28:04 +00:00
{
if ( strcmp ( argv [ 0 ], c . command ) == 0 )
{
2018-06-22 22:59:46 +02:00
c . func ( * this , ( const utf8 ** )( argv + 1 ), argc - 1 );
2017-06-06 23:24:18 +02:00
validCommand = true ;
break ;
}
}
2015-05-19 03:53:37 +01:00
2018-06-20 17:28:51 +02:00
for ( int32_t i = 0 ; i < argc ; i ++ )
2017-06-06 23:24:18 +02:00
free ( argv [ i ]);
free ( argv );
2015-05-19 03:53:37 +01:00
2018-06-22 22:59:46 +02:00
if ( ! validCommand )
{
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
{
2018-03-11 19:46:03 +00:00
WriteLine ( s , FORMAT_WINDOW_COLOUR_2 );
}
2018-06-22 22:59:46 +02:00
void InteractiveConsole :: WriteLineError ( const std :: string & s )
2018-03-11 19:46:03 +00:00
{
WriteLine ( s , FORMAT_RED );
}
2018-06-22 22:59:46 +02:00
void InteractiveConsole :: WriteLineWarning ( const std :: string & s )
2018-03-11 19:46:03 +00:00
{
WriteLine ( s , FORMAT_YELLOW );
}
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 );
}