diff --git a/OpenRCT2.xcodeproj/project.pbxproj b/OpenRCT2.xcodeproj/project.pbxproj index 37e0667fff8d..2875a0204f2d 100644 --- a/OpenRCT2.xcodeproj/project.pbxproj +++ b/OpenRCT2.xcodeproj/project.pbxproj @@ -33,7 +33,6 @@ 2ADE2F28224418B2002598AF /* DataSerialiserTag.h in Headers */ = {isa = PBXBuildFile; fileRef = 2ADE2F22224418B1002598AF /* DataSerialiserTag.h */; }; 2ADE2F29224418B2002598AF /* Numerics.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2ADE2F23224418B1002598AF /* Numerics.hpp */; }; 2ADE2F2A224418B2002598AF /* Meta.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2ADE2F24224418B2002598AF /* Meta.hpp */; }; - 2ADE2F2B224418B2002598AF /* JobPool.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2ADE2F25224418B2002598AF /* JobPool.hpp */; }; 2ADE2F2C224418B2002598AF /* FileIndex.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2ADE2F26224418B2002598AF /* FileIndex.hpp */; }; 2ADE2F2E224418E7002598AF /* ConversionTables.h in Headers */ = {isa = PBXBuildFile; fileRef = 2ADE2F2D224418E7002598AF /* ConversionTables.h */; }; 2ADE2F3122441905002598AF /* DiscordService.h in Headers */ = {isa = PBXBuildFile; fileRef = 2ADE2F2F22441905002598AF /* DiscordService.h */; }; @@ -52,6 +51,11 @@ 4C724B2221F0AD790012ADD0 /* BenchSpriteSort.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C724B2121F0AD790012ADD0 /* BenchSpriteSort.cpp */; }; 4C81F7E124672C4D000E61BF /* CustomListView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C81F7DF24672C4D000E61BF /* CustomListView.cpp */; }; 4C8A6FF323EB5326001A8255 /* Http.cURL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8A6FF223EB5326001A8255 /* Http.cURL.cpp */; }; + 4C8BB67925533D4C005C8830 /* FileStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8BB67825533D4C005C8830 /* FileStream.cpp */; }; + 4C8BB67C25533D59005C8830 /* JobPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8BB67B25533D59005C8830 /* JobPool.cpp */; }; + 4C8BB68125533D65005C8830 /* StringBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8BB67D25533D64005C8830 /* StringBuilder.cpp */; }; + 4C8BB68225533D65005C8830 /* StringReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8BB67E25533D64005C8830 /* StringReader.cpp */; }; + 4C8BB68525533DB9005C8830 /* ZoomLevel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8BB68425533DB9005C8830 /* ZoomLevel.cpp */; }; 4C93F1AD1F8CD9F000A9330D /* Input.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C93F1AC1F8CD9F000A9330D /* Input.cpp */; }; 4C93F1AF1F8CD9F600A9330D /* KeyboardShortcut.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C93F1AE1F8CD9F600A9330D /* KeyboardShortcut.cpp */; }; 4CA39E512513F8A00094066B /* RTL.ICU.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CA39E4E2513F8A00094066B /* RTL.ICU.cpp */; }; @@ -674,7 +678,6 @@ 2ADE2F22224418B1002598AF /* DataSerialiserTag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataSerialiserTag.h; sourceTree = ""; }; 2ADE2F23224418B1002598AF /* Numerics.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Numerics.hpp; sourceTree = ""; }; 2ADE2F24224418B2002598AF /* Meta.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Meta.hpp; sourceTree = ""; }; - 2ADE2F25224418B2002598AF /* JobPool.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = JobPool.hpp; sourceTree = ""; }; 2ADE2F26224418B2002598AF /* FileIndex.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FileIndex.hpp; sourceTree = ""; }; 2ADE2F2D224418E7002598AF /* ConversionTables.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConversionTables.h; sourceTree = ""; }; 2ADE2F2F22441905002598AF /* DiscordService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DiscordService.h; sourceTree = ""; }; @@ -853,6 +856,17 @@ 4C8B426E1EEB1ABD00F015CA /* X8DrawingEngine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = X8DrawingEngine.cpp; sourceTree = ""; }; 4C8B426F1EEB1ABD00F015CA /* X8DrawingEngine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = X8DrawingEngine.h; sourceTree = ""; }; 4C8B42711EEB1AE400F015CA /* HardwareDisplayDrawingEngine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HardwareDisplayDrawingEngine.cpp; sourceTree = ""; }; + 4C8BB67625533D4B005C8830 /* FileSystem.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FileSystem.hpp; sourceTree = ""; }; + 4C8BB67725533D4B005C8830 /* FileStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileStream.h; sourceTree = ""; }; + 4C8BB67825533D4C005C8830 /* FileStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileStream.cpp; sourceTree = ""; }; + 4C8BB67A25533D58005C8830 /* JobPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JobPool.h; sourceTree = ""; }; + 4C8BB67B25533D59005C8830 /* JobPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JobPool.cpp; sourceTree = ""; }; + 4C8BB67D25533D64005C8830 /* StringBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringBuilder.cpp; sourceTree = ""; }; + 4C8BB67E25533D64005C8830 /* StringReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringReader.cpp; sourceTree = ""; }; + 4C8BB67F25533D64005C8830 /* StringReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringReader.h; sourceTree = ""; }; + 4C8BB68025533D64005C8830 /* StringBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringBuilder.h; sourceTree = ""; }; + 4C8BB68325533DB9005C8830 /* ZoomLevel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZoomLevel.h; sourceTree = ""; }; + 4C8BB68425533DB9005C8830 /* ZoomLevel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ZoomLevel.cpp; sourceTree = ""; }; 4C9196ED204FF3E000869A24 /* Location.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Location.hpp; sourceTree = ""; }; 4C93F1181F8B744400A9330D /* AirPoweredVerticalCoaster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AirPoweredVerticalCoaster.cpp; sourceTree = ""; }; 4C93F1191F8B744400A9330D /* BobsleighCoaster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BobsleighCoaster.cpp; sourceTree = ""; }; @@ -983,7 +997,6 @@ 51160A24250C7A15002029F6 /* GuestPathfinding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GuestPathfinding.h; sourceTree = ""; }; 6341F4DF2400AA0E0052902B /* Drawing.Sprite.RLE.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Drawing.Sprite.RLE.cpp; sourceTree = ""; }; 6341F4E02400AA0F0052902B /* Drawing.Sprite.BMP.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Drawing.Sprite.BMP.cpp; sourceTree = ""; }; - 6341F4E32400AA1C0052902B /* ZoomLevel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ZoomLevel.hpp; sourceTree = ""; }; 9308D9FA209908080079EE96 /* TileElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TileElement.cpp; sourceTree = ""; }; 9308D9FB209908080079EE96 /* Surface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Surface.cpp; sourceTree = ""; }; 9308D9FC209908080079EE96 /* TileElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TileElement.h; sourceTree = ""; }; @@ -1687,7 +1700,6 @@ F76C83801EC4E7CC00FA49E2 /* File.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = File.h; sourceTree = ""; }; F76C83811EC4E7CC00FA49E2 /* FileScanner.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FileScanner.cpp; sourceTree = ""; }; F76C83821EC4E7CC00FA49E2 /* FileScanner.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FileScanner.h; sourceTree = ""; }; - F76C83831EC4E7CC00FA49E2 /* FileStream.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = FileStream.hpp; sourceTree = ""; }; F76C83841EC4E7CC00FA49E2 /* Guard.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Guard.cpp; sourceTree = ""; }; F76C83851EC4E7CC00FA49E2 /* Guard.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Guard.hpp; sourceTree = ""; }; F76C83861EC4E7CC00FA49E2 /* IStream.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = IStream.cpp; sourceTree = ""; }; @@ -1702,8 +1714,6 @@ F76C83901EC4E7CC00FA49E2 /* Path.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Path.hpp; sourceTree = ""; }; F76C83921EC4E7CC00FA49E2 /* String.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = String.cpp; sourceTree = ""; }; F76C83931EC4E7CC00FA49E2 /* String.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = String.hpp; sourceTree = ""; }; - F76C83941EC4E7CC00FA49E2 /* StringBuilder.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = StringBuilder.hpp; sourceTree = ""; }; - F76C83951EC4E7CC00FA49E2 /* StringReader.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = StringReader.hpp; sourceTree = ""; }; F76C83991EC4E7CC00FA49E2 /* Zip.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Zip.cpp; sourceTree = ""; }; F76C839A1EC4E7CC00FA49E2 /* Zip.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Zip.h; sourceTree = ""; }; F76C839F1EC4E7CC00FA49E2 /* drawing.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = drawing.h; sourceTree = ""; }; @@ -2828,7 +2838,9 @@ 2ADE2F26224418B2002598AF /* FileIndex.hpp */, F76C83811EC4E7CC00FA49E2 /* FileScanner.cpp */, F76C83821EC4E7CC00FA49E2 /* FileScanner.h */, - F76C83831EC4E7CC00FA49E2 /* FileStream.hpp */, + 4C8BB67825533D4C005C8830 /* FileStream.cpp */, + 4C8BB67725533D4B005C8830 /* FileStream.h */, + 4C8BB67625533D4B005C8830 /* FileSystem.hpp */, 93DFD02D24521BA0001FCBAF /* FileWatcher.cpp */, 93DFD02C24521B9F001FCBAF /* FileWatcher.h */, F76C83841EC4E7CC00FA49E2 /* Guard.cpp */, @@ -2839,7 +2851,8 @@ 93CBA4C120A7502D00867D56 /* Imaging.h */, F76C83861EC4E7CC00FA49E2 /* IStream.cpp */, F76C83871EC4E7CC00FA49E2 /* IStream.hpp */, - 2ADE2F25224418B2002598AF /* JobPool.hpp */, + 4C8BB67B25533D59005C8830 /* JobPool.cpp */, + 4C8BB67A25533D58005C8830 /* JobPool.h */, F76C83881EC4E7CC00FA49E2 /* Json.cpp */, F76C83891EC4E7CC00FA49E2 /* Json.hpp */, 93378D00252B4F550077D2D8 /* JsonFwd.hpp */, @@ -2857,8 +2870,10 @@ 4CA39E4E2513F8A00094066B /* RTL.ICU.cpp */, F76C83921EC4E7CC00FA49E2 /* String.cpp */, F76C83931EC4E7CC00FA49E2 /* String.hpp */, - F76C83941EC4E7CC00FA49E2 /* StringBuilder.hpp */, - F76C83951EC4E7CC00FA49E2 /* StringReader.hpp */, + 4C8BB67D25533D64005C8830 /* StringBuilder.cpp */, + 4C8BB68025533D64005C8830 /* StringBuilder.h */, + 4C8BB67E25533D64005C8830 /* StringReader.cpp */, + 4C8BB67F25533D64005C8830 /* StringReader.h */, F76C83991EC4E7CC00FA49E2 /* Zip.cpp */, F76C839A1EC4E7CC00FA49E2 /* Zip.h */, ); @@ -2928,7 +2943,8 @@ C67B28182002D7F200109C93 /* Window_internal.h */, 4C7B53F1200143C200A52E21 /* Window.cpp */, 4C7B53F2200143C200A52E21 /* Window.h */, - 6341F4E32400AA1C0052902B /* ZoomLevel.hpp */, + 4C8BB68425533DB9005C8830 /* ZoomLevel.cpp */, + 4C8BB68325533DB9005C8830 /* ZoomLevel.h */, ); path = interface; sourceTree = ""; @@ -3714,7 +3730,6 @@ 93CBA4C320A7502E00867D56 /* Imaging.h in Headers */, 93DFD04D24521C1A001FCBAF /* ScEntity.hpp in Headers */, 93DFD04E24521C1A001FCBAF /* Duktape.hpp in Headers */, - 2ADE2F2B224418B2002598AF /* JobPool.hpp in Headers */, 2ADE2F3622441960002598AF /* RideTypes.h in Headers */, 93DFD05324521C1A001FCBAF /* ScRide.hpp in Headers */, 93AE2389252F948A00CD03C3 /* Formatter.h in Headers */, @@ -4043,6 +4058,7 @@ 9346F9DB208A191900C77D91 /* GuestPathfinding.cpp in Sources */, C654DF361F69C0430040F43D /* Player.cpp in Sources */, 933F2CB720935653001B33FD /* LocalisationService.cpp in Sources */, + 4C8BB68225533D65005C8830 /* StringReader.cpp in Sources */, 4C255958244A328B00CE7E45 /* CustomMenu.cpp in Sources */, F76C88791EC5324E00FA49E2 /* AudioContext.cpp in Sources */, C666EE7A1F37ACB10061AA04 /* Themes.cpp in Sources */, @@ -4087,6 +4103,7 @@ C67CCD681FBBD138004FAE4C /* EditorMain.cpp in Sources */, C6E415511FAFD6DC00D4A52A /* RideConstruction.cpp in Sources */, 932A211F22D73CFA00C57EDB /* GameActionRegistration.cpp in Sources */, + 4C8BB67925533D4C005C8830 /* FileStream.cpp in Sources */, 933CBDBD20CB1BA900134678 /* ViewportInteraction.cpp in Sources */, C685E51B1F8907850090598F /* Guest.cpp in Sources */, C64644F91F3FA4120026AC2D /* EditorInventionsList.cpp in Sources */, @@ -4137,6 +4154,7 @@ C67CCD661FBBCFDB004FAE4C /* EditorBottomToolbar.cpp in Sources */, C666EE731F37ACB10061AA04 /* MusicCredits.cpp in Sources */, C654DF351F69C0430040F43D /* Park.cpp in Sources */, + 4C8BB68525533DB9005C8830 /* ZoomLevel.cpp in Sources */, C654DF3A1F69C0430040F43D /* TitleEditor.cpp in Sources */, C666EE6F1F37ACB10061AA04 /* DebugPaint.cpp in Sources */, F7CB863F1EEDA0B50030C877 /* WindowManager.cpp in Sources */, @@ -4148,8 +4166,10 @@ C68878C320289B710084B384 /* DrawRectShader.cpp in Sources */, C666EE751F37ACB10061AA04 /* NewsOptions.cpp in Sources */, C654DF311F69C0430040F43D /* GuestList.cpp in Sources */, + 4C8BB67C25533D59005C8830 /* JobPool.cpp in Sources */, 01C6F0C222FD519E0057E2F7 /* TrackImporter.cpp in Sources */, 4C93F1AD1F8CD9F000A9330D /* Input.cpp in Sources */, + 4C8BB68125533D65005C8830 /* StringBuilder.cpp in Sources */, C666EE761F37ACB10061AA04 /* Options.cpp in Sources */, 2A5354E922099C4F00A5440F /* Network.cpp in Sources */, C666EE6E1F37ACB10061AA04 /* CustomCurrency.cpp in Sources */, diff --git a/src/openrct2-ui/drawing/engines/opengl/OpenGLShaderProgram.cpp b/src/openrct2-ui/drawing/engines/opengl/OpenGLShaderProgram.cpp index f69e44161130..2056a13a18b6 100644 --- a/src/openrct2-ui/drawing/engines/opengl/OpenGLShaderProgram.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/OpenGLShaderProgram.cpp @@ -14,7 +14,7 @@ # include # include # include -# include +# include # include # include diff --git a/src/openrct2-ui/input/KeyboardShortcuts.cpp b/src/openrct2-ui/input/KeyboardShortcuts.cpp index 2b14142836b2..28c69af1d464 100644 --- a/src/openrct2-ui/input/KeyboardShortcuts.cpp +++ b/src/openrct2-ui/input/KeyboardShortcuts.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index 36c31e6cb725..ea4bd956aa00 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -31,7 +31,7 @@ #include "core/Console.hpp" #include "core/File.h" #include "core/FileScanner.h" -#include "core/FileStream.hpp" +#include "core/FileStream.h" #include "core/Guard.hpp" #include "core/Http.h" #include "core/MemoryStream.h" diff --git a/src/openrct2/FileClassifier.cpp b/src/openrct2/FileClassifier.cpp index 6f6fd74ee368..bb3bdb13f390 100644 --- a/src/openrct2/FileClassifier.cpp +++ b/src/openrct2/FileClassifier.cpp @@ -10,8 +10,9 @@ #include "FileClassifier.h" #include "core/Console.hpp" -#include "core/FileStream.hpp" +#include "core/FileStream.h" #include "core/Path.hpp" +#include "core/String.hpp" #include "rct12/SawyerChunkReader.h" #include "scenario/Scenario.h" #include "util/SawyerCoding.h" diff --git a/src/openrct2/audio/Audio.cpp b/src/openrct2/audio/Audio.cpp index e7651a842282..383cc3380e56 100644 --- a/src/openrct2/audio/Audio.cpp +++ b/src/openrct2/audio/Audio.cpp @@ -14,7 +14,7 @@ #include "../OpenRCT2.h" #include "../config/Config.h" #include "../core/File.h" -#include "../core/FileStream.hpp" +#include "../core/FileStream.h" #include "../core/Memory.hpp" #include "../core/String.hpp" #include "../interface/Viewport.h" diff --git a/src/openrct2/config/Config.cpp b/src/openrct2/config/Config.cpp index 0e791fbc84ba..68bf5cc7badf 100644 --- a/src/openrct2/config/Config.cpp +++ b/src/openrct2/config/Config.cpp @@ -13,7 +13,7 @@ #include "../OpenRCT2.h" #include "../core/Console.hpp" #include "../core/File.h" -#include "../core/FileStream.hpp" +#include "../core/FileStream.h" #include "../core/Memory.hpp" #include "../core/Path.hpp" #include "../core/String.hpp" diff --git a/src/openrct2/config/IniReader.cpp b/src/openrct2/config/IniReader.cpp index cfdab415c87a..ddc4078b7a01 100644 --- a/src/openrct2/config/IniReader.cpp +++ b/src/openrct2/config/IniReader.cpp @@ -12,7 +12,7 @@ #include "../common.h" #include "../core/IStream.hpp" #include "../core/String.hpp" -#include "../core/StringBuilder.hpp" +#include "../core/StringBuilder.h" #include #include diff --git a/src/openrct2/core/File.cpp b/src/openrct2/core/File.cpp index 76591c2760ba..9c8fb37e40b5 100644 --- a/src/openrct2/core/File.cpp +++ b/src/openrct2/core/File.cpp @@ -16,7 +16,7 @@ #include "../platform/Platform2.h" #include "../util/Util.h" #include "File.h" -#include "FileStream.hpp" +#include "FileStream.h" #include "String.hpp" #include diff --git a/src/openrct2/core/FileIndex.hpp b/src/openrct2/core/FileIndex.hpp index 6456304fefcc..25e244d7495c 100644 --- a/src/openrct2/core/FileIndex.hpp +++ b/src/openrct2/core/FileIndex.hpp @@ -13,8 +13,8 @@ #include "Console.hpp" #include "File.h" #include "FileScanner.h" -#include "FileStream.hpp" -#include "JobPool.hpp" +#include "FileStream.h" +#include "JobPool.h" #include "Path.hpp" #include diff --git a/src/openrct2/core/FileStream.cpp b/src/openrct2/core/FileStream.cpp new file mode 100644 index 000000000000..a60b4f9aacbc --- /dev/null +++ b/src/openrct2/core/FileStream.cpp @@ -0,0 +1,191 @@ +/***************************************************************************** + * Copyright (c) 2014-2020 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "FileStream.h" + +#include "Path.hpp" +#include "String.hpp" + +#include + +#ifndef _WIN32 +# include +#endif + +#if defined(__linux__) && !defined(__ANDROID__) +# define ftello ftello64 +# define fseeko fseeko64 +#endif + +#ifdef _MSC_VER +# define ftello _ftelli64 +# define fseeko _fseeki64 +#endif + +namespace OpenRCT2 +{ + FileStream::FileStream(const std::string& path, int32_t fileMode) + : FileStream(path.c_str(), fileMode) + { + } + + FileStream::FileStream(const utf8* path, int32_t fileMode) + { + const char* mode; + switch (fileMode) + { + case FILE_MODE_OPEN: + mode = "rb"; + _canRead = true; + _canWrite = false; + break; + case FILE_MODE_WRITE: + mode = "w+b"; + _canRead = true; + _canWrite = true; + break; + case FILE_MODE_APPEND: + mode = "a"; + _canRead = false; + _canWrite = true; + break; + default: + throw; + } + + // Make sure the directory exists before writing to a file inside it + if (_canWrite) + { + std::string directory = Path::GetDirectory(path); + if (!Path::DirectoryExists(directory)) + { + Path::CreateDirectory(directory); + } + } + +#ifdef _WIN32 + auto pathW = String::ToWideChar(path); + auto modeW = String::ToWideChar(mode); + _file = _wfopen(pathW.c_str(), modeW.c_str()); +#else + if (fileMode == FILE_MODE_OPEN) + { + struct stat fileStat; + // Only allow regular files to be opened as its possible to open directories. + if (stat(path, &fileStat) == 0 && S_ISREG(fileStat.st_mode)) + { + _file = fopen(path, mode); + } + } + else + { + _file = fopen(path, mode); + } +#endif + if (_file == nullptr) + { + throw IOException(String::StdFormat("Unable to open '%s'", path)); + } + + Seek(0, STREAM_SEEK_END); + _fileSize = GetPosition(); + Seek(0, STREAM_SEEK_BEGIN); + + _ownsFilePtr = true; + } + + FileStream::~FileStream() + { + if (!_disposed) + { + _disposed = true; + if (_ownsFilePtr) + { + fclose(_file); + } + } + } + + bool FileStream::CanRead() const + { + return _canRead; + } + + bool FileStream::CanWrite() const + { + return _canWrite; + } + + uint64_t FileStream::GetLength() const + { + return _fileSize; + } + + uint64_t FileStream::GetPosition() const + { + return ftello(_file); + } + + void FileStream::SetPosition(uint64_t position) + { + Seek(position, STREAM_SEEK_BEGIN); + } + + void FileStream::Seek(int64_t offset, int32_t origin) + { + switch (origin) + { + case STREAM_SEEK_BEGIN: + fseeko(_file, offset, SEEK_SET); + break; + case STREAM_SEEK_CURRENT: + fseeko(_file, offset, SEEK_CUR); + break; + case STREAM_SEEK_END: + fseeko(_file, offset, SEEK_END); + break; + } + } + + void FileStream::Read(void* buffer, uint64_t length) + { + uint64_t remainingBytes = GetLength() - GetPosition(); + if (length <= remainingBytes) + { + if (fread(buffer, static_cast(length), 1, _file) == 1) + { + return; + } + } + throw IOException("Attempted to read past end of file."); + } + + void FileStream::Write(const void* buffer, uint64_t length) + { + if (fwrite(buffer, static_cast(length), 1, _file) != 1) + { + throw IOException("Unable to write to file."); + } + + uint64_t position = GetPosition(); + _fileSize = std::max(_fileSize, position); + } + + uint64_t FileStream::TryRead(void* buffer, uint64_t length) + { + size_t readBytes = fread(buffer, 1, static_cast(length), _file); + return readBytes; + } + + const void* FileStream::GetData() const + { + return nullptr; + } + +} // namespace OpenRCT2 diff --git a/src/openrct2/core/FileStream.h b/src/openrct2/core/FileStream.h new file mode 100644 index 000000000000..c002e5bef34d --- /dev/null +++ b/src/openrct2/core/FileStream.h @@ -0,0 +1,56 @@ +/***************************************************************************** + * Copyright (c) 2014-2020 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "../common.h" +#include "IStream.hpp" + +namespace OpenRCT2 +{ + enum + { + FILE_MODE_OPEN, + FILE_MODE_WRITE, + FILE_MODE_APPEND, + }; + + /** + * A stream for reading and writing to files. + */ + class FileStream final : public IStream + { + private: + FILE* _file = nullptr; + bool _ownsFilePtr = false; + bool _canRead = false; + bool _canWrite = false; + bool _disposed = false; + uint64_t _fileSize = 0; + + public: + FileStream(const std::string& path, int32_t fileMode); + FileStream(const utf8* path, int32_t fileMode); + ~FileStream() override; + + bool CanRead() const override; + bool CanWrite() const override; + + uint64_t GetLength() const override; + uint64_t GetPosition() const override; + + void SetPosition(uint64_t position) override; + void Seek(int64_t offset, int32_t origin) override; + void Read(void* buffer, uint64_t length) override; + void Write(const void* buffer, uint64_t length) override; + uint64_t TryRead(void* buffer, uint64_t length) override; + const void* GetData() const override; + }; + +} // namespace OpenRCT2 diff --git a/src/openrct2/core/FileStream.hpp b/src/openrct2/core/FileStream.hpp deleted file mode 100644 index 529fd41e9009..000000000000 --- a/src/openrct2/core/FileStream.hpp +++ /dev/null @@ -1,213 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014-2020 OpenRCT2 developers - * - * For a complete list of all authors, please refer to contributors.md - * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 - * - * OpenRCT2 is licensed under the GNU General Public License version 3. - *****************************************************************************/ - -#pragma once - -#include "../common.h" -#include "../localisation/Language.h" -#include "IStream.hpp" -#include "Path.hpp" -#include "String.hpp" - -#include -#ifndef _WIN32 -# include -#endif - -#if defined(__linux__) && !defined(__ANDROID__) -# define ftello ftello64 -# define fseeko fseeko64 -#endif - -#ifdef _MSC_VER -# define ftello _ftelli64 -# define fseeko _fseeki64 -#endif - -namespace OpenRCT2 -{ - enum - { - FILE_MODE_OPEN, - FILE_MODE_WRITE, - FILE_MODE_APPEND, - }; - - /** - * A stream for reading and writing to files. - */ - class FileStream final : public IStream - { - private: - FILE* _file = nullptr; - bool _ownsFilePtr = false; - bool _canRead = false; - bool _canWrite = false; - bool _disposed = false; - uint64_t _fileSize = 0; - - public: - FileStream(const std::string& path, int32_t fileMode) - : FileStream(path.c_str(), fileMode) - { - } - - FileStream(const utf8* path, int32_t fileMode) - { - const char* mode; - switch (fileMode) - { - case FILE_MODE_OPEN: - mode = "rb"; - _canRead = true; - _canWrite = false; - break; - case FILE_MODE_WRITE: - mode = "w+b"; - _canRead = true; - _canWrite = true; - break; - case FILE_MODE_APPEND: - mode = "a"; - _canRead = false; - _canWrite = true; - break; - default: - throw; - } - - // Make sure the directory exists before writing to a file inside it - if (_canWrite) - { - std::string directory = Path::GetDirectory(path); - if (!Path::DirectoryExists(directory)) - { - Path::CreateDirectory(directory); - } - } - -#ifdef _WIN32 - auto pathW = String::ToWideChar(path); - auto modeW = String::ToWideChar(mode); - _file = _wfopen(pathW.c_str(), modeW.c_str()); -#else - if (fileMode == FILE_MODE_OPEN) - { - struct stat fileStat; - // Only allow regular files to be opened as its possible to open directories. - if (stat(path, &fileStat) == 0 && S_ISREG(fileStat.st_mode)) - { - _file = fopen(path, mode); - } - } - else - { - _file = fopen(path, mode); - } -#endif - if (_file == nullptr) - { - throw IOException(String::StdFormat("Unable to open '%s'", path)); - } - - Seek(0, STREAM_SEEK_END); - _fileSize = GetPosition(); - Seek(0, STREAM_SEEK_BEGIN); - - _ownsFilePtr = true; - } - - ~FileStream() override - { - if (!_disposed) - { - _disposed = true; - if (_ownsFilePtr) - { - fclose(_file); - } - } - } - - bool CanRead() const override - { - return _canRead; - } - bool CanWrite() const override - { - return _canWrite; - } - - uint64_t GetLength() const override - { - return _fileSize; - } - uint64_t GetPosition() const override - { - return ftello(_file); - } - - void SetPosition(uint64_t position) override - { - Seek(position, STREAM_SEEK_BEGIN); - } - - void Seek(int64_t offset, int32_t origin) override - { - switch (origin) - { - case STREAM_SEEK_BEGIN: - fseeko(_file, offset, SEEK_SET); - break; - case STREAM_SEEK_CURRENT: - fseeko(_file, offset, SEEK_CUR); - break; - case STREAM_SEEK_END: - fseeko(_file, offset, SEEK_END); - break; - } - } - - void Read(void* buffer, uint64_t length) override - { - uint64_t remainingBytes = GetLength() - GetPosition(); - if (length <= remainingBytes) - { - if (fread(buffer, static_cast(length), 1, _file) == 1) - { - return; - } - } - throw IOException("Attempted to read past end of file."); - } - - void Write(const void* buffer, uint64_t length) override - { - if (fwrite(buffer, static_cast(length), 1, _file) != 1) - { - throw IOException("Unable to write to file."); - } - - uint64_t position = GetPosition(); - _fileSize = std::max(_fileSize, position); - } - - uint64_t TryRead(void* buffer, uint64_t length) override - { - size_t readBytes = fread(buffer, 1, static_cast(length), _file); - return readBytes; - } - - const void* GetData() const override - { - return nullptr; - } - }; - -} // namespace OpenRCT2 diff --git a/src/openrct2/core/JobPool.cpp b/src/openrct2/core/JobPool.cpp new file mode 100644 index 000000000000..6dd3e5f7fc39 --- /dev/null +++ b/src/openrct2/core/JobPool.cpp @@ -0,0 +1,125 @@ +/***************************************************************************** + * Copyright (c) 2014-2020 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "JobPool.h" + +#include +#include + +JobPool::TaskData::TaskData(std::function workFn, std::function completionFn) + : WorkFn(workFn) + , CompletionFn(completionFn) +{ +} + +JobPool::JobPool(size_t maxThreads) +{ + maxThreads = std::min(maxThreads, std::thread::hardware_concurrency()); + for (size_t n = 0; n < maxThreads; n++) + { + _threads.emplace_back(&JobPool::ProcessQueue, this); + } +} + +JobPool::~JobPool() +{ + { + unique_lock lock(_mutex); + _shouldStop = true; + _condPending.notify_all(); + } + + for (auto&& th : _threads) + { + assert(th.joinable() != false); + th.join(); + } +} + +void JobPool::AddTask(std::function workFn, std::function completionFn) +{ + unique_lock lock(_mutex); + _pending.emplace_back(workFn, completionFn); + _condPending.notify_one(); +} + +void JobPool::Join(std::function reportFn) +{ + unique_lock lock(_mutex); + while (true) + { + // Wait for the queue to become empty or having completed tasks. + _condComplete.wait(lock, [this]() { return (_pending.empty() && _processing == 0) || !_completed.empty(); }); + + // Dispatch all completion callbacks if there are any. + while (!_completed.empty()) + { + auto taskData = _completed.front(); + _completed.pop_front(); + + if (taskData.CompletionFn) + { + lock.unlock(); + + taskData.CompletionFn(); + + lock.lock(); + } + } + + if (reportFn) + { + lock.unlock(); + + reportFn(); + + lock.lock(); + } + + // If everything is empty and no more work has to be done we can stop waiting. + if (_completed.empty() && _pending.empty() && _processing == 0) + { + break; + } + } +} + +size_t JobPool::CountPending() +{ + return _pending.size(); +} + +void JobPool::ProcessQueue() +{ + unique_lock lock(_mutex); + do + { + // Wait for work or cancelation. + _condPending.wait(lock, [this]() { return _shouldStop || !_pending.empty(); }); + + if (!_pending.empty()) + { + _processing++; + + auto taskData = _pending.front(); + _pending.pop_front(); + + lock.unlock(); + + taskData.WorkFn(); + + lock.lock(); + + _completed.push_back(taskData); + + _processing--; + _condComplete.notify_one(); + } + } while (!_shouldStop); +} diff --git a/src/openrct2/core/JobPool.h b/src/openrct2/core/JobPool.h new file mode 100644 index 000000000000..8de1abf2191a --- /dev/null +++ b/src/openrct2/core/JobPool.h @@ -0,0 +1,52 @@ +/***************************************************************************** + * Copyright (c) 2014-2020 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +class JobPool +{ +private: + struct TaskData + { + const std::function WorkFn; + const std::function CompletionFn; + + TaskData(std::function workFn, std::function completionFn); + }; + + std::atomic_bool _shouldStop = { false }; + std::atomic _processing = { 0 }; + std::vector _threads; + std::deque _pending; + std::deque _completed; + std::condition_variable _condPending; + std::condition_variable _condComplete; + std::mutex _mutex; + + using unique_lock = std::unique_lock; + +public: + JobPool(size_t maxThreads = 255); + ~JobPool(); + + void AddTask(std::function workFn, std::function completionFn = nullptr); + void Join(std::function reportFn = nullptr); + size_t CountPending(); + +private: + void ProcessQueue(); +}; diff --git a/src/openrct2/core/JobPool.hpp b/src/openrct2/core/JobPool.hpp deleted file mode 100644 index c7cac4cbf661..000000000000 --- a/src/openrct2/core/JobPool.hpp +++ /dev/null @@ -1,155 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014-2020 OpenRCT2 developers - * - * For a complete list of all authors, please refer to contributors.md - * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 - * - * OpenRCT2 is licensed under the GNU General Public License version 3. - *****************************************************************************/ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class JobPool -{ -private: - struct TaskData - { - const std::function WorkFn; - const std::function CompletionFn; - - TaskData(std::function workFn, std::function completionFn) - : WorkFn(workFn) - , CompletionFn(completionFn) - { - } - }; - - std::atomic_bool _shouldStop = { false }; - std::atomic _processing = { 0 }; - std::vector _threads; - std::deque _pending; - std::deque _completed; - std::condition_variable _condPending; - std::condition_variable _condComplete; - std::mutex _mutex; - - using unique_lock = std::unique_lock; - -public: - JobPool(size_t maxThreads = 255) - { - maxThreads = std::min(maxThreads, std::thread::hardware_concurrency()); - for (size_t n = 0; n < maxThreads; n++) - { - _threads.emplace_back(&JobPool::ProcessQueue, this); - } - } - - ~JobPool() - { - { - unique_lock lock(_mutex); - _shouldStop = true; - _condPending.notify_all(); - } - - for (auto&& th : _threads) - { - assert(th.joinable() != false); - th.join(); - } - } - - void AddTask(std::function workFn, std::function completionFn = nullptr) - { - unique_lock lock(_mutex); - _pending.emplace_back(workFn, completionFn); - _condPending.notify_one(); - } - - void Join(std::function reportFn = nullptr) - { - unique_lock lock(_mutex); - while (true) - { - // Wait for the queue to become empty or having completed tasks. - _condComplete.wait(lock, [this]() { return (_pending.empty() && _processing == 0) || !_completed.empty(); }); - - // Dispatch all completion callbacks if there are any. - while (!_completed.empty()) - { - auto taskData = _completed.front(); - _completed.pop_front(); - - if (taskData.CompletionFn) - { - lock.unlock(); - - taskData.CompletionFn(); - - lock.lock(); - } - } - - if (reportFn) - { - lock.unlock(); - - reportFn(); - - lock.lock(); - } - - // If everything is empty and no more work has to be done we can stop waiting. - if (_completed.empty() && _pending.empty() && _processing == 0) - { - break; - } - } - } - - size_t CountPending() - { - return _pending.size(); - } - -private: - void ProcessQueue() - { - unique_lock lock(_mutex); - do - { - // Wait for work or cancelation. - _condPending.wait(lock, [this]() { return _shouldStop || !_pending.empty(); }); - - if (!_pending.empty()) - { - _processing++; - - auto taskData = _pending.front(); - _pending.pop_front(); - - lock.unlock(); - - taskData.WorkFn(); - - lock.lock(); - - _completed.push_back(taskData); - - _processing--; - _condComplete.notify_one(); - } - } while (!_shouldStop); - } -}; diff --git a/src/openrct2/core/Json.cpp b/src/openrct2/core/Json.cpp index 905c51b86397..6c44360f0482 100644 --- a/src/openrct2/core/Json.cpp +++ b/src/openrct2/core/Json.cpp @@ -9,7 +9,7 @@ #include "Json.hpp" -#include "FileStream.hpp" +#include "FileStream.h" #include "Memory.hpp" #include "String.hpp" diff --git a/src/openrct2/core/String.cpp b/src/openrct2/core/String.cpp index e4a43275b19b..ee4c36768677 100644 --- a/src/openrct2/core/String.cpp +++ b/src/openrct2/core/String.cpp @@ -34,7 +34,7 @@ #include "../util/Util.h" #include "Memory.hpp" #include "String.hpp" -#include "StringBuilder.hpp" +#include "StringBuilder.h" namespace String { diff --git a/src/openrct2/core/StringBuilder.cpp b/src/openrct2/core/StringBuilder.cpp new file mode 100644 index 000000000000..4c7b9839fbd1 --- /dev/null +++ b/src/openrct2/core/StringBuilder.cpp @@ -0,0 +1,72 @@ +/***************************************************************************** + * Copyright (c) 2014-2020 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "StringBuilder.h" + +#include "String.hpp" + +#include +#include + +StringBuilder::StringBuilder(size_t capacity) +{ + _buffer.reserve(capacity); +} + +void StringBuilder::Append(int32_t codepoint) +{ + Append(static_cast(codepoint)); +} + +void StringBuilder::Append(codepoint_t codepoint) +{ + size_t codepointLength = String::GetCodepointLength(codepoint); + std::basic_string data(codepointLength, {}); + String::WriteCodepoint(data.data(), codepoint); + _buffer.insert(_buffer.end(), data.begin(), data.end()); +} + +void StringBuilder::Append(const utf8* text) +{ + size_t textLength = String::SizeOf(text); + Append(text, textLength); +} + +void StringBuilder::Append(const utf8* text, size_t textLength) +{ + _buffer.insert(_buffer.end(), text, text + textLength); +} + +void StringBuilder::Append(const StringBuilder* sb) +{ + Append(sb->GetBuffer(), sb->GetLength()); +} + +void StringBuilder::Clear() +{ + _buffer.clear(); +} + +std::string StringBuilder::GetStdString() const +{ + return std::string(GetBuffer(), GetLength()); +} + +const utf8* StringBuilder::GetBuffer() const +{ + // buffer may be empty, so return an immutable empty string + if (_buffer.empty()) + return ""; + return _buffer.c_str(); +} + +size_t StringBuilder::GetLength() const +{ + return _buffer.size(); +} diff --git a/src/openrct2/core/StringBuilder.hpp b/src/openrct2/core/StringBuilder.h similarity index 59% rename from src/openrct2/core/StringBuilder.hpp rename to src/openrct2/core/StringBuilder.h index 3b259581bfc5..36d59dff1d4b 100644 --- a/src/openrct2/core/StringBuilder.hpp +++ b/src/openrct2/core/StringBuilder.h @@ -10,10 +10,7 @@ #pragma once #include "../common.h" -#include "String.hpp" -#include -#include #include /** @@ -24,37 +21,20 @@ class StringBuilder final { public: StringBuilder() = default; - explicit StringBuilder(size_t capacity) - { - _buffer.reserve(capacity); - } - + explicit StringBuilder(size_t capacity); ~StringBuilder() = default; - void Append(int32_t codepoint) - { - Append(static_cast(codepoint)); - } + void Append(int32_t codepoint); /** * Appends the given character to the current string. */ - void Append(codepoint_t codepoint) - { - size_t codepointLength = String::GetCodepointLength(codepoint); - std::basic_string data(codepointLength, {}); - String::WriteCodepoint(data.data(), codepoint); - _buffer.insert(_buffer.end(), data.begin(), data.end()); - } + void Append(codepoint_t codepoint); /** * Appends the given string to the current string. */ - void Append(const utf8* text) - { - size_t textLength = String::SizeOf(text); - Append(text, textLength); - } + void Append(const utf8* text); /** * Appends the given string of the given length to the current string. Essentially used to ignore null terminators or copy @@ -62,54 +42,33 @@ class StringBuilder final * @param text Pointer to the UTF-8 text to append. * @param textLength Number of bytes to copy. (Can be used to append single bytes rather than codepoints) */ - void Append(const utf8* text, size_t textLength) - { - _buffer.insert(_buffer.end(), text, text + textLength); - } + void Append(const utf8* text, size_t textLength); /** * Appends the string of a given StringBuilder to the current string. */ - void Append(const StringBuilder* sb) - { - Append(sb->GetBuffer(), sb->GetLength()); - } + void Append(const StringBuilder* sb); /** * Clears the current string, but preserves the allocated memory for another string. */ - void Clear() - { - _buffer.clear(); - } + void Clear(); /** * Returns the current string buffer as a standard string. */ - std::string GetStdString() const - { - return std::string(GetBuffer(), GetLength()); - } + std::string GetStdString() const; /** * Gets the current state of the StringBuilder. Warning: this represents the StringBuilder's current working buffer and will * be deallocated when the StringBuilder is destructed. */ - const utf8* GetBuffer() const - { - // buffer may be empty, so return an immutable empty string - if (_buffer.empty()) - return ""; - return _buffer.c_str(); - } + const utf8* GetBuffer() const; /** * Gets the length of the current string. */ - size_t GetLength() const - { - return _buffer.size(); - } + size_t GetLength() const; private: std::basic_string _buffer; diff --git a/src/openrct2/core/StringReader.cpp b/src/openrct2/core/StringReader.cpp new file mode 100644 index 000000000000..a8e08842420d --- /dev/null +++ b/src/openrct2/core/StringReader.cpp @@ -0,0 +1,58 @@ +/***************************************************************************** + * Copyright (c) 2014-2020 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "StringReader.h" + +#include "../localisation/Localisation.h" +#include "../util/Util.h" +#include "String.hpp" + +UTF8StringReader::UTF8StringReader(const utf8* text) +{ + text = String::SkipBOM(text); + + _text = text; + _current = text; +} + +bool UTF8StringReader::TryPeek(codepoint_t* outCodepoint) +{ + if (_current == nullptr) + return false; + + codepoint_t codepoint = String::GetNextCodepoint(_current); + *outCodepoint = codepoint; + return true; +} + +bool UTF8StringReader::TryRead(codepoint_t* outCodepoint) +{ + if (_current == nullptr) + return false; + + codepoint_t codepoint = String::GetNextCodepoint(_current, &_current); + *outCodepoint = codepoint; + if (codepoint == 0) + { + _current = nullptr; + return false; + } + return true; +} + +void UTF8StringReader::Skip() +{ + codepoint_t codepoint; + TryRead(&codepoint); +} + +bool UTF8StringReader::CanRead() const +{ + return _current != nullptr; +} diff --git a/src/openrct2/core/StringReader.h b/src/openrct2/core/StringReader.h new file mode 100644 index 000000000000..c1a83fc9406e --- /dev/null +++ b/src/openrct2/core/StringReader.h @@ -0,0 +1,37 @@ +/***************************************************************************** + * Copyright (c) 2014-2020 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "../common.h" + +struct IStringReader +{ + virtual ~IStringReader() = default; + + virtual bool TryPeek(codepoint_t* outCodepoint) abstract; + virtual bool TryRead(codepoint_t* outCodepoint) abstract; + virtual void Skip() abstract; + virtual bool CanRead() const abstract; +}; + +class UTF8StringReader final : public IStringReader +{ +public: + explicit UTF8StringReader(const utf8* text); + + bool TryPeek(codepoint_t* outCodepoint) override; + bool TryRead(codepoint_t* outCodepoint) override; + void Skip() override; + bool CanRead() const override; + +private: + const utf8* _text; + const utf8* _current; +}; diff --git a/src/openrct2/core/StringReader.hpp b/src/openrct2/core/StringReader.hpp deleted file mode 100644 index 76586e9ff470..000000000000 --- a/src/openrct2/core/StringReader.hpp +++ /dev/null @@ -1,77 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014-2020 OpenRCT2 developers - * - * For a complete list of all authors, please refer to contributors.md - * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 - * - * OpenRCT2 is licensed under the GNU General Public License version 3. - *****************************************************************************/ - -#pragma once - -#include "../common.h" -#include "../localisation/Localisation.h" -#include "../util/Util.h" -#include "String.hpp" - -struct IStringReader -{ - virtual ~IStringReader() = default; - - virtual bool TryPeek(codepoint_t* outCodepoint) abstract; - virtual bool TryRead(codepoint_t* outCodepoint) abstract; - virtual void Skip() abstract; - virtual bool CanRead() const abstract; -}; - -class UTF8StringReader final : public IStringReader -{ -public: - explicit UTF8StringReader(const utf8* text) - { - text = String::SkipBOM(text); - - _text = text; - _current = text; - } - - bool TryPeek(codepoint_t* outCodepoint) override - { - if (_current == nullptr) - return false; - - codepoint_t codepoint = String::GetNextCodepoint(_current); - *outCodepoint = codepoint; - return true; - } - - bool TryRead(codepoint_t* outCodepoint) override - { - if (_current == nullptr) - return false; - - codepoint_t codepoint = String::GetNextCodepoint(_current, &_current); - *outCodepoint = codepoint; - if (codepoint == 0) - { - _current = nullptr; - return false; - } - return true; - } - - void Skip() override - { - codepoint_t codepoint; - TryRead(&codepoint); - } - - bool CanRead() const override - { - return _current != nullptr; - } - -private: - const utf8* _text; - const utf8* _current; -}; diff --git a/src/openrct2/drawing/Drawing.Sprite.cpp b/src/openrct2/drawing/Drawing.Sprite.cpp index c7f6800449bb..3959576c5cd7 100644 --- a/src/openrct2/drawing/Drawing.Sprite.cpp +++ b/src/openrct2/drawing/Drawing.Sprite.cpp @@ -11,7 +11,7 @@ #include "../OpenRCT2.h" #include "../PlatformEnvironment.h" #include "../config/Config.h" -#include "../core/FileStream.hpp" +#include "../core/FileStream.h" #include "../core/Path.hpp" #include "../platform/platform.h" #include "../sprites.h" diff --git a/src/openrct2/drawing/Drawing.h b/src/openrct2/drawing/Drawing.h index b719652cc770..e8fa9b95ef44 100644 --- a/src/openrct2/drawing/Drawing.h +++ b/src/openrct2/drawing/Drawing.h @@ -12,7 +12,7 @@ #include "../common.h" #include "../interface/Colour.h" -#include "../interface/ZoomLevel.hpp" +#include "../interface/ZoomLevel.h" #include "../world/Location.hpp" #include "Text.h" diff --git a/src/openrct2/interface/Screenshot.h b/src/openrct2/interface/Screenshot.h index fa2306b30721..9e73903ec61f 100644 --- a/src/openrct2/interface/Screenshot.h +++ b/src/openrct2/interface/Screenshot.h @@ -12,7 +12,7 @@ #include "../common.h" #include "../core/FileSystem.hpp" #include "../world/Location.hpp" -#include "ZoomLevel.hpp" +#include "ZoomLevel.h" #include #include diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index 7334131c862a..bd9ac0ce8cdf 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -15,7 +15,7 @@ #include "../OpenRCT2.h" #include "../config/Config.h" #include "../core/Guard.hpp" -#include "../core/JobPool.hpp" +#include "../core/JobPool.h" #include "../drawing/Drawing.h" #include "../drawing/IDrawingEngine.h" #include "../paint/Paint.h" diff --git a/src/openrct2/interface/Window.h b/src/openrct2/interface/Window.h index e61a5e1444de..4331f4d8a9e1 100644 --- a/src/openrct2/interface/Window.h +++ b/src/openrct2/interface/Window.h @@ -15,7 +15,7 @@ #include "../ride/RideTypes.h" #include "../world/Location.hpp" #include "../world/ScenerySelection.h" -#include "ZoomLevel.hpp" +#include "ZoomLevel.h" #include #include diff --git a/src/openrct2/interface/ZoomLevel.cpp b/src/openrct2/interface/ZoomLevel.cpp new file mode 100644 index 000000000000..cb380f8fd8c4 --- /dev/null +++ b/src/openrct2/interface/ZoomLevel.cpp @@ -0,0 +1,101 @@ +/***************************************************************************** + * Copyright (c) 2020 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "ZoomLevel.h" + +ZoomLevel::operator int8_t() const +{ + return _level; +} + +ZoomLevel ZoomLevel::operator++(int) +{ + ZoomLevel tmp(*this); + operator++(); + return tmp; +} + +ZoomLevel& ZoomLevel::operator++() +{ + _level++; + return *this; +} + +ZoomLevel ZoomLevel::operator--(int) +{ + ZoomLevel tmp(*this); + operator--(); + return tmp; +} + +ZoomLevel& ZoomLevel::operator--() +{ + _level--; + return *this; +} + +ZoomLevel& ZoomLevel::operator=(const ZoomLevel& other) +{ + _level = other._level; + return *this; +} + +ZoomLevel& ZoomLevel::operator+=(const ZoomLevel& rhs) +{ + _level += rhs._level; + return *this; +} + +ZoomLevel& ZoomLevel::operator-=(const ZoomLevel& rhs) +{ + _level -= rhs._level; + return *this; +} + +ZoomLevel operator+(ZoomLevel lhs, const ZoomLevel& rhs) +{ + lhs += rhs; + return lhs; +} + +ZoomLevel operator-(ZoomLevel lhs, const ZoomLevel& rhs) +{ + lhs -= rhs; + return lhs; +} + +bool operator==(const ZoomLevel& lhs, const ZoomLevel& rhs) +{ + return lhs._level == rhs._level; +} + +bool operator!=(const ZoomLevel& lhs, const ZoomLevel& rhs) +{ + return lhs._level != rhs._level; +} + +bool operator>=(const ZoomLevel& lhs, const ZoomLevel& rhs) +{ + return lhs._level >= rhs._level; +} + +bool operator<=(const ZoomLevel& lhs, const ZoomLevel& rhs) +{ + return lhs._level <= rhs._level; +} + +bool operator>(const ZoomLevel& lhs, const ZoomLevel& rhs) +{ + return lhs._level > rhs._level; +} + +bool operator<(const ZoomLevel& lhs, const ZoomLevel& rhs) +{ + return lhs._level < rhs._level; +} diff --git a/src/openrct2/interface/ZoomLevel.hpp b/src/openrct2/interface/ZoomLevel.h similarity index 57% rename from src/openrct2/interface/ZoomLevel.hpp rename to src/openrct2/interface/ZoomLevel.h index 6b12bb23e23e..84b7ce0d4584 100644 --- a/src/openrct2/interface/ZoomLevel.hpp +++ b/src/openrct2/interface/ZoomLevel.h @@ -29,96 +29,23 @@ struct ZoomLevel { } - explicit operator int8_t() const - { - return _level; - } - - ZoomLevel operator++(int) - { - ZoomLevel tmp(*this); - operator++(); - return tmp; - } - - ZoomLevel& operator++() - { - _level++; - return *this; - } - - ZoomLevel operator--(int) - { - ZoomLevel tmp(*this); - operator--(); - return tmp; - } - - ZoomLevel& operator--() - { - _level--; - return *this; - } - - ZoomLevel& operator=(const ZoomLevel& other) - { - _level = other._level; - return *this; - } - - ZoomLevel& operator+=(const ZoomLevel& rhs) - { - _level += rhs._level; - return *this; - } - - ZoomLevel& operator-=(const ZoomLevel& rhs) - { - _level -= rhs._level; - return *this; - } - - friend ZoomLevel operator+(ZoomLevel lhs, const ZoomLevel& rhs) - { - lhs += rhs; - return lhs; - } - - friend ZoomLevel operator-(ZoomLevel lhs, const ZoomLevel& rhs) - { - lhs -= rhs; - return lhs; - } - - friend bool operator==(const ZoomLevel& lhs, const ZoomLevel& rhs) - { - return lhs._level == rhs._level; - } - - friend bool operator!=(const ZoomLevel& lhs, const ZoomLevel& rhs) - { - return lhs._level != rhs._level; - } - - friend bool operator>=(const ZoomLevel& lhs, const ZoomLevel& rhs) - { - return lhs._level >= rhs._level; - } - - friend bool operator<=(const ZoomLevel& lhs, const ZoomLevel& rhs) - { - return lhs._level <= rhs._level; - } - - friend bool operator>(const ZoomLevel& lhs, const ZoomLevel& rhs) - { - return lhs._level > rhs._level; - } - - friend bool operator<(const ZoomLevel& lhs, const ZoomLevel& rhs) - { - return lhs._level < rhs._level; - } + explicit operator int8_t() const; + ZoomLevel operator++(int); + ZoomLevel& operator++(); + ZoomLevel operator--(int); + ZoomLevel& operator--(); + ZoomLevel& operator=(const ZoomLevel& other); + ZoomLevel& operator+=(const ZoomLevel& rhs); + ZoomLevel& operator-=(const ZoomLevel& rhs); + + friend ZoomLevel operator+(ZoomLevel lhs, const ZoomLevel& rhs); + friend ZoomLevel operator-(ZoomLevel lhs, const ZoomLevel& rhs); + friend bool operator==(const ZoomLevel& lhs, const ZoomLevel& rhs); + friend bool operator!=(const ZoomLevel& lhs, const ZoomLevel& rhs); + friend bool operator>=(const ZoomLevel& lhs, const ZoomLevel& rhs); + friend bool operator<=(const ZoomLevel& lhs, const ZoomLevel& rhs); + friend bool operator>(const ZoomLevel& lhs, const ZoomLevel& rhs); + friend bool operator<(const ZoomLevel& lhs, const ZoomLevel& rhs); template friend T operator*(const T& lhs, const ZoomLevel& rhs) { diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj index 03a7ffb23e3a..2dd9b0e4ea26 100644 --- a/src/openrct2/libopenrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -160,14 +160,14 @@ - + - + @@ -179,8 +179,8 @@ - - + + @@ -213,7 +213,7 @@ - + @@ -489,18 +489,22 @@ + + + + @@ -543,6 +547,7 @@ + diff --git a/src/openrct2/localisation/LanguagePack.cpp b/src/openrct2/localisation/LanguagePack.cpp index 43562669149a..0ac82012446d 100644 --- a/src/openrct2/localisation/LanguagePack.cpp +++ b/src/openrct2/localisation/LanguagePack.cpp @@ -10,12 +10,12 @@ #include "LanguagePack.h" #include "../common.h" -#include "../core/FileStream.hpp" +#include "../core/FileStream.h" #include "../core/Memory.hpp" #include "../core/RTL.h" #include "../core/String.hpp" -#include "../core/StringBuilder.hpp" -#include "../core/StringReader.hpp" +#include "../core/StringBuilder.h" +#include "../core/StringReader.h" #include "Language.h" #include "Localisation.h" diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index ba2b229c39b0..dfa5a4dce67c 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -52,7 +52,7 @@ static constexpr uint32_t CHUNK_SIZE = 1024 * 63; # include "../actions/GameAction.h" # include "../config/Config.h" # include "../core/Console.hpp" -# include "../core/FileStream.hpp" +# include "../core/FileStream.h" # include "../core/MemoryStream.h" # include "../core/Nullable.hpp" # include "../core/Path.hpp" diff --git a/src/openrct2/network/ServerList.cpp b/src/openrct2/network/ServerList.cpp index c5140225805e..1ab2a0e7c6ec 100644 --- a/src/openrct2/network/ServerList.cpp +++ b/src/openrct2/network/ServerList.cpp @@ -14,7 +14,7 @@ # include "../Context.h" # include "../PlatformEnvironment.h" # include "../config/Config.h" -# include "../core/FileStream.hpp" +# include "../core/FileStream.h" # include "../core/Guard.hpp" # include "../core/Http.h" # include "../core/Json.hpp" diff --git a/src/openrct2/object/ObjectFactory.cpp b/src/openrct2/object/ObjectFactory.cpp index e4e3f400edda..74261f1770f9 100644 --- a/src/openrct2/object/ObjectFactory.cpp +++ b/src/openrct2/object/ObjectFactory.cpp @@ -12,7 +12,7 @@ #include "../OpenRCT2.h" #include "../core/Console.hpp" #include "../core/File.h" -#include "../core/FileStream.hpp" +#include "../core/FileStream.h" #include "../core/Json.hpp" #include "../core/Memory.hpp" #include "../core/MemoryStream.h" diff --git a/src/openrct2/object/ObjectRepository.cpp b/src/openrct2/object/ObjectRepository.cpp index cda814a3976b..8795a14b1e11 100644 --- a/src/openrct2/object/ObjectRepository.cpp +++ b/src/openrct2/object/ObjectRepository.cpp @@ -15,7 +15,7 @@ #include "../config/Config.h" #include "../core/Console.hpp" #include "../core/FileIndex.hpp" -#include "../core/FileStream.hpp" +#include "../core/FileStream.h" #include "../core/Guard.hpp" #include "../core/IStream.hpp" #include "../core/Memory.hpp" diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 661ed6db778a..48007a73b8cf 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -17,7 +17,7 @@ #include "../audio/audio.h" #include "../core/Collections.hpp" #include "../core/Console.hpp" -#include "../core/FileStream.hpp" +#include "../core/FileStream.h" #include "../core/Guard.hpp" #include "../core/IStream.hpp" #include "../core/Memory.hpp" diff --git a/src/openrct2/rct1/T4Importer.cpp b/src/openrct2/rct1/T4Importer.cpp index 49cb91a0ab8f..9477f5903e2e 100644 --- a/src/openrct2/rct1/T4Importer.cpp +++ b/src/openrct2/rct1/T4Importer.cpp @@ -9,7 +9,7 @@ #include "../TrackImporter.h" #include "../config/Config.h" -#include "../core/FileStream.hpp" +#include "../core/FileStream.h" #include "../core/MemoryStream.h" #include "../core/Path.hpp" #include "../core/String.hpp" diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index 776da9df3e9a..8663ff73d664 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -15,7 +15,7 @@ #include "../OpenRCT2.h" #include "../common.h" #include "../config/Config.h" -#include "../core/FileStream.hpp" +#include "../core/FileStream.h" #include "../core/IStream.hpp" #include "../core/String.hpp" #include "../interface/Viewport.h" diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index cb19d73f80d5..d14b3af2aa56 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -15,7 +15,7 @@ #include "../ParkImporter.h" #include "../config/Config.h" #include "../core/Console.hpp" -#include "../core/FileStream.hpp" +#include "../core/FileStream.h" #include "../core/IStream.hpp" #include "../core/Path.hpp" #include "../core/Random.hpp" diff --git a/src/openrct2/rct2/T6Exporter.cpp b/src/openrct2/rct2/T6Exporter.cpp index 48f1472eddd0..01a42607009f 100644 --- a/src/openrct2/rct2/T6Exporter.cpp +++ b/src/openrct2/rct2/T6Exporter.cpp @@ -10,7 +10,7 @@ #include "T6Exporter.h" #include "../Context.h" -#include "../core/FileStream.hpp" +#include "../core/FileStream.h" #include "../core/MemoryStream.h" #include "../localisation/Localisation.h" #include "../localisation/StringIds.h" diff --git a/src/openrct2/rct2/T6Importer.cpp b/src/openrct2/rct2/T6Importer.cpp index 09e97a9917ad..48574efde9b3 100644 --- a/src/openrct2/rct2/T6Importer.cpp +++ b/src/openrct2/rct2/T6Importer.cpp @@ -9,7 +9,7 @@ #include "../TrackImporter.h" #include "../config/Config.h" -#include "../core/FileStream.hpp" +#include "../core/FileStream.h" #include "../core/MemoryStream.h" #include "../core/Path.hpp" #include "../core/String.hpp" diff --git a/src/openrct2/ride/TrackDesignRepository.cpp b/src/openrct2/ride/TrackDesignRepository.cpp index a032ad6f9d41..7e215c9aed16 100644 --- a/src/openrct2/ride/TrackDesignRepository.cpp +++ b/src/openrct2/ride/TrackDesignRepository.cpp @@ -16,7 +16,7 @@ #include "../core/Console.hpp" #include "../core/File.h" #include "../core/FileIndex.hpp" -#include "../core/FileStream.hpp" +#include "../core/FileStream.h" #include "../core/Path.hpp" #include "../core/String.hpp" #include "../localisation/LocalisationService.h" diff --git a/src/openrct2/scenario/ScenarioRepository.cpp b/src/openrct2/scenario/ScenarioRepository.cpp index 21f3432dc92b..c296f7bc8520 100644 --- a/src/openrct2/scenario/ScenarioRepository.cpp +++ b/src/openrct2/scenario/ScenarioRepository.cpp @@ -17,7 +17,7 @@ #include "../core/Console.hpp" #include "../core/File.h" #include "../core/FileIndex.hpp" -#include "../core/FileStream.hpp" +#include "../core/FileStream.h" #include "../core/MemoryStream.h" #include "../core/Path.hpp" #include "../core/String.hpp" diff --git a/src/openrct2/title/TitleSequence.cpp b/src/openrct2/title/TitleSequence.cpp index 7145f59832f4..daeec2af8fbd 100644 --- a/src/openrct2/title/TitleSequence.cpp +++ b/src/openrct2/title/TitleSequence.cpp @@ -14,13 +14,13 @@ #include "../core/Console.hpp" #include "../core/File.h" #include "../core/FileScanner.h" -#include "../core/FileStream.hpp" +#include "../core/FileStream.h" #include "../core/Guard.hpp" #include "../core/Memory.hpp" #include "../core/MemoryStream.h" #include "../core/Path.hpp" #include "../core/String.hpp" -#include "../core/StringBuilder.hpp" +#include "../core/StringBuilder.h" #include "../core/Zip.h" #include "../scenario/ScenarioRepository.h" #include "../scenario/ScenarioSources.h" diff --git a/test/testpaint/CMakeLists.txt b/test/testpaint/CMakeLists.txt index f76984cd74f5..98d8d39ae624 100644 --- a/test/testpaint/CMakeLists.txt +++ b/test/testpaint/CMakeLists.txt @@ -66,6 +66,7 @@ file(GLOB_RECURSE ORCT2_RIDE_DEP_SOURCES "${OPENRCT2_SRCPATH}/core/Guard.cpp" "${OPENRCT2_SRCPATH}/core/String.cpp" "${OPENRCT2_SRCPATH}/Diagnostic.cpp" + "${OPENRCT2_SRCPATH}/interface/ZoomLevel.cpp" "${OPENRCT2_SRCPATH}/localisation/ConversionTables.cpp" "${OPENRCT2_SRCPATH}/localisation/Convert.cpp" "${OPENRCT2_SRCPATH}/localisation/FormatCodes.cpp" diff --git a/test/tests/CMakeLists.txt b/test/tests/CMakeLists.txt index 94b994f3abf2..e13ce4ffca9e 100644 --- a/test/tests/CMakeLists.txt +++ b/test/tests/CMakeLists.txt @@ -120,8 +120,12 @@ add_test(NAME sawyercoding COMMAND test_sawyercoding) set(LANGUAGEPACK_TEST_SOURCES "${CMAKE_CURRENT_LIST_DIR}/LanguagePackTest.cpp" "${ROOT_DIR}/src/openrct2/localisation/LanguagePack.cpp" + "${ROOT_DIR}/src/openrct2/core/FileStream.cpp" + "${ROOT_DIR}/src/openrct2/core/Path.cpp" "${ROOT_DIR}/src/openrct2/core/RTL.FriBidi.cpp" "${ROOT_DIR}/src/openrct2/core/RTL.ICU.cpp" + "${ROOT_DIR}/src/openrct2/core/StringBuilder.cpp" + "${ROOT_DIR}/src/openrct2/core/StringReader.cpp" ) add_executable(test_languagepack ${LANGUAGEPACK_TEST_SOURCES}) if (UNIX AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "BSD") @@ -140,6 +144,8 @@ set(INI_TEST_SOURCES "${ROOT_DIR}/src/openrct2/config/IniWriter.cpp" "${ROOT_DIR}/src/openrct2/core/IStream.cpp" "${ROOT_DIR}/src/openrct2/core/MemoryStream.cpp" + "${ROOT_DIR}/src/openrct2/core/StringBuilder.cpp" + "${ROOT_DIR}/src/openrct2/core/StringReader.cpp" ) add_executable(test_ini ${INI_TEST_SOURCES}) SET_CHECK_CXX_FLAGS(test_ini) diff --git a/test/tests/LanguagePackTest.cpp b/test/tests/LanguagePackTest.cpp index 73cd0aee0c18..4908e39fb6e5 100644 --- a/test/tests/LanguagePackTest.cpp +++ b/test/tests/LanguagePackTest.cpp @@ -15,6 +15,9 @@ #include #ifndef _WIN32 +# include "openrct2/core/File.h" +# include "openrct2/platform/platform.h" + const language_descriptor LanguagesDescriptors[] = {}; #endif @@ -124,3 +127,20 @@ const unsigned char LanguagePackTest::LanguageZhTW[] = { 0x59, 0x20, 0x20, 0x20, 0x20, 0x3a, 0xe6, 0xaf, 0x8f, 0xe8, 0xbb, 0x8a, 0xe5, 0x8d, 0xa1, 0x34, 0xe4, 0xbd, 0x8d, 0xe4, 0xb9, 0x98, 0xe5, 0xae, 0xa2, 0x0a, 0x00, }; + +#ifndef _WIN32 +bool platform_ensure_directory_exists(const utf8* path) +{ + return true; +} + +bool platform_directory_exists(const utf8* path) +{ + return true; +} + +bool File::Exists(const std::string& path) +{ + return true; +} +#endif diff --git a/test/tests/Pathfinding.cpp b/test/tests/Pathfinding.cpp index 9ee1d01483b0..37c8d15c509d 100644 --- a/test/tests/Pathfinding.cpp +++ b/test/tests/Pathfinding.cpp @@ -1,5 +1,5 @@ #include "TestData.h" -#include "openrct2/core/StringReader.hpp" +#include "openrct2/core/StringReader.h" #include "openrct2/peep/GuestPathfinding.h" #include "openrct2/peep/Peep.h" #include "openrct2/ride/Station.h"