diff --git a/distribution/windows/install.nsi b/distribution/windows/install.nsi index d0c6204830..51ecaa085d 100644 --- a/distribution/windows/install.nsi +++ b/distribution/windows/install.nsi @@ -174,7 +174,6 @@ Section "!OpenRCT2" Section1 ; Copy executable File /oname=${OPENRCT2_EXE} ${BINARY_DIR}\${OPENRCT2_EXE} File /oname=${OPENRCT2_COM} ${BINARY_DIR}\${OPENRCT2_COM} - File /oname=openrct2.dll ${BINARY_DIR}\openrct2.dll ; Create the Registry Entries WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2" "Comments" "Visit ${APPURLLINK}" @@ -243,7 +242,6 @@ Section "Uninstall" Delete "$INSTDIR\contributors.md" Delete "$INSTDIR\${OPENRCT2_EXE}" Delete "$INSTDIR\${OPENRCT2_COM}" - Delete "$INSTDIR\openrct2.dll" Delete "$INSTDIR\INSTALL.LOG" ; Data files diff --git a/openrct2.sln b/openrct2.sln index df87492621..71fecf142a 100644 --- a/openrct2.sln +++ b/openrct2.sln @@ -3,15 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.29411.138 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openrct2-dll", "src\openrct2-dll\openrct2-dll.vcxproj", "{7B8DB129-79EF-417E-B372-8A18E009D261}" - ProjectSection(ProjectDependencies) = postProject - {8DD8AB7D-2EA6-44E3-8265-BAF08E832951} = {8DD8AB7D-2EA6-44E3-8265-BAF08E832951} - {D24D94F6-2A74-480C-B512-629C306CE92F} = {D24D94F6-2A74-480C-B512-629C306CE92F} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openrct2-win", "src\openrct2-win\openrct2-win.vcxproj", "{7A9A57D5-7006-4208-A290-5491BA3C8808}" ProjectSection(ProjectDependencies) = postProject - {7B8DB129-79EF-417E-B372-8A18E009D261} = {7B8DB129-79EF-417E-B372-8A18E009D261} {B6808F71-30B4-4499-8FF6-0B1C86391842} = {B6808F71-30B4-4499-8FF6-0B1C86391842} {8DD8AB7D-2EA6-44E3-8265-BAF08E832951} = {8DD8AB7D-2EA6-44E3-8265-BAF08E832951} {D24D94F6-2A74-480C-B512-629C306CE92F} = {D24D94F6-2A74-480C-B512-629C306CE92F} @@ -21,7 +14,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libopenrct2", "src\openrct2 EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tests", "test\tests\tests.vcxproj", "{62B020FA-E4FB-4C6E-B32A-DC999470F155}" ProjectSection(ProjectDependencies) = postProject - {7B8DB129-79EF-417E-B372-8A18E009D261} = {7B8DB129-79EF-417E-B372-8A18E009D261} {B6808F71-30B4-4499-8FF6-0B1C86391842} = {B6808F71-30B4-4499-8FF6-0B1C86391842} {8DD8AB7D-2EA6-44E3-8265-BAF08E832951} = {8DD8AB7D-2EA6-44E3-8265-BAF08E832951} {7A9A57D5-7006-4208-A290-5491BA3C8808} = {7A9A57D5-7006-4208-A290-5491BA3C8808} @@ -36,7 +28,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libopenrct2ui", "src\openrc EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openrct2-cli", "src\openrct2-cli\openrct2-cli.vcxproj", "{B6808F71-30B4-4499-8FF6-0B1C86391842}" ProjectSection(ProjectDependencies) = postProject - {7B8DB129-79EF-417E-B372-8A18E009D261} = {7B8DB129-79EF-417E-B372-8A18E009D261} {D24D94F6-2A74-480C-B512-629C306CE92F} = {D24D94F6-2A74-480C-B512-629C306CE92F} EndProjectSection EndProject @@ -48,14 +39,6 @@ Global Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7B8DB129-79EF-417E-B372-8A18E009D261}.Debug|Win32.ActiveCfg = Debug|Win32 - {7B8DB129-79EF-417E-B372-8A18E009D261}.Debug|Win32.Build.0 = Debug|Win32 - {7B8DB129-79EF-417E-B372-8A18E009D261}.Debug|x64.ActiveCfg = Debug|x64 - {7B8DB129-79EF-417E-B372-8A18E009D261}.Debug|x64.Build.0 = Debug|x64 - {7B8DB129-79EF-417E-B372-8A18E009D261}.Release|Win32.ActiveCfg = Release|Win32 - {7B8DB129-79EF-417E-B372-8A18E009D261}.Release|Win32.Build.0 = Release|Win32 - {7B8DB129-79EF-417E-B372-8A18E009D261}.Release|x64.ActiveCfg = Release|x64 - {7B8DB129-79EF-417E-B372-8A18E009D261}.Release|x64.Build.0 = Release|x64 {7A9A57D5-7006-4208-A290-5491BA3C8808}.Debug|Win32.ActiveCfg = Debug|Win32 {7A9A57D5-7006-4208-A290-5491BA3C8808}.Debug|Win32.Build.0 = Debug|Win32 {7A9A57D5-7006-4208-A290-5491BA3C8808}.Debug|x64.ActiveCfg = Debug|x64 @@ -101,7 +84,6 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {7B8DB129-79EF-417E-B372-8A18E009D261} = {2202A816-377D-4FA0-A7AF-7D4105F8A4FB} {7A9A57D5-7006-4208-A290-5491BA3C8808} = {2202A816-377D-4FA0-A7AF-7D4105F8A4FB} {D24D94F6-2A74-480C-B512-629C306CE92F} = {2202A816-377D-4FA0-A7AF-7D4105F8A4FB} {62B020FA-E4FB-4C6E-B32A-DC999470F155} = {480B577D-4E4A-4757-9A42-28A9AD33E6B0} diff --git a/scripts/build-portable b/scripts/build-portable index fbf3313eac..5e2dd2d39b 100755 --- a/scripts/build-portable +++ b/scripts/build-portable @@ -19,7 +19,7 @@ if [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" ]]; then rm $destination fi 7z a -r $destination \ - openrct2.exe openrct2.com openrct2.dll data \ + openrct2.exe openrct2.com data \ ../distribution/changelog.txt \ ../distribution/contributors.md \ ../distribution/licence.txt \ diff --git a/scripts/build-symbols b/scripts/build-symbols index 620c0e5799..d3e28e446b 100755 --- a/scripts/build-symbols +++ b/scripts/build-symbols @@ -17,9 +17,7 @@ echo -e "\033[0;36mCreating symbols archive for OpenRCT2...\033[0m" if [[ -f $destination ]]; then rm $destination fi -7z a $destination \ - openrct2.exe openrct2.com openrct2.dll \ - openrct2-dll.pdb openrct2-win.pdb +7z a $destination openrct2.exe openrct2.com openrct2-win.pdb destination=$(cygpath -w $(readlink -f $destination)) printf '\033[0;32m%s\033[0m\n' "${destination} created successfully" diff --git a/src/openrct2-dll/openrct2-dll.cpp b/src/openrct2-dll/openrct2-dll.cpp deleted file mode 100644 index 24f2340fc8..0000000000 --- a/src/openrct2-dll/openrct2-dll.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014-2019 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. - *****************************************************************************/ - -// Windows.h needs to be included first -#define WIN32_LEAN_AND_MEAN -#include -#undef CreateWindow - -// Then the rest -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace OpenRCT2; -using namespace OpenRCT2::Audio; -using namespace OpenRCT2::Ui; - -#define DLLEXPORT extern "C" __declspec(dllexport) - -static char** GetCommandLineArgs(int argc, wchar_t** argvW); -static void FreeCommandLineArgs(int argc, char** argv); -static char* ConvertWideChartoUTF8(const wchar_t* src); - -DLLEXPORT int LaunchOpenRCT2(int argc, wchar_t** argvW) -{ - char** argv = GetCommandLineArgs(argc, argvW); - if (argv == nullptr) - { - puts("Unable to fetch command line arguments."); - return -1; - } - - SetConsoleCP(CP_UTF8); - SetConsoleOutputCP(CP_UTF8); - int exitCode = NormalisedMain(argc, const_cast(argv)); - - FreeCommandLineArgs(argc, argv); - return exitCode; -} - -static char** GetCommandLineArgs(int argc, wchar_t** argvW) -{ - // Allocate UTF-8 strings - char** argv = (char**)malloc(argc * sizeof(char*)); - if (argv == nullptr) - { - return nullptr; - } - - // Convert to UTF-8 - for (int i = 0; i < argc; i++) - { - argv[i] = ConvertWideChartoUTF8(argvW[i]); - } - - return argv; -} - -static void FreeCommandLineArgs(int argc, char** argv) -{ - // Free argv - for (int i = 0; i < argc; i++) - { - free(argv[i]); - } - free(argv); -} - -static char* ConvertWideChartoUTF8(const wchar_t* src) -{ - int srcLen = lstrlenW(src); - int sizeReq = WideCharToMultiByte(CP_UTF8, 0, src, srcLen, nullptr, 0, nullptr, nullptr); - char* result = (char*)calloc(1, sizeReq + 1); - WideCharToMultiByte(CP_UTF8, 0, src, srcLen, result, sizeReq, nullptr, nullptr); - return result; -} diff --git a/src/openrct2-dll/openrct2-dll.vcxproj b/src/openrct2-dll/openrct2-dll.vcxproj deleted file mode 100644 index 5b00e1e85f..0000000000 --- a/src/openrct2-dll/openrct2-dll.vcxproj +++ /dev/null @@ -1,62 +0,0 @@ - - - - ..\..\ - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {7B8DB129-79EF-417E-B372-8A18E009D261} - openrct2-dll - openrct2-dll - - - DynamicLibrary - - - - openrct2 - $(SolutionDir)bin;$(LibraryPath) - - - - __NOENTRYPOINT__;%(PreprocessorDefinitions) - - - - - $(OPENRCT2_CL_ADDITIONALOPTIONS) %(AdditionalOptions) - - - libopenrct2.lib;libopenrct2ui.lib;%(AdditionalDependencies) - $(OutDir)openrct2-dll.pdb - - - MachineX86 - MachineX64 - - - - - - - - - - \ No newline at end of file diff --git a/src/openrct2-win/openrct2-win.cpp b/src/openrct2-win/openrct2-win.cpp index 1d7f2da57d..166d875b9d 100644 --- a/src/openrct2-win/openrct2-win.cpp +++ b/src/openrct2-win/openrct2-win.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014-2019 OpenRCT2 developers + * 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 @@ -7,8 +7,8 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ +// Windows.h needs to be included first #define WIN32_LEAN_AND_MEAN - #include // Enable visual styles @@ -16,13 +16,65 @@ linker, \ "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") -#define DLLIMPORT extern "C" -DLLIMPORT int LaunchOpenRCT2(int argc, wchar_t** argv); +// Then the rest +#include +#include +#include + +static char** GetCommandLineArgs(int argc, wchar_t** argvW); +static void FreeCommandLineArgs(int argc, char** argv); +static char* ConvertWideChartoUTF8(const wchar_t* src); /** * Windows entry point to OpenRCT2 with a console window using a traditional C main function. */ int wmain(int argc, wchar_t** argvW, [[maybe_unused]] wchar_t* envp) { - return LaunchOpenRCT2(argc, argvW); + auto argv = GetCommandLineArgs(argc, argvW); + if (argv == nullptr) + { + puts("Unable to fetch command line arguments."); + return -1; + } + + SetConsoleCP(CP_UTF8); + SetConsoleOutputCP(CP_UTF8); + auto exitCode = NormalisedMain(argc, const_cast(argv)); + + FreeCommandLineArgs(argc, argv); + return exitCode; +} + +static char** GetCommandLineArgs(int argc, wchar_t** argvW) +{ + // Allocate UTF-8 strings + auto argv = (char**)malloc(argc * sizeof(char*)); + if (argv != nullptr) + { + // Convert to UTF-8 + for (int i = 0; i < argc; i++) + { + argv[i] = ConvertWideChartoUTF8(argvW[i]); + } + } + return argv; +} + +static void FreeCommandLineArgs(int argc, char** argv) +{ + // Free argv + for (int i = 0; i < argc; i++) + { + free(argv[i]); + } + free(argv); +} + +static char* ConvertWideChartoUTF8(const wchar_t* src) +{ + auto srcLen = lstrlenW(src); + auto sizeReq = WideCharToMultiByte(CP_UTF8, 0, src, srcLen, nullptr, 0, nullptr, nullptr); + auto result = static_cast(calloc(1, static_cast(sizeReq) + 1)); + WideCharToMultiByte(CP_UTF8, 0, src, srcLen, result, sizeReq, nullptr, nullptr); + return result; } diff --git a/src/openrct2-win/openrct2-win.vcxproj b/src/openrct2-win/openrct2-win.vcxproj index 74b6e852ba..6a7f8f0f6d 100644 --- a/src/openrct2-win/openrct2-win.vcxproj +++ b/src/openrct2-win/openrct2-win.vcxproj @@ -34,17 +34,12 @@ openrct2 $(SolutionDir)bin;$(LibraryPath) - - - __NOENTRYPOINT__;%(PreprocessorDefinitions) - - $(OPENRCT2_CL_ADDITIONALOPTIONS) %(AdditionalOptions) - openrct2.lib;%(AdditionalDependencies) + libopenrct2.lib;libopenrct2ui.lib;%(AdditionalDependencies) $(OutDir)openrct2-win.pdb Console