mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #20502 from ZehMatt/platform-cleanup
Cleanup Platform code
This commit is contained in:
commit
a7bbe77148
|
@ -21,7 +21,6 @@ int main(int argc, const char** argv)
|
|||
{
|
||||
int32_t rc = EXIT_SUCCESS;
|
||||
int runGame = CommandLineRun(argv, argc);
|
||||
Platform::CoreInit();
|
||||
if (runGame == EXITCODE_CONTINUE)
|
||||
{
|
||||
gOpenRCT2Headless = true;
|
||||
|
|
|
@ -44,7 +44,6 @@ int main(int argc, const char** argv)
|
|||
std::unique_ptr<IContext> context;
|
||||
int32_t rc = EXIT_SUCCESS;
|
||||
int runGame = CommandLineRun(argv, argc);
|
||||
Platform::CoreInit();
|
||||
RegisterBitmapReader();
|
||||
if (runGame == EXITCODE_CONTINUE)
|
||||
{
|
||||
|
|
|
@ -70,7 +70,6 @@ static void fixup_pointers(std::vector<RecordedPaintSession>& s)
|
|||
|
||||
static std::vector<RecordedPaintSession> extract_paint_session(std::string_view parkFileName)
|
||||
{
|
||||
Platform::CoreInit();
|
||||
gOpenRCT2Headless = true;
|
||||
auto context = OpenRCT2::CreateContext();
|
||||
std::vector<RecordedPaintSession> sessions;
|
||||
|
|
|
@ -118,7 +118,6 @@ static int CommandLineForBenchSpriteSort(int argc, const char* const* argv)
|
|||
if (::benchmark::ReportUnrecognizedArguments(argc, &argv_for_benchmark[0]))
|
||||
return -1;
|
||||
|
||||
Platform::CoreInit();
|
||||
gOpenRCT2Headless = true;
|
||||
|
||||
::benchmark::RunSpecifiedBenchmarks();
|
||||
|
|
|
@ -39,8 +39,6 @@ static exitcode_t HandleSimulate(CommandLineArgEnumerator* argEnumerator)
|
|||
return EXITCODE_FAIL;
|
||||
}
|
||||
|
||||
Platform::CoreInit();
|
||||
|
||||
const char* inputPath = argv[0];
|
||||
uint32_t ticks = atol(argv[1]);
|
||||
|
||||
|
|
|
@ -709,30 +709,34 @@ ImageCatalogue ImageId::GetCatalogue() const
|
|||
return ImageCatalogue::UNKNOWN;
|
||||
}
|
||||
|
||||
void (*MaskFn)(
|
||||
int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst,
|
||||
int32_t maskWrap, int32_t colourWrap, int32_t dstWrap)
|
||||
= nullptr;
|
||||
|
||||
void MaskInit()
|
||||
static auto GetMaskFunction()
|
||||
{
|
||||
if (AVX2Available())
|
||||
{
|
||||
LOG_VERBOSE("registering AVX2 mask function");
|
||||
MaskFn = MaskAvx2;
|
||||
return MaskAvx2;
|
||||
}
|
||||
else if (SSE41Available())
|
||||
{
|
||||
LOG_VERBOSE("registering SSE4.1 mask function");
|
||||
MaskFn = MaskSse4_1;
|
||||
return MaskSse4_1;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_VERBOSE("registering scalar mask function");
|
||||
MaskFn = MaskScalar;
|
||||
return MaskScalar;
|
||||
}
|
||||
}
|
||||
|
||||
static const auto MaskFunc = GetMaskFunction();
|
||||
|
||||
void MaskFn(
|
||||
int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst,
|
||||
int32_t maskWrap, int32_t colourWrap, int32_t dstWrap)
|
||||
{
|
||||
MaskFunc(width, height, maskSrc, colourSrc, dst, maskWrap, colourWrap, dstWrap);
|
||||
}
|
||||
|
||||
void GfxFilterPixel(DrawPixelInfo& dpi, const ScreenCoordsXY& coords, FilterPaletteID palette)
|
||||
{
|
||||
GfxFilterRect(dpi, { coords, coords }, palette);
|
||||
|
|
|
@ -597,9 +597,8 @@ void MaskSse4_1(
|
|||
void MaskAvx2(
|
||||
int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst,
|
||||
int32_t maskWrap, int32_t colourWrap, int32_t dstWrap);
|
||||
void MaskInit();
|
||||
|
||||
extern void (*MaskFn)(
|
||||
void MaskFn(
|
||||
int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst,
|
||||
int32_t maskWrap, int32_t colourWrap, int32_t dstWrap);
|
||||
|
||||
|
|
|
@ -490,7 +490,6 @@ int32_t CommandLineForGfxbench(const char** argv, int32_t argc)
|
|||
return -1;
|
||||
}
|
||||
|
||||
Platform::CoreInit();
|
||||
int32_t iterationCount = 5;
|
||||
if (argc == 2)
|
||||
{
|
||||
|
@ -587,7 +586,6 @@ int32_t CommandLineForScreenshot(const char** argv, int32_t argc, ScreenshotOpti
|
|||
DrawPixelInfo dpi;
|
||||
try
|
||||
{
|
||||
Platform::CoreInit();
|
||||
bool customLocation = false;
|
||||
bool centreMapX = false;
|
||||
bool centreMapY = false;
|
||||
|
|
|
@ -351,7 +351,7 @@
|
|||
<ClInclude Include="object\WaterEntry.h" />
|
||||
<ClInclude Include="object\WaterObject.h" />
|
||||
<ClInclude Include="OpenRCT2.h" />
|
||||
<ClInclude Include="openrct2_pch.h" Condition="'$(UsePCH)'=='true'"/>
|
||||
<ClInclude Include="openrct2_pch.h" Condition="'$(UsePCH)'=='true'" />
|
||||
<ClInclude Include="paint\Boundbox.h" />
|
||||
<ClInclude Include="paint\Paint.Entity.h" />
|
||||
<ClInclude Include="paint\Paint.h" />
|
||||
|
@ -875,10 +875,10 @@
|
|||
<ClCompile Include="PlatformEnvironment.cpp" />
|
||||
<ClCompile Include="platform\Crash.cpp" />
|
||||
<ClCompile Include="platform\Platform.Android.cpp" />
|
||||
<ClCompile Include="platform\Platform.Common.cpp" />
|
||||
<ClCompile Include="platform\Platform.Linux.cpp" />
|
||||
<ClCompile Include="platform\Platform.Posix.cpp" />
|
||||
<ClCompile Include="platform\Platform.Win32.cpp" />
|
||||
<ClCompile Include="platform\Shared.cpp" />
|
||||
<ClCompile Include="profiling\Profiling.cpp" />
|
||||
<ClCompile Include="rct12\RCT12.cpp" />
|
||||
<ClCompile Include="rct12\SawyerChunk.cpp" />
|
||||
|
@ -1054,9 +1054,10 @@
|
|||
<ClCompile Include="world\Wall.cpp" />
|
||||
<ClCompile Include="..\thirdparty\duktape\duktape.cpp">
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<ForcedIncludeFiles></ForcedIncludeFiles>
|
||||
<ForcedIncludeFiles>
|
||||
</ForcedIncludeFiles>
|
||||
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
</Project>
|
||||
</Project>
|
|
@ -27,7 +27,7 @@ AndroidClassLoader::~AndroidClassLoader()
|
|||
jobject AndroidClassLoader::_classLoader;
|
||||
jmethodID AndroidClassLoader::_findClassMethod;
|
||||
|
||||
static std::shared_ptr<AndroidClassLoader> acl;
|
||||
static std::shared_ptr<AndroidClassLoader> acl = std::make_shared<AndroidClassLoader>();
|
||||
|
||||
namespace Platform
|
||||
{
|
||||
|
@ -173,11 +173,6 @@ namespace Platform
|
|||
return displayScale;
|
||||
}
|
||||
|
||||
void AndroidInitClassLoader()
|
||||
{
|
||||
acl = std::make_shared<AndroidClassLoader>();
|
||||
}
|
||||
|
||||
jclass AndroidFindClass(JNIEnv* env, std::string_view name)
|
||||
{
|
||||
return static_cast<jclass>(env->CallObjectMethod(
|
||||
|
|
|
@ -24,7 +24,9 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <cstring>
|
||||
#include <thread>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -35,23 +37,6 @@ static constexpr std::array _prohibitedCharacters = { '/' };
|
|||
|
||||
namespace Platform
|
||||
{
|
||||
void CoreInit()
|
||||
{
|
||||
static bool initialised = false;
|
||||
if (!initialised)
|
||||
{
|
||||
initialised = true;
|
||||
|
||||
#ifdef __ANDROID__
|
||||
Platform::AndroidInitClassLoader();
|
||||
#endif // __ANDROID__
|
||||
|
||||
InitTicks();
|
||||
BitCountInit();
|
||||
MaskInit();
|
||||
}
|
||||
}
|
||||
|
||||
CurrencyType GetCurrencyValue(const char* currCode)
|
||||
{
|
||||
if (currCode == nullptr || strlen(currCode) < 3)
|
||||
|
@ -136,4 +121,18 @@ namespace Platform
|
|||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
void Sleep(uint32_t ms)
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(ms));
|
||||
}
|
||||
|
||||
static const auto _processStartTime = std::chrono::high_resolution_clock::now();
|
||||
|
||||
uint32_t GetTicks()
|
||||
{
|
||||
const auto processTime = std::chrono::high_resolution_clock::now() - _processStartTime;
|
||||
return static_cast<uint32_t>(std::chrono::duration_cast<std::chrono::milliseconds>(processTime).count());
|
||||
}
|
||||
|
||||
} // namespace Platform
|
|
@ -379,25 +379,6 @@ namespace Platform
|
|||
return u8"app_285330" PATH_SEPARATOR u8"depot_285331";
|
||||
}
|
||||
|
||||
void Sleep(uint32_t ms)
|
||||
{
|
||||
usleep(ms * 1000);
|
||||
}
|
||||
|
||||
void InitTicks()
|
||||
{
|
||||
}
|
||||
|
||||
uint32_t GetTicks()
|
||||
{
|
||||
struct timespec ts;
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0)
|
||||
{
|
||||
LOG_FATAL("clock_gettime failed");
|
||||
exit(-1);
|
||||
}
|
||||
return static_cast<uint32_t>(ts.tv_sec * 1000 + ts.tv_nsec / 1000000);
|
||||
}
|
||||
} // namespace Platform
|
||||
|
||||
#endif
|
||||
|
|
|
@ -41,10 +41,6 @@
|
|||
# pragma comment( \
|
||||
linker, \
|
||||
"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
|
||||
static uint32_t _frequency = 0;
|
||||
static LARGE_INTEGER _entryTimestamp;
|
||||
|
||||
// The name of the mutex used to prevent multiple instances of the game from running
|
||||
static constexpr wchar_t SINGLE_INSTANCE_MUTEX_NAME[] = L"RollerCoaster Tycoon 2_GSKMUTEX";
|
||||
|
||||
|
@ -901,29 +897,6 @@ namespace Platform
|
|||
return false;
|
||||
}
|
||||
|
||||
uint32_t GetTicks()
|
||||
{
|
||||
LARGE_INTEGER pfc;
|
||||
QueryPerformanceCounter(&pfc);
|
||||
|
||||
LARGE_INTEGER runningDelta;
|
||||
runningDelta.QuadPart = pfc.QuadPart - _entryTimestamp.QuadPart;
|
||||
|
||||
return static_cast<uint32_t>(runningDelta.QuadPart / _frequency);
|
||||
}
|
||||
|
||||
void Sleep(uint32_t ms)
|
||||
{
|
||||
::Sleep(ms);
|
||||
}
|
||||
|
||||
void InitTicks()
|
||||
{
|
||||
LARGE_INTEGER freq;
|
||||
QueryPerformanceFrequency(&freq);
|
||||
_frequency = static_cast<uint32_t>(freq.QuadPart / 1000);
|
||||
QueryPerformanceCounter(&_entryTimestamp);
|
||||
}
|
||||
} // namespace Platform
|
||||
|
||||
#endif
|
||||
|
|
|
@ -45,8 +45,6 @@ struct RealWorldTime;
|
|||
|
||||
namespace Platform
|
||||
{
|
||||
// Called very early in the program before parsing commandline arguments.
|
||||
void CoreInit();
|
||||
std::string GetEnvironmentVariable(std::string_view name);
|
||||
std::string GetFolderPath(SPECIAL_FOLDER folder);
|
||||
std::string GetInstallPath();
|
||||
|
@ -103,7 +101,6 @@ namespace Platform
|
|||
bool SetupUriProtocol();
|
||||
#endif
|
||||
#ifdef __ANDROID__
|
||||
void AndroidInitClassLoader();
|
||||
jclass AndroidFindClass(JNIEnv* env, std::string_view name);
|
||||
#endif
|
||||
|
||||
|
@ -125,7 +122,6 @@ namespace Platform
|
|||
uint32_t GetTicks();
|
||||
|
||||
void Sleep(uint32_t ms);
|
||||
void InitTicks();
|
||||
} // namespace Platform
|
||||
|
||||
#ifdef __ANDROID__
|
||||
|
|
|
@ -204,12 +204,7 @@ static int32_t BitCountLut(uint32_t source)
|
|||
+ BitsSetTable256[source >> 24];
|
||||
}
|
||||
|
||||
static int32_t (*BitCountFn)(uint32_t);
|
||||
|
||||
void BitCountInit()
|
||||
{
|
||||
BitCountFn = BitCountPopcntAvailable() ? BitCountPopcnt : BitCountLut;
|
||||
}
|
||||
static const auto BitCountFn = BitCountPopcntAvailable() ? BitCountPopcnt : BitCountLut;
|
||||
|
||||
int32_t BitCount(uint32_t source)
|
||||
{
|
||||
|
|
|
@ -28,7 +28,6 @@ bool AVX2Available();
|
|||
|
||||
int32_t UtilBitScanForward(int32_t source);
|
||||
int32_t UtilBitScanForward(int64_t source);
|
||||
void BitCountInit();
|
||||
int32_t BitCount(uint32_t source);
|
||||
int32_t StrLogicalCmp(char const* a, char const* b);
|
||||
char* SafeStrCpy(char* destination, const char* source, size_t num);
|
||||
|
|
|
@ -34,7 +34,6 @@ TEST(MultiLaunchTest, all)
|
|||
gOpenRCT2Headless = true;
|
||||
gOpenRCT2NoGraphics = true;
|
||||
|
||||
Platform::CoreInit();
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
auto context = CreateContext();
|
||||
|
|
|
@ -29,8 +29,6 @@ class PathfindingTestBase : public testing::Test
|
|||
public:
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
Platform::CoreInit();
|
||||
|
||||
gOpenRCT2Headless = true;
|
||||
gOpenRCT2NoGraphics = true;
|
||||
_context = CreateContext();
|
||||
|
|
|
@ -41,7 +41,6 @@ static std::unique_ptr<IContext> localStartGame(const std::string& parkPath)
|
|||
{
|
||||
gOpenRCT2Headless = true;
|
||||
gOpenRCT2NoGraphics = true;
|
||||
Platform::CoreInit();
|
||||
|
||||
auto context = CreateContext();
|
||||
if (!context->Initialise())
|
||||
|
|
|
@ -73,7 +73,6 @@ TEST_P(ReplayTests, RunReplay)
|
|||
{
|
||||
gOpenRCT2Headless = true;
|
||||
gOpenRCT2NoGraphics = true;
|
||||
Platform::CoreInit();
|
||||
|
||||
auto testData = GetParam();
|
||||
auto replayFile = testData.filePath;
|
||||
|
|
|
@ -65,7 +65,6 @@ protected:
|
|||
gOpenRCT2Headless = true;
|
||||
gOpenRCT2NoGraphics = true;
|
||||
|
||||
Platform::CoreInit();
|
||||
auto context = CreateContext();
|
||||
bool initialised = context->Initialise();
|
||||
ASSERT_TRUE(initialised);
|
||||
|
|
|
@ -187,8 +187,6 @@ TEST(S6ImportExportBasic, all)
|
|||
gOpenRCT2Headless = true;
|
||||
gOpenRCT2NoGraphics = true;
|
||||
|
||||
Platform::CoreInit();
|
||||
|
||||
MemoryStream importBuffer;
|
||||
MemoryStream exportBuffer;
|
||||
MemoryStream snapshotStream;
|
||||
|
@ -233,8 +231,6 @@ TEST(S6ImportExportAdvanceTicks, all)
|
|||
gOpenRCT2Headless = true;
|
||||
gOpenRCT2NoGraphics = true;
|
||||
|
||||
Platform::CoreInit();
|
||||
|
||||
MemoryStream importBuffer;
|
||||
MemoryStream exportBuffer;
|
||||
MemoryStream snapshotStream;
|
||||
|
|
Loading…
Reference in New Issue