1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 19:13:07 +01:00

Check for both csg1.1 and csg1.dat when looking for RCT1 graphics

This commit is contained in:
Gymnasiast
2017-04-12 20:07:48 +02:00
parent 8198254b72
commit c8ecd98737
3 changed files with 22 additions and 6 deletions

View File

@@ -16,6 +16,7 @@
#include <memory>
#include "../common.h"
#include "../core/File.h"
#include "../core/FileStream.hpp"
#include "../core/Memory.hpp"
#include "../core/Util.hpp"
@@ -194,11 +195,22 @@ extern "C"
safe_strcat_path(pathHeader, "Data", sizeof(pathHeader));
safe_strcat_path(pathHeader, "csg1i.dat", sizeof(pathHeader));
// csg1.1 and csg1.dat are the same file.
// In the CD version, it's called csg1.1 on the CD and csg1.dat on the disk.
// In the GOG version, it's always called csg1.1.
// In the Steam version, it's always called csg1.dat.
char pathData[MAX_PATH];
safe_strcpy(pathData, gConfigGeneral.rct1_path, sizeof(pathData));
safe_strcat_path(pathData, "Data", sizeof(pathData));
safe_strcat_path(pathData, "csg1.1", sizeof(pathData));
if (!File::Exists(pathData))
{
safe_strcpy(pathData, gConfigGeneral.rct1_path, sizeof(pathData));
safe_strcat_path(pathData, "Data", sizeof(pathData));
safe_strcat_path(pathData, "csg1.dat", sizeof(pathData));
}
try
{
auto fileHeader = FileStream(pathHeader, FILE_MODE_OPEN);
@@ -632,10 +644,6 @@ extern "C"
return &_g2.elements[image_id - SPR_G2_BEGIN];
}
if (_csg.data == nullptr)
{
gfx_load_csg();
}
return &_csg.elements[image_id - SPR_CSG_BEGIN];
}

View File

@@ -163,6 +163,7 @@ bool rct2_init()
if (!gfx_load_g2()) {
return false;
}
gfx_load_csg();
font_sprite_initialise_characters();
if (!gOpenRCT2Headless) {

View File

@@ -843,12 +843,19 @@ static void window_options_mouseup(rct_window *w, sint32 widgetIndex)
utf8string rct1path = platform_open_directory_browser(language_get_string(STR_PATH_TO_RCT1_BROWSER));
if (rct1path) {
// Check if this directory actually contains RCT1
// The sprite file can be called either csg1.1 or csg1.dat, so check for both names.
utf8 checkpath[MAX_PATH];
safe_strcpy(checkpath, rct1path, MAX_PATH);
safe_strcat_path(checkpath, "Data", MAX_PATH);
safe_strcat_path(checkpath, "csg1.1", MAX_PATH);
if (platform_file_exists(checkpath))
{
if (!platform_file_exists(checkpath)) {
safe_strcpy(checkpath, rct1path, MAX_PATH);
safe_strcat_path(checkpath, "Data", MAX_PATH);
safe_strcat_path(checkpath, "csg1.dat", MAX_PATH);
}
if (platform_file_exists(checkpath)) {
SafeFree(gConfigGeneral.rct1_path);
gConfigGeneral.rct1_path = rct1path;
config_save_default();