mirror of https://github.com/OpenRCT2/OpenRCT2.git
closes #1305, uses absolute paths for all file loads
edit and update the distribution readme clean up the variables mess improve the set_exe_path and cleanup final fixes
This commit is contained in:
parent
5b4715685d
commit
be98d6d850
|
@ -1,5 +1,5 @@
|
||||||
Last updated: 2015-02-06
|
Last updated: 2015-02-06
|
||||||
Release version: 0.2.0-beta
|
Release version: 0.0.2-beta
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,13 +89,14 @@ a directory of your choice.
|
||||||
|
|
||||||
When you start OpenRCT2 for the first time, it will look for the RCT2 data files
|
When you start OpenRCT2 for the first time, it will look for the RCT2 data files
|
||||||
in the following locations:
|
in the following locations:
|
||||||
- C:\Program Files\Infogrames\RollerCoaster Tycoon 2",
|
- C:\Program Files\Infogrames\RollerCoaster Tycoon 2,
|
||||||
- C:\Program Files (x86)\Infogrames\RollerCoaster Tycoon 2",
|
- C:\Program Files (x86)\Infogrames\RollerCoaster Tycoon 2,
|
||||||
- C:\Program Files\Infogrames Interactive\RollerCoaster Tycoon 2",
|
- C:\Program Files\Infogrames Interactive\RollerCoaster Tycoon 2,
|
||||||
- C:\Program Files (x86)\Infogrames Interactive\RollerCoaster Tycoon 2",
|
- C:\Program Files (x86)\Infogrames Interactive\RollerCoaster Tycoon 2,
|
||||||
- C:\Program Files\Atari\RollerCoaster Tycoon 2",
|
- C:\Program Files\Atari\RollerCoaster Tycoon 2,
|
||||||
- C:\Program Files (x86)\Atari\RollerCoaster Tycoon 2",
|
- C:\Program Files (x86)\Atari\RollerCoaster Tycoon 2,
|
||||||
- C:\GOG Games\RollerCoaster Tycoon 2 Triple Thrill Pack"
|
- C:\GOG Games\RollerCoaster Tycoon 2 Triple Thrill Pack
|
||||||
|
- The location of the openrct2.exe (where OpenRCT2 was extracted/installed)
|
||||||
|
|
||||||
If none of these locations are found, OpenRCT2 will ask you to manually specify
|
If none of these locations are found, OpenRCT2 will ask you to manually specify
|
||||||
the directory. Alternatively after running OpenRCT2 for the first time, you can
|
the directory. Alternatively after running OpenRCT2 for the first time, you can
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "localisation/localisation.h"
|
#include "localisation/localisation.h"
|
||||||
#include "util/util.h"
|
#include "util/util.h"
|
||||||
#include "interface/themes.h"
|
#include "interface/themes.h"
|
||||||
|
#include "openrct2.h"
|
||||||
|
|
||||||
// Magic number for original game cfg file
|
// Magic number for original game cfg file
|
||||||
static const int MagicNumber = 0x0003113A;
|
static const int MagicNumber = 0x0003113A;
|
||||||
|
@ -704,7 +705,8 @@ static bool config_find_rct2_path(char *resultPath)
|
||||||
"C:\\Program Files (x86)\\Infogrames Interactive\\RollerCoaster Tycoon 2",
|
"C:\\Program Files (x86)\\Infogrames Interactive\\RollerCoaster Tycoon 2",
|
||||||
"C:\\Program Files\\Atari\\RollerCoaster Tycoon 2",
|
"C:\\Program Files\\Atari\\RollerCoaster Tycoon 2",
|
||||||
"C:\\Program Files (x86)\\Atari\\RollerCoaster Tycoon 2",
|
"C:\\Program Files (x86)\\Atari\\RollerCoaster Tycoon 2",
|
||||||
"C:\\GOG Games\\RollerCoaster Tycoon 2 Triple Thrill Pack"
|
"C:\\GOG Games\\RollerCoaster Tycoon 2 Triple Thrill Pack",
|
||||||
|
gExePath
|
||||||
};
|
};
|
||||||
|
|
||||||
for (i = 0; i < countof(searchLocations); i++) {
|
for (i = 0; i < countof(searchLocations); i++) {
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "../sprites.h"
|
#include "../sprites.h"
|
||||||
#include "drawing.h"
|
#include "drawing.h"
|
||||||
|
#include "../platform/platform.h"
|
||||||
|
#include "../openrct2.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32 num_entries;
|
uint32 num_entries;
|
||||||
|
@ -90,7 +92,9 @@ int gfx_load_g2()
|
||||||
FILE *file;
|
FILE *file;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
file = fopen("data/g2.dat", "rb");
|
char path[MAX_PATH];
|
||||||
|
sprintf(path, "%s%cdata%cg2.dat", gExePath, platform_get_path_separator(), platform_get_path_separator());
|
||||||
|
file = fopen(path, "rb");
|
||||||
if (file != NULL) {
|
if (file != NULL) {
|
||||||
if (fread(&g2.header, 8, 1, file) == 1) {
|
if (fread(&g2.header, 8, 1, file) == 1) {
|
||||||
// Read element headers
|
// Read element headers
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "../object.h"
|
#include "../object.h"
|
||||||
#include "../util/util.h"
|
#include "../util/util.h"
|
||||||
#include "localisation.h"
|
#include "localisation.h"
|
||||||
|
#include "../openrct2.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int id;
|
int id;
|
||||||
|
@ -112,21 +113,21 @@ const char *language_get_string(rct_string_id id)
|
||||||
|
|
||||||
int language_open(int id)
|
int language_open(int id)
|
||||||
{
|
{
|
||||||
static const char *languagePath = "data/language/%s.txt";
|
static const char *languagePath = "%s/data/language/%s.txt";
|
||||||
char filename[_MAX_PATH];
|
char filename[MAX_PATH];
|
||||||
|
|
||||||
language_close_all();
|
language_close_all();
|
||||||
if (id == LANGUAGE_UNDEFINED)
|
if (id == LANGUAGE_UNDEFINED)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (id != LANGUAGE_ENGLISH_UK) {
|
if (id != LANGUAGE_ENGLISH_UK) {
|
||||||
sprintf(filename, languagePath, language_filenames[LANGUAGE_ENGLISH_UK]);
|
sprintf(filename, languagePath, gExePath, language_filenames[LANGUAGE_ENGLISH_UK]);
|
||||||
if (language_open_file(filename, &_languageFallback)) {
|
if (language_open_file(filename, &_languageFallback)) {
|
||||||
_languageFallback.id = LANGUAGE_ENGLISH_UK;
|
_languageFallback.id = LANGUAGE_ENGLISH_UK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(filename, languagePath, language_filenames[id]);
|
sprintf(filename, languagePath, gExePath, language_filenames[id]);
|
||||||
if (language_open_file(filename, &_languageCurrent)) {
|
if (language_open_file(filename, &_languageCurrent)) {
|
||||||
_languageCurrent.id = id;
|
_languageCurrent.id = id;
|
||||||
gCurrentLanguage = id;
|
gCurrentLanguage = id;
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
int gOpenRCT2StartupAction = STARTUP_ACTION_TITLE;
|
int gOpenRCT2StartupAction = STARTUP_ACTION_TITLE;
|
||||||
char gOpenRCT2StartupActionPath[512] = { 0 };
|
char gOpenRCT2StartupActionPath[512] = { 0 };
|
||||||
|
char gExePath[MAX_PATH];
|
||||||
|
|
||||||
// This should probably be changed later and allow a custom selection of things to initialise like SDL_INIT
|
// This should probably be changed later and allow a custom selection of things to initialise like SDL_INIT
|
||||||
bool gOpenRCT2Headless = false;
|
bool gOpenRCT2Headless = false;
|
||||||
|
@ -99,6 +100,23 @@ static void openrct2_copy_files_over(const char *originalDirectory, const char *
|
||||||
platform_enumerate_directories_end(fileEnumHandle);
|
platform_enumerate_directories_end(fileEnumHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void openrct2_set_exe_path()
|
||||||
|
{
|
||||||
|
char exePath[MAX_PATH];
|
||||||
|
char tempPath[MAX_PATH];
|
||||||
|
char *exeDelimiter;
|
||||||
|
int pathEnd;
|
||||||
|
int exeDelimiterIndex;
|
||||||
|
|
||||||
|
GetModuleFileName(NULL, exePath, MAX_PATH);
|
||||||
|
exeDelimiter = strrchr(exePath, platform_get_path_separator());
|
||||||
|
exeDelimiterIndex = (int)(exeDelimiter - exePath);
|
||||||
|
pathEnd = strlen(exePath) - (strlen(exePath) - exeDelimiterIndex);
|
||||||
|
strncpy(tempPath, exePath, pathEnd);
|
||||||
|
tempPath[pathEnd] = '\0';
|
||||||
|
_fullpath(gExePath, tempPath, strlen(tempPath));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy saved games and landscapes to user directory
|
* Copy saved games and landscapes to user directory
|
||||||
*/
|
*/
|
||||||
|
@ -123,6 +141,8 @@ bool openrct2_initialise()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
openrct2_set_exe_path();
|
||||||
|
|
||||||
config_set_defaults();
|
config_set_defaults();
|
||||||
if (!config_open_default()) {
|
if (!config_open_default()) {
|
||||||
if (!config_find_or_browse_install_directory()) {
|
if (!config_find_or_browse_install_directory()) {
|
||||||
|
|
|
@ -32,6 +32,7 @@ enum {
|
||||||
|
|
||||||
extern int gOpenRCT2StartupAction;
|
extern int gOpenRCT2StartupAction;
|
||||||
extern char gOpenRCT2StartupActionPath[512];
|
extern char gOpenRCT2StartupActionPath[512];
|
||||||
|
extern char gExePath[MAX_PATH];
|
||||||
extern bool gOpenRCT2Headless;
|
extern bool gOpenRCT2Headless;
|
||||||
extern bool gOpenRCT2ShowChangelog;
|
extern bool gOpenRCT2ShowChangelog;
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,9 @@ typedef fixed32_1dp money32;
|
||||||
|
|
||||||
#define MONEY_FREE MONEY(0,00)
|
#define MONEY_FREE MONEY(0,00)
|
||||||
#define MONEY32_UNDEFINED ((money32)0x80000000)
|
#define MONEY32_UNDEFINED ((money32)0x80000000)
|
||||||
|
#ifndef MAX_PATH
|
||||||
|
#define MAX_PATH 260
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef void (EMPTY_ARGS_VOID_POINTER)();
|
typedef void (EMPTY_ARGS_VOID_POINTER)();
|
||||||
typedef unsigned short rct_string_id;
|
typedef unsigned short rct_string_id;
|
||||||
|
|
|
@ -325,7 +325,7 @@ static void title_do_next_script_opcode()
|
||||||
} while (*(_currentScript - 1) != 0);
|
} while (*(_currentScript - 1) != 0);
|
||||||
|
|
||||||
// Construct full relative path
|
// Construct full relative path
|
||||||
sprintf(path, "data%ctitle%c%s", platform_get_path_separator(), platform_get_path_separator(), filename);
|
sprintf(path, "%s%cData%ctitle%c%s", gExePath, platform_get_path_separator(), platform_get_path_separator(), platform_get_path_separator(), filename);
|
||||||
if (title_load_park(path)) {
|
if (title_load_park(path)) {
|
||||||
_scriptNoLoadsSinceRestart = 0;
|
_scriptNoLoadsSinceRestart = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -491,8 +491,10 @@ static uint8 *title_script_load()
|
||||||
FILE *file;
|
FILE *file;
|
||||||
char parts[3 * 32], *token, *part1, *part2, *src;
|
char parts[3 * 32], *token, *part1, *part2, *src;
|
||||||
|
|
||||||
char path[] = "data/title/script.txt";
|
char path[MAX_PATH];
|
||||||
|
char filePath[] = "data/title/script.txt";
|
||||||
|
|
||||||
|
sprintf(path, "%s%c%s", gExePath, platform_get_path_separator(), filePath);
|
||||||
log_verbose("loading title script, %s", path);
|
log_verbose("loading title script, %s", path);
|
||||||
file = fopen(path, "r");
|
file = fopen(path, "r");
|
||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#include "../world/map.h"
|
#include "../world/map.h"
|
||||||
#include "../world/footpath.h"
|
#include "../world/footpath.h"
|
||||||
#include "../util/util.h"
|
#include "../util/util.h"
|
||||||
|
#include "../openrct2.h"
|
||||||
|
#include "../platform/platform.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
WIDX_BACKGROUND,
|
WIDX_BACKGROUND,
|
||||||
|
@ -220,7 +222,9 @@ static void window_changelog_scrollpaint()
|
||||||
static bool window_changelog_read_file()
|
static bool window_changelog_read_file()
|
||||||
{
|
{
|
||||||
window_changelog_dispose_file();
|
window_changelog_dispose_file();
|
||||||
if (!readentirefile("changelog.txt", &_changelogText, &_changelogTextSize)) {
|
char path[MAX_PATH];
|
||||||
|
sprintf(path, "%s%cchangelog.txt", gExePath, platform_get_path_separator());
|
||||||
|
if (!readentirefile(path, &_changelogText, &_changelogTextSize)) {
|
||||||
log_error("Unable to read changelog.txt");
|
log_error("Unable to read changelog.txt");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue