diff --git a/CMakeLists.txt b/CMakeLists.txt index ae13bd80be..8ea4b959b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ set (ORCT2_RESOURCE_DIR ${CMAKE_INSTALL_PREFIX}/share/${PROJECT}/) project(${PROJECT}) if (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR) - message(FATAL_ERROR "Building in-source is not supported! Create a build dir and remove ${CMAKE_SOURCE_DIR}/CMakeCache.txt") + message(FATAL_ERROR "Building in-source is not supported! Create a build dir and remove ${CMAKE_SOURCE_DIR}/CMakeCache.txt") endif() add_definitions(-DORCT2_RESOURCE_DIR="${ORCT2_RESOURCE_DIR}") add_definitions(-DHAVE_CONFIG_H) @@ -32,31 +32,31 @@ add_definitions(-DCURL_STATICLIB) # Define current git branch. execute_process( - COMMAND git rev-parse --abbrev-ref HEAD - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE OPENRCT2_BRANCH - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET + COMMAND git rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE OPENRCT2_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET ) add_definitions(-DOPENRCT2_BRANCH="${OPENRCT2_BRANCH}") # Define commit hash. execute_process( - COMMAND git rev-parse HEAD - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE OPENRCT2_COMMIT_SHA1 - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET + COMMAND git rev-parse HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE OPENRCT2_COMMIT_SHA1 + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET ) add_definitions(-DOPENRCT2_COMMIT_SHA1="${OPENRCT2_COMMIT_SHA1}") # Define short commit hash. execute_process( - COMMAND git rev-parse --short HEAD - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE OPENRCT2_COMMIT_SHA1_SHORT - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET + COMMAND git rev-parse --short HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE OPENRCT2_COMMIT_SHA1_SHORT + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET ) add_definitions(-DOPENRCT2_COMMIT_SHA1_SHORT="${OPENRCT2_COMMIT_SHA1_SHORT}") @@ -99,7 +99,7 @@ INCLUDE(FindPkgConfig) # Needed for linking with non-broken OpenSSL on Apple platforms if (APPLE) - set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/opt/openssl/lib/pkgconfig") + set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/opt/openssl/lib/pkgconfig") endif (APPLE) # Options @@ -118,20 +118,20 @@ set(COMMON_COMPILE_OPTIONS "${COMMON_COMPILE_OPTIONS} -fstrict-aliasing -Werror # On mingw all code is already PIC, this will avoid compiler error on redefining this option if(NOT MINGW) - set(COMMON_COMPILE_OPTIONS "${COMMON_COMPILE_OPTIONS} -fPIC") + set(COMMON_COMPILE_OPTIONS "${COMMON_COMPILE_OPTIONS} -fPIC") endif() if (NOT DISABLE_RCT2) - set (FORCE32 ON) - message("DISABLE_RCT2 implies FORCE32") + set (FORCE32 ON) + message("DISABLE_RCT2 implies FORCE32") endif() if (DISABLE_HTTP_TWITCH) - add_definitions(-DDISABLE_HTTP -DDISABLE_TWITCH) + add_definitions(-DDISABLE_HTTP -DDISABLE_TWITCH) endif (DISABLE_HTTP_TWITCH) if (DISABLE_TTF) - add_definitions(-DNO_TTF) + add_definitions(-DNO_TTF) endif (DISABLE_TTF) # Launchpad turns on -Wdate-time for compilers that support it, this shouldn't break our build @@ -139,58 +139,58 @@ ADD_CHECK_C_COMPILER_FLAG(CMAKE_C_FLAGS C_WARN_WRITE_STRINGS -Wno-error=date-tim ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_WRITE_STRINGS -Wno-error=date-time) if (FORCE32) - set(TARGET_M "-m32") + set(TARGET_M "-m32") endif() if (FORCE32) - set(OBJ_FORMAT "elf32-i386") - set(LINKER_SCRIPT "ld_script_i386.xc") + set(OBJ_FORMAT "elf32-i386") + set(LINKER_SCRIPT "ld_script_i386.xc") endif () if (DISABLE_OPENGL) - add_definitions(-DDISABLE_OPENGL) + add_definitions(-DDISABLE_OPENGL) else (DISABLE_OPENGL) - # Makes OpenGL function get queried in run-time rather than linked-in - add_definitions(-DOPENGL_NO_LINK) + # Makes OpenGL function get queried in run-time rather than linked-in + add_definitions(-DOPENGL_NO_LINK) endif (DISABLE_OPENGL) if (USE_MMAP) - add_definitions(-DUSE_MMAP) + add_definitions(-DUSE_MMAP) endif (USE_MMAP) if (DISABLE_NETWORK) - add_definitions(-DDISABLE_NETWORK) + add_definitions(-DDISABLE_NETWORK) else (DISABLE_NETWORK) - if (WIN32) - SET(NETWORKLIBS ${NETWORKLIBS} ws2_32) - endif (WIN32) - # If you are on macOS, CMake might try using system-provided OpenSSL. - # This is too old and will not work. - PKG_CHECK_MODULES(SSL REQUIRED openssl>=1.0.0) + if (WIN32) + SET(NETWORKLIBS ${NETWORKLIBS} ws2_32) + endif (WIN32) + # If you are on macOS, CMake might try using system-provided OpenSSL. + # This is too old and will not work. + PKG_CHECK_MODULES(SSL REQUIRED openssl>=1.0.0) endif (DISABLE_NETWORK) if (DISABLE_RCT2) - add_definitions(-DNO_RCT2) + add_definitions(-DNO_RCT2) endif (DISABLE_RCT2) # Start of library checks PKG_CHECK_MODULES(PNG libpng>=1.6) if (NOT PNG_FOUND) - PKG_CHECK_MODULES(PNG libpng16) + PKG_CHECK_MODULES(PNG libpng16) endif (NOT PNG_FOUND) if (NOT PNG_FOUND) - PKG_CHECK_MODULES(PNG libpng>=1.2) + PKG_CHECK_MODULES(PNG libpng>=1.2) endif (NOT PNG_FOUND) if (NOT PNG_FOUND) - PKG_CHECK_MODULES(PNG REQUIRED libpng12) + PKG_CHECK_MODULES(PNG REQUIRED libpng12) endif (NOT PNG_FOUND) PKG_CHECK_MODULES(ZLIB REQUIRED zlib) PKG_CHECK_MODULES(JANSSON REQUIRED jansson>=2.3) # Handle creating the rct2 text and data files on macOS and Linux -# See details in src/openrct2.c:openrct2_setup_rct2_segment for how the values +# See details in src/openrct2/rct2/interop.c:rct2_interop_setup_segment for how the values # were derived. if ((NOT DISABLE_RCT2) AND UNIX) add_custom_command( @@ -206,40 +206,40 @@ if ((NOT DISABLE_RCT2) AND UNIX) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/openrct2.exe ) add_custom_target(segfiles DEPENDS openrct2_text openrct2_data) - if (NOT USE_MMAP) - if (APPLE) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -sectcreate rct2_text __text ${CMAKE_CURRENT_SOURCE_DIR}/build/openrct2_text -sectcreate rct2_data __data ${CMAKE_CURRENT_SOURCE_DIR}/build/openrct2_data -segaddr rct2_data 0x8a4000 -segprot rct2_data rwx rwx -segaddr rct2_text 0x401000 -segprot rct2_text rwx rwx -segaddr __TEXT 0x2000000 -read_only_relocs suppress") - else (APPLE) - # For Linux we have to use objcopy to wrap regular binaries into a linkable - # format. We use specific section names which are then referenced in a - # bespoke linker script so they can be placed at predefined VMAs. - add_custom_command( - OUTPUT openrct2_text_section.o - COMMAND objcopy --input binary --output ${OBJ_FORMAT} --binary-architecture i386 openrct2_text openrct2_text_section.o --rename-section .data=.rct2_text,contents,alloc,load,readonly,code - DEPENDS segfiles - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - add_custom_command( - OUTPUT openrct2_data_section.o - COMMAND objcopy --input binary --output ${OBJ_FORMAT} --binary-architecture i386 openrct2_data openrct2_data_section.o --rename-section .data=.rct2_data,contents,alloc,load,readonly,data - DEPENDS segfiles - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - add_custom_target(linkable_sections DEPENDS openrct2_text_section.o openrct2_data_section.o) - SET_SOURCE_FILES_PROPERTIES( - openrct2_text_section.o openrct2_data_section.o - PROPERTIES - EXTERNAL_OBJECT true - GENERATED true - ) - # can't use GLOB here, as the files don't exist yet at cmake-time - set(RCT2_SECTIONS "${CMAKE_BINARY_DIR}/openrct2_data_section.o" "${CMAKE_BINARY_DIR}/openrct2_text_section.o") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-T,\"${CMAKE_CURRENT_SOURCE_DIR}/distribution/linux/${LINKER_SCRIPT}\"") - endif (APPLE) - endif (NOT USE_MMAP) + if (NOT USE_MMAP) + if (APPLE) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -sectcreate rct2_text __text ${CMAKE_CURRENT_SOURCE_DIR}/build/openrct2_text -sectcreate rct2_data __data ${CMAKE_CURRENT_SOURCE_DIR}/build/openrct2_data -segaddr rct2_data 0x8a4000 -segprot rct2_data rwx rwx -segaddr rct2_text 0x401000 -segprot rct2_text rwx rwx -segaddr __TEXT 0x2000000 -read_only_relocs suppress") + else (APPLE) + # For Linux we have to use objcopy to wrap regular binaries into a linkable + # format. We use specific section names which are then referenced in a + # bespoke linker script so they can be placed at predefined VMAs. + add_custom_command( + OUTPUT openrct2_text_section.o + COMMAND objcopy --input binary --output ${OBJ_FORMAT} --binary-architecture i386 openrct2_text openrct2_text_section.o --rename-section .data=.rct2_text,contents,alloc,load,readonly,code + DEPENDS segfiles + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + add_custom_command( + OUTPUT openrct2_data_section.o + COMMAND objcopy --input binary --output ${OBJ_FORMAT} --binary-architecture i386 openrct2_data openrct2_data_section.o --rename-section .data=.rct2_data,contents,alloc,load,readonly,data + DEPENDS segfiles + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + add_custom_target(linkable_sections DEPENDS openrct2_text_section.o openrct2_data_section.o) + SET_SOURCE_FILES_PROPERTIES( + openrct2_text_section.o openrct2_data_section.o + PROPERTIES + EXTERNAL_OBJECT true + GENERATED true + ) + # can't use GLOB here, as the files don't exist yet at cmake-time + set(RCT2_SECTIONS "${CMAKE_BINARY_DIR}/openrct2_data_section.o" "${CMAKE_BINARY_DIR}/openrct2_text_section.o") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-T,\"${CMAKE_CURRENT_SOURCE_DIR}/distribution/linux/${LINKER_SCRIPT}\"") + endif (APPLE) + endif (NOT USE_MMAP) elseif (USE_MMAP) - # No dd here, can't extract data segment - message(WARNING "Sorry, your platform is not supported, you have to extract data segment manually") + # No dd here, can't extract data segment + message(WARNING "Sorry, your platform is not supported, you have to extract data segment manually") endif ((NOT DISABLE_RCT2) AND UNIX) set(DEBUG_LEVEL 0 CACHE STRING "Select debug level for compilation. Use value in range 0–3.") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDEBUG=${DEBUG_LEVEL}") @@ -248,17 +248,17 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG=${DEBUG_LEVEL}") # include lib include_directories("lib/") # add source files -file(GLOB_RECURSE ORCT2_SOURCES "src/*.c" "src/*.cpp" "src/*.h" "src/*.hpp") +file(GLOB_RECURSE ORCT2_SOURCES "src/openrct2/*.c" "src/openrct2/*.cpp" "src/openrct2/*.h" "src/openrct2/*.hpp") if (APPLE) - file(GLOB_RECURSE ORCT2_MM_SOURCES "src/*.m") - set_source_files_properties(${ORCT2_MM_SOURCES} PROPERTIES COMPILE_FLAGS "-x objective-c -fmodules") + file(GLOB_RECURSE ORCT2_MM_SOURCES "src/openrct2/*.m") + set_source_files_properties(${ORCT2_MM_SOURCES} PROPERTIES COMPILE_FLAGS "-x objective-c -fmodules") endif (APPLE) if (APPLE AND NOT USE_MMAP) - set(PIE_FLAG "-fno-pie") + set(PIE_FLAG "-fno-pie") else () - set(PIE_FLAG "-fpie") + set(PIE_FLAG "-fpie") endif () # set necessary flags to compile code as is @@ -268,78 +268,78 @@ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${TARGET_M}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS} ${PIE_FLAG}") if (MINGW) - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -static-libstdc++") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -static-libstdc++") endif () option(WITH_BREAKPAD "Enable breakpad") if (WITH_BREAKPAD) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_BREAKPAD") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_BREAKPAD") - set(BREAKPAD_DIR "/home/janisozaur/workspace/breakpad/src") - set(BREAKPAD_INCLUDE_DIR "${BREAKPAD_DIR}/src") - set(BREAKPAD_LIBRARY_DIR "${BREAKPAD_DIR}/src/client/linux") - set(BREAKPAD_LIBS breakpad_client pthread) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_BREAKPAD") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_BREAKPAD") + set(BREAKPAD_DIR "/home/janisozaur/workspace/breakpad/src") + set(BREAKPAD_INCLUDE_DIR "${BREAKPAD_DIR}/src") + set(BREAKPAD_LIBRARY_DIR "${BREAKPAD_DIR}/src/client/linux") + set(BREAKPAD_LIBS breakpad_client pthread) endif (WITH_BREAKPAD) PKG_CHECK_MODULES(LIBZIP REQUIRED libzip>=1.0) # find and include SDL2 PKG_CHECK_MODULES(SDL2 REQUIRED sdl2) if (NOT DISABLE_TTF) - PKG_CHECK_MODULES(SDL2_TTF REQUIRED SDL2_ttf) + PKG_CHECK_MODULES(SDL2_TTF REQUIRED SDL2_ttf) endif (NOT DISABLE_TTF) if (STATIC) - if (NOT DISABLE_TTF) - # FreeType is required by SDL2_ttf, but not wired up properly in package - PKG_CHECK_MODULES(FREETYPE REQUIRED freetype2) - endif (NOT DISABLE_TTF) - SET(SDL2LIBS ${SDL2_STATIC_LIBRARIES} ${SDL2_TTF_STATIC_LIBRARIES} ${FREETYPE_STATIC_LIBRARIES}) + if (NOT DISABLE_TTF) + # FreeType is required by SDL2_ttf, but not wired up properly in package + PKG_CHECK_MODULES(FREETYPE REQUIRED freetype2) + endif (NOT DISABLE_TTF) + SET(SDL2LIBS ${SDL2_STATIC_LIBRARIES} ${SDL2_TTF_STATIC_LIBRARIES} ${FREETYPE_STATIC_LIBRARIES}) else (STATIC) - SET(SDL2LIBS ${SDL2_LIBRARIES} ${SDL2_TTF_LIBRARIES}) + SET(SDL2LIBS ${SDL2_LIBRARIES} ${SDL2_TTF_LIBRARIES}) endif (STATIC) if (STATIC) - set(STATIC_START "-static") - SET(REQUIREDLIBS ${PNG_STATIC_LIBRARIES} ${JANSSON_STATIC_LIBRARIES} ${ZLIB_STATIC_LIBRARIES} ${SSL_STATIC_LIBRARIES} ${LIBZIP_STATIC_LIBRARIES}) + set(STATIC_START "-static") + SET(REQUIREDLIBS ${PNG_STATIC_LIBRARIES} ${JANSSON_STATIC_LIBRARIES} ${ZLIB_STATIC_LIBRARIES} ${SSL_STATIC_LIBRARIES} ${LIBZIP_STATIC_LIBRARIES}) else (STATIC) - SET(REQUIREDLIBS ${PNG_LIBRARIES} ${JANSSON_LIBRARIES} ${ZLIB_LIBRARIES} ${SSL_LIBRARIES} ${LIBZIP_LIBRARIES}) + SET(REQUIREDLIBS ${PNG_LIBRARIES} ${JANSSON_LIBRARIES} ${ZLIB_LIBRARIES} ${SSL_LIBRARIES} ${LIBZIP_LIBRARIES}) endif (STATIC) if (NOT DISABLE_OPENGL) - if (WIN32) - # Curl depends on openssl and ws2 in mingw builds, but is not wired up in pkg-config - set(GLLIBS opengl32) - # mingw complains about "%zu" not being a valid format specifier for printf, unless we - # tell it that it is - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__USE_MINGW_ANSI_STDIO=1") - elseif (APPLE) - # GL doesn't work nicely with macOS, while find_package doesn't work with multiarch on Ubuntu. - find_package(OpenGL REQUIRED) - set(GLLIBS ${OPENGL_LIBRARY}) - else (WIN32) - PKG_CHECK_MODULES(GL REQUIRED gl) - set(GLLIBS ${GL_LIBRARIES}) - endif (WIN32) + if (WIN32) + # Curl depends on openssl and ws2 in mingw builds, but is not wired up in pkg-config + set(GLLIBS opengl32) + # mingw complains about "%zu" not being a valid format specifier for printf, unless we + # tell it that it is + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__USE_MINGW_ANSI_STDIO=1") + elseif (APPLE) + # GL doesn't work nicely with macOS, while find_package doesn't work with multiarch on Ubuntu. + find_package(OpenGL REQUIRED) + set(GLLIBS ${OPENGL_LIBRARY}) + else (WIN32) + PKG_CHECK_MODULES(GL REQUIRED gl) + set(GLLIBS ${GL_LIBRARIES}) + endif (WIN32) endif (NOT DISABLE_OPENGL) if (NOT DISABLE_HTTP_TWITCH) - PKG_CHECK_MODULES(LIBCURL REQUIRED libcurl) - if (WIN32) - # Curl depends on openssl and ws2 in mingw builds, but is not wired up in pkg-config - set(WSLIBS ws2_32) - endif (WIN32) - if (STATIC) - SET(HTTPLIBS ${LIBCURL_STATIC_LIBRARIES} ${WSLIBS}) - else (STATIC) - SET(HTTPLIBS ${LIBCURL_LIBRARIES} ${WSLIBS}) - endif (STATIC) + PKG_CHECK_MODULES(LIBCURL REQUIRED libcurl) + if (WIN32) + # Curl depends on openssl and ws2 in mingw builds, but is not wired up in pkg-config + set(WSLIBS ws2_32) + endif (WIN32) + if (STATIC) + SET(HTTPLIBS ${LIBCURL_STATIC_LIBRARIES} ${WSLIBS}) + else (STATIC) + SET(HTTPLIBS ${LIBCURL_LIBRARIES} ${WSLIBS}) + endif (STATIC) endif (NOT DISABLE_HTTP_TWITCH) PKG_CHECK_MODULES(SPEEX REQUIRED speexdsp) if (UNIX AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "BSD") - # Include libdl for dlopen - set(DLLIB dl) + # Include libdl for dlopen + set(DLLIB dl) endif () INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS} ${LIBCURL_INCLUDE_DIRS} ${JANSSON_INCLUDE_DIRS} ${SPEEX_INCLUDE_DIRS} ${PNG_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${BREAKPAD_INCLUDE_DIR} ${SSL_INCLUDE_DIRS} ${LIBZIP_INCLUDE_DIRS}) @@ -347,39 +347,39 @@ INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS} ${LIBCURL_INCLUDE_DIRS} ${JANSSON_INCLU LINK_DIRECTORIES(${SDL2_LIBRARY_DIRS} ${JANSSON_LIBRARY_DIRS} ${LIBCURL_LIBRARY_DIRS} ${PNG_LIBRARY_DIRS} ${ZLIB_LIBRARY_DIRS} ${BREAKPAD_LIBRARY_DIR} ${SSL_LIBRARY_DIRS} ${LIBZIP_LIBRARY_DIRS}) if (NOT DISABLE_RCT2) - # Disable optimizations for addresses.c for all compilers, to allow optimized - # builds without need for -fno-omit-frame-pointer - set_source_files_properties(src/addresses.c PROPERTIES COMPILE_FLAGS -O0) + # Disable optimizations for addresses.c for all compilers, to allow optimized + # builds without need for -fno-omit-frame-pointer + set_source_files_properties(src/openrct2/addresses.c PROPERTIES COMPILE_FLAGS -O0) endif (NOT DISABLE_RCT2) if (WIN32) - # build as library for now, replace with add_executable - if (USE_MMAP OR DISABLE_RCT2) - add_executable(${PROJECT} ${ORCT2_SOURCES} ${SPEEX_SOURCES}) - else () - add_library(${PROJECT} SHARED ${ORCT2_SOURCES} ${SPEEX_SOURCES}) - endif () + # build as library for now, replace with add_executable + if (USE_MMAP OR DISABLE_RCT2) + add_executable(${PROJECT} ${ORCT2_SOURCES} ${SPEEX_SOURCES}) + else () + add_library(${PROJECT} SHARED ${ORCT2_SOURCES} ${SPEEX_SOURCES}) + endif () else (WIN32) - add_executable(${PROJECT} ${ORCT2_SOURCES} ${ORCT2_MM_SOURCES} ${RCT2_SECTIONS}) - if (NOT DISABLE_RCT2) - add_dependencies(${PROJECT} segfiles) - if (NOT APPLE AND NOT USE_MMAP) - add_dependencies(${PROJECT} linkable_sections) - endif () - endif (NOT DISABLE_RCT2) - add_custom_command( - OUTPUT g2.dat - COMMAND ./openrct2 sprite build ${CMAKE_BINARY_DIR}/g2.dat ${CMAKE_CURRENT_SOURCE_DIR}/resources/g2/ - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - add_custom_target(g2 DEPENDS ${PROJECT} g2.dat) + add_executable(${PROJECT} ${ORCT2_SOURCES} ${ORCT2_MM_SOURCES} ${RCT2_SECTIONS}) + if (NOT DISABLE_RCT2) + add_dependencies(${PROJECT} segfiles) + if (NOT APPLE AND NOT USE_MMAP) + add_dependencies(${PROJECT} linkable_sections) + endif () + endif (NOT DISABLE_RCT2) + add_custom_command( + OUTPUT g2.dat + COMMAND ./openrct2 sprite build ${CMAKE_BINARY_DIR}/g2.dat ${CMAKE_CURRENT_SOURCE_DIR}/resources/g2/ + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + add_custom_target(g2 DEPENDS ${PROJECT} g2.dat) endif (WIN32) if (UNIX AND NOT APPLE AND NOT DISABLE_TTF) - # FontConfig for TrueType fonts. - PKG_CHECK_MODULES(FONTCONFIG REQUIRED fontconfig) - INCLUDE_DIRECTORIES(${FONTCONFIG_INCLUDE_DIRS}) - TARGET_LINK_LIBRARIES(${PROJECT} ${FONTCONFIG_LIBRARIES}) + # FontConfig for TrueType fonts. + PKG_CHECK_MODULES(FONTCONFIG REQUIRED fontconfig) + INCLUDE_DIRECTORIES(${FONTCONFIG_INCLUDE_DIRS}) + TARGET_LINK_LIBRARIES(${PROJECT} ${FONTCONFIG_LIBRARIES}) endif (UNIX AND NOT APPLE AND NOT DISABLE_TTF) @@ -396,8 +396,8 @@ TARGET_LINK_LIBRARIES(${PROJECT} ${GLLIBS}) TARGET_LINK_LIBRARIES(${PROJECT} ${STATIC_START} ${SDL2LIBS} ${HTTPLIBS} ${NETWORKLIBS} ${SPEEX_LIBRARIES} ${DLLIB} ${REQUIREDLIBS} ${BREAKPAD_LIBS}) if (APPLE OR STATIC OR ${CMAKE_SYSTEM_NAME} MATCHES "BSD") - FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c) - TARGET_LINK_LIBRARIES(${PROJECT} ${ICONV_LIBRARIES}) + FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c) + TARGET_LINK_LIBRARIES(${PROJECT} ${ICONV_LIBRARIES}) endif () # Don't recurse, grab all *.txt and *.md files @@ -424,20 +424,20 @@ install(FILES resources/logo/icon_flag.svg DESTINATION share/icons/hicolor/scala install(FILES distribution/linux/openrct2.desktop DESTINATION share/applications) if (WITH_TESTS) - enable_testing() - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test/tests/) + enable_testing() + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test/tests/) endif () if (UNIX AND (NOT USE_MMAP) AND (NOT DISABLE_RCT2) AND (FORCE32)) - set(OPENRCT2_SRCPATH "src/openrct2") - file(GLOB_RECURSE ORCT2_RIDE_SOURCES "${OPENRCT2_SRCPATH}/ride/*/*.c") - file(GLOB_RECURSE ORCT2_RIDE_DEP_SOURCES "${OPENRCT2_SRCPATH}/ride/ride_data.c" "${OPENRCT2_SRCPATH}/ride/track_data.c" "${OPENRCT2_SRCPATH}/ride/track_data_old.c" "${OPENRCT2_SRCPATH}/ride/track_paint.c" "${OPENRCT2_SRCPATH}/rct2/addresses.c" "${OPENRCT2_SRCPATH}/diagnostic.c" "${OPENRCT2_SRCPATH}/rct2/hook.c" "${OPENRCT2_SRCPATH}/paint/map_element/map_element.c" "${OPENRCT2_SRCPATH}/paint/paint_helpers.c") - file(GLOB_RECURSE ORCT2_TESTPAINT_SOURCES "test/testpaint/*.c" "test/testpaint/*.cpp" "test/testpaint/*.h") + set(OPENRCT2_SRCPATH "src/openrct2") + file(GLOB_RECURSE ORCT2_RIDE_SOURCES "${OPENRCT2_SRCPATH}/ride/*/*.c") + file(GLOB_RECURSE ORCT2_RIDE_DEP_SOURCES "${OPENRCT2_SRCPATH}/ride/ride_data.c" "${OPENRCT2_SRCPATH}/ride/track_data.c" "${OPENRCT2_SRCPATH}/ride/track_data_old.c" "${OPENRCT2_SRCPATH}/ride/track_paint.c" "${OPENRCT2_SRCPATH}/rct2/addresses.c" "${OPENRCT2_SRCPATH}/diagnostic.c" "${OPENRCT2_SRCPATH}/rct2/hook.c" "${OPENRCT2_SRCPATH}/paint/map_element/map_element.c" "${OPENRCT2_SRCPATH}/paint/paint_helpers.c") + file(GLOB_RECURSE ORCT2_TESTPAINT_SOURCES "test/testpaint/*.c" "test/testpaint/*.cpp" "test/testpaint/*.h") - add_executable(testpaint EXCLUDE_FROM_ALL ${ORCT2_RIDE_SOURCES} ${ORCT2_RIDE_DEP_SOURCES} ${ORCT2_TESTPAINT_SOURCES} ${RCT2_SECTIONS}) - target_include_directories(testpaint PRIVATE "src/") - set_target_properties(testpaint PROPERTIES COMPILE_FLAGS "-DNO_VEHICLES -D__TESTPAINT__ -Wno-unused") - add_dependencies(testpaint segfiles) + add_executable(testpaint EXCLUDE_FROM_ALL ${ORCT2_RIDE_SOURCES} ${ORCT2_RIDE_DEP_SOURCES} ${ORCT2_TESTPAINT_SOURCES} ${RCT2_SECTIONS}) + target_include_directories(testpaint PRIVATE "src/") + set_target_properties(testpaint PROPERTIES COMPILE_FLAGS "-DNO_VEHICLES -D__TESTPAINT__ -Wno-unused") + add_dependencies(testpaint segfiles) endif () set(CPACK_PACKAGE_VERSION_MAJOR 0) diff --git a/appveyor.yml b/appveyor.yml index 0f85f297d4..707866e324 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,7 +14,7 @@ environment: OPENRCT2_ORG_TOKEN: secure: leQX3xCQpmBLGuMqrxjFlzexDt96ypNRMM5TTRVHbGE8PwVg9crgeykLc2BIZU6HDHveJCHqh2cGMdHtHYJYcw== BUILD_SERVER: AppVeyor - PATH: $(PATH);C:\Program Files (x86)\Windows Kits\10\bin\x86 + PATH: $(PATH);C:\Program Files (x86)\Windows Kits\10\bin\x86;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin install: - ps: >- .\scripts\ps\appveyor_install.ps1 diff --git a/distribution/windows/install.nsi b/distribution/windows/install.nsi index 0607e5c3d6..92a919333f 100644 --- a/distribution/windows/install.nsi +++ b/distribution/windows/install.nsi @@ -152,6 +152,8 @@ 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}" @@ -218,6 +220,8 @@ Section "Uninstall" Delete "$INSTDIR\readme.txt" 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.proj b/openrct2.proj index 17be4373d3..a2bbc5c1ec 100644 --- a/openrct2.proj +++ b/openrct2.proj @@ -40,6 +40,8 @@ $(DistDir)windows\install.nsi $(TargetDir)openrct2.exe + $(TargetDir)openrct2.com + $(TargetDir)openrct2.dll $(TargetDir)data\g2.dat $(DistDir)windows\code-sign-key-openrct2.org.pfx @@ -75,15 +77,22 @@ + + - + + + + + + @@ -137,6 +146,7 @@ + @@ -179,17 +189,8 @@ - - - DebugTests - ReleaseTests - $(SlnProperties);Configuration=$(Configuration) - - - - - + @@ -204,6 +205,12 @@ StandardOutputImportance="low" /> + + + + + + +#include +#include +#include +#include + +#define DLLEXPORT extern "C" __declspec(dllexport) + +static char * * GetCommandLineArgs(int argc, wchar_t * * argvW); +static void FreeCommandLineArgs(int argc, char * * argv); +static char * ConvertUTF16toUTF8(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; + } + + int exitCode = RunOpenRCT2(argc, 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 false; + } + + // Convert to UTF-8 + for (int i = 0; i < argc; i++) + { + argv[i] = ConvertUTF16toUTF8(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 * ConvertUTF16toUTF8(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 new file mode 100644 index 0000000000..79367987c9 --- /dev/null +++ b/src/openrct2-dll/openrct2-dll.vcxproj @@ -0,0 +1,63 @@ + + + + ..\..\ + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {7B8DB129-79EF-417E-B372-8A18E009D261} + openrct2-dll + openrct2-dll + + + DynamicLibrary + + + + openrct2 + $(SolutionDir)bin;$(LibraryPath) + + + + __NOENTRYPOINT__;%(PreprocessorDefinitions) + + + + + $(IntDir)\%(RelativeDir) + $(OPENRCT2_CL_ADDITIONALOPTIONS) %(AdditionalOptions) + + + libopenrct2.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 new file mode 100644 index 0000000000..24084a6c27 --- /dev/null +++ b/src/openrct2-win/openrct2-win.cpp @@ -0,0 +1,33 @@ +#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers +/***************************************************************************** + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * OpenRCT2 is the work of many authors, a full list can be found in contributors.md + * For more information, visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * A full copy of the GNU General Public License can be found in licence.txt + *****************************************************************************/ +#pragma endregion + +#define WIN32_LEAN_AND_MEAN + +#include + +// Enable visual styles +#pragma comment(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); + +/** + * Windows entry point to OpenRCT2 with a console window using a traditional C main function. + */ +int wmain(int argc, wchar_t * * argvW, wchar_t * envp) +{ + return LaunchOpenRCT2(argc, argvW); +} diff --git a/src/openrct2-win/openrct2-win.vcxproj b/src/openrct2-win/openrct2-win.vcxproj new file mode 100644 index 0000000000..dcc0fade85 --- /dev/null +++ b/src/openrct2-win/openrct2-win.vcxproj @@ -0,0 +1,64 @@ + + + + ..\..\ + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {7A9A57D5-7006-4208-A290-5491BA3C8808} + openrct2-win + openrct2-win + + + Application + + + + openrct2 + $(SolutionDir)bin;$(LibraryPath) + + + + __NOENTRYPOINT__;%(PreprocessorDefinitions) + + + + + $(IntDir)\%(RelativeDir) + $(OPENRCT2_CL_ADDITIONALOPTIONS) %(AdditionalOptions) + + + openrct2.lib;%(AdditionalDependencies) + $(OutDir)openrct2-win.pdb + Console + + + MachineX86 + MachineX64 + + + + + + + + + + \ No newline at end of file diff --git a/src/openrct2/OpenRCT2.h b/src/openrct2/OpenRCT2.h index a601dd6798..b52494aeb3 100644 --- a/src/openrct2/OpenRCT2.h +++ b/src/openrct2/OpenRCT2.h @@ -87,6 +87,10 @@ extern "C" int cmdline_run(const char * * argv, int argc); +#ifdef __WINDOWS__ + int RunOpenRCT2(int argc, char * * argv); +#endif + #ifdef __cplusplus } #endif diff --git a/src/openrct2/cmdline/RootCommands.cpp b/src/openrct2/cmdline/RootCommands.cpp index fefd5c8869..0fe7173b17 100644 --- a/src/openrct2/cmdline/RootCommands.cpp +++ b/src/openrct2/cmdline/RootCommands.cpp @@ -39,10 +39,6 @@ extern "C" #define IMPLIES_SILENT_BREAKPAD #endif // USE_BREAKPAD -#if defined(__WINDOWS__) && !defined(DEBUG) - #define __PROVIDE_CONSOLE__ 1 -#endif // defined(__WINDOWS__) && !defined(DEBUG) - #ifndef DISABLE_NETWORK int gNetworkStart = NETWORK_MODE_NONE; char gNetworkStartHost[128]; @@ -51,10 +47,6 @@ int gNetworkStartPort = NETWORK_DEFAULT_PORT; static uint32 _port = 0; #endif -#ifdef __PROVIDE_CONSOLE__ - static bool _provideConsole; -#endif - static bool _help = false; static bool _version = false; static bool _noInstall = false; @@ -77,9 +69,6 @@ static const CommandLineOptionDefinition StandardOptions[] { CMDLINE_TYPE_SWITCH, &_about, NAC, "about", "show information about " OPENRCT2_NAME }, { CMDLINE_TYPE_SWITCH, &_verbose, NAC, "verbose", "log verbose messages" }, { CMDLINE_TYPE_SWITCH, &_headless, NAC, "headless", "run " OPENRCT2_NAME " headless" IMPLIES_SILENT_BREAKPAD }, -#ifdef __PROVIDE_CONSOLE__ - { CMDLINE_TYPE_SWITCH, &_provideConsole, NAC, "console", "creates a new or attaches to an existing console window for standard output" }, -#endif #ifndef DISABLE_NETWORK { CMDLINE_TYPE_INTEGER, &_port, NAC, "port", "port to use for hosting or joining a server" }, #endif @@ -166,13 +155,6 @@ exitcode_t CommandLine::HandleCommandDefault() { exitcode_t result = EXITCODE_CONTINUE; -#ifdef __PROVIDE_CONSOLE__ - if (_provideConsole) - { - platform_windows_open_console(); - } -#endif - if (_about) { PrintAbout(); diff --git a/src/openrct2/openrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj similarity index 95% rename from src/openrct2/openrct2.vcxproj rename to src/openrct2/libopenrct2.vcxproj index 2cd5814180..e585fe0d34 100644 --- a/src/openrct2/openrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -12,14 +12,6 @@ Debug x64 - - DebugTests - Win32 - - - DebugTests - x64 - Release Win32 @@ -28,35 +20,23 @@ Release x64 - - ReleaseTests - Win32 - - - ReleaseTests - x64 - {D24D94F6-2A74-480C-B512-629C306CE92F} - openrct2 - openrct2 + openrct2-lib + libopenrct2 - Application + StaticLibrary DynamicLibrary - - StaticLibrary - USE_BREAKPAD;%(PreprocessorDefinitions) - __NOENTRYPOINT__;%(PreprocessorDefinitions) @@ -64,10 +44,6 @@ $(IntDir)\%(RelativeDir) $(OPENRCT2_CL_ADDITIONALOPTIONS) %(AdditionalOptions) - - Console - Windows - MachineX86 MachineX64 diff --git a/src/openrct2/management/research.c b/src/openrct2/management/research.c index 2c5f763691..ca18285b83 100644 --- a/src/openrct2/management/research.c +++ b/src/openrct2/management/research.c @@ -183,63 +183,69 @@ void research_finish_item(sint32 entryIndex) int base_ride_type = (entryIndex >> 8) & 0xFF; int rideEntryIndex = entryIndex & 0xFF; rct_ride_entry *rideEntry = get_ride_entry(rideEntryIndex); - ride_type_set_invented(base_ride_type); - gResearchedTrackTypesA[base_ride_type] = (RideTypePossibleTrackConfigurations[base_ride_type] ) & 0xFFFFFFFFULL; - gResearchedTrackTypesB[base_ride_type] = (RideTypePossibleTrackConfigurations[base_ride_type] >> 32ULL) & 0xFFFFFFFFULL; + if (rideEntry != NULL && rideEntry != (rct_ride_entry *)-1) + { + ride_type_set_invented(base_ride_type); + gResearchedTrackTypesA[base_ride_type] = (RideTypePossibleTrackConfigurations[base_ride_type]) & 0xFFFFFFFFULL; + gResearchedTrackTypesB[base_ride_type] = (RideTypePossibleTrackConfigurations[base_ride_type] >> 32ULL) & 0xFFFFFFFFULL; - if (RideData4[base_ride_type].flags & RIDE_TYPE_FLAG4_3) { - int ebx = RideData4[base_ride_type].alternate_type; - gResearchedTrackTypesA[ebx] = (RideTypePossibleTrackConfigurations[ebx] ) & 0xFFFFFFFFULL; - gResearchedTrackTypesB[ebx] = (RideTypePossibleTrackConfigurations[ebx] >> 32ULL) & 0xFFFFFFFFULL; - } + if (RideData4[base_ride_type].flags & RIDE_TYPE_FLAG4_3) { + int ebx = RideData4[base_ride_type].alternate_type; + gResearchedTrackTypesA[ebx] = (RideTypePossibleTrackConfigurations[ebx]) & 0xFFFFFFFFULL; + gResearchedTrackTypesB[ebx] = (RideTypePossibleTrackConfigurations[ebx] >> 32ULL) & 0xFFFFFFFFULL; + } - ride_entry_set_invented(rideEntryIndex); + ride_entry_set_invented(rideEntryIndex); - if (!(rideEntry->flags & RIDE_ENTRY_FLAG_SEPARATE_RIDE)) { - for (int i = 0; i < 128; i++) { - rct_ride_entry *rideEntry2 = get_ride_entry(i); - if (rideEntry2 == (rct_ride_entry*)-1) - continue; - if ((rideEntry2->flags & RIDE_ENTRY_FLAG_SEPARATE_RIDE)) - continue; + if (!(rideEntry->flags & RIDE_ENTRY_FLAG_SEPARATE_RIDE)) { + for (int i = 0; i < 128; i++) { + rct_ride_entry *rideEntry2 = get_ride_entry(i); + if (rideEntry2 == (rct_ride_entry*)-1) + continue; + if ((rideEntry2->flags & RIDE_ENTRY_FLAG_SEPARATE_RIDE)) + continue; - if (rideEntry2->ride_type[0] == base_ride_type || - rideEntry2->ride_type[1] == base_ride_type || - rideEntry2->ride_type[2] == base_ride_type - ) { - ride_entry_set_invented(i); + if (rideEntry2->ride_type[0] == base_ride_type || + rideEntry2->ride_type[1] == base_ride_type || + rideEntry2->ride_type[2] == base_ride_type + ) { + ride_entry_set_invented(i); + } } } - } - set_format_arg(0, rct_string_id, ((rideEntry->flags & RIDE_ENTRY_FLAG_SEPARATE_RIDE_NAME)) ? - rideEntry->name : RideNaming[base_ride_type].name); + set_format_arg(0, rct_string_id, ((rideEntry->flags & RIDE_ENTRY_FLAG_SEPARATE_RIDE_NAME)) ? + rideEntry->name : RideNaming[base_ride_type].name); - if (!gSilentResearch) { - if (gConfigNotifications.ride_researched) { - news_item_add_to_queue(NEWS_ITEM_RESEARCH, STR_NEWS_ITEM_RESEARCH_NEW_RIDE_AVAILABLE, entryIndex); + if (!gSilentResearch) { + if (gConfigNotifications.ride_researched) { + news_item_add_to_queue(NEWS_ITEM_RESEARCH, STR_NEWS_ITEM_RESEARCH_NEW_RIDE_AVAILABLE, entryIndex); + } } - } - research_invalidate_related_windows(); + research_invalidate_related_windows(); + } } else { // Scenery rct_scenery_set_entry *scenerySetEntry = get_scenery_group_entry(entryIndex & 0xFFFF); - for (int i = 0; i < scenerySetEntry->entry_count; i++) { - int subSceneryEntryIndex = scenerySetEntry->scenery_entries[i]; - gResearchedSceneryItems[subSceneryEntryIndex >> 5] |= 1UL << (subSceneryEntryIndex & 0x1F); - } - - set_format_arg(0, rct_string_id, scenerySetEntry->name); - - if (!gSilentResearch) { - if (gConfigNotifications.ride_researched) { - news_item_add_to_queue(NEWS_ITEM_RESEARCH, STR_NEWS_ITEM_RESEARCH_NEW_SCENERY_SET_AVAILABLE, entryIndex); + if (scenerySetEntry != NULL && scenerySetEntry != (rct_scenery_set_entry *)-1) + { + for (int i = 0; i < scenerySetEntry->entry_count; i++) { + int subSceneryEntryIndex = scenerySetEntry->scenery_entries[i]; + gResearchedSceneryItems[subSceneryEntryIndex >> 5] |= 1UL << (subSceneryEntryIndex & 0x1F); } - } - research_invalidate_related_windows(); - init_scenery(); + set_format_arg(0, rct_string_id, scenerySetEntry->name); + + if (!gSilentResearch) { + if (gConfigNotifications.ride_researched) { + news_item_add_to_queue(NEWS_ITEM_RESEARCH, STR_NEWS_ITEM_RESEARCH_NEW_SCENERY_SET_AVAILABLE, entryIndex); + } + } + + research_invalidate_related_windows(); + init_scenery(); + } } } diff --git a/src/openrct2/platform/platform.h b/src/openrct2/platform/platform.h index 27cc648cfb..32652a44fb 100644 --- a/src/openrct2/platform/platform.h +++ b/src/openrct2/platform/platform.h @@ -220,8 +220,6 @@ void core_init(); #include #undef GetMessage - void platform_windows_open_console(); - void platform_windows_close_console(); int windows_get_registry_install_info(rct2_install_info *installInfo, char *source, char *font, uint8 charset); HWND windows_get_window_handle(); void platform_setup_file_associations(); diff --git a/src/openrct2/platform/shared.c b/src/openrct2/platform/shared.c index 6ee2e3ac89..d4673430ab 100644 --- a/src/openrct2/platform/shared.c +++ b/src/openrct2/platform/shared.c @@ -643,10 +643,6 @@ void platform_free() platform_close_window(); SDL_Quit(); - -#ifdef __WINDOWS__ - platform_windows_close_console(); -#endif } void platform_start_text_input(utf8* buffer, int max_length) diff --git a/src/openrct2/platform/windows.c b/src/openrct2/platform/windows.c index 4c90cb9b64..517f827aa5 100644 --- a/src/openrct2/platform/windows.c +++ b/src/openrct2/platform/windows.c @@ -47,7 +47,6 @@ static utf8 _userDataDirectoryPath[MAX_PATH] = { 0 }; static utf8 _openrctDataDirectoryPath[MAX_PATH] = { 0 }; -static bool _consoleIsAttached = false; utf8 **windows_get_command_line_args(int *outNumArgs); @@ -55,38 +54,10 @@ utf8 **windows_get_command_line_args(int *outNumArgs); static HMODULE _dllModule = NULL; -#if defined(NO_RCT2) && !defined(__NOENTRYPOINT__) - -/** - * Windows entry point to OpenRCT2 without a console window. - */ -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) -{ - _dllModule = hInstance; - - core_init(); - - int argc; - char ** argv = (char**)windows_get_command_line_args(&argc); - int runGame = cmdline_run((const char **)argv, argc); - - // Free argv - for (int i = 0; i < argc; i++) { - free(argv[i]); - } - free(argv); - - if (runGame == 1) { - openrct2_launch(); - } - - return gExitCode; -} - /** * Windows entry point to OpenRCT2 with a console window using a traditional C main function. */ -int main(int argc, char *argv[]) +int RunOpenRCT2(int argc, char * * argv) { HINSTANCE hInstance = GetModuleHandle(NULL); _dllModule = hInstance; @@ -101,6 +72,17 @@ int main(int argc, char *argv[]) return gExitCode; } +#ifdef NO_RCT2 + +#ifdef __MINGW32__ + +int main(int argc, char **argv) +{ + return RunOpenRCT2(argc, argv); +} + +#endif + #else /* DllMain is already defined in one of static libraries we implicitly depend @@ -153,28 +135,6 @@ __declspec(dllexport) int StartOpenRCT(HINSTANCE hInstance, HINSTANCE hPrevInsta #endif // NO_RCT2 -void platform_windows_open_console() -{ - if (!AttachConsole(ATTACH_PARENT_PROCESS)) { - if (!AllocConsole()) { - return; - } - } - - freopen("CONIN$", "r", stdin); - freopen("CONOUT$", "w", stdout); - freopen("CONOUT$", "w", stderr); - _consoleIsAttached = true; -} - -void platform_windows_close_console() -{ - if (_consoleIsAttached) { - _consoleIsAttached = false; - FreeConsole(); - } -} - utf8 **windows_get_command_line_args(int *outNumArgs) { int argc; diff --git a/test/tests/tests.vcxproj b/test/tests/tests.vcxproj index d10bc48bf3..5b866801fb 100644 --- a/test/tests/tests.vcxproj +++ b/test/tests/tests.vcxproj @@ -5,20 +5,20 @@ $(SolutionDir)lib\googletest\googletest - - DebugTests + + Debug Win32 - - ReleaseTests + + Release Win32 - - DebugTests + + Debug x64 - - ReleaseTests + + Release x64 @@ -33,7 +33,7 @@ $(SolutionDir)bin\tests\ - $(GtestDir);$(GtestDir)\include;$(SolutionDir)src\openrct2;$(IncludePath) + $(GtestDir);$(GtestDir)\include;$(IncludePath) $(SolutionDir)bin;$(LibraryPath) @@ -41,7 +41,7 @@ GTEST_LANG_CXX11;%(PreprocessorDefinitions) - openrct2.lib;%(AdditionalDependencies) + libopenrct2.lib;%(AdditionalDependencies) Console