2016-05-04 19:24:41 +02:00
|
|
|
#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers
|
2014-04-09 15:43:27 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
|
|
|
*
|
2016-05-04 19:24:41 +02:00
|
|
|
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
|
|
|
|
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
|
2014-04-09 15:43:27 +02:00
|
|
|
*
|
|
|
|
* OpenRCT2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2016-05-04 19:24:41 +02:00
|
|
|
*
|
|
|
|
* A full copy of the GNU General Public License can be found in licence.txt
|
2014-04-09 15:43:27 +02:00
|
|
|
*****************************************************************************/
|
2016-05-04 19:24:41 +02:00
|
|
|
#pragma endregion
|
2014-04-09 15:43:27 +02:00
|
|
|
|
|
|
|
#include "addresses.h"
|
2014-10-06 18:36:58 +02:00
|
|
|
#include "audio/audio.h"
|
|
|
|
#include "drawing/drawing.h"
|
2014-04-09 15:43:27 +02:00
|
|
|
#include "editor.h"
|
2014-05-02 03:12:14 +02:00
|
|
|
#include "game.h"
|
2014-10-06 18:36:58 +02:00
|
|
|
#include "interface/window.h"
|
|
|
|
#include "interface/viewport.h"
|
|
|
|
#include "localisation/date.h"
|
|
|
|
#include "localisation/localisation.h"
|
|
|
|
#include "management/finance.h"
|
|
|
|
#include "management/news_item.h"
|
2014-05-24 19:07:29 +02:00
|
|
|
#include "object.h"
|
2016-07-07 23:58:48 +02:00
|
|
|
#include "object/ObjectManager.h"
|
2014-10-06 20:41:43 +02:00
|
|
|
#include "peep/staff.h"
|
2015-02-12 21:51:40 +01:00
|
|
|
#include "platform/platform.h"
|
2015-01-21 16:54:33 +01:00
|
|
|
#include "rct1.h"
|
2014-10-06 18:36:58 +02:00
|
|
|
#include "ride/ride.h"
|
2014-11-24 00:03:45 +01:00
|
|
|
#include "scenario.h"
|
2014-10-10 23:50:22 +02:00
|
|
|
#include "util/sawyercoding.h"
|
2014-10-11 02:18:08 +02:00
|
|
|
#include "util/util.h"
|
2014-10-10 23:50:22 +02:00
|
|
|
#include "world/banner.h"
|
2014-11-24 00:03:45 +01:00
|
|
|
#include "world/climate.h"
|
2015-07-06 15:40:37 +02:00
|
|
|
#include "world/footpath.h"
|
2014-10-06 18:36:58 +02:00
|
|
|
#include "world/map.h"
|
|
|
|
#include "world/park.h"
|
2015-03-29 03:29:07 +02:00
|
|
|
#include "world/scenery.h"
|
2014-10-06 18:36:58 +02:00
|
|
|
#include "world/sprite.h"
|
2014-04-09 18:06:47 +02:00
|
|
|
|
2016-09-05 23:26:02 +02:00
|
|
|
uint8 _editorSelectedRides[128];
|
|
|
|
uint8 _editorSelectedSmallScenery[252];
|
|
|
|
uint8 _editorSelectedLargeScenery[128];
|
|
|
|
uint8 _editorSelectedWalls[128];
|
|
|
|
uint8 _editorSelectedBanners[32];
|
|
|
|
uint8 _editorSelectedFootpaths[16];
|
|
|
|
uint8 _editorSelectedFootpathAdditions[15];
|
|
|
|
uint8 _editorSelectedSceneryGroups[19];
|
|
|
|
uint8 _editorSelectedParkEntrances[1];
|
|
|
|
uint8 _editorSelectedWaters[1];
|
|
|
|
uint8 _editorSelectedStexs[1];
|
|
|
|
|
|
|
|
uint8 * gEditorSelectedObjects[OBJECT_ENTRY_GROUP_COUNT] = {
|
|
|
|
_editorSelectedRides,
|
|
|
|
_editorSelectedSmallScenery,
|
|
|
|
_editorSelectedLargeScenery,
|
|
|
|
_editorSelectedWalls,
|
|
|
|
_editorSelectedBanners,
|
|
|
|
_editorSelectedFootpaths,
|
|
|
|
_editorSelectedFootpathAdditions,
|
|
|
|
_editorSelectedSceneryGroups,
|
|
|
|
_editorSelectedParkEntrances,
|
|
|
|
_editorSelectedWaters,
|
|
|
|
_editorSelectedStexs,
|
|
|
|
};
|
|
|
|
|
2015-11-02 22:09:27 +01:00
|
|
|
void editor_convert_save_to_scenario_callback(int result);
|
2014-04-09 18:06:47 +02:00
|
|
|
static void set_all_land_owned();
|
2014-10-10 23:50:22 +02:00
|
|
|
static int editor_load_landscape_from_sv4(const char *path);
|
|
|
|
static int editor_load_landscape_from_sc4(const char *path);
|
2015-04-01 19:13:25 +02:00
|
|
|
static void editor_finalise_main_view();
|
2014-10-10 23:50:22 +02:00
|
|
|
static int editor_read_s6(const char *path);
|
2016-09-05 23:31:12 +02:00
|
|
|
static void editor_clear_map_for_editing(bool fromSave);
|
2014-05-24 05:28:26 +02:00
|
|
|
|
2014-04-09 15:43:27 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0066FFE1
|
|
|
|
*/
|
|
|
|
void editor_load()
|
|
|
|
{
|
2014-04-09 18:06:47 +02:00
|
|
|
rct_window *mainWindow;
|
|
|
|
|
2015-11-16 23:39:40 +01:00
|
|
|
audio_pause_sounds();
|
|
|
|
audio_unpause_sounds();
|
2016-07-07 23:58:48 +02:00
|
|
|
object_manager_unload_all_objects();
|
2016-07-04 19:26:36 +02:00
|
|
|
object_list_load();
|
2015-02-09 19:32:58 +01:00
|
|
|
map_init(150);
|
2015-02-18 04:40:54 +01:00
|
|
|
banner_init();
|
2014-05-06 00:10:28 +02:00
|
|
|
reset_park_entrances();
|
2014-11-24 03:58:48 +01:00
|
|
|
user_string_clear_all();
|
2014-06-21 14:31:28 +02:00
|
|
|
reset_sprite_list();
|
2014-04-09 18:06:47 +02:00
|
|
|
ride_init_all();
|
2014-05-06 23:04:09 +02:00
|
|
|
window_guest_list_init_vars_a();
|
2015-07-14 19:18:10 +02:00
|
|
|
staff_reset_modes();
|
2014-04-09 18:06:47 +02:00
|
|
|
park_init();
|
2014-05-06 00:10:28 +02:00
|
|
|
finance_init();
|
2014-04-09 18:06:47 +02:00
|
|
|
date_reset();
|
2014-05-06 23:04:09 +02:00
|
|
|
window_guest_list_init_vars_b();
|
2014-10-07 20:39:52 +02:00
|
|
|
window_staff_list_init_vars();
|
2016-04-23 12:16:46 +02:00
|
|
|
gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR;
|
2016-09-10 19:30:53 +02:00
|
|
|
gS6Info.editor_step = EDITOR_STEP_OBJECT_SELECTION;
|
2016-04-23 01:51:22 +02:00
|
|
|
gParkFlags |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
|
2014-05-10 00:11:51 +02:00
|
|
|
window_new_ride_init_vars();
|
2016-09-10 19:30:53 +02:00
|
|
|
gS6Info.category = SCENARIO_CATEGORY_OTHER;
|
2014-04-09 18:06:47 +02:00
|
|
|
viewport_init_all();
|
|
|
|
news_item_init_queue();
|
2014-11-23 17:28:23 +01:00
|
|
|
window_editor_main_open();
|
2014-04-09 18:06:47 +02:00
|
|
|
mainWindow = window_get_main();
|
2014-04-11 18:38:15 +02:00
|
|
|
window_scroll_to_location(mainWindow, 2400, 2400, 112);
|
2014-08-24 13:33:37 +02:00
|
|
|
mainWindow->flags &= ~WF_SCROLLING_TO_LOCATION;
|
2015-02-07 18:40:20 +01:00
|
|
|
load_palette();
|
2014-04-09 18:06:47 +02:00
|
|
|
gfx_invalidate_screen();
|
2016-04-23 12:16:46 +02:00
|
|
|
gScreenAge = 0;
|
2015-02-25 19:08:13 +01:00
|
|
|
|
2016-07-14 14:07:49 +02:00
|
|
|
safe_strcpy(gScenarioName, language_get_string(STR_MY_NEW_SCENARIO), 64);
|
2014-11-24 00:03:45 +01:00
|
|
|
}
|
|
|
|
|
2014-04-09 15:43:27 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00672781
|
|
|
|
*/
|
|
|
|
void editor_convert_save_to_scenario()
|
|
|
|
{
|
2014-11-24 00:03:45 +01:00
|
|
|
tool_cancel();
|
2015-11-02 22:09:27 +01:00
|
|
|
window_loadsave_open(LOADSAVETYPE_LOAD | LOADSAVETYPE_GAME, NULL);
|
|
|
|
gLoadSaveCallback = editor_convert_save_to_scenario_callback;
|
|
|
|
}
|
2014-11-24 00:03:45 +01:00
|
|
|
|
2015-11-02 22:09:27 +01:00
|
|
|
void editor_convert_save_to_scenario_callback(int result)
|
|
|
|
{
|
|
|
|
if (result != MODAL_RESULT_OK) {
|
2014-11-24 00:03:45 +01:00
|
|
|
return;
|
2015-11-02 22:09:27 +01:00
|
|
|
}
|
|
|
|
|
2016-04-23 01:51:22 +02:00
|
|
|
if (gParkFlags & PARK_FLAGS_NO_MONEY)
|
|
|
|
gParkFlags |= PARK_FLAGS_NO_MONEY_SCENARIO;
|
2014-11-24 00:03:45 +01:00
|
|
|
else
|
2016-04-23 01:51:22 +02:00
|
|
|
gParkFlags &= ~PARK_FLAGS_NO_MONEY_SCENARIO;
|
|
|
|
gParkFlags |= PARK_FLAGS_NO_MONEY;
|
2014-11-24 00:03:45 +01:00
|
|
|
|
2016-09-10 19:30:53 +02:00
|
|
|
safe_strcpy(gS6Info.name, gScenarioName, 64);
|
|
|
|
safe_strcpy(gS6Info.details, gScenarioDetails, 256);
|
|
|
|
gS6Info.objective_type = gScenarioObjectiveType;
|
|
|
|
gS6Info.objective_arg_1 = gScenarioObjectiveYear;
|
|
|
|
gS6Info.objective_arg_2 = gScenarioObjectiveCurrency;
|
|
|
|
gS6Info.objective_arg_3 = gScenarioObjectiveNumGuests;
|
2016-04-23 11:53:48 +02:00
|
|
|
climate_reset(gClimate);
|
2014-11-24 00:03:45 +01:00
|
|
|
|
2016-04-23 12:16:46 +02:00
|
|
|
gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR;
|
2016-09-10 19:30:53 +02:00
|
|
|
gS6Info.editor_step = EDITOR_STEP_OBJECTIVE_SELECTION;
|
|
|
|
gS6Info.category = SCENARIO_CATEGORY_OTHER;
|
2014-11-24 00:03:45 +01:00
|
|
|
viewport_init_all();
|
|
|
|
news_item_init_queue();
|
|
|
|
window_editor_main_open();
|
2015-04-01 19:13:25 +02:00
|
|
|
editor_finalise_main_view();
|
2016-04-23 12:16:46 +02:00
|
|
|
gScreenAge = 0;
|
2014-04-09 15:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00672957
|
|
|
|
*/
|
|
|
|
void trackdesigner_load()
|
|
|
|
{
|
2014-04-09 18:06:47 +02:00
|
|
|
rct_window *mainWindow;
|
|
|
|
|
2016-04-23 12:16:46 +02:00
|
|
|
gScreenFlags = SCREEN_FLAGS_TRACK_DESIGNER;
|
|
|
|
gScreenAge = 0;
|
2016-03-26 16:41:58 +01:00
|
|
|
|
2016-07-07 23:58:48 +02:00
|
|
|
object_manager_unload_all_objects();
|
2016-07-04 19:26:36 +02:00
|
|
|
object_list_load();
|
2015-02-09 19:32:58 +01:00
|
|
|
map_init(150);
|
2014-04-09 18:06:47 +02:00
|
|
|
set_all_land_owned();
|
2015-02-18 04:40:54 +01:00
|
|
|
banner_init();
|
2014-05-06 00:10:28 +02:00
|
|
|
reset_park_entrances();
|
2014-11-24 03:58:48 +01:00
|
|
|
user_string_clear_all();
|
2015-10-20 20:16:30 +02:00
|
|
|
reset_sprite_list();
|
2014-04-09 18:06:47 +02:00
|
|
|
ride_init_all();
|
2014-05-06 23:04:09 +02:00
|
|
|
window_guest_list_init_vars_a();
|
2015-07-14 19:18:10 +02:00
|
|
|
staff_reset_modes();
|
2014-04-09 18:06:47 +02:00
|
|
|
park_init();
|
2014-05-06 00:10:28 +02:00
|
|
|
finance_init();
|
2014-04-09 18:06:47 +02:00
|
|
|
date_reset();
|
2014-05-06 23:04:09 +02:00
|
|
|
window_guest_list_init_vars_b();
|
2014-10-07 20:39:52 +02:00
|
|
|
window_staff_list_init_vars();
|
2016-09-10 19:30:53 +02:00
|
|
|
gS6Info.editor_step = EDITOR_STEP_OBJECT_SELECTION;
|
2014-05-10 00:11:51 +02:00
|
|
|
window_new_ride_init_vars();
|
2014-04-09 18:06:47 +02:00
|
|
|
viewport_init_all();
|
|
|
|
news_item_init_queue();
|
2014-11-23 17:28:23 +01:00
|
|
|
window_editor_main_open();
|
2014-04-09 18:06:47 +02:00
|
|
|
mainWindow = window_get_main();
|
2014-04-11 18:38:15 +02:00
|
|
|
window_scroll_to_location(mainWindow, 2400, 2400, 112);
|
2014-08-24 13:33:37 +02:00
|
|
|
mainWindow->flags &= ~WF_SCROLLING_TO_LOCATION;
|
2015-02-07 18:40:20 +01:00
|
|
|
load_palette();
|
2014-04-09 18:06:47 +02:00
|
|
|
gfx_invalidate_screen();
|
2014-04-09 15:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006729FD
|
|
|
|
*/
|
|
|
|
void trackmanager_load()
|
|
|
|
{
|
2014-04-09 18:06:47 +02:00
|
|
|
rct_window *mainWindow;
|
|
|
|
|
2016-04-23 12:16:46 +02:00
|
|
|
gScreenFlags = SCREEN_FLAGS_TRACK_MANAGER;
|
|
|
|
gScreenAge = 0;
|
2016-03-26 16:41:58 +01:00
|
|
|
|
2016-07-07 23:58:48 +02:00
|
|
|
object_manager_unload_all_objects();
|
2016-07-04 19:26:36 +02:00
|
|
|
object_list_load();
|
2015-02-09 19:32:58 +01:00
|
|
|
map_init(150);
|
2014-04-09 18:06:47 +02:00
|
|
|
set_all_land_owned();
|
2015-02-18 04:40:54 +01:00
|
|
|
banner_init();
|
2014-05-06 00:10:28 +02:00
|
|
|
reset_park_entrances();
|
2014-11-24 03:58:48 +01:00
|
|
|
user_string_clear_all();
|
2014-06-21 14:31:28 +02:00
|
|
|
reset_sprite_list();
|
2014-04-09 18:06:47 +02:00
|
|
|
ride_init_all();
|
2014-05-06 23:04:09 +02:00
|
|
|
window_guest_list_init_vars_a();
|
2015-07-14 19:18:10 +02:00
|
|
|
staff_reset_modes();
|
2014-04-09 18:06:47 +02:00
|
|
|
park_init();
|
2014-05-06 00:10:28 +02:00
|
|
|
finance_init();
|
2014-04-09 18:06:47 +02:00
|
|
|
date_reset();
|
2014-05-06 23:04:09 +02:00
|
|
|
window_guest_list_init_vars_b();
|
2014-10-07 20:39:52 +02:00
|
|
|
window_staff_list_init_vars();
|
2016-09-10 19:30:53 +02:00
|
|
|
gS6Info.editor_step = EDITOR_STEP_OBJECT_SELECTION;
|
2014-05-10 00:11:51 +02:00
|
|
|
window_new_ride_init_vars();
|
2014-04-09 18:06:47 +02:00
|
|
|
viewport_init_all();
|
|
|
|
news_item_init_queue();
|
2014-11-23 17:28:23 +01:00
|
|
|
window_editor_main_open();
|
2014-04-09 18:06:47 +02:00
|
|
|
mainWindow = window_get_main();
|
2014-04-11 18:38:15 +02:00
|
|
|
window_scroll_to_location(mainWindow, 2400, 2400, 112);
|
2014-08-24 13:33:37 +02:00
|
|
|
mainWindow->flags &= ~WF_SCROLLING_TO_LOCATION;
|
2015-02-07 18:40:20 +01:00
|
|
|
load_palette();
|
2014-04-09 18:06:47 +02:00
|
|
|
gfx_invalidate_screen();
|
2014-09-10 20:36:11 +02:00
|
|
|
}
|
|
|
|
|
2014-04-09 18:06:47 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068ABEC
|
|
|
|
*/
|
|
|
|
static void set_all_land_owned()
|
|
|
|
{
|
2016-04-24 15:00:26 +02:00
|
|
|
int mapSize = gMapSize;
|
2014-04-09 18:06:47 +02:00
|
|
|
|
2016-05-01 20:41:48 +02:00
|
|
|
game_do_command(64, 1, 64, 2, GAME_COMMAND_SET_LAND_OWNERSHIP, (mapSize - 3) * 32, (mapSize - 3) * 32);
|
2014-05-07 22:16:57 +02:00
|
|
|
}
|
|
|
|
|
2014-10-10 23:50:22 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006758C0
|
|
|
|
*/
|
2016-01-09 01:25:09 +01:00
|
|
|
bool editor_load_landscape(const utf8 *path)
|
2014-10-10 23:50:22 +02:00
|
|
|
{
|
|
|
|
window_close_construction_windows();
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2014-10-10 23:50:22 +02:00
|
|
|
char *extension = strrchr(path, '.');
|
|
|
|
if (extension != NULL) {
|
|
|
|
if (_stricmp(extension, ".sv4") == 0) {
|
2016-01-09 01:25:09 +01:00
|
|
|
return editor_load_landscape_from_sv4(path);
|
2014-10-10 23:50:22 +02:00
|
|
|
} else if (_stricmp(extension, ".sc4") == 0) {
|
2016-01-09 01:25:09 +01:00
|
|
|
return editor_load_landscape_from_sc4(path);
|
2014-10-10 23:50:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load SC6 / SV6
|
2016-01-09 01:25:09 +01:00
|
|
|
return editor_read_s6(path);
|
2014-10-10 23:50:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006A2B02
|
|
|
|
*/
|
|
|
|
static int editor_load_landscape_from_sv4(const char *path)
|
|
|
|
{
|
2016-04-22 20:26:15 +02:00
|
|
|
rct1_load_saved_game(path);
|
2016-09-05 23:31:12 +02:00
|
|
|
editor_clear_map_for_editing(true);
|
2015-01-20 02:04:28 +01:00
|
|
|
|
2016-09-10 19:30:53 +02:00
|
|
|
gS6Info.editor_step = EDITOR_STEP_LANDSCAPE_EDITOR;
|
2016-04-23 12:16:46 +02:00
|
|
|
gScreenAge = 0;
|
|
|
|
gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR;
|
2016-04-22 20:26:15 +02:00
|
|
|
viewport_init_all();
|
|
|
|
window_editor_main_open();
|
|
|
|
editor_finalise_main_view();
|
2014-10-10 23:50:22 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-04-01 19:13:25 +02:00
|
|
|
static int editor_load_landscape_from_sc4(const char *path)
|
2014-10-10 23:50:22 +02:00
|
|
|
{
|
2016-04-22 20:26:15 +02:00
|
|
|
rct1_load_scenario(path);
|
2016-09-05 23:31:12 +02:00
|
|
|
editor_clear_map_for_editing(false);
|
2014-10-10 23:50:22 +02:00
|
|
|
|
2016-09-10 19:30:53 +02:00
|
|
|
gS6Info.editor_step = EDITOR_STEP_LANDSCAPE_EDITOR;
|
2016-04-23 12:16:46 +02:00
|
|
|
gScreenAge = 0;
|
|
|
|
gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR;
|
2016-04-22 20:26:15 +02:00
|
|
|
viewport_init_all();
|
|
|
|
window_editor_main_open();
|
|
|
|
editor_finalise_main_view();
|
2014-10-10 23:50:22 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006758FE
|
|
|
|
*/
|
|
|
|
static int editor_read_s6(const char *path)
|
|
|
|
{
|
2016-08-14 16:50:52 +02:00
|
|
|
if (!scenario_load(path)) {
|
|
|
|
return 0;
|
2016-04-22 20:26:15 +02:00
|
|
|
}
|
2014-11-24 03:58:48 +01:00
|
|
|
|
2016-09-05 23:31:12 +02:00
|
|
|
editor_clear_map_for_editing(true);
|
2016-08-14 16:50:52 +02:00
|
|
|
|
2016-09-10 19:30:53 +02:00
|
|
|
gS6Info.editor_step = EDITOR_STEP_LANDSCAPE_EDITOR;
|
2016-08-14 16:50:52 +02:00
|
|
|
gScreenAge = 0;
|
|
|
|
gScreenFlags = SCREEN_FLAGS_SCENARIO_EDITOR;
|
|
|
|
viewport_init_all();
|
|
|
|
window_editor_main_open();
|
|
|
|
editor_finalise_main_view();
|
|
|
|
return 1;
|
2016-04-22 20:26:15 +02:00
|
|
|
}
|
2014-11-24 03:58:48 +01:00
|
|
|
|
2016-09-05 23:31:12 +02:00
|
|
|
static void editor_clear_map_for_editing(bool fromSave)
|
2016-04-22 20:26:15 +02:00
|
|
|
{
|
|
|
|
map_remove_all_rides();
|
2014-11-24 03:58:48 +01:00
|
|
|
|
2016-04-22 20:26:15 +02:00
|
|
|
//
|
|
|
|
for (int i = 0; i < MAX_BANNERS; i++) {
|
|
|
|
if (gBanners[i].type == 255) {
|
|
|
|
gBanners[i].flags &= ~BANNER_FLAG_2;
|
2014-11-24 03:58:48 +01:00
|
|
|
}
|
2016-04-22 20:26:15 +02:00
|
|
|
}
|
2014-11-24 03:58:48 +01:00
|
|
|
|
2016-04-22 20:26:15 +02:00
|
|
|
//
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
rct_ride *ride;
|
|
|
|
FOR_ALL_RIDES(i, ride) {
|
|
|
|
user_string_free(ride->name);
|
2014-11-24 03:58:48 +01:00
|
|
|
}
|
2016-04-22 20:26:15 +02:00
|
|
|
}
|
2014-11-24 03:58:48 +01:00
|
|
|
|
2016-04-22 20:26:15 +02:00
|
|
|
ride_init_all();
|
2014-11-24 03:58:48 +01:00
|
|
|
|
2016-04-22 20:26:15 +02:00
|
|
|
//
|
|
|
|
for (int i = 0; i < MAX_SPRITES; i++) {
|
2016-07-17 22:14:44 +02:00
|
|
|
rct_sprite *sprite = get_sprite(i);
|
2016-04-22 20:26:15 +02:00
|
|
|
user_string_free(sprite->unknown.name_string_idx);
|
|
|
|
}
|
2014-11-24 03:58:48 +01:00
|
|
|
|
2016-04-22 20:26:15 +02:00
|
|
|
reset_sprite_list();
|
|
|
|
staff_reset_modes();
|
2016-04-23 02:00:00 +02:00
|
|
|
gNumGuestsInPark = 0;
|
2016-04-23 03:56:55 +02:00
|
|
|
gNumGuestsHeadingForPark = 0;
|
2016-04-23 03:55:14 +02:00
|
|
|
gNumGuestsInParkLastWeek = 0;
|
2016-04-23 03:51:38 +02:00
|
|
|
gGuestChangeModifier = 0;
|
2016-09-05 23:31:12 +02:00
|
|
|
if (fromSave) {
|
2016-04-22 20:26:15 +02:00
|
|
|
research_populate_list_random();
|
|
|
|
research_remove_non_separate_vehicle_types();
|
|
|
|
|
2016-04-23 01:51:22 +02:00
|
|
|
if (gParkFlags & PARK_FLAGS_NO_MONEY)
|
|
|
|
gParkFlags |= PARK_FLAGS_NO_MONEY_SCENARIO;
|
2016-04-22 20:26:15 +02:00
|
|
|
else
|
2016-04-23 01:51:22 +02:00
|
|
|
gParkFlags &= ~PARK_FLAGS_NO_MONEY_SCENARIO;
|
|
|
|
gParkFlags |= PARK_FLAGS_NO_MONEY;
|
2016-04-22 20:26:15 +02:00
|
|
|
|
2016-04-23 02:00:00 +02:00
|
|
|
if (gParkEntranceFee == 0)
|
2016-04-23 01:51:22 +02:00
|
|
|
gParkFlags |= PARK_FLAGS_PARK_FREE_ENTRY;
|
2016-04-22 20:26:15 +02:00
|
|
|
else
|
2016-04-23 01:51:22 +02:00
|
|
|
gParkFlags &= ~PARK_FLAGS_PARK_FREE_ENTRY;
|
2016-04-22 20:26:15 +02:00
|
|
|
|
2016-04-23 01:51:22 +02:00
|
|
|
gParkFlags &= ~PARK_FLAGS_18;
|
2016-04-22 20:26:15 +02:00
|
|
|
|
2016-04-23 03:35:03 +02:00
|
|
|
gGuestInitialCash = clamp(MONEY(10,00), gGuestInitialCash, MONEY(100,00));
|
2016-04-22 20:26:15 +02:00
|
|
|
|
2016-04-25 23:38:09 +02:00
|
|
|
gInitialCash = min(gInitialCash, 100000);
|
2016-04-22 20:26:15 +02:00
|
|
|
finance_reset_cash_to_initial();
|
|
|
|
|
2016-04-23 03:00:44 +02:00
|
|
|
gBankLoan = clamp(
|
2016-04-22 20:26:15 +02:00
|
|
|
MONEY(0,00),
|
2016-04-23 03:00:44 +02:00
|
|
|
gBankLoan,
|
2016-04-22 20:26:15 +02:00
|
|
|
MONEY(5000000,00)
|
|
|
|
);
|
|
|
|
|
2016-04-25 23:38:09 +02:00
|
|
|
gMaxBankLoan = clamp(
|
2016-04-22 20:26:15 +02:00
|
|
|
MONEY(0,00),
|
2016-04-25 23:38:09 +02:00
|
|
|
gMaxBankLoan,
|
2016-04-22 20:26:15 +02:00
|
|
|
MONEY(5000000,00)
|
|
|
|
);
|
|
|
|
|
2016-04-23 03:06:56 +02:00
|
|
|
gBankLoanInterestRate = clamp(5, gBankLoanInterestRate, 80);
|
2016-04-22 20:26:15 +02:00
|
|
|
}
|
2014-11-24 03:58:48 +01:00
|
|
|
|
2016-04-23 11:53:48 +02:00
|
|
|
climate_reset(gClimate);
|
2016-04-22 20:26:15 +02:00
|
|
|
|
|
|
|
news_item_init_queue();
|
2014-10-21 18:59:47 +02:00
|
|
|
}
|
2014-11-23 17:28:23 +01:00
|
|
|
|
|
|
|
/**
|
2014-11-25 00:05:35 +01:00
|
|
|
*
|
|
|
|
* rct2: 0x0067009A
|
|
|
|
*/
|
|
|
|
void editor_open_windows_for_current_step()
|
|
|
|
{
|
2016-04-23 12:16:46 +02:00
|
|
|
if (!(gScreenFlags & SCREEN_FLAGS_EDITOR))
|
2014-11-23 17:28:23 +01:00
|
|
|
return;
|
|
|
|
|
2016-09-10 19:30:53 +02:00
|
|
|
switch (gS6Info.editor_step) {
|
2014-11-23 17:28:23 +01:00
|
|
|
case EDITOR_STEP_OBJECT_SELECTION:
|
|
|
|
if (window_find_by_class(WC_EDITOR_OBJECT_SELECTION))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (window_find_by_class(49))
|
|
|
|
return;
|
|
|
|
|
2016-04-23 12:16:46 +02:00
|
|
|
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) {
|
2016-07-07 23:58:48 +02:00
|
|
|
object_manager_unload_all_objects();
|
2014-11-23 17:28:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
window_editor_object_selection_open();
|
|
|
|
break;
|
|
|
|
case EDITOR_STEP_INVENTIONS_LIST_SET_UP:
|
|
|
|
if (window_find_by_class(WC_EDITOR_INVENTION_LIST))
|
|
|
|
return;
|
|
|
|
|
2014-11-25 00:05:35 +01:00
|
|
|
window_editor_inventions_list_open();
|
2014-11-23 17:28:23 +01:00
|
|
|
break;
|
|
|
|
case EDITOR_STEP_OPTIONS_SELECTION:
|
|
|
|
if (window_find_by_class(WC_EDITOR_SCENARIO_OPTIONS))
|
|
|
|
return;
|
|
|
|
|
2014-11-25 00:05:35 +01:00
|
|
|
window_editor_scenario_options_open();
|
2014-11-23 17:28:23 +01:00
|
|
|
break;
|
|
|
|
case EDITOR_STEP_OBJECTIVE_SELECTION:
|
|
|
|
if (window_find_by_class(WC_EDTIOR_OBJECTIVE_OPTIONS))
|
|
|
|
return;
|
|
|
|
|
2014-11-25 00:05:35 +01:00
|
|
|
window_editor_objective_options_open();
|
2014-11-23 17:28:23 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-03-31 14:06:34 +02:00
|
|
|
|
2015-04-01 19:13:25 +02:00
|
|
|
static void editor_finalise_main_view()
|
|
|
|
{
|
|
|
|
rct_window *w = window_get_main();
|
|
|
|
rct_viewport *viewport = w->viewport;
|
|
|
|
|
|
|
|
w->viewport_target_sprite = -1;
|
2016-04-25 22:37:48 +02:00
|
|
|
w->saved_view_x = gSavedViewX;
|
|
|
|
w->saved_view_y = gSavedViewY;
|
|
|
|
gCurrentRotation = gSavedViewRotation;
|
2015-04-01 19:13:25 +02:00
|
|
|
|
2016-04-25 22:37:48 +02:00
|
|
|
int zoom_difference = gSavedViewZoom - viewport->zoom;
|
|
|
|
viewport->zoom = gSavedViewZoom;
|
2015-04-01 19:13:25 +02:00
|
|
|
if (zoom_difference != 0) {
|
|
|
|
if (zoom_difference >= 0) {
|
|
|
|
viewport->view_width <<= zoom_difference;
|
|
|
|
viewport->view_height <<= zoom_difference;
|
|
|
|
} else {
|
|
|
|
zoom_difference = -zoom_difference;
|
|
|
|
viewport->view_width >>= zoom_difference;
|
|
|
|
viewport->view_height >>= zoom_difference;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
w->saved_view_x -= viewport->view_width >> 1;
|
|
|
|
w->saved_view_y -= viewport->view_height >> 1;
|
|
|
|
|
|
|
|
window_invalidate(w);
|
2015-05-30 11:15:29 +02:00
|
|
|
reset_all_sprite_quadrant_placements();
|
2015-04-01 19:13:25 +02:00
|
|
|
scenery_set_default_placement_configuration();
|
|
|
|
window_new_ride_init_vars();
|
2016-08-06 02:35:46 +02:00
|
|
|
gWindowUpdateTicks = 0;
|
2015-04-01 19:13:25 +02:00
|
|
|
load_palette();
|
|
|
|
gfx_invalidate_screen();
|
2015-07-06 15:40:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006AB9B8
|
|
|
|
*/
|
2015-07-06 16:37:40 +02:00
|
|
|
int editor_check_object_selection()
|
2015-07-06 15:40:37 +02:00
|
|
|
{
|
2015-07-06 16:37:40 +02:00
|
|
|
bool isTrackDesignerManager =
|
2016-04-23 12:16:46 +02:00
|
|
|
gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER);
|
2015-07-06 16:37:40 +02:00
|
|
|
|
|
|
|
if (!isTrackDesignerManager) {
|
|
|
|
if (!editor_check_object_group_at_least_one_selected(OBJECT_TYPE_PATHS)) {
|
2016-04-15 18:54:46 +02:00
|
|
|
gGameCommandErrorText = STR_AT_LEAST_ONE_PATH_OBJECT_MUST_BE_SELECTED;
|
2015-07-06 16:37:40 +02:00
|
|
|
return OBJECT_TYPE_PATHS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!editor_check_object_group_at_least_one_selected(OBJECT_TYPE_RIDE)) {
|
2016-04-15 18:54:46 +02:00
|
|
|
gGameCommandErrorText = STR_AT_LEAST_ONE_RIDE_OBJECT_MUST_BE_SELECTED;
|
2015-07-06 16:37:40 +02:00
|
|
|
return OBJECT_TYPE_RIDE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isTrackDesignerManager) {
|
|
|
|
if (!editor_check_object_group_at_least_one_selected(OBJECT_TYPE_PARK_ENTRANCE)) {
|
2016-04-15 18:54:46 +02:00
|
|
|
gGameCommandErrorText = STR_PARK_ENTRANCE_TYPE_MUST_BE_SELECTED;
|
2015-07-06 16:37:40 +02:00
|
|
|
return OBJECT_TYPE_PARK_ENTRANCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!editor_check_object_group_at_least_one_selected(OBJECT_TYPE_WATER)) {
|
2016-04-15 18:54:46 +02:00
|
|
|
gGameCommandErrorText = STR_WATER_TYPE_MUST_BE_SELECTED;
|
2015-07-06 16:37:40 +02:00
|
|
|
return OBJECT_TYPE_WATER;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
2015-07-06 15:40:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0066FEAC
|
|
|
|
*/
|
|
|
|
bool editor_check_park()
|
|
|
|
{
|
|
|
|
int parkSize = park_calculate_size();
|
|
|
|
if (parkSize == 0) {
|
2016-04-15 18:54:46 +02:00
|
|
|
gGameCommandErrorText = STR_PARK_MUST_OWN_SOME_LAND;
|
2015-07-06 15:40:37 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
2016-04-24 23:25:32 +02:00
|
|
|
if (gParkEntranceX[i] != (sint16)0x8000)
|
2015-07-06 15:40:37 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (i == 3) {
|
2016-04-15 18:54:46 +02:00
|
|
|
gGameCommandErrorText = STR_NO_PARK_ENTRANCES;
|
2015-07-06 15:40:37 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
2016-04-24 23:25:32 +02:00
|
|
|
if (gParkEntranceX[i] == (sint16)0x8000)
|
2015-07-06 15:40:37 +02:00
|
|
|
continue;
|
|
|
|
|
2016-04-24 11:53:04 +02:00
|
|
|
int x = gParkEntranceX[i];
|
|
|
|
int y = gParkEntranceY[i];
|
|
|
|
int z = gParkEntranceZ[i] / 8;
|
|
|
|
int direction = gParkEntranceDirection[i] ^ 2;
|
2015-07-06 15:40:37 +02:00
|
|
|
|
|
|
|
switch (footpath_is_connected_to_map_edge(x, y, z, direction, 0)) {
|
|
|
|
case FOOTPATH_SEARCH_NOT_FOUND:
|
2016-04-15 18:54:46 +02:00
|
|
|
gGameCommandErrorText = STR_PARK_ENTRANCE_WRONG_DIRECTION_OR_NO_PATH;
|
2015-07-06 15:40:37 +02:00
|
|
|
return false;
|
|
|
|
case FOOTPATH_SEARCH_INCOMPLETE:
|
|
|
|
case FOOTPATH_SEARCH_TOO_COMPLEX:
|
2016-04-15 18:54:46 +02:00
|
|
|
gGameCommandErrorText = STR_PARK_ENTRANCE_PATH_INCOMPLETE_OR_COMPLEX;
|
2015-07-06 15:40:37 +02:00
|
|
|
return false;
|
|
|
|
case FOOTPATH_SEARCH_SUCCESS:
|
|
|
|
// Run the search again and unown the path
|
2016-05-17 23:03:06 +02:00
|
|
|
footpath_is_connected_to_map_edge(x, y, z, direction, (1 << 5));
|
2015-07-06 15:40:37 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gPeepSpawns[0].x == 0xFFFF && gPeepSpawns[1].x == 0xFFFF) {
|
2016-04-15 18:54:46 +02:00
|
|
|
gGameCommandErrorText = STR_PEEP_SPAWNS_NOT_SET;
|
2015-07-06 15:40:37 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|