1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-24 00:03:11 +01:00

Add initial support for RCT Classic

This commit is contained in:
Ted John
2022-08-16 19:38:00 +01:00
committed by Gymnasiast
parent 2062084dab
commit 85a66c67ac
4 changed files with 25 additions and 4 deletions

View File

@@ -22,6 +22,7 @@ class PlatformEnvironment final : public IPlatformEnvironment
{
private:
u8string _basePath[DIRBASE_COUNT];
bool _usingRctClassic{};
public:
explicit PlatformEnvironment(DIRBASE_VALUES basePaths)
@@ -45,9 +46,11 @@ public:
{
default:
case DIRBASE::RCT1:
case DIRBASE::RCT2:
directoryName = DirectoryNamesRCT2[static_cast<size_t>(did)];
break;
case DIRBASE::RCT2:
directoryName = _usingRctClassic ? "Assets" : DirectoryNamesRCT2[static_cast<size_t>(did)];
break;
case DIRBASE::OPENRCT2:
case DIRBASE::USER:
case DIRBASE::CONFIG:
@@ -86,6 +89,12 @@ public:
void SetBasePath(DIRBASE base, u8string_view path) override
{
_basePath[static_cast<size_t>(base)] = path;
if (base == DIRBASE::RCT2)
{
// Check whether the RCT2 base is RCT2 or RCT Classic
_usingRctClassic = Platform::IsRCT2ClassicPath(path);
}
}
private:

View File

@@ -199,7 +199,7 @@ bool gfx_load_g1(const IPlatformEnvironment& env)
log_verbose("gfx_load_g1(...)");
try
{
auto path = Path::Combine(env.GetDirectoryPath(DIRBASE::RCT2, DIRID::DATA), u8"g1.dat");
auto path = env.FindFile(DIRBASE::RCT2, DIRID::DATA, u8"g1.dat");
auto fs = FileStream(path, FILE_MODE_OPEN);
_g1.header = fs.ReadValue<rct_g1_header>();

View File

@@ -87,6 +87,7 @@ namespace Platform
bool ProcessIsElevated();
float GetDefaultScale();
bool IsRCT2ClassicPath(std::string_view path);
bool OriginalGameDataExists(std::string_view path);
std::string GetUsername();

View File

@@ -94,10 +94,21 @@ namespace Platform
return outTime;
}
bool IsRCT2ClassicPath(std::string_view path)
{
auto combinedPath = Path::ResolveCasing(Path::Combine(path, u8"Assets", u8"g1.dat"));
return File::Exists(combinedPath);
}
bool OriginalGameDataExists(std::string_view path)
{
std::string combinedPath = Path::ResolveCasing(Path::Combine(path, u8"Data", u8"g1.dat"));
return File::Exists(combinedPath);
// Check if path is RCT2
auto combinedPath = Path::ResolveCasing(Path::Combine(path, u8"Data", u8"g1.dat"));
if (File::Exists(combinedPath))
return true;
// Check if path is RCT Classic
return IsRCT2ClassicPath(path);
}
std::string SanitiseFilename(std::string_view originalName)