Merge pull request #5027 from IntelOrca/refactor/vs-static-lib

This merge does several things:
* Changes all the code to be built as a static library, `libopenrct2.lib`
* Adds two new projects to produce `openrct2.dll` and `openrct2.exe`
* Adds a build step to create `openrct2.com`

This is to remove the test configurations and make building the test projects quicker and simpler.
It also distributes two very small shims, `openrct2.exe` and `openrct2.com` which are a GUI windows app and console app respectively. This simplifies the experience of using openrct2 on the command line as .com has higher precedence. `--console` is therefore no longer necessary.

`libopenrct2.lib` will probably be the beginning of several static libraries which make up the game as we will split up the UI from the core logic and possibly more.
This commit is contained in:
Ted John 2017-01-10 20:44:27 +00:00
commit f94daa08df
17 changed files with 538 additions and 356 deletions

View File

@ -24,7 +24,7 @@ set (ORCT2_RESOURCE_DIR ${CMAKE_INSTALL_PREFIX}/share/${PROJECT}/)
project(${PROJECT}) project(${PROJECT})
if (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR) 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() endif()
add_definitions(-DORCT2_RESOURCE_DIR="${ORCT2_RESOURCE_DIR}") add_definitions(-DORCT2_RESOURCE_DIR="${ORCT2_RESOURCE_DIR}")
add_definitions(-DHAVE_CONFIG_H) add_definitions(-DHAVE_CONFIG_H)
@ -32,31 +32,31 @@ add_definitions(-DCURL_STATICLIB)
# Define current git branch. # Define current git branch.
execute_process( execute_process(
COMMAND git rev-parse --abbrev-ref HEAD COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE OPENRCT2_BRANCH OUTPUT_VARIABLE OPENRCT2_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET ERROR_QUIET
) )
add_definitions(-DOPENRCT2_BRANCH="${OPENRCT2_BRANCH}") add_definitions(-DOPENRCT2_BRANCH="${OPENRCT2_BRANCH}")
# Define commit hash. # Define commit hash.
execute_process( execute_process(
COMMAND git rev-parse HEAD COMMAND git rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE OPENRCT2_COMMIT_SHA1 OUTPUT_VARIABLE OPENRCT2_COMMIT_SHA1
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET ERROR_QUIET
) )
add_definitions(-DOPENRCT2_COMMIT_SHA1="${OPENRCT2_COMMIT_SHA1}") add_definitions(-DOPENRCT2_COMMIT_SHA1="${OPENRCT2_COMMIT_SHA1}")
# Define short commit hash. # Define short commit hash.
execute_process( execute_process(
COMMAND git rev-parse --short HEAD COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE OPENRCT2_COMMIT_SHA1_SHORT OUTPUT_VARIABLE OPENRCT2_COMMIT_SHA1_SHORT
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET ERROR_QUIET
) )
add_definitions(-DOPENRCT2_COMMIT_SHA1_SHORT="${OPENRCT2_COMMIT_SHA1_SHORT}") 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 # Needed for linking with non-broken OpenSSL on Apple platforms
if (APPLE) 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) endif (APPLE)
# Options # 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 # On mingw all code is already PIC, this will avoid compiler error on redefining this option
if(NOT MINGW) if(NOT MINGW)
set(COMMON_COMPILE_OPTIONS "${COMMON_COMPILE_OPTIONS} -fPIC") set(COMMON_COMPILE_OPTIONS "${COMMON_COMPILE_OPTIONS} -fPIC")
endif() endif()
if (NOT DISABLE_RCT2) if (NOT DISABLE_RCT2)
set (FORCE32 ON) set (FORCE32 ON)
message("DISABLE_RCT2 implies FORCE32") message("DISABLE_RCT2 implies FORCE32")
endif() endif()
if (DISABLE_HTTP_TWITCH) if (DISABLE_HTTP_TWITCH)
add_definitions(-DDISABLE_HTTP -DDISABLE_TWITCH) add_definitions(-DDISABLE_HTTP -DDISABLE_TWITCH)
endif (DISABLE_HTTP_TWITCH) endif (DISABLE_HTTP_TWITCH)
if (DISABLE_TTF) if (DISABLE_TTF)
add_definitions(-DNO_TTF) add_definitions(-DNO_TTF)
endif (DISABLE_TTF) endif (DISABLE_TTF)
# Launchpad turns on -Wdate-time for compilers that support it, this shouldn't break our build # 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) ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_WRITE_STRINGS -Wno-error=date-time)
if (FORCE32) if (FORCE32)
set(TARGET_M "-m32") set(TARGET_M "-m32")
endif() endif()
if (FORCE32) if (FORCE32)
set(OBJ_FORMAT "elf32-i386") set(OBJ_FORMAT "elf32-i386")
set(LINKER_SCRIPT "ld_script_i386.xc") set(LINKER_SCRIPT "ld_script_i386.xc")
endif () endif ()
if (DISABLE_OPENGL) if (DISABLE_OPENGL)
add_definitions(-DDISABLE_OPENGL) add_definitions(-DDISABLE_OPENGL)
else (DISABLE_OPENGL) else (DISABLE_OPENGL)
# Makes OpenGL function get queried in run-time rather than linked-in # Makes OpenGL function get queried in run-time rather than linked-in
add_definitions(-DOPENGL_NO_LINK) add_definitions(-DOPENGL_NO_LINK)
endif (DISABLE_OPENGL) endif (DISABLE_OPENGL)
if (USE_MMAP) if (USE_MMAP)
add_definitions(-DUSE_MMAP) add_definitions(-DUSE_MMAP)
endif (USE_MMAP) endif (USE_MMAP)
if (DISABLE_NETWORK) if (DISABLE_NETWORK)
add_definitions(-DDISABLE_NETWORK) add_definitions(-DDISABLE_NETWORK)
else (DISABLE_NETWORK) else (DISABLE_NETWORK)
if (WIN32) if (WIN32)
SET(NETWORKLIBS ${NETWORKLIBS} ws2_32) SET(NETWORKLIBS ${NETWORKLIBS} ws2_32)
endif (WIN32) endif (WIN32)
# If you are on macOS, CMake might try using system-provided OpenSSL. # If you are on macOS, CMake might try using system-provided OpenSSL.
# This is too old and will not work. # This is too old and will not work.
PKG_CHECK_MODULES(SSL REQUIRED openssl>=1.0.0) PKG_CHECK_MODULES(SSL REQUIRED openssl>=1.0.0)
endif (DISABLE_NETWORK) endif (DISABLE_NETWORK)
if (DISABLE_RCT2) if (DISABLE_RCT2)
add_definitions(-DNO_RCT2) add_definitions(-DNO_RCT2)
endif (DISABLE_RCT2) endif (DISABLE_RCT2)
# Start of library checks # Start of library checks
PKG_CHECK_MODULES(PNG libpng>=1.6) PKG_CHECK_MODULES(PNG libpng>=1.6)
if (NOT PNG_FOUND) if (NOT PNG_FOUND)
PKG_CHECK_MODULES(PNG libpng16) PKG_CHECK_MODULES(PNG libpng16)
endif (NOT PNG_FOUND) endif (NOT PNG_FOUND)
if (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) endif (NOT PNG_FOUND)
if (NOT PNG_FOUND) if (NOT PNG_FOUND)
PKG_CHECK_MODULES(PNG REQUIRED libpng12) PKG_CHECK_MODULES(PNG REQUIRED libpng12)
endif (NOT PNG_FOUND) endif (NOT PNG_FOUND)
PKG_CHECK_MODULES(ZLIB REQUIRED zlib) PKG_CHECK_MODULES(ZLIB REQUIRED zlib)
PKG_CHECK_MODULES(JANSSON REQUIRED jansson>=2.3) PKG_CHECK_MODULES(JANSSON REQUIRED jansson>=2.3)
# Handle creating the rct2 text and data files on macOS and Linux # 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. # were derived.
if ((NOT DISABLE_RCT2) AND UNIX) if ((NOT DISABLE_RCT2) AND UNIX)
add_custom_command( add_custom_command(
@ -206,40 +206,40 @@ if ((NOT DISABLE_RCT2) AND UNIX)
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/openrct2.exe DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/openrct2.exe
) )
add_custom_target(segfiles DEPENDS openrct2_text openrct2_data) add_custom_target(segfiles DEPENDS openrct2_text openrct2_data)
if (NOT USE_MMAP) if (NOT USE_MMAP)
if (APPLE) 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") 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) else (APPLE)
# For Linux we have to use objcopy to wrap regular binaries into a linkable # 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 # format. We use specific section names which are then referenced in a
# bespoke linker script so they can be placed at predefined VMAs. # bespoke linker script so they can be placed at predefined VMAs.
add_custom_command( add_custom_command(
OUTPUT openrct2_text_section.o 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 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 DEPENDS segfiles
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
) )
add_custom_command( add_custom_command(
OUTPUT openrct2_data_section.o 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 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 DEPENDS segfiles
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
) )
add_custom_target(linkable_sections DEPENDS openrct2_text_section.o openrct2_data_section.o) add_custom_target(linkable_sections DEPENDS openrct2_text_section.o openrct2_data_section.o)
SET_SOURCE_FILES_PROPERTIES( SET_SOURCE_FILES_PROPERTIES(
openrct2_text_section.o openrct2_data_section.o openrct2_text_section.o openrct2_data_section.o
PROPERTIES PROPERTIES
EXTERNAL_OBJECT true EXTERNAL_OBJECT true
GENERATED true GENERATED true
) )
# can't use GLOB here, as the files don't exist yet at cmake-time # 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(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}\"") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-T,\"${CMAKE_CURRENT_SOURCE_DIR}/distribution/linux/${LINKER_SCRIPT}\"")
endif (APPLE) endif (APPLE)
endif (NOT USE_MMAP) endif (NOT USE_MMAP)
elseif (USE_MMAP) elseif (USE_MMAP)
# No dd here, can't extract data segment # No dd here, can't extract data segment
message(WARNING "Sorry, your platform is not supported, you have to extract data segment manually") message(WARNING "Sorry, your platform is not supported, you have to extract data segment manually")
endif ((NOT DISABLE_RCT2) AND UNIX) endif ((NOT DISABLE_RCT2) AND UNIX)
set(DEBUG_LEVEL 0 CACHE STRING "Select debug level for compilation. Use value in range 03.") set(DEBUG_LEVEL 0 CACHE STRING "Select debug level for compilation. Use value in range 03.")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDEBUG=${DEBUG_LEVEL}") 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 lib
include_directories("lib/") include_directories("lib/")
# add source files # 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) if (APPLE)
file(GLOB_RECURSE ORCT2_MM_SOURCES "src/*.m") file(GLOB_RECURSE ORCT2_MM_SOURCES "src/openrct2/*.m")
set_source_files_properties(${ORCT2_MM_SOURCES} PROPERTIES COMPILE_FLAGS "-x objective-c -fmodules") set_source_files_properties(${ORCT2_MM_SOURCES} PROPERTIES COMPILE_FLAGS "-x objective-c -fmodules")
endif (APPLE) endif (APPLE)
if (APPLE AND NOT USE_MMAP) if (APPLE AND NOT USE_MMAP)
set(PIE_FLAG "-fno-pie") set(PIE_FLAG "-fno-pie")
else () else ()
set(PIE_FLAG "-fpie") set(PIE_FLAG "-fpie")
endif () endif ()
# set necessary flags to compile code as is # 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}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS} ${PIE_FLAG}")
if (MINGW) 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 () endif ()
option(WITH_BREAKPAD "Enable breakpad") option(WITH_BREAKPAD "Enable breakpad")
if (WITH_BREAKPAD) if (WITH_BREAKPAD)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_BREAKPAD") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_BREAKPAD")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_BREAKPAD") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_BREAKPAD")
set(BREAKPAD_DIR "/home/janisozaur/workspace/breakpad/src") set(BREAKPAD_DIR "/home/janisozaur/workspace/breakpad/src")
set(BREAKPAD_INCLUDE_DIR "${BREAKPAD_DIR}/src") set(BREAKPAD_INCLUDE_DIR "${BREAKPAD_DIR}/src")
set(BREAKPAD_LIBRARY_DIR "${BREAKPAD_DIR}/src/client/linux") set(BREAKPAD_LIBRARY_DIR "${BREAKPAD_DIR}/src/client/linux")
set(BREAKPAD_LIBS breakpad_client pthread) set(BREAKPAD_LIBS breakpad_client pthread)
endif (WITH_BREAKPAD) endif (WITH_BREAKPAD)
PKG_CHECK_MODULES(LIBZIP REQUIRED libzip>=1.0) PKG_CHECK_MODULES(LIBZIP REQUIRED libzip>=1.0)
# find and include SDL2 # find and include SDL2
PKG_CHECK_MODULES(SDL2 REQUIRED sdl2) PKG_CHECK_MODULES(SDL2 REQUIRED sdl2)
if (NOT DISABLE_TTF) if (NOT DISABLE_TTF)
PKG_CHECK_MODULES(SDL2_TTF REQUIRED SDL2_ttf) PKG_CHECK_MODULES(SDL2_TTF REQUIRED SDL2_ttf)
endif (NOT DISABLE_TTF) endif (NOT DISABLE_TTF)
if (STATIC) if (STATIC)
if (NOT DISABLE_TTF) if (NOT DISABLE_TTF)
# FreeType is required by SDL2_ttf, but not wired up properly in package # FreeType is required by SDL2_ttf, but not wired up properly in package
PKG_CHECK_MODULES(FREETYPE REQUIRED freetype2) PKG_CHECK_MODULES(FREETYPE REQUIRED freetype2)
endif (NOT DISABLE_TTF) endif (NOT DISABLE_TTF)
SET(SDL2LIBS ${SDL2_STATIC_LIBRARIES} ${SDL2_TTF_STATIC_LIBRARIES} ${FREETYPE_STATIC_LIBRARIES}) SET(SDL2LIBS ${SDL2_STATIC_LIBRARIES} ${SDL2_TTF_STATIC_LIBRARIES} ${FREETYPE_STATIC_LIBRARIES})
else (STATIC) else (STATIC)
SET(SDL2LIBS ${SDL2_LIBRARIES} ${SDL2_TTF_LIBRARIES}) SET(SDL2LIBS ${SDL2_LIBRARIES} ${SDL2_TTF_LIBRARIES})
endif (STATIC) endif (STATIC)
if (STATIC) if (STATIC)
set(STATIC_START "-static") set(STATIC_START "-static")
SET(REQUIREDLIBS ${PNG_STATIC_LIBRARIES} ${JANSSON_STATIC_LIBRARIES} ${ZLIB_STATIC_LIBRARIES} ${SSL_STATIC_LIBRARIES} ${LIBZIP_STATIC_LIBRARIES}) SET(REQUIREDLIBS ${PNG_STATIC_LIBRARIES} ${JANSSON_STATIC_LIBRARIES} ${ZLIB_STATIC_LIBRARIES} ${SSL_STATIC_LIBRARIES} ${LIBZIP_STATIC_LIBRARIES})
else (STATIC) 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) endif (STATIC)
if (NOT DISABLE_OPENGL) if (NOT DISABLE_OPENGL)
if (WIN32) if (WIN32)
# Curl depends on openssl and ws2 in mingw builds, but is not wired up in pkg-config # Curl depends on openssl and ws2 in mingw builds, but is not wired up in pkg-config
set(GLLIBS opengl32) set(GLLIBS opengl32)
# mingw complains about "%zu" not being a valid format specifier for printf, unless we # mingw complains about "%zu" not being a valid format specifier for printf, unless we
# tell it that it is # tell it that it is
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__USE_MINGW_ANSI_STDIO=1") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__USE_MINGW_ANSI_STDIO=1")
elseif (APPLE) elseif (APPLE)
# GL doesn't work nicely with macOS, while find_package doesn't work with multiarch on Ubuntu. # GL doesn't work nicely with macOS, while find_package doesn't work with multiarch on Ubuntu.
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
set(GLLIBS ${OPENGL_LIBRARY}) set(GLLIBS ${OPENGL_LIBRARY})
else (WIN32) else (WIN32)
PKG_CHECK_MODULES(GL REQUIRED gl) PKG_CHECK_MODULES(GL REQUIRED gl)
set(GLLIBS ${GL_LIBRARIES}) set(GLLIBS ${GL_LIBRARIES})
endif (WIN32) endif (WIN32)
endif (NOT DISABLE_OPENGL) endif (NOT DISABLE_OPENGL)
if (NOT DISABLE_HTTP_TWITCH) if (NOT DISABLE_HTTP_TWITCH)
PKG_CHECK_MODULES(LIBCURL REQUIRED libcurl) PKG_CHECK_MODULES(LIBCURL REQUIRED libcurl)
if (WIN32) if (WIN32)
# Curl depends on openssl and ws2 in mingw builds, but is not wired up in pkg-config # Curl depends on openssl and ws2 in mingw builds, but is not wired up in pkg-config
set(WSLIBS ws2_32) set(WSLIBS ws2_32)
endif (WIN32) endif (WIN32)
if (STATIC) if (STATIC)
SET(HTTPLIBS ${LIBCURL_STATIC_LIBRARIES} ${WSLIBS}) SET(HTTPLIBS ${LIBCURL_STATIC_LIBRARIES} ${WSLIBS})
else (STATIC) else (STATIC)
SET(HTTPLIBS ${LIBCURL_LIBRARIES} ${WSLIBS}) SET(HTTPLIBS ${LIBCURL_LIBRARIES} ${WSLIBS})
endif (STATIC) endif (STATIC)
endif (NOT DISABLE_HTTP_TWITCH) endif (NOT DISABLE_HTTP_TWITCH)
PKG_CHECK_MODULES(SPEEX REQUIRED speexdsp) PKG_CHECK_MODULES(SPEEX REQUIRED speexdsp)
if (UNIX AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "BSD") if (UNIX AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "BSD")
# Include libdl for dlopen # Include libdl for dlopen
set(DLLIB dl) set(DLLIB dl)
endif () 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}) 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}) 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) if (NOT DISABLE_RCT2)
# Disable optimizations for addresses.c for all compilers, to allow optimized # Disable optimizations for addresses.c for all compilers, to allow optimized
# builds without need for -fno-omit-frame-pointer # builds without need for -fno-omit-frame-pointer
set_source_files_properties(src/addresses.c PROPERTIES COMPILE_FLAGS -O0) set_source_files_properties(src/openrct2/addresses.c PROPERTIES COMPILE_FLAGS -O0)
endif (NOT DISABLE_RCT2) endif (NOT DISABLE_RCT2)
if (WIN32) if (WIN32)
# build as library for now, replace with add_executable # build as library for now, replace with add_executable
if (USE_MMAP OR DISABLE_RCT2) if (USE_MMAP OR DISABLE_RCT2)
add_executable(${PROJECT} ${ORCT2_SOURCES} ${SPEEX_SOURCES}) add_executable(${PROJECT} ${ORCT2_SOURCES} ${SPEEX_SOURCES})
else () else ()
add_library(${PROJECT} SHARED ${ORCT2_SOURCES} ${SPEEX_SOURCES}) add_library(${PROJECT} SHARED ${ORCT2_SOURCES} ${SPEEX_SOURCES})
endif () endif ()
else (WIN32) else (WIN32)
add_executable(${PROJECT} ${ORCT2_SOURCES} ${ORCT2_MM_SOURCES} ${RCT2_SECTIONS}) add_executable(${PROJECT} ${ORCT2_SOURCES} ${ORCT2_MM_SOURCES} ${RCT2_SECTIONS})
if (NOT DISABLE_RCT2) if (NOT DISABLE_RCT2)
add_dependencies(${PROJECT} segfiles) add_dependencies(${PROJECT} segfiles)
if (NOT APPLE AND NOT USE_MMAP) if (NOT APPLE AND NOT USE_MMAP)
add_dependencies(${PROJECT} linkable_sections) add_dependencies(${PROJECT} linkable_sections)
endif () endif ()
endif (NOT DISABLE_RCT2) endif (NOT DISABLE_RCT2)
add_custom_command( add_custom_command(
OUTPUT g2.dat OUTPUT g2.dat
COMMAND ./openrct2 sprite build ${CMAKE_BINARY_DIR}/g2.dat ${CMAKE_CURRENT_SOURCE_DIR}/resources/g2/ COMMAND ./openrct2 sprite build ${CMAKE_BINARY_DIR}/g2.dat ${CMAKE_CURRENT_SOURCE_DIR}/resources/g2/
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
) )
add_custom_target(g2 DEPENDS ${PROJECT} g2.dat) add_custom_target(g2 DEPENDS ${PROJECT} g2.dat)
endif (WIN32) endif (WIN32)
if (UNIX AND NOT APPLE AND NOT DISABLE_TTF) if (UNIX AND NOT APPLE AND NOT DISABLE_TTF)
# FontConfig for TrueType fonts. # FontConfig for TrueType fonts.
PKG_CHECK_MODULES(FONTCONFIG REQUIRED fontconfig) PKG_CHECK_MODULES(FONTCONFIG REQUIRED fontconfig)
INCLUDE_DIRECTORIES(${FONTCONFIG_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${FONTCONFIG_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(${PROJECT} ${FONTCONFIG_LIBRARIES}) TARGET_LINK_LIBRARIES(${PROJECT} ${FONTCONFIG_LIBRARIES})
endif (UNIX AND NOT APPLE AND NOT DISABLE_TTF) 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}) 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") if (APPLE OR STATIC OR ${CMAKE_SYSTEM_NAME} MATCHES "BSD")
FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c) FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c)
TARGET_LINK_LIBRARIES(${PROJECT} ${ICONV_LIBRARIES}) TARGET_LINK_LIBRARIES(${PROJECT} ${ICONV_LIBRARIES})
endif () endif ()
# Don't recurse, grab all *.txt and *.md files # 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) install(FILES distribution/linux/openrct2.desktop DESTINATION share/applications)
if (WITH_TESTS) if (WITH_TESTS)
enable_testing() enable_testing()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test/tests/) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test/tests/)
endif () endif ()
if (UNIX AND (NOT USE_MMAP) AND (NOT DISABLE_RCT2) AND (FORCE32)) if (UNIX AND (NOT USE_MMAP) AND (NOT DISABLE_RCT2) AND (FORCE32))
set(OPENRCT2_SRCPATH "src/openrct2") set(OPENRCT2_SRCPATH "src/openrct2")
file(GLOB_RECURSE ORCT2_RIDE_SOURCES "${OPENRCT2_SRCPATH}/ride/*/*.c") 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_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") 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}) add_executable(testpaint EXCLUDE_FROM_ALL ${ORCT2_RIDE_SOURCES} ${ORCT2_RIDE_DEP_SOURCES} ${ORCT2_TESTPAINT_SOURCES} ${RCT2_SECTIONS})
target_include_directories(testpaint PRIVATE "src/") target_include_directories(testpaint PRIVATE "src/")
set_target_properties(testpaint PROPERTIES COMPILE_FLAGS "-DNO_VEHICLES -D__TESTPAINT__ -Wno-unused") set_target_properties(testpaint PROPERTIES COMPILE_FLAGS "-DNO_VEHICLES -D__TESTPAINT__ -Wno-unused")
add_dependencies(testpaint segfiles) add_dependencies(testpaint segfiles)
endif () endif ()
set(CPACK_PACKAGE_VERSION_MAJOR 0) set(CPACK_PACKAGE_VERSION_MAJOR 0)

View File

@ -14,7 +14,7 @@ environment:
OPENRCT2_ORG_TOKEN: OPENRCT2_ORG_TOKEN:
secure: leQX3xCQpmBLGuMqrxjFlzexDt96ypNRMM5TTRVHbGE8PwVg9crgeykLc2BIZU6HDHveJCHqh2cGMdHtHYJYcw== secure: leQX3xCQpmBLGuMqrxjFlzexDt96ypNRMM5TTRVHbGE8PwVg9crgeykLc2BIZU6HDHveJCHqh2cGMdHtHYJYcw==
BUILD_SERVER: AppVeyor 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: install:
- ps: >- - ps: >-
.\scripts\ps\appveyor_install.ps1 .\scripts\ps\appveyor_install.ps1

View File

@ -152,6 +152,8 @@ Section "!OpenRCT2" Section1
; Copy executable ; Copy executable
File /oname=${OPENRCT2_EXE} ${BINARY_DIR}\${OPENRCT2_EXE} 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 ; Create the Registry Entries
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2" "Comments" "Visit ${APPURLLINK}" 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\readme.txt"
Delete "$INSTDIR\contributors.md" Delete "$INSTDIR\contributors.md"
Delete "$INSTDIR\${OPENRCT2_EXE}" Delete "$INSTDIR\${OPENRCT2_EXE}"
Delete "$INSTDIR\openrct2.com"
Delete "$INSTDIR\openrct2.dll"
Delete "$INSTDIR\INSTALL.LOG" Delete "$INSTDIR\INSTALL.LOG"
; Data files ; Data files

View File

@ -40,6 +40,8 @@
<NsisScript>$(DistDir)windows\install.nsi</NsisScript> <NsisScript>$(DistDir)windows\install.nsi</NsisScript>
<OutputExe>$(TargetDir)openrct2.exe</OutputExe> <OutputExe>$(TargetDir)openrct2.exe</OutputExe>
<OutputCom>$(TargetDir)openrct2.com</OutputCom>
<OutputDll>$(TargetDir)openrct2.dll</OutputDll>
<g2Output>$(TargetDir)data\g2.dat</g2Output> <g2Output>$(TargetDir)data\g2.dat</g2Output>
<SignCertificate Condition="'$(SignCertificate)'==''">$(DistDir)windows\code-sign-key-openrct2.org.pfx</SignCertificate> <SignCertificate Condition="'$(SignCertificate)'==''">$(DistDir)windows\code-sign-key-openrct2.org.pfx</SignCertificate>
@ -75,15 +77,22 @@
<ItemGroup> <ItemGroup>
<g2Inputs Include="$(RootDir)resources\g2\*" /> <g2Inputs Include="$(RootDir)resources\g2\*" />
<SignItems Include="$(OutputExe)" /> <SignItems Include="$(OutputExe)" />
<SignItems Include="$(OutputDll)" />
<SignItems Include="$(OutputCom)" />
</ItemGroup> </ItemGroup>
<ItemGroup Label="Symbol Items"> <ItemGroup Label="Symbol Items">
<SymbolItems Include="$(OutputExe)" /> <SymbolItems Include="$(OutputExe)" />
<SymbolItems Include="$([System.IO.Path]::ChangeExtension($(OutputExe), '.pdb'))" /> <SymbolItems Include="$(OutputCom)" />
<SymbolItems Include="$(OutputDll)" />
<SymbolItems Include="$(TargetDir)openrct2-dll.pdb" />
<SymbolItems Include="$(TargetDir)openrct2-win.pdb" />
</ItemGroup> </ItemGroup>
<ItemGroup Label="Publish Items"> <ItemGroup Label="Publish Items">
<PublishItems Include="$(OutputExe)" /> <PublishItems Include="$(OutputExe)" />
<PublishItems Include="$(OutputCom)" />
<PublishItems Include="$(OutputDll)" />
<PublishItems Include="$(TargetDir)data" /> <PublishItems Include="$(TargetDir)data" />
<PublishItems Include="$(DistDir)changelog.txt" /> <PublishItems Include="$(DistDir)changelog.txt" />
<PublishItems Include="$(DistDir)known_issues.txt" /> <PublishItems Include="$(DistDir)known_issues.txt" />
@ -137,6 +146,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<CleanItems Condition="'$(Platform)'=='Win32'" Include="$(OutputExe)" /> <CleanItems Condition="'$(Platform)'=='Win32'" Include="$(OutputExe)" />
<CleanItems Include="$(OutputCom)" />
<CleanItems Include="$(g2Output)" /> <CleanItems Include="$(g2Output)" />
<CleanItems Include="$(ArtifactsDir)openrct2-installer-$(Configuration)-$(Platform)*.exe" /> <CleanItems Include="$(ArtifactsDir)openrct2-installer-$(Configuration)-$(Platform)*.exe" />
<CleanItems Include="$(ArtifactsDir)openrct2-portable-$(Configuration)-$(Platform)*.zip" /> <CleanItems Include="$(ArtifactsDir)openrct2-portable-$(Configuration)-$(Platform)*.zip" />
@ -179,17 +189,8 @@
<Message Text="SlnProperties: $(SlnProperties)" /> <Message Text="SlnProperties: $(SlnProperties)" />
<MSBuild Projects="openrct2.sln" Targets="Rebuild" Properties="$(SlnProperties)" /> <MSBuild Projects="openrct2.sln" Targets="Rebuild" Properties="$(SlnProperties)" />
</Target> </Target>
<Target Name="BuildTests">
<PropertyGroup>
<Configuration Condition="'$(Configuration)'=='Debug'">DebugTests</Configuration>
<Configuration Condition="'$(Configuration)'=='Release'">ReleaseTests</Configuration>
<SlnProperties>$(SlnProperties);Configuration=$(Configuration)</SlnProperties>
</PropertyGroup>
<Message Text="SlnProperties: $(SlnProperties)" />
<MSBuild Projects="openrct2.sln" Targets="Build" Properties="$(SlnProperties)" />
</Target>
<Target Name="Test" DependsOnTargets="BuildTests"> <Target Name="Test" DependsOnTargets="Build">
<Exec Command="$(TargetDir)tests\tests.exe" /> <Exec Command="$(TargetDir)tests\tests.exe" />
</Target> </Target>
<Target Name="TestPaint" DependsOnTargets="Build" Condition="'$(Platform)'=='Win32'"> <Target Name="TestPaint" DependsOnTargets="Build" Condition="'$(Platform)'=='Win32'">
@ -204,6 +205,12 @@
StandardOutputImportance="low" /> StandardOutputImportance="low" />
</Target> </Target>
<!-- Target to create openrct2.exe (windows) and openrct2.com (console) -->
<Target Name="CreateGUI" DependsOnTargets="Build" AfterTargets="Build" Inputs="$(OutputExe)" Outputs="$(OutputCom)">
<Copy SourceFiles="$(OutputExe)" DestinationFiles="$(OutputCom)" />
<Exec Command="editbin /subsystem:windows $(OutputExe)" />
</Target>
<!-- Target to download the title sequences --> <!-- Target to download the title sequences -->
<Target Name="DownloadTitleSequences" AfterTargets="Build"> <Target Name="DownloadTitleSequences" AfterTargets="Build">
<DownloadDependency Name="TitleSequences" <DownloadDependency Name="TitleSequences"

View File

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14 # Visual Studio 14
VisualStudioVersion = 14.0.25420.1 VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openrct2", "src\openrct2\openrct2.vcxproj", "{D24D94F6-2A74-480C-B512-629C306CE92F}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libopenrct2", "src\openrct2\libopenrct2.vcxproj", "{D24D94F6-2A74-480C-B512-629C306CE92F}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testpaint", "test\testpaint\testpaint.vcxproj", "{57E60BA1-FB76-4316-909E-C1449C142327}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testpaint", "test\testpaint\testpaint.vcxproj", "{57E60BA1-FB76-4316-909E-C1449C142327}"
EndProject EndProject
@ -16,55 +16,62 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2202A816-377
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{480B577D-4E4A-4757-9A42-28A9AD33E6B0}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{480B577D-4E4A-4757-9A42-28A9AD33E6B0}"
EndProject 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}
{D24D94F6-2A74-480C-B512-629C306CE92F} = {D24D94F6-2A74-480C-B512-629C306CE92F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openrct2-dll", "src\openrct2-dll\openrct2-dll.vcxproj", "{7B8DB129-79EF-417E-B372-8A18E009D261}"
ProjectSection(ProjectDependencies) = postProject
{D24D94F6-2A74-480C-B512-629C306CE92F} = {D24D94F6-2A74-480C-B512-629C306CE92F}
EndProjectSection
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32 Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64 Debug|x64 = Debug|x64
DebugTests|Win32 = DebugTests|Win32
DebugTests|x64 = DebugTests|x64
Release|Win32 = Release|Win32 Release|Win32 = Release|Win32
Release|x64 = Release|x64 Release|x64 = Release|x64
ReleaseTests|Win32 = ReleaseTests|Win32
ReleaseTests|x64 = ReleaseTests|x64
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Win32.ActiveCfg = Debug|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Win32.ActiveCfg = Debug|Win32
{D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Win32.Build.0 = Debug|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Win32.Build.0 = Debug|Win32
{D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|x64.ActiveCfg = Debug|x64 {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|x64.ActiveCfg = Debug|x64
{D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|x64.Build.0 = Debug|x64 {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|x64.Build.0 = Debug|x64
{D24D94F6-2A74-480C-B512-629C306CE92F}.DebugTests|Win32.ActiveCfg = DebugTests|Win32
{D24D94F6-2A74-480C-B512-629C306CE92F}.DebugTests|Win32.Build.0 = DebugTests|Win32
{D24D94F6-2A74-480C-B512-629C306CE92F}.DebugTests|x64.ActiveCfg = DebugTests|x64
{D24D94F6-2A74-480C-B512-629C306CE92F}.DebugTests|x64.Build.0 = DebugTests|x64
{D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Win32.ActiveCfg = Release|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Win32.ActiveCfg = Release|Win32
{D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Win32.Build.0 = Release|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Win32.Build.0 = Release|Win32
{D24D94F6-2A74-480C-B512-629C306CE92F}.Release|x64.ActiveCfg = Release|x64 {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|x64.ActiveCfg = Release|x64
{D24D94F6-2A74-480C-B512-629C306CE92F}.Release|x64.Build.0 = Release|x64 {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|x64.Build.0 = Release|x64
{D24D94F6-2A74-480C-B512-629C306CE92F}.ReleaseTests|Win32.ActiveCfg = ReleaseTests|Win32
{D24D94F6-2A74-480C-B512-629C306CE92F}.ReleaseTests|Win32.Build.0 = ReleaseTests|Win32
{D24D94F6-2A74-480C-B512-629C306CE92F}.ReleaseTests|x64.ActiveCfg = ReleaseTests|x64
{D24D94F6-2A74-480C-B512-629C306CE92F}.ReleaseTests|x64.Build.0 = ReleaseTests|x64
{57E60BA1-FB76-4316-909E-C1449C142327}.Debug|Win32.ActiveCfg = Debug|Win32 {57E60BA1-FB76-4316-909E-C1449C142327}.Debug|Win32.ActiveCfg = Debug|Win32
{57E60BA1-FB76-4316-909E-C1449C142327}.Debug|Win32.Build.0 = Debug|Win32 {57E60BA1-FB76-4316-909E-C1449C142327}.Debug|Win32.Build.0 = Debug|Win32
{57E60BA1-FB76-4316-909E-C1449C142327}.Debug|x64.ActiveCfg = Debug|Win32 {57E60BA1-FB76-4316-909E-C1449C142327}.Debug|x64.ActiveCfg = Debug|Win32
{57E60BA1-FB76-4316-909E-C1449C142327}.DebugTests|Win32.ActiveCfg = Debug|Win32
{57E60BA1-FB76-4316-909E-C1449C142327}.DebugTests|x64.ActiveCfg = Debug|Win32
{57E60BA1-FB76-4316-909E-C1449C142327}.Release|Win32.ActiveCfg = Release|Win32 {57E60BA1-FB76-4316-909E-C1449C142327}.Release|Win32.ActiveCfg = Release|Win32
{57E60BA1-FB76-4316-909E-C1449C142327}.Release|x64.ActiveCfg = Release|Win32 {57E60BA1-FB76-4316-909E-C1449C142327}.Release|x64.ActiveCfg = Release|Win32
{57E60BA1-FB76-4316-909E-C1449C142327}.ReleaseTests|Win32.ActiveCfg = Release|Win32 {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Debug|Win32.ActiveCfg = Debug|Win32
{57E60BA1-FB76-4316-909E-C1449C142327}.ReleaseTests|x64.ActiveCfg = Release|Win32 {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Debug|Win32.Build.0 = Debug|Win32
{62B020FA-E4FB-4C6E-B32A-DC999470F155}.Debug|Win32.ActiveCfg = DebugTests|Win32 {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Debug|x64.ActiveCfg = Debug|x64
{62B020FA-E4FB-4C6E-B32A-DC999470F155}.Debug|x64.ActiveCfg = DebugTests|x64 {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Debug|x64.Build.0 = Debug|x64
{62B020FA-E4FB-4C6E-B32A-DC999470F155}.DebugTests|Win32.ActiveCfg = DebugTests|Win32 {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Release|Win32.ActiveCfg = Release|Win32
{62B020FA-E4FB-4C6E-B32A-DC999470F155}.DebugTests|Win32.Build.0 = DebugTests|Win32 {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Release|Win32.Build.0 = Release|Win32
{62B020FA-E4FB-4C6E-B32A-DC999470F155}.DebugTests|x64.ActiveCfg = DebugTests|x64 {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Release|x64.ActiveCfg = Release|x64
{62B020FA-E4FB-4C6E-B32A-DC999470F155}.DebugTests|x64.Build.0 = DebugTests|x64 {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Release|x64.Build.0 = Release|x64
{62B020FA-E4FB-4C6E-B32A-DC999470F155}.Release|Win32.ActiveCfg = ReleaseTests|Win32 {7A9A57D5-7006-4208-A290-5491BA3C8808}.Debug|Win32.ActiveCfg = Debug|Win32
{62B020FA-E4FB-4C6E-B32A-DC999470F155}.Release|x64.ActiveCfg = ReleaseTests|x64 {7A9A57D5-7006-4208-A290-5491BA3C8808}.Debug|Win32.Build.0 = Debug|Win32
{62B020FA-E4FB-4C6E-B32A-DC999470F155}.ReleaseTests|Win32.ActiveCfg = ReleaseTests|Win32 {7A9A57D5-7006-4208-A290-5491BA3C8808}.Debug|x64.ActiveCfg = Debug|x64
{62B020FA-E4FB-4C6E-B32A-DC999470F155}.ReleaseTests|Win32.Build.0 = ReleaseTests|Win32 {7A9A57D5-7006-4208-A290-5491BA3C8808}.Debug|x64.Build.0 = Debug|x64
{62B020FA-E4FB-4C6E-B32A-DC999470F155}.ReleaseTests|x64.ActiveCfg = ReleaseTests|x64 {7A9A57D5-7006-4208-A290-5491BA3C8808}.Release|Win32.ActiveCfg = Release|Win32
{62B020FA-E4FB-4C6E-B32A-DC999470F155}.ReleaseTests|x64.Build.0 = ReleaseTests|x64 {7A9A57D5-7006-4208-A290-5491BA3C8808}.Release|Win32.Build.0 = Release|Win32
{7A9A57D5-7006-4208-A290-5491BA3C8808}.Release|x64.ActiveCfg = Release|x64
{7A9A57D5-7006-4208-A290-5491BA3C8808}.Release|x64.Build.0 = Release|x64
{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
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -73,5 +80,7 @@ Global
{D24D94F6-2A74-480C-B512-629C306CE92F} = {2202A816-377D-4FA0-A7AF-7D4105F8A4FB} {D24D94F6-2A74-480C-B512-629C306CE92F} = {2202A816-377D-4FA0-A7AF-7D4105F8A4FB}
{57E60BA1-FB76-4316-909E-C1449C142327} = {480B577D-4E4A-4757-9A42-28A9AD33E6B0} {57E60BA1-FB76-4316-909E-C1449C142327} = {480B577D-4E4A-4757-9A42-28A9AD33E6B0}
{62B020FA-E4FB-4C6E-B32A-DC999470F155} = {480B577D-4E4A-4757-9A42-28A9AD33E6B0} {62B020FA-E4FB-4C6E-B32A-DC999470F155} = {480B577D-4E4A-4757-9A42-28A9AD33E6B0}
{7A9A57D5-7006-4208-A290-5491BA3C8808} = {2202A816-377D-4FA0-A7AF-7D4105F8A4FB}
{7B8DB129-79EF-417E-B372-8A18E009D261} = {2202A816-377D-4FA0-A7AF-7D4105F8A4FB}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@ -0,0 +1,80 @@
#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 <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <shellapi.h>
#include <openrct2/OpenRCT2.h>
#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;
}

View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="'$(SolutionDir)'==''">..\..\</SolutionDir>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{7B8DB129-79EF-417E-B372-8A18E009D261}</ProjectGuid>
<RootNamespace>openrct2-dll</RootNamespace>
<ProjectName>openrct2-dll</ProjectName>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
</PropertyGroup>
<Import Project="..\..\openrct2.common.props" />
<PropertyGroup>
<TargetName>openrct2</TargetName>
<LibraryPath>$(SolutionDir)bin;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions Condition="'$(Configuration)'=='DebugTests' OR '$(Configuration)'=='ReleaseTests'">__NOENTRYPOINT__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup>
<ClCompile>
<ObjectFileName>$(IntDir)\%(RelativeDir)</ObjectFileName>
<AdditionalOptions>$(OPENRCT2_CL_ADDITIONALOPTIONS) %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<AdditionalDependencies>libopenrct2.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ProgramDatabaseFile>$(OutDir)openrct2-dll.pdb</ProgramDatabaseFile>
</Link>
<Lib>
<TargetMachine Condition="'$(Platform)'=='Win32'">MachineX86</TargetMachine>
<TargetMachine Condition="'$(Platform)'=='x64'">MachineX64</TargetMachine>
</Lib>
</ItemDefinitionGroup>
<ItemGroup>
<ResourceCompile Include="..\..\resources\OpenRCT2.rc" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="openrct2-dll.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@ -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 <windows.h>
// 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);
}

View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="'$(SolutionDir)'==''">..\..\</SolutionDir>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{7A9A57D5-7006-4208-A290-5491BA3C8808}</ProjectGuid>
<RootNamespace>openrct2-win</RootNamespace>
<ProjectName>openrct2-win</ProjectName>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
</PropertyGroup>
<Import Project="..\..\openrct2.common.props" />
<PropertyGroup>
<TargetName>openrct2</TargetName>
<LibraryPath>$(SolutionDir)bin;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions Condition="'$(Configuration)'=='DebugTests' OR '$(Configuration)'=='ReleaseTests'">__NOENTRYPOINT__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup>
<ClCompile>
<ObjectFileName>$(IntDir)\%(RelativeDir)</ObjectFileName>
<AdditionalOptions>$(OPENRCT2_CL_ADDITIONALOPTIONS) %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<AdditionalDependencies>openrct2.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ProgramDatabaseFile>$(OutDir)openrct2-win.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
</Link>
<Lib>
<TargetMachine Condition="'$(Platform)'=='Win32'">MachineX86</TargetMachine>
<TargetMachine Condition="'$(Platform)'=='x64'">MachineX64</TargetMachine>
</Lib>
</ItemDefinitionGroup>
<ItemGroup>
<ResourceCompile Include="..\..\resources\OpenRCT2.rc" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="openrct2-win.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@ -87,6 +87,10 @@ extern "C"
int cmdline_run(const char * * argv, int argc); int cmdline_run(const char * * argv, int argc);
#ifdef __WINDOWS__
int RunOpenRCT2(int argc, char * * argv);
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -39,10 +39,6 @@ extern "C"
#define IMPLIES_SILENT_BREAKPAD #define IMPLIES_SILENT_BREAKPAD
#endif // USE_BREAKPAD #endif // USE_BREAKPAD
#if defined(__WINDOWS__) && !defined(DEBUG)
#define __PROVIDE_CONSOLE__ 1
#endif // defined(__WINDOWS__) && !defined(DEBUG)
#ifndef DISABLE_NETWORK #ifndef DISABLE_NETWORK
int gNetworkStart = NETWORK_MODE_NONE; int gNetworkStart = NETWORK_MODE_NONE;
char gNetworkStartHost[128]; char gNetworkStartHost[128];
@ -51,10 +47,6 @@ int gNetworkStartPort = NETWORK_DEFAULT_PORT;
static uint32 _port = 0; static uint32 _port = 0;
#endif #endif
#ifdef __PROVIDE_CONSOLE__
static bool _provideConsole;
#endif
static bool _help = false; static bool _help = false;
static bool _version = false; static bool _version = false;
static bool _noInstall = 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, &_about, NAC, "about", "show information about " OPENRCT2_NAME },
{ CMDLINE_TYPE_SWITCH, &_verbose, NAC, "verbose", "log verbose messages" }, { CMDLINE_TYPE_SWITCH, &_verbose, NAC, "verbose", "log verbose messages" },
{ CMDLINE_TYPE_SWITCH, &_headless, NAC, "headless", "run " OPENRCT2_NAME " headless" IMPLIES_SILENT_BREAKPAD }, { 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 #ifndef DISABLE_NETWORK
{ CMDLINE_TYPE_INTEGER, &_port, NAC, "port", "port to use for hosting or joining a server" }, { CMDLINE_TYPE_INTEGER, &_port, NAC, "port", "port to use for hosting or joining a server" },
#endif #endif
@ -166,13 +155,6 @@ exitcode_t CommandLine::HandleCommandDefault()
{ {
exitcode_t result = EXITCODE_CONTINUE; exitcode_t result = EXITCODE_CONTINUE;
#ifdef __PROVIDE_CONSOLE__
if (_provideConsole)
{
platform_windows_open_console();
}
#endif
if (_about) if (_about)
{ {
PrintAbout(); PrintAbout();

View File

@ -12,14 +12,6 @@
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
<Platform>x64</Platform> <Platform>x64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="DebugTests|Win32">
<Configuration>DebugTests</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="DebugTests|x64">
<Configuration>DebugTests</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32"> <ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration> <Configuration>Release</Configuration>
<Platform>Win32</Platform> <Platform>Win32</Platform>
@ -28,35 +20,23 @@
<Configuration>Release</Configuration> <Configuration>Release</Configuration>
<Platform>x64</Platform> <Platform>x64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="ReleaseTests|Win32">
<Configuration>ReleaseTests</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="ReleaseTests|x64">
<Configuration>ReleaseTests</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{D24D94F6-2A74-480C-B512-629C306CE92F}</ProjectGuid> <ProjectGuid>{D24D94F6-2A74-480C-B512-629C306CE92F}</ProjectGuid>
<RootNamespace>openrct2</RootNamespace> <RootNamespace>openrct2-lib</RootNamespace>
<ProjectName>openrct2</ProjectName> <ProjectName>libopenrct2</ProjectName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Label="Configuration"> <PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
</PropertyGroup> </PropertyGroup>
<!-- Debug|Win32 is reserved for RCT2 interop builds, this means it has to be a DLL --> <!-- Debug|Win32 is reserved for RCT2 interop builds, this means it has to be a DLL -->
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)'=='DebugTests' OR '$(Configuration)'=='ReleaseTests'">
<ConfigurationType>StaticLibrary</ConfigurationType>
</PropertyGroup>
<Import Project="..\..\openrct2.common.props" /> <Import Project="..\..\openrct2.common.props" />
<ItemDefinitionGroup> <ItemDefinitionGroup>
<ClCompile> <ClCompile>
<PreprocessorDefinitions Condition="'$(Breakpad)'=='true'">USE_BREAKPAD;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions Condition="'$(Breakpad)'=='true'">USE_BREAKPAD;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)'=='DebugTests' OR '$(Configuration)'=='ReleaseTests'">__NOENTRYPOINT__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile> </ClCompile>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup> <ItemDefinitionGroup>
@ -64,10 +44,6 @@
<ObjectFileName>$(IntDir)\%(RelativeDir)</ObjectFileName> <ObjectFileName>$(IntDir)\%(RelativeDir)</ObjectFileName>
<AdditionalOptions>$(OPENRCT2_CL_ADDITIONALOPTIONS) %(AdditionalOptions)</AdditionalOptions> <AdditionalOptions>$(OPENRCT2_CL_ADDITIONALOPTIONS) %(AdditionalOptions)</AdditionalOptions>
</ClCompile> </ClCompile>
<Link>
<SubSystem Condition="'$(Configuration)'!='Release'">Console</SubSystem>
<SubSystem Condition="'$(Configuration)'=='Release'">Windows</SubSystem>
</Link>
<Lib> <Lib>
<TargetMachine Condition="'$(Platform)'=='Win32'">MachineX86</TargetMachine> <TargetMachine Condition="'$(Platform)'=='Win32'">MachineX86</TargetMachine>
<TargetMachine Condition="'$(Platform)'=='x64'">MachineX64</TargetMachine> <TargetMachine Condition="'$(Platform)'=='x64'">MachineX64</TargetMachine>

View File

@ -183,63 +183,69 @@ void research_finish_item(sint32 entryIndex)
int base_ride_type = (entryIndex >> 8) & 0xFF; int base_ride_type = (entryIndex >> 8) & 0xFF;
int rideEntryIndex = entryIndex & 0xFF; int rideEntryIndex = entryIndex & 0xFF;
rct_ride_entry *rideEntry = get_ride_entry(rideEntryIndex); rct_ride_entry *rideEntry = get_ride_entry(rideEntryIndex);
ride_type_set_invented(base_ride_type); if (rideEntry != NULL && rideEntry != (rct_ride_entry *)-1)
gResearchedTrackTypesA[base_ride_type] = (RideTypePossibleTrackConfigurations[base_ride_type] ) & 0xFFFFFFFFULL; {
gResearchedTrackTypesB[base_ride_type] = (RideTypePossibleTrackConfigurations[base_ride_type] >> 32ULL) & 0xFFFFFFFFULL; 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) { if (RideData4[base_ride_type].flags & RIDE_TYPE_FLAG4_3) {
int ebx = RideData4[base_ride_type].alternate_type; int ebx = RideData4[base_ride_type].alternate_type;
gResearchedTrackTypesA[ebx] = (RideTypePossibleTrackConfigurations[ebx] ) & 0xFFFFFFFFULL; gResearchedTrackTypesA[ebx] = (RideTypePossibleTrackConfigurations[ebx]) & 0xFFFFFFFFULL;
gResearchedTrackTypesB[ebx] = (RideTypePossibleTrackConfigurations[ebx] >> 32ULL) & 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)) { if (!(rideEntry->flags & RIDE_ENTRY_FLAG_SEPARATE_RIDE)) {
for (int i = 0; i < 128; i++) { for (int i = 0; i < 128; i++) {
rct_ride_entry *rideEntry2 = get_ride_entry(i); rct_ride_entry *rideEntry2 = get_ride_entry(i);
if (rideEntry2 == (rct_ride_entry*)-1) if (rideEntry2 == (rct_ride_entry*)-1)
continue; continue;
if ((rideEntry2->flags & RIDE_ENTRY_FLAG_SEPARATE_RIDE)) if ((rideEntry2->flags & RIDE_ENTRY_FLAG_SEPARATE_RIDE))
continue; continue;
if (rideEntry2->ride_type[0] == base_ride_type || if (rideEntry2->ride_type[0] == base_ride_type ||
rideEntry2->ride_type[1] == base_ride_type || rideEntry2->ride_type[1] == base_ride_type ||
rideEntry2->ride_type[2] == base_ride_type rideEntry2->ride_type[2] == base_ride_type
) { ) {
ride_entry_set_invented(i); ride_entry_set_invented(i);
}
} }
} }
}
set_format_arg(0, rct_string_id, ((rideEntry->flags & RIDE_ENTRY_FLAG_SEPARATE_RIDE_NAME)) ? set_format_arg(0, rct_string_id, ((rideEntry->flags & RIDE_ENTRY_FLAG_SEPARATE_RIDE_NAME)) ?
rideEntry->name : RideNaming[base_ride_type].name); rideEntry->name : RideNaming[base_ride_type].name);
if (!gSilentResearch) { if (!gSilentResearch) {
if (gConfigNotifications.ride_researched) { if (gConfigNotifications.ride_researched) {
news_item_add_to_queue(NEWS_ITEM_RESEARCH, STR_NEWS_ITEM_RESEARCH_NEW_RIDE_AVAILABLE, entryIndex); 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 { } else {
// Scenery // Scenery
rct_scenery_set_entry *scenerySetEntry = get_scenery_group_entry(entryIndex & 0xFFFF); rct_scenery_set_entry *scenerySetEntry = get_scenery_group_entry(entryIndex & 0xFFFF);
for (int i = 0; i < scenerySetEntry->entry_count; i++) { if (scenerySetEntry != NULL && scenerySetEntry != (rct_scenery_set_entry *)-1)
int subSceneryEntryIndex = scenerySetEntry->scenery_entries[i]; {
gResearchedSceneryItems[subSceneryEntryIndex >> 5] |= 1UL << (subSceneryEntryIndex & 0x1F); 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);
} }
}
research_invalidate_related_windows(); set_format_arg(0, rct_string_id, scenerySetEntry->name);
init_scenery();
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();
}
} }
} }

View File

@ -220,8 +220,6 @@ void core_init();
#include <windows.h> #include <windows.h>
#undef GetMessage #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); int windows_get_registry_install_info(rct2_install_info *installInfo, char *source, char *font, uint8 charset);
HWND windows_get_window_handle(); HWND windows_get_window_handle();
void platform_setup_file_associations(); void platform_setup_file_associations();

View File

@ -643,10 +643,6 @@ void platform_free()
platform_close_window(); platform_close_window();
SDL_Quit(); SDL_Quit();
#ifdef __WINDOWS__
platform_windows_close_console();
#endif
} }
void platform_start_text_input(utf8* buffer, int max_length) void platform_start_text_input(utf8* buffer, int max_length)

View File

@ -47,7 +47,6 @@
static utf8 _userDataDirectoryPath[MAX_PATH] = { 0 }; static utf8 _userDataDirectoryPath[MAX_PATH] = { 0 };
static utf8 _openrctDataDirectoryPath[MAX_PATH] = { 0 }; static utf8 _openrctDataDirectoryPath[MAX_PATH] = { 0 };
static bool _consoleIsAttached = false;
utf8 **windows_get_command_line_args(int *outNumArgs); utf8 **windows_get_command_line_args(int *outNumArgs);
@ -55,38 +54,10 @@ utf8 **windows_get_command_line_args(int *outNumArgs);
static HMODULE _dllModule = NULL; 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. * 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); HINSTANCE hInstance = GetModuleHandle(NULL);
_dllModule = hInstance; _dllModule = hInstance;
@ -101,6 +72,17 @@ int main(int argc, char *argv[])
return gExitCode; return gExitCode;
} }
#ifdef NO_RCT2
#ifdef __MINGW32__
int main(int argc, char **argv)
{
return RunOpenRCT2(argc, argv);
}
#endif
#else #else
/* DllMain is already defined in one of static libraries we implicitly depend /* 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 #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) utf8 **windows_get_command_line_args(int *outNumArgs)
{ {
int argc; int argc;

View File

@ -5,20 +5,20 @@
<GtestDir Condition="'$(GtestDir)'==''">$(SolutionDir)lib\googletest\googletest</GtestDir> <GtestDir Condition="'$(GtestDir)'==''">$(SolutionDir)lib\googletest\googletest</GtestDir>
</PropertyGroup> </PropertyGroup>
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="DebugTests|Win32"> <ProjectConfiguration Include="Debug|Win32">
<Configuration>DebugTests</Configuration> <Configuration>Debug</Configuration>
<Platform>Win32</Platform> <Platform>Win32</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="ReleaseTests|Win32"> <ProjectConfiguration Include="Release|Win32">
<Configuration>ReleaseTests</Configuration> <Configuration>Release</Configuration>
<Platform>Win32</Platform> <Platform>Win32</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="DebugTests|x64"> <ProjectConfiguration Include="Debug|x64">
<Configuration>DebugTests</Configuration> <Configuration>Debug</Configuration>
<Platform>x64</Platform> <Platform>x64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="ReleaseTests|x64"> <ProjectConfiguration Include="Release|x64">
<Configuration>ReleaseTests</Configuration> <Configuration>Release</Configuration>
<Platform>x64</Platform> <Platform>x64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
</ItemGroup> </ItemGroup>
@ -33,7 +33,7 @@
<Import Project="..\..\openrct2.common.props" /> <Import Project="..\..\openrct2.common.props" />
<PropertyGroup> <PropertyGroup>
<OutDir>$(SolutionDir)bin\tests\</OutDir> <OutDir>$(SolutionDir)bin\tests\</OutDir>
<IncludePath>$(GtestDir);$(GtestDir)\include;$(SolutionDir)src\openrct2;$(IncludePath)</IncludePath> <IncludePath>$(GtestDir);$(GtestDir)\include;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)bin;$(LibraryPath)</LibraryPath> <LibraryPath>$(SolutionDir)bin;$(LibraryPath)</LibraryPath>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup> <ItemDefinitionGroup>
@ -41,7 +41,7 @@
<PreprocessorDefinitions>GTEST_LANG_CXX11;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>GTEST_LANG_CXX11;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalDependencies>openrct2.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>libopenrct2.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>