2016-05-04 19:24:41 +02:00
|
|
|
#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers
|
2014-04-02 01:31:55 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
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
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2014-04-02 01:31:55 +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-02 01:31:55 +02:00
|
|
|
*****************************************************************************/
|
2016-05-04 19:24:41 +02:00
|
|
|
#pragma endregion
|
2014-05-12 02:45:45 +02:00
|
|
|
|
|
|
|
#pragma warning(disable : 4996) // GetVersionExA deprecated
|
2014-04-02 01:31:55 +02:00
|
|
|
|
2015-07-03 12:06:53 +02:00
|
|
|
#include <time.h>
|
2014-10-06 18:36:58 +02:00
|
|
|
#include "audio/audio.h"
|
|
|
|
#include "audio/mixer.h"
|
2014-04-08 01:05:05 +02:00
|
|
|
#include "config.h"
|
2014-10-06 18:36:58 +02:00
|
|
|
#include "drawing/drawing.h"
|
2014-06-21 17:04:13 +02:00
|
|
|
#include "editor.h"
|
2014-04-02 01:31:55 +02:00
|
|
|
#include "game.h"
|
2016-01-05 23:33:47 +01:00
|
|
|
#include "input.h"
|
2015-07-19 01:57:42 +02:00
|
|
|
#include "interface/chat.h"
|
2015-05-19 04:53:37 +02:00
|
|
|
#include "interface/console.h"
|
2014-10-06 18:36:58 +02:00
|
|
|
#include "interface/viewport.h"
|
2014-04-02 17:46:58 +02:00
|
|
|
#include "intro.h"
|
2014-10-06 18:36:58 +02:00
|
|
|
#include "localisation/date.h"
|
|
|
|
#include "localisation/localisation.h"
|
|
|
|
#include "management/news_item.h"
|
2015-08-16 00:19:15 +02:00
|
|
|
#include "network/network.h"
|
2015-05-25 21:36:40 +02:00
|
|
|
#include "network/twitch.h"
|
2014-04-10 19:41:35 +02:00
|
|
|
#include "object.h"
|
2016-07-07 23:58:48 +02:00
|
|
|
#include "object/ObjectManager.h"
|
2014-10-09 15:31:51 +02:00
|
|
|
#include "openrct2.h"
|
2015-07-14 19:18:10 +02:00
|
|
|
#include "peep/staff.h"
|
2014-10-09 15:03:54 +02:00
|
|
|
#include "platform/platform.h"
|
2015-07-14 19:18:10 +02:00
|
|
|
#include "rct1.h"
|
2014-10-06 18:36:58 +02:00
|
|
|
#include "ride/ride.h"
|
|
|
|
#include "ride/track.h"
|
2016-04-28 22:46:39 +02:00
|
|
|
#include "ride/track_design.h"
|
2014-04-06 18:45:09 +02:00
|
|
|
#include "scenario.h"
|
2014-04-02 01:31:55 +02:00
|
|
|
#include "title.h"
|
2015-11-20 20:41:27 +01:00
|
|
|
#include "util/util.h"
|
2014-10-06 18:36:58 +02:00
|
|
|
#include "world/map.h"
|
|
|
|
#include "world/park.h"
|
|
|
|
#include "world/climate.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-02 01:31:55 +02:00
|
|
|
|
2016-01-09 01:34:34 +01:00
|
|
|
// rct2: 0x0097F67C
|
|
|
|
const char * const RCT2FilePaths[PATH_ID_END] = {
|
2016-09-19 18:59:06 +02:00
|
|
|
"Data" PATH_SEPARATOR "g1.dat",
|
|
|
|
"Data" PATH_SEPARATOR "plugin.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css1.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css2.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css4.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css5.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css6.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css7.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css8.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css9.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css11.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css12.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css13.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css14.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css15.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css3.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css17.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css18.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css19.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css20.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css21.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css22.dat",
|
|
|
|
"Saved Games" PATH_SEPARATOR "scores.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css23.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css24.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css25.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css26.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css27.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css28.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css29.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css30.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css31.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css32.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css33.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css34.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css35.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css36.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css37.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css38.dat",
|
|
|
|
"Data" PATH_SEPARATOR "CUSTOM1.WAV",
|
|
|
|
"Data" PATH_SEPARATOR "CUSTOM2.WAV",
|
|
|
|
"Data" PATH_SEPARATOR "css39.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css40.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css41.dat",
|
|
|
|
"Scenarios" PATH_SEPARATOR "Six Flags Magic Mountain.SC6",
|
|
|
|
"Data" PATH_SEPARATOR "css42.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css43.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css44.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css45.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css46.dat",
|
|
|
|
"Data" PATH_SEPARATOR "css50.dat"
|
2016-01-09 01:34:34 +01:00
|
|
|
};
|
|
|
|
|
2015-07-29 04:06:51 +02:00
|
|
|
uint32 gCurrentDrawCount = 0;
|
|
|
|
|
2016-04-23 12:16:46 +02:00
|
|
|
uint8 gScreenFlags;
|
|
|
|
uint32 gScreenAge;
|
|
|
|
uint8 gSavePromptMode;
|
2016-04-24 01:36:39 +02:00
|
|
|
sint32 gScreenWidth;
|
|
|
|
sint32 gScreenHeight;
|
2016-04-23 12:16:46 +02:00
|
|
|
|
2016-09-18 23:25:49 +02:00
|
|
|
char gRCT2AddressAppPath[MAX_PATH];
|
2016-06-19 23:47:06 +02:00
|
|
|
char gRCT2AddressSavedGamesPath[MAX_PATH];
|
|
|
|
char gRCT2AddressSavedGamesPath2[MAX_PATH];
|
|
|
|
char gRCT2AddressScenariosPath[MAX_PATH];
|
|
|
|
char gRCT2AddressLandscapesPath[MAX_PATH];
|
|
|
|
char gRCT2AddressObjectDataPath[MAX_PATH];
|
|
|
|
char gRCT2AddressTracksPath[MAX_PATH];
|
|
|
|
|
2014-05-23 13:15:08 +02:00
|
|
|
typedef struct tm tm_t;
|
|
|
|
|
2014-05-23 01:53:52 +02:00
|
|
|
void print_launch_information();
|
2014-04-15 01:50:20 +02:00
|
|
|
|
2014-11-23 00:30:03 +01:00
|
|
|
int rct2_init_directories();
|
|
|
|
int rct2_startup_checks();
|
2014-04-02 01:31:55 +02:00
|
|
|
|
2016-06-05 16:11:12 +02:00
|
|
|
static void rct2_draw_fps(rct_drawpixelinfo *dpi);
|
2014-04-02 01:31:55 +02:00
|
|
|
|
2015-05-21 04:11:53 +02:00
|
|
|
void rct2_quit()
|
|
|
|
{
|
2016-04-23 12:16:46 +02:00
|
|
|
gSavePromptMode = PM_QUIT;
|
2015-05-21 04:11:53 +02:00
|
|
|
window_save_prompt_open();
|
2016-01-15 16:23:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void rct2_dispose()
|
|
|
|
{
|
2016-08-08 02:30:55 +02:00
|
|
|
object_manager_unload_all_objects();
|
2016-01-15 19:18:31 +01:00
|
|
|
gfx_unload_g2();
|
|
|
|
gfx_unload_g1();
|
2014-05-24 01:00:58 +02:00
|
|
|
}
|
|
|
|
|
2016-09-10 13:45:33 +02:00
|
|
|
bool rct2_init()
|
2014-04-02 01:31:55 +02:00
|
|
|
{
|
2014-11-21 19:39:56 +01:00
|
|
|
log_verbose("initialising game");
|
|
|
|
|
2016-05-09 00:20:42 +02:00
|
|
|
gScenarioTicks = 0;
|
2015-11-20 20:41:27 +01:00
|
|
|
util_srand((unsigned int)time(0));
|
2014-11-23 00:30:03 +01:00
|
|
|
if (!rct2_init_directories())
|
2016-09-10 13:45:33 +02:00
|
|
|
return false;
|
2014-11-23 00:30:03 +01:00
|
|
|
|
|
|
|
if (!rct2_startup_checks())
|
2016-09-10 13:45:33 +02:00
|
|
|
return false;
|
2014-11-23 00:30:03 +01:00
|
|
|
|
2014-04-26 02:16:32 +02:00
|
|
|
config_reset_shortcut_keys();
|
2015-02-27 18:28:45 +01:00
|
|
|
config_shortcut_keys_load();
|
2016-01-05 23:33:47 +01:00
|
|
|
gInputPlaceObjectModifier = PLACE_OBJECT_MODIFIER_NONE;
|
2014-10-09 16:55:47 +02:00
|
|
|
// config_load();
|
2014-12-07 22:58:19 +01:00
|
|
|
|
2016-09-10 13:45:33 +02:00
|
|
|
if (!gfx_load_g1()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!gfx_load_g2()) {
|
|
|
|
return false;
|
|
|
|
}
|
2016-04-28 13:40:12 +02:00
|
|
|
|
2014-05-24 02:34:17 +02:00
|
|
|
object_list_load();
|
2014-04-06 18:45:09 +02:00
|
|
|
scenario_load_list();
|
2016-04-27 01:15:48 +02:00
|
|
|
track_design_index_create();
|
2014-09-27 01:41:24 +02:00
|
|
|
|
2015-07-29 15:36:21 +02:00
|
|
|
font_sprite_initialise_characters();
|
2015-05-29 21:45:21 +02:00
|
|
|
if (!gOpenRCT2Headless) {
|
|
|
|
platform_init();
|
2015-11-17 01:42:23 +01:00
|
|
|
audio_init_ride_sounds_and_info();
|
2015-05-29 21:45:21 +02:00
|
|
|
}
|
2014-04-08 18:52:39 +02:00
|
|
|
viewport_init_all();
|
2014-04-04 22:46:26 +02:00
|
|
|
news_item_init_queue();
|
2014-05-06 23:04:09 +02:00
|
|
|
reset_park_entrances();
|
2014-11-24 03:58:48 +01:00
|
|
|
user_string_clear_all();
|
2014-06-20 16:31:28 +02:00
|
|
|
reset_sprite_list();
|
2014-04-09 03:39:28 +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();
|
2015-02-09 19:32:58 +01:00
|
|
|
map_init(150);
|
2014-04-10 01:22:57 +02:00
|
|
|
park_init();
|
2015-05-29 21:45:21 +02:00
|
|
|
if (!gOpenRCT2Headless)
|
|
|
|
window_title_menu_open();
|
2014-04-10 01:22:57 +02:00
|
|
|
date_reset();
|
|
|
|
climate_reset(CLIMATE_COOL_AND_WET);
|
2015-03-29 03:29:07 +02:00
|
|
|
scenery_set_default_placement_configuration();
|
2014-05-10 00:11:51 +02:00
|
|
|
window_new_ride_init_vars();
|
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();
|
2014-04-02 01:31:55 +02:00
|
|
|
|
2015-05-29 21:45:21 +02:00
|
|
|
if (!gOpenRCT2Headless) {
|
|
|
|
title_load();
|
|
|
|
}
|
2014-11-23 00:30:03 +01:00
|
|
|
|
2015-02-04 18:44:39 +01:00
|
|
|
log_verbose("initialising game finished");
|
2016-09-10 13:45:33 +02:00
|
|
|
return true;
|
2014-04-02 01:31:55 +02:00
|
|
|
}
|
|
|
|
|
2014-11-23 00:30:03 +01:00
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2014-11-23 00:30:03 +01:00
|
|
|
* rct2: 0x00683499
|
|
|
|
*/
|
|
|
|
int rct2_init_directories()
|
2014-04-02 01:31:55 +02:00
|
|
|
{
|
2015-02-11 23:17:49 +01:00
|
|
|
// windows_get_registry_install_info((rct2_install_info*)0x009AA10C, "RollerCoaster Tycoon 2 Setup", "MS Sans Serif", 0);
|
|
|
|
|
2015-09-19 09:29:39 +02:00
|
|
|
char separator[] = {platform_get_path_separator(), 0};
|
|
|
|
|
2016-09-18 23:25:49 +02:00
|
|
|
if (str_is_null_or_empty(gCustomRCT2DataPath)) {
|
|
|
|
// check install directory
|
|
|
|
if (!platform_original_game_data_exists(gConfigGeneral.game_path)) {
|
|
|
|
log_verbose("install directory does not exist or invalid directory selected, %s", gConfigGeneral.game_path);
|
|
|
|
if (!config_find_or_browse_install_directory()) {
|
|
|
|
utf8 path[MAX_PATH];
|
|
|
|
config_get_default_path(path);
|
|
|
|
log_fatal("Invalid RCT2 installation path. Please correct \"game_path\" in %s.", path);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
strcpy(gRCT2AddressAppPath, gConfigGeneral.game_path);
|
|
|
|
} else {
|
|
|
|
strcpy(gRCT2AddressAppPath, gCustomRCT2DataPath);
|
|
|
|
}
|
2016-06-19 23:47:06 +02:00
|
|
|
strcat(gRCT2AddressAppPath, separator);
|
|
|
|
|
|
|
|
strcpy(gRCT2AddressSavedGamesPath, gRCT2AddressAppPath);
|
|
|
|
strcat(gRCT2AddressSavedGamesPath, "Saved Games");
|
|
|
|
strcat(gRCT2AddressSavedGamesPath, separator);
|
|
|
|
|
|
|
|
strcpy(gRCT2AddressScenariosPath, gRCT2AddressAppPath);
|
|
|
|
strcat(gRCT2AddressScenariosPath, "Scenarios");
|
|
|
|
strcat(gRCT2AddressScenariosPath, separator);
|
|
|
|
strcat(gRCT2AddressScenariosPath, "*.SC6");
|
|
|
|
|
|
|
|
strcpy(gRCT2AddressLandscapesPath, gRCT2AddressAppPath);
|
|
|
|
strcat(gRCT2AddressLandscapesPath, "Landscapes");
|
|
|
|
strcat(gRCT2AddressLandscapesPath, separator);
|
|
|
|
strcat(gRCT2AddressLandscapesPath, "*.SC6");
|
|
|
|
|
|
|
|
strcpy(gRCT2AddressObjectDataPath, gRCT2AddressAppPath);
|
|
|
|
strcat(gRCT2AddressObjectDataPath, "ObjData");
|
|
|
|
strcat(gRCT2AddressObjectDataPath, separator);
|
|
|
|
strcat(gRCT2AddressObjectDataPath, "*.DAT");
|
|
|
|
|
|
|
|
strcpy(gRCT2AddressTracksPath, gRCT2AddressAppPath);
|
|
|
|
strcat(gRCT2AddressTracksPath, "Tracks");
|
|
|
|
strcat(gRCT2AddressTracksPath, separator);
|
|
|
|
strcat(gRCT2AddressTracksPath, "*.TD?");
|
|
|
|
|
|
|
|
strcpy(gRCT2AddressSavedGamesPath2, gRCT2AddressSavedGamesPath);
|
2014-11-23 00:30:03 +01:00
|
|
|
return 1;
|
2014-04-02 01:31:55 +02:00
|
|
|
}
|
|
|
|
|
2015-12-22 16:31:51 +01:00
|
|
|
void substitute_path(char *dest, const char *path, const char *filename)
|
2014-05-24 00:52:13 +02:00
|
|
|
{
|
|
|
|
while (*path != '*') {
|
|
|
|
*dest++ = *path++;
|
|
|
|
}
|
|
|
|
strcpy(dest, filename);
|
|
|
|
}
|
|
|
|
|
2014-11-23 00:30:03 +01:00
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2014-11-23 00:30:03 +01:00
|
|
|
* rct2: 0x00674B42
|
|
|
|
*/
|
|
|
|
int rct2_startup_checks()
|
2014-04-02 01:31:55 +02:00
|
|
|
{
|
2014-11-23 00:30:03 +01:00
|
|
|
if (!check_file_paths())
|
|
|
|
return 0;
|
2014-04-02 01:31:55 +02:00
|
|
|
|
2014-11-23 00:30:03 +01:00
|
|
|
return 1;
|
2014-04-02 01:31:55 +02:00
|
|
|
}
|
|
|
|
|
2016-06-05 16:11:12 +02:00
|
|
|
void rct2_draw(rct_drawpixelinfo *dpi)
|
2015-07-04 21:00:32 +02:00
|
|
|
{
|
2016-05-13 22:36:07 +02:00
|
|
|
if (gIntroState != INTRO_STATE_NONE) {
|
2016-05-13 19:37:00 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-03 01:29:02 +02:00
|
|
|
// redraw_rain();
|
|
|
|
// window_update_all();
|
2016-06-04 00:06:22 +02:00
|
|
|
// gfx_invalidate_pickedup_peep();
|
|
|
|
// gfx_draw_pickedup_peep();
|
|
|
|
// update_rain_animation();
|
2015-07-11 04:13:19 +02:00
|
|
|
update_palette_effects();
|
2015-07-04 21:00:32 +02:00
|
|
|
|
2016-06-05 16:11:12 +02:00
|
|
|
chat_draw(dpi);
|
|
|
|
console_draw(dpi);
|
2015-07-04 21:00:32 +02:00
|
|
|
|
2016-05-13 19:37:00 +02:00
|
|
|
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) {
|
2016-06-05 16:11:12 +02:00
|
|
|
DrawOpenRCT2(dpi, 0, gScreenHeight - 20);
|
2015-07-04 21:00:32 +02:00
|
|
|
}
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2015-12-09 22:42:46 +01:00
|
|
|
if (gConfigGeneral.show_fps) {
|
2016-06-05 16:11:12 +02:00
|
|
|
rct2_draw_fps(dpi);
|
2015-12-09 22:42:46 +01:00
|
|
|
}
|
|
|
|
|
2015-07-29 04:06:51 +02:00
|
|
|
gCurrentDrawCount++;
|
2015-07-04 21:00:32 +02:00
|
|
|
}
|
|
|
|
|
2016-07-23 17:09:42 +02:00
|
|
|
static time_t _lastSecond;
|
|
|
|
static int _currentFPS;
|
|
|
|
static int _frames;
|
2015-12-09 22:42:46 +01:00
|
|
|
|
2016-07-23 17:09:42 +02:00
|
|
|
static void rct2_measure_fps()
|
2015-12-09 22:42:46 +01:00
|
|
|
{
|
2016-07-27 16:31:25 +02:00
|
|
|
_frames++;
|
2015-12-09 22:42:46 +01:00
|
|
|
|
2016-07-27 16:31:25 +02:00
|
|
|
time_t currentTime = time(NULL);
|
2016-07-23 17:32:15 +02:00
|
|
|
|
2016-07-27 16:31:25 +02:00
|
|
|
if (currentTime != _lastSecond) {
|
|
|
|
_currentFPS = _frames;
|
|
|
|
_frames = 0;
|
|
|
|
}
|
2016-07-23 17:09:42 +02:00
|
|
|
|
2016-07-27 16:31:25 +02:00
|
|
|
_lastSecond = currentTime;
|
2015-12-09 22:42:46 +01:00
|
|
|
}
|
|
|
|
|
2016-06-05 16:11:12 +02:00
|
|
|
static void rct2_draw_fps(rct_drawpixelinfo *dpi)
|
2015-12-09 22:42:46 +01:00
|
|
|
{
|
2016-04-24 01:36:39 +02:00
|
|
|
int x = gScreenWidth / 2;
|
2015-12-09 22:42:46 +01:00
|
|
|
int y = 2;
|
|
|
|
|
|
|
|
// Measure FPS
|
2016-05-13 19:21:58 +02:00
|
|
|
rct2_measure_fps();
|
2015-12-09 22:42:46 +01:00
|
|
|
|
|
|
|
// Format string
|
|
|
|
utf8 buffer[64];
|
|
|
|
utf8 *ch = buffer;
|
|
|
|
ch = utf8_write_codepoint(ch, FORMAT_MEDIUMFONT);
|
|
|
|
ch = utf8_write_codepoint(ch, FORMAT_OUTLINE);
|
|
|
|
ch = utf8_write_codepoint(ch, FORMAT_WHITE);
|
2016-07-27 16:31:25 +02:00
|
|
|
|
2016-07-23 17:09:42 +02:00
|
|
|
sprintf(ch, "%d", _currentFPS);
|
2015-12-09 22:42:46 +01:00
|
|
|
|
|
|
|
// Draw Text
|
|
|
|
int stringWidth = gfx_get_string_width(buffer);
|
|
|
|
x = x - (stringWidth / 2);
|
|
|
|
gfx_draw_string(dpi, buffer, 0, x, y);
|
|
|
|
|
|
|
|
// Make area dirty so the text doesn't get drawn over the last
|
|
|
|
gfx_set_dirty_blocks(x - 16, y - 4, gLastDrawStringX + 16, 16);
|
|
|
|
}
|
|
|
|
|
2016-03-05 13:20:02 +01:00
|
|
|
bool rct2_open_file(const char *path)
|
2014-05-02 14:32:44 +02:00
|
|
|
{
|
2014-09-10 20:36:11 +02:00
|
|
|
char *extension = strrchr(path, '.');
|
2016-03-05 13:20:02 +01:00
|
|
|
if (extension == NULL) {
|
|
|
|
return false;
|
|
|
|
}
|
2014-09-10 20:36:11 +02:00
|
|
|
extension++;
|
|
|
|
|
2014-10-09 02:36:59 +02:00
|
|
|
if (_stricmp(extension, "sv6") == 0) {
|
2016-06-19 23:47:06 +02:00
|
|
|
strcpy((char*)gRCT2AddressSavedGamesPath2, path);
|
2014-09-10 20:36:11 +02:00
|
|
|
game_load_save(path);
|
2016-04-15 22:52:15 +02:00
|
|
|
gFirstTimeSave = 0;
|
2016-03-05 13:20:02 +01:00
|
|
|
return true;
|
2014-10-09 02:36:59 +02:00
|
|
|
} else if (_stricmp(extension, "sc6") == 0) {
|
2014-09-10 20:36:11 +02:00
|
|
|
// TODO scenario install
|
|
|
|
rct_scenario_basic scenarioBasic;
|
|
|
|
strcpy(scenarioBasic.path, path);
|
|
|
|
scenario_load_and_play_from_path(scenarioBasic.path);
|
2016-03-05 13:20:02 +01:00
|
|
|
return true;
|
2014-10-09 02:36:59 +02:00
|
|
|
} else if (_stricmp(extension, "td6") == 0 || _stricmp(extension, "td4") == 0) {
|
2014-09-10 20:36:11 +02:00
|
|
|
// TODO track design install
|
2016-03-05 13:20:02 +01:00
|
|
|
return true;
|
2015-07-14 19:14:43 +02:00
|
|
|
} else if (_stricmp(extension, "sv4") == 0) {
|
2016-04-22 20:26:15 +02:00
|
|
|
if (rct1_load_saved_game(path)) {
|
|
|
|
game_load_init();
|
|
|
|
}
|
2015-07-14 19:14:43 +02:00
|
|
|
} else if (_stricmp(extension, "sc4") == 0) {
|
2016-04-22 20:26:15 +02:00
|
|
|
if (rct1_load_scenario(path)) {
|
|
|
|
scenario_begin();
|
|
|
|
}
|
2014-09-10 20:36:11 +02:00
|
|
|
}
|
2014-09-25 03:39:17 +02:00
|
|
|
|
2016-03-05 13:20:02 +01:00
|
|
|
return false;
|
2014-09-10 20:36:11 +02:00
|
|
|
}
|
2014-05-02 14:32:44 +02:00
|
|
|
|
2014-11-23 00:30:03 +01:00
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2014-11-23 00:30:03 +01:00
|
|
|
* rct2: 0x00674C95
|
|
|
|
*/
|
|
|
|
int check_file_paths()
|
2016-01-09 01:34:34 +01:00
|
|
|
{
|
|
|
|
for (int pathId = 0; pathId < PATH_ID_END; pathId++) {
|
|
|
|
if (!check_file_path(pathId)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2014-11-23 00:30:03 +01:00
|
|
|
return 1;
|
2014-06-28 20:45:25 +02:00
|
|
|
}
|
|
|
|
|
2014-11-23 00:30:03 +01:00
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2014-11-23 00:30:03 +01:00
|
|
|
* rct2: 0x00674CA5
|
|
|
|
*/
|
|
|
|
int check_file_path(int pathId)
|
2014-06-28 20:45:25 +02:00
|
|
|
{
|
2015-08-29 14:12:52 +02:00
|
|
|
const utf8* path = get_file_path(pathId);
|
|
|
|
SDL_RWops *file = SDL_RWFromFile(path, "rb");
|
2014-06-28 20:45:25 +02:00
|
|
|
|
2014-11-23 00:30:03 +01:00
|
|
|
switch (pathId) {
|
2015-02-07 00:15:11 +01:00
|
|
|
case PATH_ID_G1:
|
2015-08-29 14:12:52 +02:00
|
|
|
if (file == NULL) {
|
2014-11-23 00:30:03 +01:00
|
|
|
log_fatal("Could not find file %s", path);
|
|
|
|
return 0;
|
2014-06-28 20:45:25 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PATH_ID_CUSTOM1:
|
2016-01-09 01:34:34 +01:00
|
|
|
if (file != NULL) {
|
|
|
|
// Store file size in music_custom1_size @ 0x009AF164
|
|
|
|
gRideMusicInfoList[36]->length = (uint32)SDL_RWsize(file);
|
|
|
|
}
|
2014-06-28 20:45:25 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PATH_ID_CUSTOM2:
|
2016-01-09 01:34:34 +01:00
|
|
|
if (file != NULL) {
|
|
|
|
// Store file size in music_custom2_size @ 0x009AF16E
|
|
|
|
gRideMusicInfoList[37]->length = (uint32)SDL_RWsize(file);
|
|
|
|
}
|
2014-06-28 20:45:25 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-01-09 01:34:34 +01:00
|
|
|
if (file != NULL) {
|
2015-08-29 14:12:52 +02:00
|
|
|
SDL_RWclose(file);
|
2014-06-19 13:52:34 +02:00
|
|
|
}
|
2014-11-23 00:30:03 +01:00
|
|
|
|
|
|
|
return 1;
|
2014-06-19 13:52:34 +02:00
|
|
|
}
|
|
|
|
|
2016-01-09 01:25:09 +01:00
|
|
|
void rct2_update()
|
2014-04-02 01:31:55 +02:00
|
|
|
{
|
2016-05-20 23:56:45 +02:00
|
|
|
int tickCount = SDL_GetTicks();
|
|
|
|
gTicksSinceLastUpdate = min(tickCount - gLastTickCount, 500);
|
|
|
|
gLastTickCount = tickCount;
|
2016-04-24 03:02:56 +02:00
|
|
|
if (game_is_not_paused()) {
|
2016-05-20 23:56:45 +02:00
|
|
|
gPaletteEffectFrame += gTicksSinceLastUpdate;
|
2016-04-24 03:02:56 +02:00
|
|
|
}
|
2014-04-02 01:31:55 +02:00
|
|
|
|
2016-05-20 21:06:04 +02:00
|
|
|
date_update_real_time_of_day();
|
|
|
|
|
2014-04-02 01:31:55 +02:00
|
|
|
// TODO: screenshot countdown process
|
|
|
|
|
2015-08-16 00:19:15 +02:00
|
|
|
network_update();
|
|
|
|
|
2014-10-09 01:30:22 +02:00
|
|
|
// check_cmdline_arg();
|
2014-04-02 01:31:55 +02:00
|
|
|
// Screens
|
2016-05-13 22:36:07 +02:00
|
|
|
if (gIntroState != INTRO_STATE_NONE) {
|
2014-04-02 01:31:55 +02:00
|
|
|
intro_update();
|
2016-05-13 22:36:07 +02:00
|
|
|
} else if ((gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) && !gOpenRCT2Headless) {
|
2014-04-02 01:31:55 +02:00
|
|
|
title_update();
|
2016-05-13 22:36:07 +02:00
|
|
|
} else {
|
2014-04-02 01:31:55 +02:00
|
|
|
game_update();
|
2016-05-13 22:36:07 +02:00
|
|
|
}
|
2015-05-19 04:53:37 +02:00
|
|
|
|
2015-09-23 10:39:45 +02:00
|
|
|
//stop_completed_sounds(); // removes other sounds that are no longer playing in directsound
|
2015-07-04 21:00:32 +02:00
|
|
|
|
2015-05-25 21:36:40 +02:00
|
|
|
twitch_update();
|
2015-07-19 01:57:42 +02:00
|
|
|
chat_update();
|
2015-05-19 04:53:37 +02:00
|
|
|
console_update();
|
2014-04-04 20:59:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2014-04-04 20:59:32 +02:00
|
|
|
* rct2: 0x00674E6C
|
|
|
|
*/
|
2015-08-29 14:12:52 +02:00
|
|
|
const utf8 *get_file_path(int pathId)
|
2014-04-04 20:59:32 +02:00
|
|
|
{
|
2016-01-09 01:34:34 +01:00
|
|
|
static utf8 path[MAX_PATH];
|
2016-09-18 23:25:49 +02:00
|
|
|
strcpy(path, gRCT2AddressAppPath);
|
|
|
|
safe_strcat_path(path, RCT2FilePaths[pathId], sizeof(path));
|
2014-06-15 15:10:35 +02:00
|
|
|
return path;
|
2014-04-08 18:52:39 +02:00
|
|
|
}
|
2016-04-19 23:09:42 +02:00
|
|
|
|
|
|
|
uint32 get_file_extension_type(const utf8 *path)
|
|
|
|
{
|
|
|
|
const utf8 *extension = path_get_extension(path);
|
|
|
|
if (strcicmp(extension, ".dat") == 0) return FILE_EXTENSION_DAT;
|
|
|
|
if (strcicmp(extension, ".sc4") == 0) return FILE_EXTENSION_SC4;
|
|
|
|
if (strcicmp(extension, ".sv4") == 0) return FILE_EXTENSION_SV4;
|
|
|
|
if (strcicmp(extension, ".td4") == 0) return FILE_EXTENSION_TD4;
|
|
|
|
if (strcicmp(extension, ".sc6") == 0) return FILE_EXTENSION_SC6;
|
|
|
|
if (strcicmp(extension, ".sv6") == 0) return FILE_EXTENSION_SV6;
|
|
|
|
if (strcicmp(extension, ".td6") == 0) return FILE_EXTENSION_TD6;
|
2016-04-22 19:37:04 +02:00
|
|
|
return FILE_EXTENSION_UNKNOWN;
|
2016-04-28 13:40:12 +02:00
|
|
|
}
|