mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
Add .sea support to New Scenario list and extension handling
This commit is contained in:
@@ -49,6 +49,7 @@
|
|||||||
<comment xml:lang="zh-TW">OpenRCT2 劇情檔案</comment>
|
<comment xml:lang="zh-TW">OpenRCT2 劇情檔案</comment>
|
||||||
<glob weight="60" pattern="*.sc6"/>
|
<glob weight="60" pattern="*.sc6"/>
|
||||||
<glob weight="60" pattern="*.sc4"/>
|
<glob weight="60" pattern="*.sc4"/>
|
||||||
|
<glob weight="60" pattern="*.sea"/>
|
||||||
</mime-type>
|
</mime-type>
|
||||||
|
|
||||||
</mime-info>
|
</mime-info>
|
||||||
|
|||||||
@@ -175,6 +175,8 @@ uint32_t get_file_extension_type(const utf8* path)
|
|||||||
return FILE_EXTENSION_TD4;
|
return FILE_EXTENSION_TD4;
|
||||||
if (String::Equals(extension, ".sc6", true))
|
if (String::Equals(extension, ".sc6", true))
|
||||||
return FILE_EXTENSION_SC6;
|
return FILE_EXTENSION_SC6;
|
||||||
|
if (String::Equals(extension, ".sea", true))
|
||||||
|
return FILE_EXTENSION_SC6;
|
||||||
if (String::Equals(extension, ".sv6", true))
|
if (String::Equals(extension, ".sv6", true))
|
||||||
return FILE_EXTENSION_SV6;
|
return FILE_EXTENSION_SV6;
|
||||||
if (String::Equals(extension, ".sv7", true))
|
if (String::Equals(extension, ".sv7", true))
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ namespace ParkImporter
|
|||||||
|
|
||||||
bool ExtensionIsScenario(const std::string& extension)
|
bool ExtensionIsScenario(const std::string& extension)
|
||||||
{
|
{
|
||||||
return String::Equals(extension, ".sc4", true) || String::Equals(extension, ".sc6", true);
|
return String::Equals(extension, ".sc4", true) || String::Equals(extension, ".sc6", true)
|
||||||
|
|| String::Equals(extension, ".sea", true);
|
||||||
}
|
}
|
||||||
} // namespace ParkImporter
|
} // namespace ParkImporter
|
||||||
|
|||||||
@@ -363,6 +363,7 @@ namespace Platform
|
|||||||
SetUpFileAssociation(".sv4", "RCT1 Saved Game (.sc4)", "Play", "\"%1\"", 0);
|
SetUpFileAssociation(".sv4", "RCT1 Saved Game (.sc4)", "Play", "\"%1\"", 0);
|
||||||
SetUpFileAssociation(".sv6", "RCT2 Saved Game (.sv6)", "Play", "\"%1\"", 0);
|
SetUpFileAssociation(".sv6", "RCT2 Saved Game (.sv6)", "Play", "\"%1\"", 0);
|
||||||
SetUpFileAssociation(".sv7", "RCT Modified Saved Game (.sv7)", "Play", "\"%1\"", 0);
|
SetUpFileAssociation(".sv7", "RCT Modified Saved Game (.sv7)", "Play", "\"%1\"", 0);
|
||||||
|
SetUpFileAssociation(".sea", "RCTC Saved Game (.sea)", "Play", "\"%1\"", 0);
|
||||||
SetUpFileAssociation(".td4", "RCT1 Track Design (.td4)", "Install", "\"%1\"", 0);
|
SetUpFileAssociation(".td4", "RCT1 Track Design (.td4)", "Install", "\"%1\"", 0);
|
||||||
SetUpFileAssociation(".td6", "RCT2 Track Design (.td6)", "Install", "\"%1\"", 0);
|
SetUpFileAssociation(".td6", "RCT2 Track Design (.td6)", "Install", "\"%1\"", 0);
|
||||||
|
|
||||||
@@ -507,6 +508,7 @@ namespace Platform
|
|||||||
RemoveFileAssociation(".sv4");
|
RemoveFileAssociation(".sv4");
|
||||||
RemoveFileAssociation(".sv6");
|
RemoveFileAssociation(".sv6");
|
||||||
RemoveFileAssociation(".sv7");
|
RemoveFileAssociation(".sv7");
|
||||||
|
RemoveFileAssociation(".sea");
|
||||||
RemoveFileAssociation(".td4");
|
RemoveFileAssociation(".td4");
|
||||||
RemoveFileAssociation(".td6");
|
RemoveFileAssociation(".td6");
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "../core/File.h"
|
#include "../core/File.h"
|
||||||
#include "../core/FileIndex.hpp"
|
#include "../core/FileIndex.hpp"
|
||||||
#include "../core/FileStream.hpp"
|
#include "../core/FileStream.hpp"
|
||||||
|
#include "../core/MemoryStream.h"
|
||||||
#include "../core/Path.hpp"
|
#include "../core/Path.hpp"
|
||||||
#include "../core/String.hpp"
|
#include "../core/String.hpp"
|
||||||
#include "../localisation/Language.h"
|
#include "../localisation/Language.h"
|
||||||
@@ -128,7 +129,7 @@ class ScenarioFileIndex final : public FileIndex<scenario_index_entry>
|
|||||||
private:
|
private:
|
||||||
static constexpr uint32_t MAGIC_NUMBER = 0x58444953; // SIDX
|
static constexpr uint32_t MAGIC_NUMBER = 0x58444953; // SIDX
|
||||||
static constexpr uint16_t VERSION = 3;
|
static constexpr uint16_t VERSION = 3;
|
||||||
static constexpr auto PATTERN = "*.sc4;*.sc6";
|
static constexpr auto PATTERN = "*.sc4;*.sc6;*.sea";
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ScenarioFileIndex(const IPlatformEnvironment& env)
|
explicit ScenarioFileIndex(const IPlatformEnvironment& env)
|
||||||
@@ -203,6 +204,19 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static IStream* GetStreamFromRCT2Scenario(const std::string& path)
|
||||||
|
{
|
||||||
|
if (String::Equals(Path::GetExtension(path), ".sea", true))
|
||||||
|
{
|
||||||
|
auto data = DecryptSea(fs::u8path(path));
|
||||||
|
auto ms = new MemoryStream(data.data(), data.size(), MEMORY_ACCESS::READ);
|
||||||
|
return ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto fs = new FileStream(path, FILE_MODE_OPEN);
|
||||||
|
return fs;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads basic information from a scenario file.
|
* Reads basic information from a scenario file.
|
||||||
*/
|
*/
|
||||||
@@ -234,9 +248,9 @@ private:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// RCT2 scenario
|
// RCT2 or RCTC scenario
|
||||||
auto fs = FileStream(path, FILE_MODE_OPEN);
|
auto stream = GetStreamFromRCT2Scenario(path);
|
||||||
auto chunkReader = SawyerChunkReader(&fs);
|
auto chunkReader = SawyerChunkReader(stream);
|
||||||
|
|
||||||
rct_s6_header header = chunkReader.ReadChunkAs<rct_s6_header>();
|
rct_s6_header header = chunkReader.ReadChunkAs<rct_s6_header>();
|
||||||
if (header.type == S6_TYPE_SCENARIO)
|
if (header.type == S6_TYPE_SCENARIO)
|
||||||
@@ -251,10 +265,12 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
*entry = CreateNewScenarioEntry(path, timestamp, &info);
|
*entry = CreateNewScenarioEntry(path, timestamp, &info);
|
||||||
|
delete stream;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
delete stream;
|
||||||
log_verbose("%s is not a scenario", path.c_str());
|
log_verbose("%s is not a scenario", path.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user