summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build-cmake-conan.yml116
-rw-r--r--CMakeLists.txt77
-rw-r--r--cmake/FindMPG123.cmake28
-rw-r--r--cmake/FindMilesSDK.cmake34
-rw-r--r--cmake/FindSndFile.cmake84
-rw-r--r--cmake/Findmpg123.cmake38
-rw-r--r--cmake/Findopusfile.cmake64
-rw-r--r--conanfile.py135
-rw-r--r--src/CMakeLists.txt150
-rw-r--r--src/audio/oal/stream.cpp2
-rw-r--r--src/control/CarCtrl.cpp2
-rw-r--r--src/control/Script.cpp8
-rw-r--r--src/control/Script5.cpp10
-rw-r--r--src/render/Particle.cpp6
-rw-r--r--src/vehicles/Automobile.cpp20
15 files changed, 588 insertions, 186 deletions
diff --git a/.github/workflows/build-cmake-conan.yml b/.github/workflows/build-cmake-conan.yml
new file mode 100644
index 00000000..2d9b3a98
--- /dev/null
+++ b/.github/workflows/build-cmake-conan.yml
@@ -0,0 +1,116 @@
+name: Build re3 using conan+cmake
+on:
+ pull_request:
+ push:
+ release:
+ types: published
+jobs:
+ build-cmake:
+ strategy:
+ matrix:
+ include:
+ - os: 'windows-latest'
+ platform: 'gl3'
+ gl3_gfxlib: 'glfw'
+ audio: 'openal'
+# - os: 'windows-latest'
+# platform: 'gl3'
+# gl3_gfxlib: 'sdl2'
+# audio: 'openal'
+ - os: 'windows-latest'
+ platform: 'd3d9'
+ audio: 'openal'
+# - os: 'windows-latest'
+# platform: 'd3d9'
+# audio: 'miles'
+ - os: 'ubuntu-latest'
+ platform: 'gl3'
+ gl3_gfxlib: 'glfw'
+ audio: 'openal'
+# - os: 'ubuntu-latest'
+# platform: 'gl3'
+# gl3_gfxlib: 'sdl2'
+# audio: 'openal'
+ - os: 'macos-latest'
+ platform: 'gl3'
+ gl3_gfxlib: 'glfw'
+ audio: 'openal'
+# - os: 'macos-latest'
+# platform: 'gl3'
+# gl3_gfxlib: 'sdl2'
+# audio: 'openal'
+ runs-on: ${{ matrix.os }}
+ continue-on-error: ${{ matrix.platform == 'ps2' || matrix.gl3_gfxlib == 'sdl2' || matrix.audio == 'miles' }}
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ submodules: true
+ - name: "Checkout Miles SDK Import Library project"
+ uses: actions/checkout@v2
+ if: ${{ matrix.audio == 'miles' }}
+ with:
+ repository: 'withmorten/re3mss'
+ path: 're3mss'
+ - uses: actions/setup-python@v2
+ with:
+ python-version: '3.x'
+ - name: "Use XCode 11 as default (conan-center-index does not provide XCode 12 binaries at the moment)"
+ if: startsWith(matrix.os, 'macos')
+ run: |
+ sudo xcode-select --switch /Applications/Xcode_11.7.app
+ - name: "Setup conan"
+ run: |
+ python -m pip install conan
+ conan config init
+ conan config set log.print_run_commands=True
+ conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan
+ conan remote add madebr_ps2dev https://api.bintray.com/conan/madebr/ps2dev
+ - name: "Add os=playstation2 + gcc.version=3.2 to .conan/settings.yml"
+ shell: python
+ run: |
+ import os, yaml
+ settings_path = os.path.expanduser("~/.conan/settings.yml")
+ yml = yaml.safe_load(open(settings_path))
+ yml["os"]["playstation2"] = None
+ yml["compiler"]["gcc"]["version"].append("3.2")
+ yml["compiler"]["gcc"]["version"].sort()
+ yaml.safe_dump(yml, open(settings_path, "w"))
+ - name: "Create host profile"
+ shell: bash
+ run: |
+ if test "${{ matrix.platform }}" = "ps2"; then
+ cp vendor/librw/conan/playstation2 host_profile
+ else
+ cp ~/.conan/profiles/default host_profile
+ fi
+ - name: "Export Playstation 2 CMake toolchain conan recipe"
+ run: |
+ conan export vendor/librw/cmake/ps2toolchain ps2dev-cmaketoolchain/master@
+ - name: "Export librw conan recipe"
+ run: |
+ conan export vendor/librw librw/master@
+ - name: "Export Miles SDK conan recipe"
+ if: ${{ matrix.audio == 'miles' }}
+ run: |
+ conan export re3mss miles-sdk/master@
+ - name: "Download/build dependencies (conan install)"
+ run: |
+ conan install ${{ github.workspace }} re3/master@ -if build -o re3:audio=${{ matrix.audio }} -o librw:platform=${{ matrix.platform }} -o librw:gl3_gfxlib=${{ matrix.gl3_gfxlib || 'glfw' }} --build missing -pr:h ./host_profile -pr:b default -s re3:build_type=RelWithDebInfo -s librw:build_type=RelWithDebInfo
+ env:
+ CONAN_SYSREQUIRES_MODE: enabled
+ - name: "Build re3 (conan build)"
+ run: |
+ conan build ${{ github.workspace }} -if build -bf build -pf package
+ - name: "Package re3 (conan package)"
+ run: |
+ conan package ${{ github.workspace }} -if build -bf build -pf package
+ - name: "Create binary package (cpack)"
+ working-directory: ./build
+ run: |
+ cpack -C RelWithDebInfo
+ - name: "Archive binary package (github artifacts)"
+ uses: actions/upload-artifact@v2
+ with:
+ name: "${{ matrix.os }}-${{ matrix.platform }}"
+ path: build/*.tar.xz
+ if-no-files-found: error
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5daf1d15..665b85e5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,13 +4,16 @@ project(re3 C CXX)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
if(WIN32)
- set(RE3_AUDIOS "NULL" "OAL" "MSS")
+ set(RE3_AUDIOS "OAL" "MSS")
else()
- set(RE3_AUDIOS "NULL" "OAL")
+ set(RE3_AUDIOS "OAL")
endif()
set(RE3_AUDIO "OAL" CACHE STRING "Audio")
+option(RE3_WITH_OPUS "Build re3 with opus support" ON)
+option(RE3_WITH_LIBSNDFILE "Build re3 with libsndfile (instead of internal decoder)" OFF)
+
set_property(CACHE RE3_AUDIO PROPERTY STRINGS ${RE3_AUDIOS})
message(STATUS "RE3_AUDIO = ${RE3_AUDIO} (choices=${RE3_AUDIOS})")
set("RE3_AUDIO_${RE3_AUDIO}" ON)
@@ -18,27 +21,59 @@ if(NOT RE3_AUDIO IN_LIST RE3_AUDIOS)
message(FATAL_ERROR "Illegal RE3_AUDIO=${RE3_AUDIO}")
endif()
-if(RE3_INSTALL)
- include(GNUInstallDirs)
- set(RE3_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/re3")
+option(RE3_VENDORED_LIBRW "Use vendored librw" ON)
+if(RE3_VENDORED_LIBRW)
+ add_subdirectory(vendor/librw)
+else()
+ find_package(librw REQUIRED)
endif()
-
-add_subdirectory("vendor/librw")
add_subdirectory(src)
if(RE3_INSTALL)
- include(CMakePackageConfigHelpers)
- configure_package_config_file(re3-config.cmake.in re3-config.cmake
- INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}"
- )
- install(
- FILES "${CMAKE_CURRENT_BINARY_DIR}/re3-config.cmake"
- DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
- )
- install(
- EXPORT re3-targets
- DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
- )
-
- include(CMakeCPack.cmake)
+ install(DIRECTORY gamefiles/ DESTINATION ".")
+ if(LIBRW_PLATFORM_NULL)
+ set(platform "-null")
+ elseif(LIBRW_PLATFORM_PS2)
+ set(platform "-ps2")
+ elseif(LIBRW_PLATFORM_GL3)
+ if(LIBRW_GL3_GFXLIB STREQUAL "GLFW")
+ set(platform "-gl3-glfw")
+ else()
+ set(platform "-gl3-sdl2")
+ endif()
+ elseif(LIBRW_PLATFORM_D3D9)
+ set(platform "-d3d9")
+ endif()
+ if(RE3_AUDIO_OAL)
+ set(audio "-oal")
+ elseif(RE3_AUDIO_MSS)
+ set(audio "-mss")
+ endif()
+ if(RE3_WITH_OPUS)
+ set(audio "${audio}-opus")
+ endif()
+ if(NOT LIBRW_PLATFORM_PS2)
+ if(WIN32)
+ set(os "-win")
+ elseif(APPLE)
+ set(os "-apple")
+ elseif(UNIX)
+ set(os "-linux")
+ else()
+ set(compiler "-UNK")
+ message(WARNING "Unknown os. Created cpack package will be wrong. (override using cpack -P)")
+ endif()
+ endif()
+
+ set(CPACK_PACKAGE_NAME "${PROJECT_NAME}${platform}${audio}${os}${compiler}")
+ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "GTA III reversed")
+ set(CPACK_PACKAGE_VENDOR "GTAModding")
+ # FIXME: missing license (https://github.com/GTAmodding/re3/issues/794)
+ # set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/LICENSE")
+ # set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
+ set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}")
+ set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}")
+ set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}")
+ set(CPACK_GENERATOR "TXZ")
+ include(CPack)
endif()
diff --git a/cmake/FindMPG123.cmake b/cmake/FindMPG123.cmake
deleted file mode 100644
index a9b6dd8b..00000000
--- a/cmake/FindMPG123.cmake
+++ /dev/null
@@ -1,28 +0,0 @@
-# - Find mpg123
-# Find the native mpg123 includes and library
-#
-# MPG123_INCLUDE_DIR - where to find mpg123.h
-# MPG123_LIBRARIES - List of libraries when using mpg123.
-# MPG123_FOUND - True if mpg123 found.
-
-IF(MPG123_INCLUDE_DIR AND MPG123_LIBRARIES)
- # Already in cache, be silent
- SET(MPG123_FIND_QUIETLY TRUE)
-ENDIF(MPG123_INCLUDE_DIR AND MPG123_LIBRARIES)
-
-FIND_PATH(MPG123_INCLUDE_DIR mpg123.h
- PATHS "${MPG123_DIR}"
- PATH_SUFFIXES include
- )
-
-FIND_LIBRARY(MPG123_LIBRARIES NAMES mpg123 mpg123-0
- PATHS "${MPG123_DIR}"
- PATH_SUFFIXES lib
- )
-
-# MARK_AS_ADVANCED(MPG123_LIBRARIES MPG123_INCLUDE_DIR)
-
-# handle the QUIETLY and REQUIRED arguments and set MPG123_FOUND to TRUE if
-# all listed variables are TRUE
-INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(MPG123 DEFAULT_MSG MPG123_LIBRARIES MPG123_INCLUDE_DIR)
diff --git a/cmake/FindMilesSDK.cmake b/cmake/FindMilesSDK.cmake
new file mode 100644
index 00000000..57da3a6e
--- /dev/null
+++ b/cmake/FindMilesSDK.cmake
@@ -0,0 +1,34 @@
+# - Find Miles SDK
+# Find the Miles SDK header + import library
+#
+# MilesSDK_INCLUDE_DIR - Where to find mss.h
+# MilesSDK_LIBRARIES - List of libraries when using MilesSDK.
+# MilesSDK_FOUND - True if Miles SDK found.
+# MilesSDK::MilesSDK - Imported library of Miles SDK
+
+find_path(MilesSDK_INCLUDE_DIR mss.h
+ PATHS "${MilesSDK_DIR}"
+ PATH_SUFFIXES include
+)
+
+if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(_miles_sdk_libname mss64)
+else()
+ set(_miles_sdk_libname mss32)
+endif()
+
+find_library(MilesSDK_LIBRARIES NAMES ${_miles_sdk_libname}
+ PATHS "${MilesSDK_DIR}"
+ PATH_SUFFIXES lib
+)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(MilesSDK DEFAULT_MSG MilesSDK_LIBRARIES MilesSDK_INCLUDE_DIR)
+
+if(NOT TARGET MilesSDK::MilesSDK)
+ add_library(MilesSDK::MilesSDK UNKNOWN IMPORTED)
+ set_target_properties(MilesSDK::MilesSDK PROPERTIES
+ IMPORTED_LOCATION "${MilesSDK_LIBRARIES}
+ INTERFACE_INCLUDE_DIRECTORIES "${MilesSDK_INCLUDE_DIR}"
+ )
+endif()
diff --git a/cmake/FindSndFile.cmake b/cmake/FindSndFile.cmake
index 8ae47b70..5381af48 100644
--- a/cmake/FindSndFile.cmake
+++ b/cmake/FindSndFile.cmake
@@ -4,9 +4,11 @@
#
# Once done this will define
#
-# SNDFILE_FOUND - system has libsndfile
+# SNDFILE_FOUND - system has libsndfile
# SNDFILE_INCLUDE_DIRS - the libsndfile include directory
-# SNDFILE_LIBRARIES - Link these to use libsndfile
+# SNDFILE_LIBRARIES - Link these to use libsndfile
+# SNDFILE_CFLAGS - Compile options to use libsndfile
+# SndFile::SndFile - Imported library of libsndfile
#
# Copyright (C) 2006 Wengo
#
@@ -15,53 +17,51 @@
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
-if (SNDFILE_LIBRARIES AND SNDFILE_INCLUDE_DIRS)
- # in cache already
- set(SNDFILE_FOUND TRUE)
-else (SNDFILE_LIBRARIES AND SNDFILE_INCLUDE_DIRS)
+find_package(PkgConfig QUIET)
+if(PKG_CONFIG_FOUND)
+ pkg_search_module(PKG_SNDFILE "sndfile")
+endif()
- find_path(SNDFILE_INCLUDE_DIR
+find_path(SNDFILE_INCLUDE_DIR
NAMES
- sndfile.h
+ sndfile.h
+ HINTS
+ ${PKG_SNDFILE_INCLUDE_DIRS}
PATHS
- /usr/include
- /usr/local/include
- /opt/local/include
- /sw/include
- )
-
- find_library(SNDFILE_LIBRARY
+ /usr/include
+ /usr/local/include
+ /opt/local/include
+ /sw/include
+ )
+
+find_library(SNDFILE_LIBRARY
NAMES
- sndfile
+ sndfile
+ HINTS
+ ${PKG_SNDFILE_LIBRARIES}
PATHS
- /usr/lib
- /usr/local/lib
- /opt/local/lib
- /sw/lib
- )
+ /usr/lib
+ /usr/local/lib
+ /opt/local/lib
+ /sw/lib
+)
- set(SNDFILE_INCLUDE_DIRS
- ${SNDFILE_INCLUDE_DIR}
- )
- set(SNDFILE_LIBRARIES
- ${SNDFILE_LIBRARY}
- )
+set(SNDFILE_CFLAGS "${PKG_SNDFILE_CFLAGS_OTHER}" CACHE STRING "CFLAGS of libsndfile")
- if (SNDFILE_INCLUDE_DIRS AND SNDFILE_LIBRARIES)
- set(SNDFILE_FOUND TRUE)
- endif (SNDFILE_INCLUDE_DIRS AND SNDFILE_LIBRARIES)
+set(SNDFILE_INCLUDE_DIRS "${SNDFILE_INCLUDE_DIR}")
+set(SNDFILE_LIBRARIES "${SNDFILE_LIBRARY}")
- if (SNDFILE_FOUND)
- if (NOT SndFile_FIND_QUIETLY)
- message(STATUS "Found libsndfile: ${SNDFILE_LIBRARIES}")
- endif (NOT SndFile_FIND_QUIETLY)
- else (SNDFILE_FOUND)
- if (SndFile_FIND_REQUIRED)
- message(FATAL_ERROR "Could not find libsndfile")
- endif (SndFile_FIND_REQUIRED)
- endif (SNDFILE_FOUND)
+if(SNDFILE_INCLUDE_DIRS AND SNDFILE_LIBRARIES)
+ set(SNDFILE_FOUND TRUE)
+endif()
- # show the SNDFILE_INCLUDE_DIRS and SNDFILE_LIBRARIES variables only in the advanced view
- mark_as_advanced(SNDFILE_INCLUDE_DIRS SNDFILE_LIBRARIES)
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(SndFile DEFAULT_MSG SNDFILE_INCLUDE_DIRS SNDFILE_LIBRARIES)
-endif (SNDFILE_LIBRARIES AND SNDFILE_INCLUDE_DIRS)
+if(NOT TARGET SndFile::SndFile)
+ add_library(__SndFile INTERFACE)
+ target_compile_options(__SndFile INTERFACE ${SNDFILE_CFLAGS})
+ target_include_directories(__SndFile INTERFACE ${SNDFILE_INCLUDE_DIRS})
+ target_link_libraries(__SndFile INTERFACE ${SNDFILE_LIBRARIES})
+ add_library(SndFile::SndFile ALIAS __SndFile)
+endif()
diff --git a/cmake/Findmpg123.cmake b/cmake/Findmpg123.cmake
new file mode 100644
index 00000000..c6fe56bb
--- /dev/null
+++ b/cmake/Findmpg123.cmake
@@ -0,0 +1,38 @@
+# - Find mpg123
+# Find the native mpg123 includes and library
+#
+# mpg123_INCLUDE_DIR - Where to find mpg123.h
+# mpg123_LIBRARIES - List of libraries when using mpg123.
+# mpg123_CFLAGS - Compile options to use mpg123
+# mpg123_FOUND - True if mpg123 found.
+# MPG123::libmpg123 - Imported library of libmpg123
+
+find_package(PkgConfig QUIET)
+if(PKG_CONFIG_FOUND)
+ pkg_search_module(PKG_MPG123 mpg123)
+endif()
+
+find_path(mpg123_INCLUDE_DIR mpg123.h
+ HINTS ${PKG_MPG123_INCLUDE_DIRS}
+ PATHS "${mpg123_DIR}"
+ PATH_SUFFIXES include
+)
+
+find_library(mpg123_LIBRARIES NAMES mpg123 mpg123-0
+ HINTS ${PKG_MPG123_LIBRARIES}
+ PATHS "${mpg123_DIR}"
+ PATH_SUFFIXES lib
+)
+
+set(mpg123_CFLAGS "${PKG_MPG123_CFLAGS_OTHER}" CACHE STRING "CFLAGS of mpg123")
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(mpg123 DEFAULT_MSG mpg123_LIBRARIES mpg123_INCLUDE_DIR)
+
+if(NOT TARGET MPG123::libmpg123)
+ add_library(__libmpg123 INTERFACE)
+ target_compile_options(__libmpg123 INTERFACE ${mpg123_CFLAGS})
+ target_include_directories(__libmpg123 INTERFACE ${mpg123_INCLUDE_DIR})
+ target_link_libraries(__libmpg123 INTERFACE ${mpg123_LIBRARIES})
+ add_library(MPG123::libmpg123 ALIAS __libmpg123)
+endif()
diff --git a/cmake/Findopusfile.cmake b/cmake/Findopusfile.cmake
new file mode 100644
index 00000000..faae7645
--- /dev/null
+++ b/cmake/Findopusfile.cmake
@@ -0,0 +1,64 @@
+# - Try to find opusfile
+#
+# Once done this will define
+#
+# OPUSFILE_FOUND - system has opusfile
+# OPUSFILE_INCLUDE_DIRS - the opusfile include directories
+# OPUSFILE_LIBRARIES - Link these to use opusfile
+# OPUSFILE_CFLAGS - Compile options to use opusfile
+# opusfile::opusfile - Imported library of opusfile
+#
+
+# FIXME: opusfile does not ship an official opusfile cmake script,
+# rename this file/variables/target when/if it has.
+
+find_package(PkgConfig QUIET)
+if(PKG_CONFIG_FOUND)
+ pkg_search_module(PKG_OPUSFILE "opusfile")
+endif()
+
+find_path(OPUSFILE_INCLUDE_DIR
+ NAMES
+ opusfile.h
+ PATH_SUFFIXES
+ opusfile
+ HINTS
+ ${PKG_OPUSFILE_INCLUDE_DIRS}
+ PATHS
+ /usr/include
+ /usr/local/include
+ /opt/local/include
+ /sw/include
+ )
+
+find_library(OPUSFILE_LIBRARY
+ NAMES
+ opusfile
+ HINTS
+ ${PKG_OPUSFILE_LIBRARIES}
+ PATHS
+ /usr/lib
+ /usr/local/lib
+ /opt/local/lib
+ /sw/lib
+)
+
+set(OPUSFILE_CFLAGS "${PKG_OPUSFILE_CFLAGS_OTHER}" CACHE STRING "CFLAGS of opusfile")
+
+set(OPUSFILE_INCLUDE_DIRS "${OPUSFILE_INCLUDE_DIR}")
+set(OPUSFILE_LIBRARIES "${OPUSFILE_LIBRARY}")
+
+if (OPUSFILE_INCLUDE_DIRS AND OPUSFILE_LIBRARIES)
+set(OPUSFILE_FOUND TRUE)
+endif (OPUSFILE_INCLUDE_DIRS AND OPUSFILE_LIBRARIES)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(opusfile DEFAULT_MSG OPUSFILE_INCLUDE_DIRS OPUSFILE_LIBRARIES)
+
+if(NOT TARGET opusfile::opusfile)
+ add_library(__opusfile INTERFACE)
+ target_compile_options(__opusfile INTERFACE ${OPUSFILE_CFLAGS})
+ target_include_directories(__opusfile INTERFACE ${OPUSFILE_INCLUDE_DIRS})
+ target_link_libraries(__opusfile INTERFACE ${OPUSFILE_LIBRARIES})
+ add_library(opusfile::opusfile ALIAS __opusfile)
+endif()
diff --git a/conanfile.py b/conanfile.py
new file mode 100644
index 00000000..f0d63a20
--- /dev/null
+++ b/conanfile.py
@@ -0,0 +1,135 @@
+from conans import ConanFile, CMake, tools
+from conans.errors import ConanException, ConanInvalidConfiguration
+import os
+import shutil
+import textwrap
+
+
+class Re3Conan(ConanFile):
+ name = "re3"
+ version = "master"
+ license = "???" # FIXME: https://github.com/GTAmodding/re3/issues/794
+ settings = "os", "arch", "compiler", "build_type"
+ generators = "cmake", "cmake_find_package"
+ options = {
+ "audio": ["openal", "miles"],
+ "with_libsndfile": [True, False],
+ "with_opus": [True, False],
+ }
+ default_options = {
+ "audio": "openal",
+ "with_libsndfile": False,
+ "with_opus": True,
+ # "libsndfile:with_external_libs": False,
+ # "mpg123:flexible_resampling": False,
+ # "mpg123:network": False,
+ # "mpg123:icy": False,
+ # "mpg123:id3v2": False,
+ # "mpg123:ieeefloat": False,
+ # "mpg123:layer1": False,
+ # "mpg123:layer2": False,
+ # "mpg123:layer3": False,
+ # "mpg123:moreinfo": False,
+ # "sdl2:vulkan": False,
+ # "sdl2:opengl": True,
+ # "sdl2:sdl2main": True,
+ }
+ no_copy_source = True
+
+ @property
+ def _os_is_playstation2(self):
+ try:
+ return self.settings.os == "Playstation2"
+ except ConanException:
+ return False
+
+ def configure(self):
+ if self.options.audio != "openal":
+ self.options.with_libsndfile = False
+
+ def requirements(self):
+ self.requires("librw/{}".format(self.version))
+ self.requires("mpg123/1.26.4")
+ if self.options.audio == "openal":
+ self.requires("openal/1.21.0")
+ elif self.options.audio == "miles":
+ self.requires("miles-sdk/{}".format(self.version))
+ if self.options.with_libsndfile:
+ self.requires("libsndfile/1.0.30")
+ if self.options.with_opus:
+ self.requires("opusfile/0.12")
+
+ def export_sources(self):
+ for d in ("cmake", "src"):
+ shutil.copytree(src=d, dst=os.path.join(self.export_sources_folder, d))
+ self.copy("CMakeLists.txt")
+
+ def validate(self):
+ if self.options["librw"].platform == "gl3" and self.options["librw"].gl3_gfxlib != "glfw":
+ raise ConanInvalidConfiguration("Only `glfw` is supported as gl3_gfxlib.")
+ if not self.options.with_opus:
+ if not self.options["libsndfile"].with_external_libs:
+ raise ConanInvalidConfiguration("re3 with opus support requires a libsndfile built with external libs (=ogg/flac/opus/vorbis)")
+
+ @property
+ def _re3_audio(self):
+ return {
+ "miles": "MSS",
+ "openal": "OAL",
+ }[str(self.options.audio)]
+
+ def build(self):
+ if self.source_folder == self.build_folder:
+ raise Exception("cannot build with source_folder == build_folder")
+ try:
+ os.unlink(os.path.join(self.install_folder, "Findlibrw.cmake"))
+ tools.save("FindOpenAL.cmake",
+ textwrap.dedent(
+ """
+ set(OPENAL_FOUND ON)
+ set(OPENAL_INCLUDE_DIR ${OpenAL_INCLUDE_DIRS})
+ set(OPENAL_LIBRARY ${OpenAL_LIBRARIES})
+ set(OPENAL_DEFINITIONS ${OpenAL_DEFINITIONS})
+ """), append=True)
+ if self.options["librw"].platform == "gl3" and self.options["librw"].gl3_gfxlib == "glfw":
+ tools.save("Findglfw3.cmake",
+ textwrap.dedent(
+ """
+ if(NOT TARGET glfw)
+ message(STATUS "Creating glfw TARGET")
+ add_library(glfw INTERFACE IMPORTED)
+ set_target_properties(glfw PROPERTIES
+ INTERFACE_LINK_LIBRARIES CONAN_PKG::glfw)
+ endif()
+ """), append=True)
+ tools.save("CMakeLists.txt",
+ textwrap.dedent(
+ """
+ cmake_minimum_required(VERSION 3.0)
+ project(cmake_wrapper)
+
+ include("{}/conanbuildinfo.cmake")
+ conan_basic_setup(TARGETS NO_OUTPUT_DIRS)
+
+ add_subdirectory("{}" re3)
+ """).format(self.install_folder.replace("\\", "/"),
+ self.source_folder.replace("\\", "/")))
+ except FileNotFoundError:
+ pass
+ cmake = CMake(self)
+ cmake.definitions["RE3_AUDIO"] = self._re3_audio
+ cmake.definitions["RE3_WITH_OPUS"] = self.options.with_opus
+ cmake.definitions["RE3_INSTALL"] = True
+ cmake.definitions["RE3_VENDORED_LIBRW"] = False
+ env = {}
+ if self._os_is_playstation2:
+ cmake.definitions["CMAKE_TOOLCHAIN_FILE"] = self.deps_user_info["ps2dev-cmaketoolchain"].cmake_toolchain_file
+ env["PS2SDK"] = self.deps_cpp_info["ps2dev-ps2sdk"].rootpath
+
+ with tools.environment_append(env):
+ cmake.configure(source_folder=self.build_folder)
+ cmake.build()
+
+ def package(self):
+ cmake = CMake(self)
+ cmake.install()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ef322a9a..2f663061 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,89 +1,102 @@
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
-if(${RE3_AUDIO} STREQUAL "OAL")
- find_package(OpenAL REQUIRED)
- find_package(MPG123 REQUIRED)
- find_package(SndFile REQUIRED)
-endif()
-
-file(GLOB_RECURSE Sources "*.cpp" "*.h")
+file(GLOB_RECURSE RE3_SOURCES "*.cpp" "*.h" "*.rc")
-MACRO(HEADER_DIRECTORIES return_list)
- FILE(GLOB_RECURSE new_list *.cpp)
- SET(dir_list "animation"
- "audio"
- "collision"
- "control"
- "core"
- "entities"
- "extras"
- "fakerw"
- "math"
- "modelinfo"
- "objects"
- "peds"
- "render"
- "rw"
- "save"
- "skel"
- "text"
- "vehicles"
- "weapons")
- FOREACH(file_path ${new_list})
- GET_FILENAME_COMPONENT(dir_path ${file_path} PATH)
- SET(dir_list ${dir_list} ${dir_path})
- ENDFOREACH()
- LIST(REMOVE_DUPLICATES dir_list)
- SET(${return_list} ${dir_list})
-ENDMACRO()
+function(header_directories RETURN_LIST)
+ file(GLOB_RECURSE ALL_SRCS *.h *.cpp *.c)
+ set(RELDIRS)
+ foreach(SRC ${ALL_SRCS})
+ file(RELATIVE_PATH RELSRC "${CMAKE_CURRENT_SOURCE_DIR}" "${SRC}")
+ get_filename_component(RELDIR "${RELSRC}" DIRECTORY)
+ list(APPEND RELDIRS ${RELDIR})
+ endforeach()
+ list(REMOVE_DUPLICATES RELDIRS)
+ set(${RETURN_LIST} ${RELDIRS} PARENT_SCOPE)
+endfunction()
-HEADER_DIRECTORIES(header_list)
-include_directories(${header_list})
+header_directories(RE3_INCLUDES)
+add_executable(re3 WIN32
+ ${RE3_SOURCES}
+)
-add_executable(re3 ${Sources})
-target_link_libraries(re3 librw)
-target_link_libraries(re3 Threads::Threads)
-
-if(${RE3_AUDIO} STREQUAL "OAL")
- target_link_libraries(re3 ${OPENAL_LIBRARY})
- target_link_libraries(re3 ${MPG123_LIBRARIES})
- target_link_libraries(re3 ${SNDFILE_LIBRARIES})
-endif()
+target_link_libraries(re3 PRIVATE
+ librw::librw
+ Threads::Threads
+)
target_include_directories(re3
- INTERFACE
+ PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
- )
+ $<BUILD_INTERFACE:${RE3_INCLUDES}>
+)
target_compile_definitions(re3
PRIVATE
- "$<IF:$<CONFIG:DEBUG>,DEBUG,NDEBUG>"
- PUBLIC
- "RW_${RE3_PLATFORM}"
+ $<IF:$<CONFIG:DEBUG>,DEBUG,NDEBUG>
+ LIBRW
+ RE3_NO_AUTOLINK
+)
+
+if(LIBRW_PLATFORM_D3D9)
+ target_compile_definitions(re3
+ PUBLIC
+ USE_D3D9
)
+endif()
-target_compile_definitions(re3 PRIVATE LIBRW=1 AUDIO_OAL=1)
+if(RE3_AUDIO STREQUAL "OAL")
+ find_package(OpenAL REQUIRED)
+ target_include_directories(re3 PRIVATE ${OPENAL_INCLUDE_DIR})
+ target_link_libraries(re3 PRIVATE ${OPENAL_LIBRARY})
+ target_compile_definitions(re3 PRIVATE ${OPENAL_DEFINITIONS})
+ target_compile_definitions(re3 PRIVATE AUDIO_OAL)
+elseif(RE3_AUDIO STREQUAL "MSS")
+ find_package(MilesSDK REQUIRED)
+ target_compile_definitions(re3 PRIVATE AUDIO_MSS)
+ target_link_libraries(re3 PRIVATE MilesSDK::MilesSDK)
+endif()
+
+find_package(mpg123 REQUIRED)
+target_link_libraries(re3 PRIVATE
+ MPG123::libmpg123
+)
+if(RE3_WITH_OPUS)
+ find_package(opusfile REQUIRED)
+ target_link_libraries(re3 PRIVATE
+ opusfile::opusfile
+ )
+ target_compile_definitions(re3 PRIVATE AUDIO_OPUS)
+endif()
+if(RE3_WITH_LIBSNDFILE)
+ find_package(SndFile REQUIRED)
+ target_link_libraries(re3 PRIVATE
+ SndFile::SndFile
+ )
+ target_compile_definitions(re3 PRIVATE AUDIO_OAL_USE_SNDFILE)
+endif()
+
+target_compile_definitions(re3 PRIVATE )
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
target_compile_options(re3
PRIVATE
"-Wall"
- )
- if (NOT RE3_PLATFORM_PS2)
+ )
+ if (NOT LIBRW_PLATFORM_PS2)
target_compile_options(re3
PRIVATE
- "-Wextra"
- "-Wdouble-promotion"
- "-Wpedantic"
- )
+ -Wextra
+ -Wdouble-promotion
+ -Wpedantic
+ )
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(re3
PUBLIC
- /wd4996 /wd4244
- )
+ /Zc:sizedDealloc-
+ )
endif()
set_target_properties(re3
@@ -94,20 +107,15 @@ set_target_properties(re3
CXX_STANDARD 11
CXX_EXTENSIONS OFF
CXX_STANDARD_REQUIRED ON
- PREFIX ""
- )
+)
if(RE3_INSTALL)
- target_include_directories(re3
- INTERFACE
- $<INSTALL_INTERFACE:${RE3_INSTALL_INCLUDEDIR}>
- )
-
install(
TARGETS re3
EXPORT re3-targets
- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
- LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
- )
+ RUNTIME DESTINATION "."
+ )
+ if(MSVC)
+ install(FILES $<TARGET_PDB_FILE:re3> DESTINATION "." OPTIONAL)
+ endif()
endif()
diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp
index ccb17577..74ed86f4 100644
--- a/src/audio/oal/stream.cpp
+++ b/src/audio/oal/stream.cpp
@@ -4,7 +4,7 @@
#include "stream.h"
#include "sampman.h"
-#ifdef _WIN32
+#if defined _MSC_VER && !defined RE3_NO_AUTOLINK
#ifdef AUDIO_OAL_USE_SNDFILE
#pragma comment( lib, "libsndfile-1.lib" )
#endif
diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp
index cb4229eb..edf367b8 100644
--- a/src/control/CarCtrl.cpp
+++ b/src/control/CarCtrl.cpp
@@ -2415,7 +2415,7 @@ void CCarCtrl::SteerAICarWithPhysicsHeadingForTarget(CVehicle* pVehicle, CPhysic
*pHandbrake = true;
float maxAngle = FindMaxSteerAngle(pVehicle);
steerAngle = Min(maxAngle, Max(-maxAngle, steerAngle));
- float speedMultiplier = FindSpeedMultiplier(angleToTarget - angleForward,
+ float speedMultiplier = FindSpeedMultiplier(CGeneral::GetATanOfXY(targetX - pVehicle->GetPosition().x, targetY - pVehicle->GetPosition().y) - angleForward,
MIN_ANGLE_FOR_SPEED_LIMITING, MAX_ANGLE_FOR_SPEED_LIMITING, MIN_LOWERING_SPEED_COEFFICIENT);
float speedTarget = pVehicle->AutoPilot.m_nCruiseSpeed * speedMultiplier;
float currentSpeed = pVehicle->GetMoveSpeed().Magnitude() * GAME_SPEED_TO_CARAI_SPEED;
diff --git a/src/control/Script.cpp b/src/control/Script.cpp
index 3563a2b4..09a696cf 100644
--- a/src/control/Script.cpp
+++ b/src/control/Script.cpp
@@ -260,12 +260,12 @@ const tScriptCommandData commands[] = {
REGISTER_COMMAND(COMMAND_SET_LVAR_INT_TO_VAR_INT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " ="),
REGISTER_COMMAND(COMMAND_CSET_VAR_INT_TO_VAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " =#"),
REGISTER_COMMAND(COMMAND_CSET_VAR_FLOAT_TO_VAR_INT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " =#"),
- REGISTER_COMMAND(COMMAND_CSET_LVAR_INT_TO_LVAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " =#"),
- REGISTER_COMMAND(COMMAND_CSET_LVAR_FLOAT_TO_LVAR_INT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " =#"),
+ REGISTER_COMMAND(COMMAND_CSET_LVAR_INT_TO_VAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, 0, " =#"),
+ REGISTER_COMMAND(COMMAND_CSET_LVAR_FLOAT_TO_VAR_INT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, 0, " =#"),
REGISTER_COMMAND(COMMAND_CSET_VAR_INT_TO_LVAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " =#"),
REGISTER_COMMAND(COMMAND_CSET_VAR_FLOAT_TO_LVAR_INT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " =#"),
- REGISTER_COMMAND(COMMAND_CSET_LVAR_INT_TO_VAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " =#"),
- REGISTER_COMMAND(COMMAND_CSET_LVAR_FLOAT_TO_VAR_INT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " =#"),
+ REGISTER_COMMAND(COMMAND_CSET_LVAR_INT_TO_LVAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, 0, " =#"),
+ REGISTER_COMMAND(COMMAND_CSET_LVAR_FLOAT_TO_LVAR_INT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, 0, " =#"),
REGISTER_COMMAND(COMMAND_ABS_VAR_INT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " ABS"),
REGISTER_COMMAND(COMMAND_ABS_LVAR_INT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " ABS"),
REGISTER_COMMAND(COMMAND_ABS_VAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " ABS"),
diff --git a/src/control/Script5.cpp b/src/control/Script5.cpp
index 751fefa2..e74a1081 100644
--- a/src/control/Script5.cpp
+++ b/src/control/Script5.cpp
@@ -2355,7 +2355,7 @@ int CTheScripts::FindFreeSlotInCollectiveArray()
void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective objective, int16 p1, int16 p2)
{
for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) {
- if (CollectiveArray[i].colIndex = colIndex) {
+ if (CollectiveArray[i].colIndex == colIndex) {
CPed* pPed = CPools::GetPedPool()->GetAt(CollectiveArray[i].pedIndex);
if (pPed == nil) {
CollectiveArray[i].colIndex = -1;
@@ -2372,7 +2372,7 @@ void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective ob
void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective objective, CVector p1, float p2)
{
for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) {
- if (CollectiveArray[i].colIndex = colIndex) {
+ if (CollectiveArray[i].colIndex == colIndex) {
CPed* pPed = CPools::GetPedPool()->GetAt(CollectiveArray[i].pedIndex);
if (pPed == nil) {
CollectiveArray[i].colIndex = -1;
@@ -2389,7 +2389,7 @@ void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective ob
void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective objective, CVector p1)
{
for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) {
- if (CollectiveArray[i].colIndex = colIndex) {
+ if (CollectiveArray[i].colIndex == colIndex) {
CPed* pPed = CPools::GetPedPool()->GetAt(CollectiveArray[i].pedIndex);
if (pPed == nil) {
CollectiveArray[i].colIndex = -1;
@@ -2406,7 +2406,7 @@ void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective ob
void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective objective, void* p1)
{
for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) {
- if (CollectiveArray[i].colIndex = colIndex) {
+ if (CollectiveArray[i].colIndex == colIndex) {
CPed* pPed = CPools::GetPedPool()->GetAt(CollectiveArray[i].pedIndex);
if (pPed == nil) {
CollectiveArray[i].colIndex = -1;
@@ -2423,7 +2423,7 @@ void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective ob
void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective objective)
{
for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) {
- if (CollectiveArray[i].colIndex = colIndex) {
+ if (CollectiveArray[i].colIndex == colIndex) {
CPed* pPed = CPools::GetPedPool()->GetAt(CollectiveArray[i].pedIndex);
if (pPed == nil) {
CollectiveArray[i].colIndex = -1;
diff --git a/src/render/Particle.cpp b/src/render/Particle.cpp
index 08137d0c..6c643caf 100644
--- a/src/render/Particle.cpp
+++ b/src/render/Particle.cpp
@@ -1839,9 +1839,9 @@ void CParticle::AddJetExplosion(CVector const &vecPos, float fPower, float fSize
vecStepPos,
CVector
(
- CGeneral::GetRandomNumberInRange(-0.2f, 0.2f),
- CGeneral::GetRandomNumberInRange(-0.2f, 0.2f),
- CGeneral::GetRandomNumberInRange(-0.2f, 0.0f)
+ CGeneral::GetRandomNumberInRange(-0.02f, 0.02f),
+ CGeneral::GetRandomNumberInRange(-0.02f, 0.02f),
+ CGeneral::GetRandomNumberInRange(-0.02f, 0.0f)
),
nil,
fSize, color, 0, 0, 0, 0);
diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp
index 8f034126..ed187849 100644
--- a/src/vehicles/Automobile.cpp
+++ b/src/vehicles/Automobile.cpp
@@ -239,17 +239,17 @@ CAutomobile::ProcessControl(void)
// Improve grip of vehicles in certain cases
bool strongGrip1 = false;
bool strongGrip2 = false;
- if(FindPlayerVehicle() && this != FindPlayerVehicle() &&
+ if(FindPlayerVehicle() && this != FindPlayerVehicle() && FindPlayerPed()->m_pWanted->m_nWantedLevel > 3 &&
(AutoPilot.m_nCarMission == MISSION_RAMPLAYER_FARAWAY || AutoPilot.m_nCarMission == MISSION_RAMPLAYER_CLOSE ||
- AutoPilot.m_nCarMission == MISSION_BLOCKPLAYER_FARAWAY || AutoPilot.m_nCarMission == MISSION_BLOCKPLAYER_CLOSE)){
- if(FindPlayerSpeed().Magnitude() > 0.3f){
- strongGrip1 = true;
- if(FindPlayerSpeed().Magnitude() > 0.4f &&
- m_vecMoveSpeed.Magnitude() < 0.3f)
- strongGrip2 = true;
- else if((GetPosition() - FindPlayerCoors()).Magnitude() > 50.0f)
- strongGrip2 = true;
- }
+ AutoPilot.m_nCarMission == MISSION_BLOCKPLAYER_FARAWAY || AutoPilot.m_nCarMission == MISSION_BLOCKPLAYER_CLOSE) &&
+ FindPlayerSpeed().Magnitude() > 0.3f){
+
+ strongGrip1 = true;
+ if(FindPlayerSpeed().Magnitude() > 0.4f &&
+ m_vecMoveSpeed.Magnitude() < 0.3f)
+ strongGrip2 = true;
+ else if((GetPosition() - FindPlayerCoors()).Magnitude() > 50.0f)
+ strongGrip2 = true;
}
if(bIsBus)