1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
From: Mathias Gibbens <gibmat@debian.org>
Description: Adjust displaying changelog to work with compressed docs
Forwarded: not-needed
diff --git a/src/openrct2-ui/CMakeLists.txt b/src/openrct2-ui/CMakeLists.txt
index 366fc3d2..4a59df11 100644
--- a/src/openrct2-ui/CMakeLists.txt
+++ b/src/openrct2-ui/CMakeLists.txt
@@ -73,7 +73,8 @@ if (EMSCRIPTEN)
elseif (NOT MSVC AND NOT WIN32)
target_link_libraries(openrct2 "libopenrct2"
PkgConfig::SDL2
- PkgConfig::SPEEX)
+ PkgConfig::SPEEX
+ "gzstream")
else ()
target_link_libraries(openrct2 "libopenrct2"
${SDL2_LDFLAGS}
diff --git a/src/openrct2-ui/windows/Changelog.cpp b/src/openrct2-ui/windows/Changelog.cpp
index 3a668005..feed30d3 100644
--- a/src/openrct2-ui/windows/Changelog.cpp
+++ b/src/openrct2-ui/windows/Changelog.cpp
@@ -8,6 +8,7 @@
*****************************************************************************/
#include <fstream>
+#include <gzstream.h>
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Windows.h>
#include <openrct2/Diagnostic.h>
@@ -65,18 +66,12 @@ namespace OpenRCT2::Ui::Windows
{
auto& env = GetContext()->GetPlatformEnvironment();
auto path = env.GetFilePath(pathId);
- auto fs = std::ifstream(fs::u8path(path), std::ios::in);
- if (!fs.is_open())
+ auto fs = igzstream(fs::u8path(path).c_str(), std::ios::in);
+ if (!fs.rdbuf()->is_open())
{
throw std::runtime_error("Unable to open " + path);
}
- fs.seekg(0, fs.end);
- auto length = fs.tellg();
- fs.seekg(0, fs.beg);
- std::unique_ptr<char[]> buffer = std::make_unique<char[]>(length);
- fs.read(buffer.get(), length);
- auto result = std::string(buffer.get(), buffer.get() + length);
- return result;
+ return std::string((std::istreambuf_iterator<char>(fs)), std::istreambuf_iterator<char>());
}
/**
diff --git a/src/openrct2/PlatformEnvironment.cpp b/src/openrct2/PlatformEnvironment.cpp
index eb49c457..01a4279c 100644
--- a/src/openrct2/PlatformEnvironment.cpp
+++ b/src/openrct2/PlatformEnvironment.cpp
@@ -75,9 +75,9 @@ static constexpr u8string_view kFileNames[] = {
u8"highscores.dat", // SCORES
u8"scores.dat", // SCORES (LEGACY)
u8"Saved Games" PATH_SEPARATOR "scores.dat", // SCORES (RCT2)
- u8"changelog.txt", // CHANGELOG
+ u8"changelog.gz", // CHANGELOG
u8"plugin.store.json", // PLUGIN_STORE
- u8"contributors.md", // CONTRIBUTORS
+ u8"contributors.md.gz", // CONTRIBUTORS
};
class PlatformEnvironment final : public IPlatformEnvironment
|