diff options
-rw-r--r-- | .github/workflows/build-cmake-conan.yml | 116 | ||||
-rw-r--r-- | .github/workflows/reLCS_msvc_amd64.yml | 2 | ||||
-rw-r--r-- | .github/workflows/reLCS_msvc_x86.yml | 2 | ||||
-rw-r--r-- | .travis.yml | 44 | ||||
-rw-r--r-- | cmake/FindMilesSDK.cmake | 34 | ||||
-rw-r--r-- | cmake/Findopusfile.cmake | 64 | ||||
-rw-r--r-- | conanfile.py | 135 | ||||
-rw-r--r-- | premake5.lua | 2 | ||||
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/audio/AudioLogic.cpp | 1 | ||||
-rw-r--r-- | src/audio/oal/stream.cpp | 2 | ||||
-rw-r--r-- | src/audio/sampman_oal.cpp | 19 | ||||
-rw-r--r-- | src/collision/Collision.cpp | 15 | ||||
-rw-r--r-- | src/control/Script7.cpp | 4 | ||||
-rw-r--r-- | src/control/Script8.cpp | 6 | ||||
-rw-r--r-- | src/core/Cam.cpp | 10 | ||||
-rw-r--r-- | src/core/SurfaceTable.h | 1 | ||||
-rw-r--r-- | src/render/Font.cpp | 836 | ||||
-rw-r--r-- | src/render/Font.h | 111 | ||||
-rw-r--r-- | src/render/Hud.cpp | 8 | ||||
-rw-r--r-- | src/weapons/Weapon.cpp | 18 |
21 files changed, 919 insertions, 513 deletions
diff --git a/.github/workflows/build-cmake-conan.yml b/.github/workflows/build-cmake-conan.yml new file mode 100644 index 00000000..04bca81f --- /dev/null +++ b/.github/workflows/build-cmake-conan.yml @@ -0,0 +1,116 @@ +name: reLCS 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 }} reLCS/master@ -if build -o reLCS: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 reLCS:build_type=RelWithDebInfo -s librw:build_type=RelWithDebInfo + env: + CONAN_SYSREQUIRES_MODE: enabled + - name: "Build reLCS (conan build)" + run: | + conan build ${{ github.workspace }} -if build -bf build -pf package + - name: "Package reLCS (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/.github/workflows/reLCS_msvc_amd64.yml b/.github/workflows/reLCS_msvc_amd64.yml index 012051a9..f79df578 100644 --- a/.github/workflows/reLCS_msvc_amd64.yml +++ b/.github/workflows/reLCS_msvc_amd64.yml @@ -1,4 +1,4 @@ -name: reLCS_msvc_amd64 +name: reLCS premake amd64 on: pull_request: diff --git a/.github/workflows/reLCS_msvc_x86.yml b/.github/workflows/reLCS_msvc_x86.yml index bffd545f..324f0754 100644 --- a/.github/workflows/reLCS_msvc_x86.yml +++ b/.github/workflows/reLCS_msvc_x86.yml @@ -1,4 +1,4 @@ -name: reLCS_msvc_x86 +name: reLCS premake x86 on: pull_request: diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c124a9f0..00000000 --- a/.travis.yml +++ /dev/null @@ -1,44 +0,0 @@ -language: cpp -dist: focal -os: linux -jobs: - include: - - env: TARGET=release_linux-amd64-librw_gl3_glfw-oal - os: linux - - env: TARGET=debug_linux-amd64-librw_gl3_glfw-oal - os: linux - - env: TARGET=release_macosx-amd64-librw_gl3_glfw-oal PREMAKE5=premake-5.0.0-alpha15 - compiler: clang - os: osx - osx_image: xcode12u - - env: TARGET=debug_macosx-amd64-librw_gl3_glfw-oal PREMAKE5=premake-5.0.0-alpha15 - compiler: clang - os: osx - osx_image: xcode12u -addons: - apt: - update: true - packages: - - linux-libc-dev - - libopenal-dev - - libglew-dev - - libglfw3-dev - - libsndfile1-dev - - libmpg123-dev - - gcc-8-multilib - - g++-8-multilib - homebrew: - packages: - - libsndfile - - mpg123 - - glew - - glfw - - openal-soft -script: - - mkdir -p "$TRAVIS_BUILD_DIR/build" - - cd "$TRAVIS_BUILD_DIR" - - if [ "$TRAVIS_OS_NAME" = linux ]; then ./premake5Linux --with-librw gmake2; fi - - if [ "$TRAVIS_OS_NAME" = osx ]; then curl -L -o "${PREMAKE5}.zip" "https://github.com/premake/premake-core/releases/download/v5.0.0-alpha15/${PREMAKE5}-src.zip" && unzip -q "${PREMAKE5}.zip" && cd "$PREMAKE5" && make -f Bootstrap.mak osx && cd .. && "./${PREMAKE5}/bin/release/premake5" --with-librw gmake2; fi - - cd build - - if [ "$TRAVIS_OS_NAME" = linux ]; then env CC=gcc-8 CXX=g++-8 make config=$TARGET -j4 verbose=1; fi - - if [ "$TRAVIS_OS_NAME" = osx ]; then make config=$TARGET -j4 verbose=1; fi 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/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..69a77503 --- /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 ReLCSConan(ConanFile): + name = "reLCS" + 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": False, + # "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("reLCS with opus support requires a libsndfile built with external libs (=ogg/flac/opus/vorbis)") + + @property + def _reLCS_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("{}" reLCS) + """).format(self.install_folder.replace("\\", "/"), + self.source_folder.replace("\\", "/"))) + except FileNotFoundError: + pass + cmake = CMake(self) + cmake.definitions["RELCS_AUDIO"] = self._reLCS_audio + cmake.definitions["RELCS_WITH_OPUS"] = self.options.with_opus + cmake.definitions["RELCS_INSTALL"] = True + cmake.definitions["RELCS_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/premake5.lua b/premake5.lua index 11a0bbbd..128f3cae 100644 --- a/premake5.lua +++ b/premake5.lua @@ -309,7 +309,7 @@ project "reLCS" filter {} if(os.getenv("GTA_LCS_RE_DIR")) then - setpaths("$(GTA_LCS_RE_DIR)/", "%(cfg.buildtarget.name)", "") + setpaths("$(GTA_LCS_RE_DIR)/", "%(cfg.buildtarget.name)") end filter "platforms:win*" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dc204d17..ad72eb56 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -36,7 +36,7 @@ target_compile_definitions(${EXECUTABLE} PRIVATE $<IF:$<CONFIG:DEBUG>,DEBUG,NDEBUG> LIBRW - ${PROJECT}_NO_AUTOLINK + CMAKE_NO_AUTOLINK ) if(LIBRW_PLATFORM_D3D9) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index cd341eac..1f32890c 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -4106,6 +4106,7 @@ cAudioManager::SetupJumboFlySound(uint8 emittingVol) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 5; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; // todo port fix to re3 diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index 81a78381..19fa4ec4 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 CMAKE_NO_AUTOLINK #ifdef AUDIO_OAL_USE_SNDFILE #pragma comment( lib, "libsndfile-1.lib" ) #endif diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index ef070825..ec85fc43 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -38,7 +38,7 @@ //TODO: max channels //TODO: loop count -#ifdef _WIN32 +#if defined _MSC_VER && !defined CMAKE_NO_AUTOLINK #pragma comment( lib, "OpenAL32.lib" ) #endif @@ -996,12 +996,14 @@ cSampleManager::Initialise(void) #ifdef AUDIO_CACHE FILE *cacheFile = fcaseopen("audio\\sound.cache", "rb"); if (cacheFile) { + debug("Loadind audio cache (If game crashes around here, then your cache is corrupted, remove audio/sound.cache)\n"); fread(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); fclose(cacheFile); } else -#endif { - + debug("Cannot load audio cache\n"); +#endif + for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) { aStream[0] = new CStream(StreamedNameTable[i], ALStreamSources[0], ALStreamBuffers[0], IsThisTrackAt16KHz(i) ? 16000 : 32000); @@ -1019,10 +1021,15 @@ cSampleManager::Initialise(void) } #ifdef AUDIO_CACHE cacheFile = fcaseopen("audio\\sound.cache", "wb"); - fwrite(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); - fclose(cacheFile); -#endif + if(cacheFile) { + debug("Saving audio cache\n"); + fwrite(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); + fclose(cacheFile); + } else { + debug("Cannot save audio cache\n"); + } } +#endif { if ( !InitialiseSampleBanks() ) diff --git a/src/collision/Collision.cpp b/src/collision/Collision.cpp index c90390c4..703804d9 100644 --- a/src/collision/Collision.cpp +++ b/src/collision/Collision.cpp @@ -507,12 +507,14 @@ CCollision::TestLineOfSight(const CColLine &line, const CMatrix &matrix, CColMod for(i = 0; i < model.numSpheres; i++){ if(ignoreSeeThrough && IsSeeThrough(model.spheres[i].surface)) continue; + if(ignoreShootThrough && IsShootThrough(model.spheres[i].surface)) continue; if(TestLineSphere(*(CColLine*)newline, model.spheres[i])) return true; } for(i = 0; i < model.numBoxes; i++){ if(ignoreSeeThrough && IsSeeThrough(model.boxes[i].surface)) continue; + if(ignoreShootThrough && IsShootThrough(model.boxes[i].surface)) continue; if(TestLineBox(*(CColLine*)newline, model.boxes[i])) return true; } @@ -522,6 +524,7 @@ CCollision::TestLineOfSight(const CColLine &line, const CMatrix &matrix, CColMod VuTriangle vutri; for(i = 0; i < model.numTriangles; i++){ if(ignoreSeeThrough && IsSeeThrough(model.triangles[i].surface)) continue; + if(ignoreShootThrough && IsShootThrough(model.triangles[i].surface)) continue; CColTriangle *tri = &model.triangles[i]; model.vertices[tri->a].Unpack(vutri.v0); @@ -539,6 +542,7 @@ CCollision::TestLineOfSight(const CColLine &line, const CMatrix &matrix, CColMod #endif for(; i < model.numTriangles; i++){ if(ignoreSeeThrough && IsSeeThrough(model.triangles[i].surface)) continue; + if(ignoreShootThrough && IsShootThrough(model.triangles[i].surface)) continue; CColTriangle *tri = &model.triangles[i]; model.vertices[tri->a].Unpack(vutri.v0); @@ -1333,6 +1337,7 @@ CCollision::ProcessLineOfSight(const CColLine &line, float coldist = 1.0f; for(i = 0; i < model.numSpheres; i++){ if(ignoreSeeThrough && IsSeeThrough(model.spheres[i].surface)) continue; + if(ignoreShootThrough && IsShootThrough(model.spheres[i].surface)) continue; if(ProcessLineSphere(*(CColLine*)newline, model.spheres[i], point, coldist)) point.Set(0, 0, model.spheres[i].surface, model.spheres[i].piece); } @@ -1348,6 +1353,7 @@ CCollision::ProcessLineOfSight(const CColLine &line, CColTriangle *lasttri = nil; for(i = 0; i < model.numTriangles; i++){ if(ignoreSeeThrough && IsSeeThrough(model.triangles[i].surface)) continue; + if(ignoreShootThrough && IsShootThrough(model.triangles[i].surface)) continue; CColTriangle *tri = &model.triangles[i]; model.vertices[tri->a].Unpack(vutri.v0); @@ -1367,6 +1373,7 @@ CCollision::ProcessLineOfSight(const CColLine &line, float dist; for(; i < model.numTriangles; i++){ if(ignoreSeeThrough && IsSeeThrough(model.triangles[i].surface)) continue; + if(ignoreShootThrough && IsShootThrough(model.triangles[i].surface)) continue; CColTriangle *tri = &model.triangles[i]; model.vertices[tri->a].Unpack(vutri.v0); @@ -1466,13 +1473,13 @@ CCollision::ProcessVerticalLine(const CColLine &line, float coldist = 1.0f; for(i = 0; i < model.numSpheres; i++){ - if(ignoreSeeThrough && IsSeeThrough(model.spheres[i].surface)) continue; + if(ignoreSeeThrough && IsSeeThroughVertical(model.spheres[i].surface)) continue; if(ProcessLineSphere(*(CColLine*)newline, model.spheres[i], point, coldist)) point.Set(0, 0, model.spheres[i].surface, model.spheres[i].piece); } for(i = 0; i < model.numBoxes; i++){ - if(ignoreSeeThrough && IsSeeThrough(model.boxes[i].surface)) continue; + if(ignoreSeeThrough && IsSeeThroughVertical(model.boxes[i].surface)) continue; if(ProcessLineBox(*(CColLine*)newline, model.boxes[i], point, coldist)) point.Set(0, 0, model.boxes[i].surface, model.boxes[i].piece); } @@ -1484,7 +1491,7 @@ CCollision::ProcessVerticalLine(const CColLine &line, CColTriangle *lasttri = nil; VuTriangle vutri; for(i = 0; i < model.numTriangles; i++){ - if(ignoreSeeThrough && IsSeeThrough(model.triangles[i].surface)) continue; + if(ignoreSeeThrough && IsSeeThroughVertical(model.triangles[i].surface)) continue; CColTriangle *tri = &model.triangles[i]; model.vertices[tri->a].Unpack(vutri.v0); @@ -1503,7 +1510,7 @@ CCollision::ProcessVerticalLine(const CColLine &line, CVuVector pnt, normal; float dist; for(; i < model.numTriangles; i++){ - if(ignoreSeeThrough && IsSeeThrough(model.triangles[i].surface)) continue; + if(ignoreSeeThrough && IsSeeThroughVertical(model.triangles[i].surface)) continue; CColTriangle *tri = &model.triangles[i]; model.vertices[tri->a].Unpack(vutri.v0); diff --git a/src/control/Script7.cpp b/src/control/Script7.cpp index b3f16106..a5c8e717 100644 --- a/src/control/Script7.cpp +++ b/src/control/Script7.cpp @@ -95,8 +95,8 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); script_assert(pPed); - ScriptParams[0] = pPed->GetWeapon(ScriptParams[1]).m_eWeaponType; - ScriptParams[1] = pPed->GetWeapon(ScriptParams[1]).m_nAmmoTotal; + ScriptParams[0] = pPed->GetWeapon(ScriptParams[1] - 1).m_eWeaponType; + ScriptParams[1] = pPed->GetWeapon(ScriptParams[1] - 1).m_nAmmoTotal; ScriptParams[2] = CPickups::ModelForWeapon((eWeaponType)ScriptParams[0]); StoreParameters(&m_nIp, 3); return 0; diff --git a/src/control/Script8.cpp b/src/control/Script8.cpp index 2f52b150..afa213f2 100644 --- a/src/control/Script8.cpp +++ b/src/control/Script8.cpp @@ -66,7 +66,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) return 0; case COMMAND_WANTED_STARS_ARE_FLASHING: { - CWanted *pWanted = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted; + CWanted* pWanted = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted; UpdateCompareFlag(pWanted->m_nMinWantedLevel - pWanted->m_nWantedLevel > 0); return 0; } @@ -136,7 +136,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) CTheScripts::ReadTextLabelFromScript(&m_nIp, key); m_nIp += KEY_LENGTH_IN_SCRIPT; CVector pos = pPlayerInfo->GetPos(); - CZone *infoZone = CTheZones::FindInformationZoneForPosition(&pos); + CZone* infoZone = CTheZones::FindInformationZoneForPosition(&pos); UpdateCompareFlag(strncmp(key, infoZone->name, 8) == 0); // original code doesn't seem to be using strncmp in here and compare 2 ints instead return 0; } @@ -352,7 +352,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_CREATE_DUST_EFFECT_FOR_CUTSCENE_HELI: { CollectParameters(&m_nIp, 3); - CObject *pHeli = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pHeli = CPools::GetObjectPool()->GetAt(ScriptParams[0]); bool found = false; float waterLevel = -1000.0f; CVector pos = pHeli->GetPosition(); diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp index 581e219a..bb3a0fbe 100644 --- a/src/core/Cam.cpp +++ b/src/core/Cam.cpp @@ -4350,7 +4350,7 @@ CCam::ProcessArrestCamOne(void) ((CPed*)TheCamera.pTargetEntity)->m_pedIK.GetComponentPosition(TargetPos, PED_MID); if(FindPlayerPed() && FindPlayerPed()->m_pArrestingCop) cop = FindPlayerPed()->m_pArrestingCop; - if(cop && CGeneral::GetRandomNumberInRange(0.0f, 0.1f) > 0.5f){ + if(cop && CGeneral::GetRandomNumberInRange(0.0f, 1.0f) > 0.5f){ ArrestModes[0] = ARRESTCAM_OVERSHOULDER; ArrestModes[1] = ARRESTCAM_ALONGGROUND; ArrestModes[2] = ARRESTCAM_OVERSHOULDER; @@ -4372,7 +4372,7 @@ CCam::ProcessArrestCamOne(void) if(FindPlayerPed() && FindPlayerPed()->m_pArrestingCop) cop = FindPlayerPed()->m_pArrestingCop; - if(cop && CGeneral::GetRandomNumberInRange(0.0f, 0.1f) > 0.65f){ + if(cop && CGeneral::GetRandomNumberInRange(0.0f, 1.0f) > 0.65f){ ArrestModes[0] = ARRESTCAM_OVERSHOULDER; ArrestModes[1] = ARRESTCAM_LAMPPOST; ArrestModes[2] = ARRESTCAM_ALONGGROUND; @@ -4442,6 +4442,7 @@ CCam::ProcessArrestCamOne(void) pStoredCopPed = nil; } + Source = CamSource; CVector OrigSource = Source; TheCamera.AvoidTheGeometry(OrigSource, TargetPos, Source, FOV); Front = TargetPos - Source; @@ -4468,8 +4469,9 @@ CCam::ProcessArrestCamOne(void) if(nUsingWhichCamera == ARRESTCAM_OVERSHOULDER && pStoredCopPed){ foundPos = GetLookOverShoulderPos(TheCamera.pTargetEntity, pStoredCopPed, TargetPos, CamSource); - if(CamSource.z > Source.z + ARRESTCAM_S_ROTATION_UP*CTimer::GetTimeStep()) - CamSource.z = Source.z + ARRESTCAM_S_ROTATION_UP*CTimer::GetTimeStep(); + float newZ = Source.z + ARRESTCAM_S_ROTATION_UP*CTimer::GetTimeStep(); + if(CamSource.z > newZ) + CamSource.z = newZ; }else if(nUsingWhichCamera >= ARRESTCAM_ALONGGROUND_RIGHT && nUsingWhichCamera <= ARRESTCAM_ALONGGROUND_LEFT_UP){ CamSource = Source; Front = TargetPos - CamSource; diff --git a/src/core/SurfaceTable.h b/src/core/SurfaceTable.h index cd08c843..8ff43106 100644 --- a/src/core/SurfaceTable.h +++ b/src/core/SurfaceTable.h @@ -81,6 +81,7 @@ inline bool IsShootThrough(uint8 surfType) { switch(surfType) + case SURFACE_TRANSPARENT_CLOTH: case SURFACE_METAL_CHAIN_FENCE: case SURFACE_TRANSPARENT_STONE: case SURFACE_SCAFFOLD_POLE: diff --git a/src/render/Font.cpp b/src/render/Font.cpp index d15dc7d3..3798c5f2 100644 --- a/src/render/Font.cpp +++ b/src/render/Font.cpp @@ -390,7 +390,7 @@ CFont::InitPerFrame(void) Details.anonymous_25 = 0; FontRenderStatePointer.pRenderState = (CFontRenderState*)FontRenderStateBuf; SetDropShadowPosition(0); - NewLine = 0; + NewLine = false; #ifdef BUTTON_ICONS PS2Symbol = BUTTON_NONE; #endif @@ -543,6 +543,210 @@ bool CFont::IsAnsiCharacter(wchar *s) #endif void +CFont::RenderFontBuffer() +{ + if (FontRenderStatePointer.pRenderState == (CFontRenderState*)FontRenderStateBuf) return; + + float textPosX; + float textPosY; + CRGBA color; + bool bBold = false; + bool bFlash = false; + + Sprite[RenderState.style].SetRenderState(); + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); + RenderState = *(CFontRenderState*)&FontRenderStateBuf[0]; + textPosX = RenderState.fTextPosX; + textPosY = RenderState.fTextPosY; + color = RenderState.color; + tFontRenderStatePointer pRenderStateBufPointer; + pRenderStateBufPointer.pRenderState = (CFontRenderState*)&FontRenderStateBuf[0]; + for (++pRenderStateBufPointer.pRenderState; pRenderStateBufPointer.pStr < FontRenderStatePointer.pStr; pRenderStateBufPointer.pStr++) { + if (*pRenderStateBufPointer.pStr == '\0') { + tFontRenderStatePointer tmpPointer = pRenderStateBufPointer; + tmpPointer.pStr++; + tmpPointer.Align(); + if (tmpPointer.pStr >= FontRenderStatePointer.pStr) + break; + + RenderState = *(tmpPointer.pRenderState++); + + pRenderStateBufPointer = tmpPointer; + + textPosX = RenderState.fTextPosX; + textPosY = RenderState.fTextPosY; + color = RenderState.color; + } + if (*pRenderStateBufPointer.pStr == '~') { +#ifdef BUTTON_ICONS + PS2Symbol = BUTTON_NONE; +#endif + pRenderStateBufPointer.pStr = ParseToken(pRenderStateBufPointer.pStr, color, bFlash, bBold); +#ifdef BUTTON_ICONS + if(PS2Symbol != BUTTON_NONE) { + DrawButton(textPosX, textPosY); + textPosX += Details.scaleY * 17.0f; + PS2Symbol = BUTTON_NONE; + } +#endif + if (bFlash) { + if (CTimer::GetTimeInMilliseconds() - Details.nFlashTimer > 300) { + Details.bFlashState = !Details.bFlashState; + Details.nFlashTimer = CTimer::GetTimeInMilliseconds(); + } + Details.color.alpha = Details.bFlashState ? 0 : 255; + } + if (!RenderState.bIsShadow) + RenderState.color = color; + } + wchar c = *pRenderStateBufPointer.pStr; + c -= ' '; + if (RenderState.bFontHalfTexture) + c = FindNewCharacter(c); + else if (c > 155) + c = '\0'; + + if (RenderState.slant != 0.0f) + textPosY = (RenderState.slantRefX - textPosX) * RenderState.slant + RenderState.slantRefY; + PrintChar(textPosX, textPosY, c); + if (bBold) { + PrintChar(textPosX + 1.0f, textPosY, c); + PrintChar(textPosX + 2.0f, textPosY, c); + textPosX += 2.0f; + } +#ifdef FIX_BUGS + // PS2 uses different chars for some symbols + if (!RenderState.bFontHalfTexture && c == 30) c = 61; // wanted star +#endif + textPosX += RenderState.scaleX * GetCharacterWidth(c); + if (c == '\0') + textPosX += RenderState.fExtraSpace; + } + CSprite2d::RenderVertexBuffer(); + FontRenderStatePointer.pRenderState = (CFontRenderState*)FontRenderStateBuf; +} + +#ifdef MORE_LANGUAGES +bool +CFont::PrintString(float x, float y, wchar *start, wchar *&end, float spwidth, float japX) +{ + wchar *s, c, unused; + + if (IsJapanese()) { + float jx = 0.0f; + for (s = start; s < end; s++) { + if (*s == JAP_TERMINATION || *s == '~') + s = ParseToken(s, &unused, true); + if (NewLine) { + NewLine = false; + break; + } + jx += GetCharacterSize(*s - ' '); + } + s = start; + if (Details.centre) + x = japX - jx / 2.0f; + else if (Details.rightJustify) + x = japX - jx; + } + + for (s = start; s < end; s++) { + if (*s == '~' || (IsJapanese() && *s == JAP_TERMINATION)) + s = ParseToken(s, &unused); + if (NewLine && IsJapanese()) { + NewLine = false; + end = s; + return true; + } + c = *s - ' '; + if (Details.slant != 0.0f && !IsJapanese()) + y = (Details.slantRefX - x) * Details.slant + Details.slantRefY; + + PrintChar(x, y, c); + x += GetCharacterSize(c); + if (c == 0 && (!NewLine || !IsJapanese())) // space + x += spwidth; + } + return false; +} +#else +void +CFont::PrintString(float x, float y, uint32, wchar *start, wchar *end, float spwidth) +{ + wchar *s; + + if (RenderState.style != Details.style) { + RenderFontBuffer(); + RenderState.style = Details.style; + } + + float dropShadowPosition = Details.dropShadowPosition; + if (dropShadowPosition != 0.0f && (Details.style == FONT_BANK || Details.style == FONT_STANDARD)) { + CRGBA color = Details.color; + Details.color = Details.dropColor; + Details.dropShadowPosition = 0; + Details.bIsShadow = true; + if (Details.slant != 0.0f) { + Details.slantRefX += SCREEN_SCALE_X(dropShadowPosition); + Details.slantRefY += SCREEN_SCALE_Y(dropShadowPosition); + PrintString(SCREEN_SCALE_X(dropShadowPosition) + x, SCREEN_SCALE_Y(dropShadowPosition) + y, Details.anonymous_25, start, end, spwidth); + Details.slantRefX -= SCREEN_SCALE_X(dropShadowPosition); + Details.slantRefY -= SCREEN_SCALE_Y(dropShadowPosition); + } else { + PrintString(SCREEN_SCALE_X(dropShadowPosition) + x, SCREEN_SCALE_Y(dropShadowPosition) + y, Details.anonymous_25, start, end, spwidth); + } + Details.color = color; + Details.dropShadowPosition = dropShadowPosition; + Details.bIsShadow = false; + } + if (FontRenderStatePointer.pStr >= (wchar*)&FontRenderStateBuf[ARRAY_SIZE(FontRenderStateBuf)] - (end - start + 26)) // why 26? + RenderFontBuffer(); + CFontRenderState *pRenderState = FontRenderStatePointer.pRenderState; + pRenderState->fTextPosX = x; + pRenderState->fTextPosY = y; + pRenderState->scaleX = Details.scaleX; + pRenderState->scaleY = Details.scaleY; + pRenderState->color = Details.color; + pRenderState->fExtraSpace = spwidth; + pRenderState->slant = Details.slant; + pRenderState->slantRefX = Details.slantRefX; + pRenderState->slantRefY = Details.slantRefY; + pRenderState->bFontHalfTexture = Details.bFontHalfTexture; + pRenderState->proportional = Details.proportional; + pRenderState->style = Details.style; + pRenderState->bIsShadow = Details.bIsShadow; + FontRenderStatePointer.pRenderState++; + + for(s = start; s < end;){ + if (*s == '~') { + for (wchar *i = ParseToken(s); s != i; FontRenderStatePointer.pStr++) { + *FontRenderStatePointer.pStr = *(s++); + } + if (Details.bFlash) { + if (CTimer::GetTimeInMilliseconds() - Details.nFlashTimer > 300) { + Details.bFlashState = !Details.bFlashState; + Details.nFlashTimer = CTimer::GetTimeInMilliseconds(); + } + Details.color.a = Details.bFlashState ? 0 : 255; + } + } else + *(FontRenderStatePointer.pStr++) = *(s++); + } + *(FontRenderStatePointer.pStr++) = '\0'; + FontRenderStatePointer.Align(); +} +#endif + +void +CFont::PrintStringFromBottom(float x, float y, wchar *str) +{ + y -= (32.0f * Details.scaleY / 2.0f + 2.0f * Details.scaleY) * GetNumberLines(x, y, str); + if (Details.slant == 0.0f) + y -= ((Details.slantRefX - x) * Details.slant + Details.slantRefY); + PrintString(x, y, str); +} + +void CFont::PrintString(float xstart, float ystart, wchar *s) { CRect rect; @@ -893,126 +1097,6 @@ CFont::GetTextRect(CRect *rect, float xstart, float ystart, wchar *s) } } -#ifdef MORE_LANGUAGES -bool -CFont::PrintString(float x, float y, wchar *start, wchar *&end, float spwidth, float japX) -{ - wchar *s, c, unused; - - if (IsJapanese()) { - float jx = 0.0f; - for (s = start; s < end; s++) { - if (*s == JAP_TERMINATION || *s == '~') - s = ParseToken(s, &unused, true); - if (NewLine) { - NewLine = false; - break; - } - jx += GetCharacterSize(*s - ' '); - } - s = start; - if (Details.centre) - x = japX - jx / 2.0f; - else if (Details.rightJustify) - x = japX - jx; - } - - for (s = start; s < end; s++) { - if (*s == '~' || (IsJapanese() && *s == JAP_TERMINATION)) - s = ParseToken(s, &unused); - if (NewLine && IsJapanese()) { - NewLine = false; - end = s; - return true; - } - c = *s - ' '; - if (Details.slant != 0.0f && !IsJapanese()) - y = (Details.slantRefX - x) * Details.slant + Details.slantRefY; - - PrintChar(x, y, c); - x += GetCharacterSize(c); - if (c == 0 && (!NewLine || !IsJapanese())) // space - x += spwidth; - } - return false; -} -#else -void -CFont::PrintString(float x, float y, uint32, wchar *start, wchar *end, float spwidth) -{ - wchar *s; - - if (RenderState.style != Details.style) { - RenderFontBuffer(); - RenderState.style = Details.style; - } - - float dropShadowPosition = Details.dropShadowPosition; - if (dropShadowPosition != 0.0f && (Details.style == FONT_BANK || Details.style == FONT_STANDARD)) { - CRGBA color = Details.color; - Details.color = Details.dropColor; - Details.dropShadowPosition = 0; - Details.bIsShadow = true; - if (Details.slant != 0.0f) { - Details.slantRefX += SCREEN_SCALE_X(dropShadowPosition); - Details.slantRefY += SCREEN_SCALE_Y(dropShadowPosition); - PrintString(SCREEN_SCALE_X(dropShadowPosition) + x, SCREEN_SCALE_Y(dropShadowPosition) + y, Details.anonymous_25, start, end, spwidth); - Details.slantRefX -= SCREEN_SCALE_X(dropShadowPosition); - Details.slantRefY -= SCREEN_SCALE_Y(dropShadowPosition); - } else { - PrintString(SCREEN_SCALE_X(dropShadowPosition) + x, SCREEN_SCALE_Y(dropShadowPosition) + y, Details.anonymous_25, start, end, spwidth); - } - Details.color = color; - Details.dropShadowPosition = dropShadowPosition; - Details.bIsShadow = false; - } - if (FontRenderStatePointer.pStr >= (wchar*)&FontRenderStateBuf[ARRAY_SIZE(FontRenderStateBuf)] - (end - start + 26)) // why 26? - RenderFontBuffer(); - CFontRenderState *pRenderState = FontRenderStatePointer.pRenderState; - pRenderState->fTextPosX = x; - pRenderState->fTextPosY = y; - pRenderState->scaleX = Details.scaleX; - pRenderState->scaleY = Details.scaleY; - pRenderState->color = Details.color; - pRenderState->fExtraSpace = spwidth; - pRenderState->slant = Details.slant; - pRenderState->slantRefX = Details.slantRefX; - pRenderState->slantRefY = Details.slantRefY; - pRenderState->bFontHalfTexture = Details.bFontHalfTexture; - pRenderState->proportional = Details.proportional; - pRenderState->style = Details.style; - pRenderState->bIsShadow = Details.bIsShadow; - FontRenderStatePointer.pRenderState++; - - for(s = start; s < end;){ - if (*s == '~') { - for (wchar *i = ParseToken(s); s != i; FontRenderStatePointer.pStr++) { - *FontRenderStatePointer.pStr = *(s++); - } - if (Details.bFlash) { - if (CTimer::GetTimeInMilliseconds() - Details.nFlashTimer > 300) { - Details.bFlashState = !Details.bFlashState; - Details.nFlashTimer = CTimer::GetTimeInMilliseconds(); - } - Details.color.a = Details.bFlashState ? 0 : 255; - } - } else - *(FontRenderStatePointer.pStr++) = *(s++); - } - *(FontRenderStatePointer.pStr++) = '\0'; - FontRenderStatePointer.Align(); -} -#endif - -void -CFont::PrintStringFromBottom(float x, float y, wchar *str) -{ - y -= (32.0f * Details.scaleY / 2.0f + 2.0f * Details.scaleY) * GetNumberLines(x, y, str); - if (Details.slant == 0.0f) - y -= ((Details.slantRefX - x) * Details.slant + Details.slantRefY); - PrintString(x, y, str); -} - float CFont::GetCharacterWidth(wchar c) { @@ -1252,6 +1336,118 @@ CFont::GetNextSpace(wchar *s) return s; } +wchar* +CFont::ParseToken(wchar* str, CRGBA &color, bool &flash, bool &bold) +{ + Details.anonymous_23 = false; + wchar *s = str + 1; + if (Details.color.r || Details.color.g || Details.color.b) + { + switch (*s) + { + case 'B': + bold = !bold; + break; + case 'b': + color.r = 27; + color.g = 89; + color.b = 130; + break; + case 'f': + flash = !flash; + break; + case 'g': + color.r = 255; + color.g = 150; + color.b = 225; + break; + case 'h': + color.r = 225; + color.g = 225; + color.b = 225; + break; + case 'l': + color.r = 0; + color.g = 0; + color.b = 0; + break; + case 'o': + color.r = 229; + color.g = 125; + color.b = 126; + break; + case 'p': + color.r = 168; + color.g = 110; + color.b = 252; + break; + case 'q': + color.r = 199; + color.g = 144; + color.b = 203; + break; + case 'r': + color.r = 255; + color.g = 150; + color.b = 225; + break; + case 't': + color.r = 86; + color.g = 212; + color.b = 146; + break; + case 'w': + color.r = 175; + color.g = 175; + color.b = 175; + break; +#ifdef FIX_BUGS + case 'x': + color.r = 0; + color.g = 255; + color.b = 255; + break; +#else + case 'x': + color.r = 132; + color.g = 146; + color.b = 197; + break; +#endif + case 'y': + color.r = 255; + color.g = 227; + color.b = 79; + break; +#ifdef BUTTON_ICONS + case 'U': PS2Symbol = BUTTON_UP; break; + case 'D': PS2Symbol = BUTTON_DOWN; break; + case '<': PS2Symbol = BUTTON_LEFT; break; + case '>': PS2Symbol = BUTTON_RIGHT; break; + case 'X': PS2Symbol = BUTTON_CROSS; break; + case 'O': PS2Symbol = BUTTON_CIRCLE; break; + case 'Q': PS2Symbol = BUTTON_SQUARE; break; + case 'T': PS2Symbol = BUTTON_TRIANGLE; break; + case 'K': PS2Symbol = BUTTON_L1; break; + case 'M': PS2Symbol = BUTTON_L2; break; + case 'A': PS2Symbol = BUTTON_L3; break; + case 'J': PS2Symbol = BUTTON_R1; break; + case 'V': PS2Symbol = BUTTON_R2; break; + case 'C': PS2Symbol = BUTTON_R3; break; + case '(': PS2Symbol = BUTTON_RSTICK_LEFT; break; + case ')': PS2Symbol = BUTTON_RSTICK_RIGHT; break; +#endif + default: + break; + } + } + while (*s != '~') + ++s; + if (*(++s) == '~') + s = ParseToken(s, color, flash, bold); + return s; +} + #ifdef MORE_LANGUAGES wchar* CFont::ParseToken(wchar *s, bool japShit) @@ -1313,7 +1509,7 @@ CFont::ParseToken(wchar *s) break; case 'N': case 'n': - NewLine = 1; + NewLine = true; break; case 'b': Details.color.r = 27; @@ -1424,116 +1620,22 @@ CFont::ParseToken(wchar *s) } #endif -wchar* -CFont::ParseToken(wchar* str, CRGBA &color, bool &flash, bool &bold) +void +CFont::FilterOutTokensFromString(wchar *str) { - Details.anonymous_23 = false; - wchar *s = str + 1; - if (Details.color.r || Details.color.g || Details.color.b) - { - switch (*s) - { - case 'B': - bold = !bold; - break; - case 'b': - color.r = 27; - color.g = 89; - color.b = 130; - break; - case 'f': - flash = !flash; - break; - case 'g': - color.r = 255; - color.g = 150; - color.b = 225; - break; - case 'h': - color.r = 225; - color.g = 225; - color.b = 225; - break; - case 'l': - color.r = 0; - color.g = 0; - color.b = 0; - break; - case 'o': - color.r = 229; - color.g = 125; - color.b = 126; - break; - case 'p': - color.r = 168; - color.g = 110; - color.b = 252; - break; - case 'q': - color.r = 199; - color.g = 144; - color.b = 203; - break; - case 'r': - color.r = 255; - color.g = 150; - color.b = 225; - break; - case 't': - color.r = 86; - color.g = 212; - color.b = 146; - break; - case 'w': - color.r = 175; - color.g = 175; - color.b = 175; - break; -#ifdef FIX_BUGS - case 'x': - color.r = 0; - color.g = 255; - color.b = 255; - break; -#else - case 'x': - color.r = 132; - color.g = 146; - color.b = 197; - break; -#endif - case 'y': - color.r = 255; - color.g = 227; - color.b = 79; - break; -#ifdef BUTTON_ICONS - case 'U': PS2Symbol = BUTTON_UP; break; - case 'D': PS2Symbol = BUTTON_DOWN; break; - case '<': PS2Symbol = BUTTON_LEFT; break; - case '>': PS2Symbol = BUTTON_RIGHT; break; - case 'X': PS2Symbol = BUTTON_CROSS; break; - case 'O': PS2Symbol = BUTTON_CIRCLE; break; - case 'Q': PS2Symbol = BUTTON_SQUARE; break; - case 'T': PS2Symbol = BUTTON_TRIANGLE; break; - case 'K': PS2Symbol = BUTTON_L1; break; - case 'M': PS2Symbol = BUTTON_L2; break; - case 'A': PS2Symbol = BUTTON_L3; break; - case 'J': PS2Symbol = BUTTON_R1; break; - case 'V': PS2Symbol = BUTTON_R2; break; - case 'C': PS2Symbol = BUTTON_R3; break; - case '(': PS2Symbol = BUTTON_RSTICK_LEFT; break; - case ')': PS2Symbol = BUTTON_RSTICK_RIGHT; break; -#endif - default: - break; + int newIdx = 0; + wchar copy[256], *c; + UnicodeStrcpy(copy, str); + + for (c = copy; *c != '\0'; c++) { + if (*c == '~') { + c++; + while (*c != '~') c++; + } else { + str[newIdx++] = *c; } } - while (*s != '~') - ++s; - if (*(++s) == '~') - s = ParseToken(s, color, flash, bold); - return s; + str[newIdx] = '\0'; } void @@ -1543,139 +1645,90 @@ CFont::DrawFonts(void) } void -CFont::RenderFontBuffer() +CFont::SetScale(float x, float y) { - if (FontRenderStatePointer.pRenderState == (CFontRenderState*)FontRenderStateBuf) return; - - float textPosX; - float textPosY; - CRGBA color; - bool bBold = false; - bool bFlash = false; +#ifdef MORE_LANGUAGES + /*if (IsJapanese()) { + x *= 1.35f; + y *= 1.25f; + }*/ +#endif + Details.scaleX = x; + Details.scaleY = y; +} - Sprite[RenderState.style].SetRenderState(); - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); - RenderState = *(CFontRenderState*)&FontRenderStateBuf[0]; - textPosX = RenderState.fTextPosX; - textPosY = RenderState.fTextPosY; - color = RenderState.color; - tFontRenderStatePointer pRenderStateBufPointer; - pRenderStateBufPointer.pRenderState = (CFontRenderState*)&FontRenderStateBuf[0]; - for (++pRenderStateBufPointer.pRenderState; pRenderStateBufPointer.pStr < FontRenderStatePointer.pStr; pRenderStateBufPointer.pStr++) { - if (*pRenderStateBufPointer.pStr == '\0') { - tFontRenderStatePointer tmpPointer = pRenderStateBufPointer; - tmpPointer.pStr++; - tmpPointer.Align(); - if (tmpPointer.pStr >= FontRenderStatePointer.pStr) - break; +void +CFont::SetSlantRefPoint(float x, float y) +{ + Details.slantRefX = x; + Details.slantRefY = y; +} - RenderState = *(tmpPointer.pRenderState++); +void +CFont::SetSlant(float s) +{ + Details.slant = s; +} - pRenderStateBufPointer = tmpPointer; +void +CFont::SetColor(CRGBA col) +{ + Details.color = col; + if (Details.alphaFade < 255.0f) + Details.color.a *= Details.alphaFade / 255.0f; +} - textPosX = RenderState.fTextPosX; - textPosY = RenderState.fTextPosY; - color = RenderState.color; - } - if (*pRenderStateBufPointer.pStr == '~') { -#ifdef BUTTON_ICONS - PS2Symbol = BUTTON_NONE; -#endif - pRenderStateBufPointer.pStr = ParseToken(pRenderStateBufPointer.pStr, color, bFlash, bBold); -#ifdef BUTTON_ICONS - if(PS2Symbol != BUTTON_NONE) { - DrawButton(textPosX, textPosY); - textPosX += Details.scaleY * 17.0f; - PS2Symbol = BUTTON_NONE; - } -#endif - if (bFlash) { - if (CTimer::GetTimeInMilliseconds() - Details.nFlashTimer > 300) { - Details.bFlashState = !Details.bFlashState; - Details.nFlashTimer = CTimer::GetTimeInMilliseconds(); - } - Details.color.alpha = Details.bFlashState ? 0 : 255; - } - if (!RenderState.bIsShadow) - RenderState.color = color; - } - wchar c = *pRenderStateBufPointer.pStr; - c -= ' '; - if (RenderState.bFontHalfTexture) - c = FindNewCharacter(c); - else if (c > 155) - c = '\0'; +void +CFont::SetJustifyOn(void) +{ + Details.justify = true; + Details.centre = false; + Details.rightJustify = false; +} - if (RenderState.slant != 0.0f) - textPosY = (RenderState.slantRefX - textPosX) * RenderState.slant + RenderState.slantRefY; - PrintChar(textPosX, textPosY, c); - if (bBold) { - PrintChar(textPosX + 1.0f, textPosY, c); - PrintChar(textPosX + 2.0f, textPosY, c); - textPosX += 2.0f; - } -#ifdef FIX_BUGS - // PS2 uses different chars for some symbols - if (!RenderState.bFontHalfTexture && c == 30) c = 61; // wanted star -#endif - textPosX += RenderState.scaleX * GetCharacterWidth(c); - if (c == '\0') - textPosX += RenderState.fExtraSpace; - } - CSprite2d::RenderVertexBuffer(); - FontRenderStatePointer.pRenderState = (CFontRenderState*)FontRenderStateBuf; +void +CFont::SetJustifyOff(void) +{ + Details.justify = false; + Details.rightJustify = false; } +void +CFont::SetCentreOn(void) +{ + Details.centre = true; + Details.justify = false; + Details.rightJustify = false; +} void -CFont::SetFontStyle(int16 style) +CFont::SetCentreOff(void) { - if (style == FONT_HEADING) { - Details.style = FONT_STANDARD; - Details.bFontHalfTexture = true; - } else { - Details.style = style; - Details.bFontHalfTexture = false; - } + Details.centre = false; } -wchar CFont::FindNewCharacter(wchar c) +void +CFont::SetWrapx(float x) { - if (c >= 16 && c <= 26) return c + 128; - if (c >= 8 && c <= 9) return c + 86; - if (c == 4) return c + 89; - if (c == 7) return 206; - if (c == 14) return 207; - if (c >= 33 && c <= 58) return c + 122; - if (c >= 65 && c <= 90) return c + 90; - if (c >= 96 && c <= 118) return c + 85; - if (c >= 119 && c <= 140) return c + 62; - if (c >= 141 && c <= 142) return 204; - if (c == 143) return 205; - if (c == 1) return 208; - return c; + Details.wrapX = x; } -wchar -CFont::character_code(uint8 c) +void +CFont::SetCentreSize(float s) { - if(c < 128) - return c; - return foreign_table[c-128]; + Details.centreSize = s; } +void +CFont::SetBackgroundOn(void) +{ + Details.background = true; +} void -CFont::SetScale(float x, float y) +CFont::SetBackgroundOff(void) { -#ifdef MORE_LANGUAGES - /*if (IsJapanese()) { - x *= 1.35f; - y *= 1.25f; - }*/ -#endif - Details.scaleX = x; - Details.scaleY = y; + Details.background = false; } void @@ -1685,11 +1738,67 @@ CFont::SetBackgroundColor(CRGBA col) } void -CFont::SetColor(CRGBA col) +CFont::SetBackGroundOnlyTextOn(void) { - Details.color = col; - if (Details.alphaFade < 255.0f) - Details.color.a *= Details.alphaFade / 255.0f; + Details.backgroundOnlyText = true; +} + +void +CFont::SetBackGroundOnlyTextOff(void) +{ + Details.backgroundOnlyText = false; +} + +void +CFont::SetRightJustifyOn(void) +{ + Details.rightJustify = true; + Details.justify = false; + Details.centre = false; +} + +void +CFont::SetRightJustifyOff(void) +{ + Details.rightJustify = false; + Details.justify = false; + Details.centre = false; +} + +void +CFont::SetPropOff(void) +{ + Details.proportional = false; +} + +void +CFont::SetPropOn(void) +{ + Details.proportional = true; +} + +void +CFont::SetFontStyle(int16 style) +{ + if (style == FONT_HEADING) { + Details.style = FONT_STANDARD; + Details.bFontHalfTexture = true; + } else { + Details.style = style; + Details.bFontHalfTexture = false; + } +} + +void +CFont::SetRightJustifyWrap(float wrap) +{ + Details.rightJustifyWrap = wrap; +} + +void +CFont::SetAlphaFade(float fade) +{ + Details.alphaFade = fade; } void @@ -1701,19 +1810,32 @@ CFont::SetDropColor(CRGBA col) } void -CFont::FilterOutTokensFromString(wchar *str) +CFont::SetDropShadowPosition(int16 pos) { - int newIdx = 0; - wchar copy[256], *c; - UnicodeStrcpy(copy, str); + Details.dropShadowPosition = pos; +} - for (c = copy; *c != '\0'; c++) { - if (*c == '~') { - c++; - while (*c != '~') c++; - } else { - str[newIdx++] = *c; - } - } - str[newIdx] = '\0'; +wchar CFont::FindNewCharacter(wchar c) +{ + if (c >= 16 && c <= 26) return c + 128; + if (c >= 8 && c <= 9) return c + 86; + if (c == 4) return c + 89; + if (c == 7) return 206; + if (c == 14) return 207; + if (c >= 33 && c <= 58) return c + 122; + if (c >= 65 && c <= 90) return c + 90; + if (c >= 96 && c <= 118) return c + 85; + if (c >= 119 && c <= 140) return c + 62; + if (c >= 141 && c <= 142) return 204; + if (c == 143) return 205; + if (c == 1) return 208; + return c; } + +wchar +CFont::character_code(uint8 c) +{ + if(c < 128) + return c; + return foreign_table[c-128]; +}
\ No newline at end of file diff --git a/src/render/Font.h b/src/render/Font.h index 36424bf5..4b2dda2b 100644 --- a/src/render/Font.h +++ b/src/render/Font.h @@ -14,28 +14,28 @@ struct CFontDetails float slant; float slantRefX; float slantRefY; - bool justify; - bool centre; - bool rightJustify; - bool background; - bool backgroundOnlyText; - bool proportional; - bool bIsShadow; - bool bFlash; - bool bBold; + bool8 justify; + bool8 centre; + bool8 rightJustify; + bool8 background; + bool8 backgroundOnlyText; + bool8 proportional; + bool8 bIsShadow; + bool8 bFlash; + bool8 bBold; float alphaFade; CRGBA backgroundColor; float wrapX; float centreSize; float rightJustifyWrap; int16 style; - bool bFontHalfTexture; + bool8 bFontHalfTexture; uint32 bank; int16 dropShadowPosition; CRGBA dropColor; - bool bFlashState; + bool8 bFlashState; int nFlashTimer; - bool anonymous_23; + bool8 anonymous_23; uint32 anonymous_25; }; @@ -51,10 +51,10 @@ struct CFontRenderState float slant; float slantRefX; float slantRefY; - bool bIsShadow; - bool bFontHalfTexture; - bool proportional; - bool anonymous_14; + bool8 bIsShadow; + bool8 bFontHalfTexture; + bool8 proportional; + bool8 anonymous_14; int16 style; }; @@ -168,72 +168,33 @@ public: static uint16 *ParseToken(wchar *s, bool japShit = false); #else static uint16 *ParseToken(wchar *s); - static uint16* ParseToken(wchar *s, CRGBA &color, bool &flash, bool &bold); + static uint16 *ParseToken(wchar *s, CRGBA &color, bool &flash, bool &bold); #endif static void DrawFonts(void); static void RenderFontBuffer(void); static uint16 character_code(uint8 c); - static CFontDetails GetDetails() { return Details; } static void SetScale(float x, float y); - static void SetSlantRefPoint(float x, float y) { Details.slantRefX = x; Details.slantRefY = y; } - static void SetSlant(float s) { Details.slant = s; } - static void SetJustifyOn(void) { - Details.justify = true; - Details.centre = false; - Details.rightJustify = false; - } - static void SetJustifyOff(void) { - Details.justify = false; - Details.rightJustify = false; - } - static void SetRightJustifyOn(void) { - Details.rightJustify = true; - Details.justify = false; - Details.centre = false; - } - static void SetRightJustifyOff(void) { - Details.rightJustify = false; - Details.justify = false; - Details.centre = false; - } - static void SetCentreOn(void) { - Details.centre = true; - Details.justify = false; - Details.rightJustify = false; - } - static void SetCentreOff(void) { - Details.centre = false; - } - static void SetAlignment(uint8 alignment) { - if (alignment == ALIGN_LEFT) { - CFont::Details.justify = true; - CFont::Details.centre = false; - CFont::Details.rightJustify = false; - } - else if (alignment == ALIGN_CENTER) { - CFont::Details.justify = false; - CFont::Details.centre = true; - CFont::Details.rightJustify = false; - } - else if (alignment == ALIGN_RIGHT) { - CFont::Details.justify = false; - CFont::Details.centre = false; - CFont::Details.rightJustify = true; - } - } - static void SetWrapx(float x) { Details.wrapX = x; } - static void SetCentreSize(float s) { Details.centreSize = s; } - static void SetBackgroundOn(void) { Details.background = true; } - static void SetBackgroundOff(void) { Details.background = false; } - static void SetBackGroundOnlyTextOn(void) { Details.backgroundOnlyText = true; } - static void SetBackGroundOnlyTextOff(void) { Details.backgroundOnlyText = false; } - static void SetPropOn(void) { Details.proportional = true; } - static void SetPropOff(void) { Details.proportional = false; } + static void SetSlantRefPoint(float x, float y); + static void SetSlant(float s); + static void SetJustifyOn(void); + static void SetJustifyOff(void); + static void SetRightJustifyOn(void); + static void SetRightJustifyOff(void); + static void SetCentreOn(void); + static void SetCentreOff(void); + static void SetWrapx(float x); + static void SetCentreSize(float s); + static void SetBackgroundOn(void); + static void SetBackgroundOff(void); + static void SetBackGroundOnlyTextOn(void); + static void SetBackGroundOnlyTextOff(void); + static void SetPropOn(void); + static void SetPropOff(void); static void SetFontStyle(int16 style); - static void SetRightJustifyWrap(float wrap) { Details.rightJustifyWrap = wrap; } - static void SetAlphaFade(float fade) { Details.alphaFade = fade; } - static void SetDropShadowPosition(int16 pos) { Details.dropShadowPosition = pos; } + static void SetRightJustifyWrap(float wrap); + static void SetAlphaFade(float fade); + static void SetDropShadowPosition(int16 pos); static void SetBackgroundColor(CRGBA col); static void SetColor(CRGBA col); static void SetDropColor(CRGBA col); diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 350e8c45..f3181fa8 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -449,10 +449,10 @@ void CHud::Draw() } if (m_WeaponState != FADED_OUT) { CWeapon *weapon = playerPed->GetWeapon(); - uint32 AmmoAmount = CWeaponInfo::GetWeaponInfo((eWeaponType)WeaponType)->m_nAmountofAmmunition; - uint32 AmmoInClip = weapon->m_nAmmoInClip; - uint32 TotalAmmo = weapon->m_nAmmoTotal; - uint32 Ammo, Clip; + int32 AmmoAmount = CWeaponInfo::GetWeaponInfo((eWeaponType)WeaponType)->m_nAmountofAmmunition; + int32 AmmoInClip = weapon->m_nAmmoInClip; + int32 TotalAmmo = weapon->m_nAmmoTotal; + int32 Ammo, Clip; if (AmmoAmount <= 1 || AmmoAmount >= 1000) sprintf(sTemp, "%d", TotalAmmo); diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp index e2213399..940a6b98 100644 --- a/src/weapons/Weapon.cpp +++ b/src/weapons/Weapon.cpp @@ -911,7 +911,7 @@ CWeapon::FireInstantHit(CEntity *shooter, CVector *fireSource) CWorld::bIncludeDeadPeds = true; CWorld::bIncludeBikers = true; - CWorld::ProcessLineOfSight(*fireSource, target, point, victim, true, true, true, true, true, false, false, true); + ProcessLineOfSight(*fireSource, target, point, victim, m_eWeaponType, shooter, true, true, true, true, true, false, false); CWorld::bIncludeDeadPeds = false; CWorld::bIncludeBikers = false; } @@ -924,7 +924,7 @@ CWeapon::FireInstantHit(CEntity *shooter, CVector *fireSource) shooterPed->TransformToNode(target, PED_HANDR); CWorld::bIncludeBikers = true; - CWorld::ProcessLineOfSight(*fireSource, target, point, victim, true, true, true, true, true, false, false, true); + ProcessLineOfSight(*fireSource, target, point, victim, m_eWeaponType, shooter, true, true, true, true, true, false, false); CWorld::bIncludeBikers = false; } } @@ -935,7 +935,7 @@ CWeapon::FireInstantHit(CEntity *shooter, CVector *fireSource) CWorld::bIncludeBikers = true; CWorld::bIncludeDeadPeds = true; CWorld::bIncludeCarTyres = true; - CWorld::ProcessLineOfSight(source, target, point, victim, true, true, true, true, true, false, false, true); + ProcessLineOfSight(source, target, point, victim, m_eWeaponType, shooter, true, true, true, true, true, false, false); CWorld::bIncludeBikers = false; CWorld::bIncludeDeadPeds = false; CWorld::bIncludeCarTyres = false; @@ -981,7 +981,7 @@ CWeapon::FireInstantHit(CEntity *shooter, CVector *fireSource) target *= info->m_fRange; target += *fireSource; CWorld::pIgnoreEntity = shooter; - CWorld::ProcessLineOfSight(*fireSource, target, point, victim, true, true, true, true, true, false, false, true); + ProcessLineOfSight(*fireSource, target, point, victim, m_eWeaponType, shooter, true, true, true, true, true, true, false); CWorld::pIgnoreEntity = nil; int32 rotSpeed = 1; @@ -1014,7 +1014,7 @@ CWeapon::FireInstantHit(CEntity *shooter, CVector *fireSource) } CWorld::bIncludeBikers = true; - CWorld::ProcessLineOfSight(*fireSource, target, point, victim, true, true, true, true, true, false, false, true); + ProcessLineOfSight(*fireSource, target, point, victim, m_eWeaponType, shooter, true, true, true, true, true, false, false); CWorld::bIncludeBikers = false; int32 rotSpeed = 1; @@ -1683,7 +1683,7 @@ CWeapon::FireShotgun(CEntity *shooter, CVector *fireSource) CWorld::bIncludeCarTyres = true; CWorld::bIncludeBikers = true; CWorld::bIncludeDeadPeds = true; - CWorld::ProcessLineOfSight(source, target, point, victim, true, true, true, true, true, false, false, true); + ProcessLineOfSight(source, target, point, victim, m_eWeaponType, shooter, true, true, true, true, true, false, false); CWorld::bIncludeDeadPeds = false; CWorld::bIncludeCarTyres = false; } @@ -1716,7 +1716,7 @@ CWeapon::FireShotgun(CEntity *shooter, CVector *fireSource) CWorld::bIncludeDeadPeds = true; CWorld::bIncludeBikers = true; - CWorld::ProcessLineOfSight(*fireSource, target, point, victim, true, true, true, true, true, false, false, true); + ProcessLineOfSight(*fireSource, target, point, victim, m_eWeaponType, shooter, true, true, true, true, true, false, false); CWorld::bIncludeDeadPeds = false; } CWorld::bIncludeBikers = false; @@ -2329,7 +2329,7 @@ CWeapon::FireM16_1stPerson(CEntity *shooter) CVector source = cam->Source; CVector target = cam->Front*info->m_fRange + source; - if (CWorld::ProcessLineOfSight(source, target, point, victim, true, true, true, true, true, false, false, true)) { + if (ProcessLineOfSight(source, target, point, victim, m_eWeaponType, shooter, true, true, true, true, true, true, false)) { CheckForShootingVehicleOccupant(&victim, &point, m_eWeaponType, source, target); } CWorld::pIgnoreEntity = nil; @@ -3176,7 +3176,7 @@ CPed::IsPedDoingDriveByShooting(void) bool CWeapon::ProcessLineOfSight(CVector const &point1, CVector const &point2, CColPoint &point, CEntity *&entity, eWeaponType type, CEntity *shooter, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects) { - return CWorld::ProcessLineOfSight(point1, point2, point, entity, checkBuildings, checkVehicles, checkPeds, checkObjects, checkDummies, ignoreSeeThrough, ignoreSomeObjects); + return CWorld::ProcessLineOfSight(point1, point2, point, entity, checkBuildings, checkVehicles, checkPeds, checkObjects, checkDummies, false, ignoreSomeObjects, true); } |