mirror of https://github.com/OpenRCT2/OpenRCT2.git
Split declarations and definitions to improve compile times when editing (#13332)
* Split FileStream declarations and definitions * Split JobPool declarations and definitions * Split StringBuilder declarations and definitions * Split StringReader declarations and definitions * Split ZoomLevel declarations and definitions * Fix missing include in FileClassifier.cpp * Remove pragma once from source files * Fix missing include in StringBuilder.h * Update Xcode project * Fix compilation of tests Co-authored-by: Michael Steenbeek <m.o.steenbeek@gmail.com>
This commit is contained in:
parent
92a5f1aa24
commit
f0c1ea1d37
|
@ -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 = "<group>"; };
|
||||
2ADE2F23224418B1002598AF /* Numerics.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Numerics.hpp; sourceTree = "<group>"; };
|
||||
2ADE2F24224418B2002598AF /* Meta.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Meta.hpp; sourceTree = "<group>"; };
|
||||
2ADE2F25224418B2002598AF /* JobPool.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = JobPool.hpp; sourceTree = "<group>"; };
|
||||
2ADE2F26224418B2002598AF /* FileIndex.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FileIndex.hpp; sourceTree = "<group>"; };
|
||||
2ADE2F2D224418E7002598AF /* ConversionTables.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConversionTables.h; sourceTree = "<group>"; };
|
||||
2ADE2F2F22441905002598AF /* DiscordService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DiscordService.h; sourceTree = "<group>"; };
|
||||
|
@ -853,6 +856,17 @@
|
|||
4C8B426E1EEB1ABD00F015CA /* X8DrawingEngine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = X8DrawingEngine.cpp; sourceTree = "<group>"; };
|
||||
4C8B426F1EEB1ABD00F015CA /* X8DrawingEngine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = X8DrawingEngine.h; sourceTree = "<group>"; };
|
||||
4C8B42711EEB1AE400F015CA /* HardwareDisplayDrawingEngine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HardwareDisplayDrawingEngine.cpp; sourceTree = "<group>"; };
|
||||
4C8BB67625533D4B005C8830 /* FileSystem.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FileSystem.hpp; sourceTree = "<group>"; };
|
||||
4C8BB67725533D4B005C8830 /* FileStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileStream.h; sourceTree = "<group>"; };
|
||||
4C8BB67825533D4C005C8830 /* FileStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileStream.cpp; sourceTree = "<group>"; };
|
||||
4C8BB67A25533D58005C8830 /* JobPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JobPool.h; sourceTree = "<group>"; };
|
||||
4C8BB67B25533D59005C8830 /* JobPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JobPool.cpp; sourceTree = "<group>"; };
|
||||
4C8BB67D25533D64005C8830 /* StringBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringBuilder.cpp; sourceTree = "<group>"; };
|
||||
4C8BB67E25533D64005C8830 /* StringReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringReader.cpp; sourceTree = "<group>"; };
|
||||
4C8BB67F25533D64005C8830 /* StringReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringReader.h; sourceTree = "<group>"; };
|
||||
4C8BB68025533D64005C8830 /* StringBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringBuilder.h; sourceTree = "<group>"; };
|
||||
4C8BB68325533DB9005C8830 /* ZoomLevel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZoomLevel.h; sourceTree = "<group>"; };
|
||||
4C8BB68425533DB9005C8830 /* ZoomLevel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ZoomLevel.cpp; sourceTree = "<group>"; };
|
||||
4C9196ED204FF3E000869A24 /* Location.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Location.hpp; sourceTree = "<group>"; };
|
||||
4C93F1181F8B744400A9330D /* AirPoweredVerticalCoaster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AirPoweredVerticalCoaster.cpp; sourceTree = "<group>"; };
|
||||
4C93F1191F8B744400A9330D /* BobsleighCoaster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BobsleighCoaster.cpp; sourceTree = "<group>"; };
|
||||
|
@ -983,7 +997,6 @@
|
|||
51160A24250C7A15002029F6 /* GuestPathfinding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GuestPathfinding.h; sourceTree = "<group>"; };
|
||||
6341F4DF2400AA0E0052902B /* Drawing.Sprite.RLE.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Drawing.Sprite.RLE.cpp; sourceTree = "<group>"; };
|
||||
6341F4E02400AA0F0052902B /* Drawing.Sprite.BMP.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Drawing.Sprite.BMP.cpp; sourceTree = "<group>"; };
|
||||
6341F4E32400AA1C0052902B /* ZoomLevel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ZoomLevel.hpp; sourceTree = "<group>"; };
|
||||
9308D9FA209908080079EE96 /* TileElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TileElement.cpp; sourceTree = "<group>"; };
|
||||
9308D9FB209908080079EE96 /* Surface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Surface.cpp; sourceTree = "<group>"; };
|
||||
9308D9FC209908080079EE96 /* TileElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TileElement.h; sourceTree = "<group>"; };
|
||||
|
@ -1687,7 +1700,6 @@
|
|||
F76C83801EC4E7CC00FA49E2 /* File.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = File.h; sourceTree = "<group>"; };
|
||||
F76C83811EC4E7CC00FA49E2 /* FileScanner.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FileScanner.cpp; sourceTree = "<group>"; };
|
||||
F76C83821EC4E7CC00FA49E2 /* FileScanner.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FileScanner.h; sourceTree = "<group>"; };
|
||||
F76C83831EC4E7CC00FA49E2 /* FileStream.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = FileStream.hpp; sourceTree = "<group>"; };
|
||||
F76C83841EC4E7CC00FA49E2 /* Guard.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Guard.cpp; sourceTree = "<group>"; };
|
||||
F76C83851EC4E7CC00FA49E2 /* Guard.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Guard.hpp; sourceTree = "<group>"; };
|
||||
F76C83861EC4E7CC00FA49E2 /* IStream.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = IStream.cpp; sourceTree = "<group>"; };
|
||||
|
@ -1702,8 +1714,6 @@
|
|||
F76C83901EC4E7CC00FA49E2 /* Path.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Path.hpp; sourceTree = "<group>"; };
|
||||
F76C83921EC4E7CC00FA49E2 /* String.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = String.cpp; sourceTree = "<group>"; };
|
||||
F76C83931EC4E7CC00FA49E2 /* String.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = String.hpp; sourceTree = "<group>"; };
|
||||
F76C83941EC4E7CC00FA49E2 /* StringBuilder.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = StringBuilder.hpp; sourceTree = "<group>"; };
|
||||
F76C83951EC4E7CC00FA49E2 /* StringReader.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = StringReader.hpp; sourceTree = "<group>"; };
|
||||
F76C83991EC4E7CC00FA49E2 /* Zip.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Zip.cpp; sourceTree = "<group>"; };
|
||||
F76C839A1EC4E7CC00FA49E2 /* Zip.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Zip.h; sourceTree = "<group>"; };
|
||||
F76C839F1EC4E7CC00FA49E2 /* drawing.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = drawing.h; sourceTree = "<group>"; };
|
||||
|
@ -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 = "<group>";
|
||||
|
@ -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 */,
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# include <openrct2/Context.h>
|
||||
# include <openrct2/PlatformEnvironment.h>
|
||||
# include <openrct2/core/Console.hpp>
|
||||
# include <openrct2/core/FileStream.hpp>
|
||||
# include <openrct2/core/FileStream.h>
|
||||
# include <openrct2/core/Path.hpp>
|
||||
# include <openrct2/core/String.hpp>
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <openrct2/common.h>
|
||||
#include <openrct2/core/Console.hpp>
|
||||
#include <openrct2/core/File.h>
|
||||
#include <openrct2/core/FileStream.hpp>
|
||||
#include <openrct2/core/FileStream.h>
|
||||
#include <openrct2/core/Path.hpp>
|
||||
#include <openrct2/core/String.hpp>
|
||||
#include <openrct2/localisation/Localisation.h>
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "../common.h"
|
||||
#include "../core/IStream.hpp"
|
||||
#include "../core/String.hpp"
|
||||
#include "../core/StringBuilder.hpp"
|
||||
#include "../core/StringBuilder.h"
|
||||
|
||||
#include <cctype>
|
||||
#include <initializer_list>
|
||||
|
|
|
@ -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 <fstream>
|
||||
|
|
|
@ -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 <chrono>
|
||||
|
|
|
@ -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 <algorithm>
|
||||
|
||||
#ifndef _WIN32
|
||||
# include <sys/stat.h>
|
||||
#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<size_t>(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<size_t>(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<size_t>(length), _file);
|
||||
return readBytes;
|
||||
}
|
||||
|
||||
const void* FileStream::GetData() const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace OpenRCT2
|
|
@ -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
|
|
@ -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 <algorithm>
|
||||
#ifndef _WIN32
|
||||
# include <sys/stat.h>
|
||||
#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<size_t>(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<size_t>(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<size_t>(length), _file);
|
||||
return readBytes;
|
||||
}
|
||||
|
||||
const void* GetData() const override
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace OpenRCT2
|
|
@ -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 <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
JobPool::TaskData::TaskData(std::function<void()> workFn, std::function<void()> completionFn)
|
||||
: WorkFn(workFn)
|
||||
, CompletionFn(completionFn)
|
||||
{
|
||||
}
|
||||
|
||||
JobPool::JobPool(size_t maxThreads)
|
||||
{
|
||||
maxThreads = std::min<size_t>(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<void()> workFn, std::function<void()> completionFn)
|
||||
{
|
||||
unique_lock lock(_mutex);
|
||||
_pending.emplace_back(workFn, completionFn);
|
||||
_condPending.notify_one();
|
||||
}
|
||||
|
||||
void JobPool::Join(std::function<void()> 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);
|
||||
}
|
|
@ -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 <atomic>
|
||||
#include <condition_variable>
|
||||
#include <deque>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
class JobPool
|
||||
{
|
||||
private:
|
||||
struct TaskData
|
||||
{
|
||||
const std::function<void()> WorkFn;
|
||||
const std::function<void()> CompletionFn;
|
||||
|
||||
TaskData(std::function<void()> workFn, std::function<void()> completionFn);
|
||||
};
|
||||
|
||||
std::atomic_bool _shouldStop = { false };
|
||||
std::atomic<size_t> _processing = { 0 };
|
||||
std::vector<std::thread> _threads;
|
||||
std::deque<TaskData> _pending;
|
||||
std::deque<TaskData> _completed;
|
||||
std::condition_variable _condPending;
|
||||
std::condition_variable _condComplete;
|
||||
std::mutex _mutex;
|
||||
|
||||
using unique_lock = std::unique_lock<std::mutex>;
|
||||
|
||||
public:
|
||||
JobPool(size_t maxThreads = 255);
|
||||
~JobPool();
|
||||
|
||||
void AddTask(std::function<void()> workFn, std::function<void()> completionFn = nullptr);
|
||||
void Join(std::function<void()> reportFn = nullptr);
|
||||
size_t CountPending();
|
||||
|
||||
private:
|
||||
void ProcessQueue();
|
||||
};
|
|
@ -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 <algorithm>
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
#include <condition_variable>
|
||||
#include <deque>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
class JobPool
|
||||
{
|
||||
private:
|
||||
struct TaskData
|
||||
{
|
||||
const std::function<void()> WorkFn;
|
||||
const std::function<void()> CompletionFn;
|
||||
|
||||
TaskData(std::function<void()> workFn, std::function<void()> completionFn)
|
||||
: WorkFn(workFn)
|
||||
, CompletionFn(completionFn)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
std::atomic_bool _shouldStop = { false };
|
||||
std::atomic<size_t> _processing = { 0 };
|
||||
std::vector<std::thread> _threads;
|
||||
std::deque<TaskData> _pending;
|
||||
std::deque<TaskData> _completed;
|
||||
std::condition_variable _condPending;
|
||||
std::condition_variable _condComplete;
|
||||
std::mutex _mutex;
|
||||
|
||||
using unique_lock = std::unique_lock<std::mutex>;
|
||||
|
||||
public:
|
||||
JobPool(size_t maxThreads = 255)
|
||||
{
|
||||
maxThreads = std::min<size_t>(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<void()> workFn, std::function<void()> completionFn = nullptr)
|
||||
{
|
||||
unique_lock lock(_mutex);
|
||||
_pending.emplace_back(workFn, completionFn);
|
||||
_condPending.notify_one();
|
||||
}
|
||||
|
||||
void Join(std::function<void()> 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);
|
||||
}
|
||||
};
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "Json.hpp"
|
||||
|
||||
#include "FileStream.hpp"
|
||||
#include "FileStream.h"
|
||||
#include "Memory.hpp"
|
||||
#include "String.hpp"
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "../util/Util.h"
|
||||
#include "Memory.hpp"
|
||||
#include "String.hpp"
|
||||
#include "StringBuilder.hpp"
|
||||
#include "StringBuilder.h"
|
||||
|
||||
namespace String
|
||||
{
|
||||
|
|
|
@ -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 <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
StringBuilder::StringBuilder(size_t capacity)
|
||||
{
|
||||
_buffer.reserve(capacity);
|
||||
}
|
||||
|
||||
void StringBuilder::Append(int32_t codepoint)
|
||||
{
|
||||
Append(static_cast<codepoint_t>(codepoint));
|
||||
}
|
||||
|
||||
void StringBuilder::Append(codepoint_t codepoint)
|
||||
{
|
||||
size_t codepointLength = String::GetCodepointLength(codepoint);
|
||||
std::basic_string<utf8> 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();
|
||||
}
|
|
@ -10,10 +10,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "../common.h"
|
||||
#include "String.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
|
@ -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_t>(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<utf8> 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 @@ public:
|
|||
* @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<utf8> _buffer;
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
};
|
|
@ -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;
|
||||
};
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "../common.h"
|
||||
#include "../core/FileSystem.hpp"
|
||||
#include "../world/Location.hpp"
|
||||
#include "ZoomLevel.hpp"
|
||||
#include "ZoomLevel.h"
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "../ride/RideTypes.h"
|
||||
#include "../world/Location.hpp"
|
||||
#include "../world/ScenerySelection.h"
|
||||
#include "ZoomLevel.hpp"
|
||||
#include "ZoomLevel.h"
|
||||
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -29,96 +29,23 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
explicit operator int8_t() const
|
||||
{
|
||||
return _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);
|
||||
|
||||
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;
|
||||
}
|
||||
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<typename T> friend T operator*(const T& lhs, const ZoomLevel& rhs)
|
||||
{
|
|
@ -160,14 +160,14 @@
|
|||
<ClInclude Include="core\File.h" />
|
||||
<ClInclude Include="core\FileIndex.hpp" />
|
||||
<ClInclude Include="core\FileScanner.h" />
|
||||
<ClInclude Include="core\FileStream.hpp" />
|
||||
<ClInclude Include="core\FileStream.h" />
|
||||
<ClInclude Include="core\FileSystem.hpp" />
|
||||
<ClInclude Include="core\FileWatcher.h" />
|
||||
<ClInclude Include="core\Guard.hpp" />
|
||||
<ClInclude Include="core\Http.h" />
|
||||
<ClInclude Include="core\Imaging.h" />
|
||||
<ClInclude Include="core\IStream.hpp" />
|
||||
<ClInclude Include="core\JobPool.hpp" />
|
||||
<ClInclude Include="core\JobPool.h" />
|
||||
<ClInclude Include="core\Json.hpp" />
|
||||
<ClInclude Include="core\JsonFwd.hpp" />
|
||||
<ClInclude Include="core\Memory.hpp" />
|
||||
|
@ -179,8 +179,8 @@
|
|||
<ClInclude Include="core\Random.hpp" />
|
||||
<ClInclude Include="core\RTL.h" />
|
||||
<ClInclude Include="core\String.hpp" />
|
||||
<ClInclude Include="core\StringBuilder.hpp" />
|
||||
<ClInclude Include="core\StringReader.hpp" />
|
||||
<ClInclude Include="core\StringBuilder.h" />
|
||||
<ClInclude Include="core\StringReader.h" />
|
||||
<ClInclude Include="core\Zip.h" />
|
||||
<ClInclude Include="Date.h" />
|
||||
<ClInclude Include="Diagnostic.h" />
|
||||
|
@ -213,7 +213,7 @@
|
|||
<ClInclude Include="interface\Widget.h" />
|
||||
<ClInclude Include="interface\Window.h" />
|
||||
<ClInclude Include="interface\Window_internal.h" />
|
||||
<ClInclude Include="interface\ZoomLevel.hpp" />
|
||||
<ClInclude Include="interface\ZoomLevel.h" />
|
||||
<ClInclude Include="Intro.h" />
|
||||
<ClInclude Include="localisation\ConversionTables.h" />
|
||||
<ClInclude Include="localisation\Currency.h" />
|
||||
|
@ -489,18 +489,22 @@
|
|||
<ClCompile Include="core\Diagnostics.cpp" />
|
||||
<ClCompile Include="core\File.cpp" />
|
||||
<ClCompile Include="core\FileScanner.cpp" />
|
||||
<ClCompile Include="core\FileStream.cpp" />
|
||||
<ClCompile Include="core\FileWatcher.cpp" />
|
||||
<ClCompile Include="core\Guard.cpp" />
|
||||
<ClCompile Include="core\Http.cURL.cpp" />
|
||||
<ClCompile Include="core\Http.WinHttp.cpp" />
|
||||
<ClCompile Include="core\Imaging.cpp" />
|
||||
<ClCompile Include="core\IStream.cpp" />
|
||||
<ClCompile Include="core\JobPool.cpp" />
|
||||
<ClCompile Include="core\Json.cpp" />
|
||||
<ClCompile Include="core\MemoryStream.cpp" />
|
||||
<ClCompile Include="core\Path.cpp" />
|
||||
<ClCompile Include="core\RTL.FriBidi.cpp" />
|
||||
<ClCompile Include="core\RTL.ICU.cpp" />
|
||||
<ClCompile Include="core\String.cpp" />
|
||||
<ClCompile Include="core\StringBuilder.cpp" />
|
||||
<ClCompile Include="core\StringReader.cpp" />
|
||||
<ClCompile Include="core\Zip.cpp" />
|
||||
<ClCompile Include="core\ZipAndroid.cpp" />
|
||||
<ClCompile Include="Date.cpp" />
|
||||
|
@ -543,6 +547,7 @@
|
|||
<ClCompile Include="interface\Viewport.cpp" />
|
||||
<ClCompile Include="interface\Window.cpp" />
|
||||
<ClCompile Include="interface\Window_internal.cpp" />
|
||||
<ClCompile Include="interface\ZoomLevel.cpp" />
|
||||
<ClCompile Include="Intro.cpp" />
|
||||
<ClCompile Include="localisation\ConversionTables.cpp" />
|
||||
<ClCompile Include="localisation\Convert.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"
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#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
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue