├── .gitattributes ├── .github └── workflows │ └── main.yml ├── .gitignore ├── .gitmodules ├── Android.mk ├── Application.mk ├── GTASA_CHEATS.md ├── LICENSE ├── README.md ├── j_sa.cpp ├── j_vc.cpp ├── main.cpp ├── patches ├── patches_sa.inl ├── patches_sa64.inl ├── patches_vc.inl ├── patches_vc64.inl ├── preparations_sa.inl ├── preparations_sa64.inl ├── preparations_vc.inl └── preparations_vc64.inl └── updater.txt /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: AML Mod Compiler 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | steps: 13 | 14 | - name: Checkout repository... 15 | uses: actions/checkout@v4 16 | with: 17 | submodules: recursive 18 | 19 | - name: Setup SSH keys... 20 | uses: webfactory/ssh-agent@v0.8.0 21 | with: 22 | ssh-private-key: | 23 | ${{ secrets.SSH }} 24 | 25 | - name: Download AndroidModLoader`s mod template... 26 | uses: wei/wget@v1 27 | with: 28 | args: -O ./AML_src.zip https://github.com/RusJJ/AndroidModLoader/archive/refs/heads/main.zip 29 | 30 | - name: Install AndroidModLoader`s mod template... 31 | run: | 32 | unzip ./AML_src.zip 33 | mv ./AndroidModLoader-main/mod ./mod 34 | 35 | - name: Get GTA:SA structures file (private)... 36 | run: | 37 | git clone ssh://git@github.com/RusJJ/GTASAAndroid_Structs.git ./structs 38 | mv ./structs/* ./ 39 | 40 | - name: Install Android NDK (r25c)... 41 | uses: nttld/setup-ndk@v1 42 | with: 43 | ndk-version: r25c 44 | local-cache: true 45 | 46 | - name: Build the code... 47 | run: ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk NDK_APPLICATION_MK=./Application.mk NDK_DEBUG=0 -j12 48 | 49 | - name: Upload the mod! 50 | uses: actions/upload-artifact@v4 51 | with: 52 | name: compiled-mod.zip 53 | path: ./libs 54 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Ll]og/ 33 | [Ll]ogs/ 34 | 35 | # Visual Studio 2015/2017 cache/options directory 36 | .vs/ 37 | # Uncomment if you have tasks that create the project's static files in wwwroot 38 | #wwwroot/ 39 | 40 | # Visual Studio 2017 auto generated files 41 | Generated\ Files/ 42 | 43 | # MSTest test Results 44 | [Tt]est[Rr]esult*/ 45 | [Bb]uild[Ll]og.* 46 | 47 | # NUnit 48 | *.VisualState.xml 49 | TestResult.xml 50 | nunit-*.xml 51 | 52 | # Build Results of an ATL Project 53 | [Dd]ebugPS/ 54 | [Rr]eleasePS/ 55 | dlldata.c 56 | 57 | # Benchmark Results 58 | BenchmarkDotNet.Artifacts/ 59 | 60 | # .NET Core 61 | project.lock.json 62 | project.fragment.lock.json 63 | artifacts/ 64 | 65 | # ASP.NET Scaffolding 66 | ScaffoldingReadMe.txt 67 | 68 | # StyleCop 69 | StyleCopReport.xml 70 | 71 | # Files built by Visual Studio 72 | *_i.c 73 | *_p.c 74 | *_h.h 75 | *.ilk 76 | *.meta 77 | *.obj 78 | *.iobj 79 | *.pch 80 | *.pdb 81 | *.ipdb 82 | *.pgc 83 | *.pgd 84 | *.rsp 85 | *.sbr 86 | *.tlb 87 | *.tli 88 | *.tlh 89 | *.tmp 90 | *.tmp_proj 91 | *_wpftmp.csproj 92 | *.log 93 | *.tlog 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio 6 auto-generated project file (contains which files were open etc.) 298 | *.vbp 299 | 300 | # Visual Studio 6 workspace and project file (working project files containing files to include in project) 301 | *.dsw 302 | *.dsp 303 | 304 | # Visual Studio 6 technical files 305 | *.ncb 306 | *.aps 307 | 308 | # Visual Studio LightSwitch build output 309 | **/*.HTMLClient/GeneratedArtifacts 310 | **/*.DesktopClient/GeneratedArtifacts 311 | **/*.DesktopClient/ModelManifest.xml 312 | **/*.Server/GeneratedArtifacts 313 | **/*.Server/ModelManifest.xml 314 | _Pvt_Extensions 315 | 316 | # Paket dependency manager 317 | .paket/paket.exe 318 | paket-files/ 319 | 320 | # FAKE - F# Make 321 | .fake/ 322 | 323 | # CodeRush personal settings 324 | .cr/personal 325 | 326 | # Python Tools for Visual Studio (PTVS) 327 | __pycache__/ 328 | *.pyc 329 | 330 | # Cake - Uncomment if you are using it 331 | # tools/** 332 | # !tools/packages.config 333 | 334 | # Tabs Studio 335 | *.tss 336 | 337 | # Telerik's JustMock configuration file 338 | *.jmconfig 339 | 340 | # BizTalk build output 341 | *.btp.cs 342 | *.btm.cs 343 | *.odx.cs 344 | *.xsd.cs 345 | 346 | # OpenCover UI analysis results 347 | OpenCover/ 348 | 349 | # Azure Stream Analytics local run output 350 | ASALocalRun/ 351 | 352 | # MSBuild Binary and Structured Log 353 | *.binlog 354 | 355 | # NVidia Nsight GPU debugger configuration file 356 | *.nvuser 357 | 358 | # MFractors (Xamarin productivity tool) working folder 359 | .mfractor/ 360 | 361 | # Local History for Visual Studio 362 | .localhistory/ 363 | 364 | # Visual Studio History (VSHistory) files 365 | .vshistory/ 366 | 367 | # BeatPulse healthcheck temp database 368 | healthchecksdb 369 | 370 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 371 | MigrationBackup/ 372 | 373 | # Ionide (cross platform F# VS Code tools) working folder 374 | .ionide/ 375 | 376 | # Fody - auto-generated XML schema 377 | FodyWeavers.xsd 378 | 379 | # VS Code files for those working on multiple tools 380 | .vscode/* 381 | !.vscode/settings.json 382 | !.vscode/tasks.json 383 | !.vscode/launch.json 384 | !.vscode/extensions.json 385 | *.code-workspace 386 | 387 | # Local History for Visual Studio Code 388 | .history/ 389 | 390 | # Windows Installer files from build outputs 391 | *.cab 392 | *.msi 393 | *.msix 394 | *.msm 395 | *.msp 396 | 397 | # JetBrains Rider 398 | *.sln.iml 399 | 400 | # Own 401 | mod/ 402 | libs/ 403 | .vscode/ 404 | *.bak 405 | build.ps1 406 | ndkpath.txt 407 | GTASA_ENUMS.h 408 | GTASA_STRUCTS.h 409 | RW_STRUCTS.h 410 | GTASA_DECLS.h 411 | GTASA_STRUCTS_210.h 412 | RW_STRUCTS_210.h 413 | GTAVC_STRUCTS.h 414 | GTA_SHARED.h 415 | GTAVC_ENUMS.h 416 | GTASADE_STRUCTS.h 417 | GTAVC_STRUCTS_112.h 418 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "AArch64_ModHelper"] 2 | path = AArch64_ModHelper 3 | url = https://github.com/RusJJ/AArch64_ModHelper 4 | -------------------------------------------------------------------------------- /Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | LOCAL_CPP_EXTENSION := .cpp .cc 5 | ifeq ($(TARGET_ARCH_ABI), armeabi-v7a) 6 | LOCAL_MODULE := JPatch 7 | else 8 | LOCAL_MODULE := JPatch64 9 | endif 10 | LOCAL_SRC_FILES := main.cpp mod/logger.cpp mod/config.cpp j_sa.cpp j_vc.cpp 11 | LOCAL_CFLAGS += -O2 -mfloat-abi=softfp -DNDEBUG -std=c++17 12 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/patches 13 | LOCAL_LDLIBS += -llog #$(LOCAL_PATH)/libGLESv2.so 14 | ifeq ($(TARGET_ARCH_ABI), armeabi-v7a) 15 | LOCAL_CFLAGS += -mfpu=neon 16 | endif 17 | include $(BUILD_SHARED_LIBRARY) -------------------------------------------------------------------------------- /Application.mk: -------------------------------------------------------------------------------- 1 | APP_STL := c++_static 2 | APP_ABI := armeabi-v7a arm64-v8a 3 | APP_OPTIM := release 4 | APP_PLATFORM := android-21 5 | APP_CFLAGS += -Ofast 6 | NDK_TOOLCHAIN_VERSION := clang 7 | -------------------------------------------------------------------------------- /GTASA_CHEATS.md: -------------------------------------------------------------------------------- 1 | ``` 2 | Weapon Set 4 (hash 0xbc39f5a2) = SECRETSPYSET 3 | Time travel (+4 hours) (hash 0x87237a8e) = TIMETRAVELER 4 | Script Bypass (hash 0xbb5adfd7) = SCRIPTBYPASS 5 | Show Mappings (hash 0x37b458aa) = SHOWMAPPINGS 6 | CJ Invincibility (hash 0xe1614ccb) = GONPXWR 7 | Show Tap to target (hash 0x438f0792) = SHOWTAPTOTARGET 8 | Show targeting (hash 0x1983b67d) = SHOWTARGETING 9 | Stock car 2 (hash 0x7cbc2154) = RRRANCHER 10 | Back to the future (hash 0x6652908f) = SEAWAYS 11 | Gambler cheat (hash 0x6a562342) = THEGAMBLER 12 | Spawn hunter (hash 0xf51f7ed1) = SKYPREDATOR 13 | Prostitues pay you (hash 0x57e1ca95) = IMAPIMP 14 | All taxis have nitro (hash 0xf689f99f) = FASTASF 15 | Xbox Helper (hash 0x68afad9) = XBOXHELPER 16 | ``` -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 RusJJ 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![AML Mod Compiler](https://github.com/AndroidModLoader/JPatch/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/AndroidModLoader/JPatch/actions/workflows/main.yml) 2 | 3 | ![jpatch_mini](https://github.com/AndroidModLoader/JPatch/assets/8864329/5e273283-baad-4f2c-8697-f75040991f64) 4 | 5 | # What am i? 6 | I am a little mod that wants to fix your game! 7 | Need a preview version of upcoming changes? Get it there: https://github.com/AndroidModLoader/JPatch/actions 8 | 9 | Currently i can fix those things: 10 | 11 | ### ***GTA:VC v1.12*** 12 | **Since v1.8.1** 13 | - Fixing drunk camera on high FPS 14 | 15 | **Since v1.8** 16 | - GLAlphaFunc mod is now included (fixing a crash on Huawei phones) 17 | - Fixed boat speed on high FPS 18 | - Fix wheels rotation speed on high FPS 19 | - Fix car slowdown on high FPS 20 | - Fix heli rotor rotation speed on high FPS 21 | - Streaming distance fix (it's incomplete!) 22 | - Wide coronas/sprites fix 23 | - RE3: Fix R* optimization that prevents peds to spawn 24 | - RE3: Road reflections 25 | - Fix traffic lights 26 | - Bringing back a framelimiter (may be inaccurate) 27 | - Water texture scrolling speed fix on high FPS 28 | - Clouds rotating speed on high FPS (it is few times faster than it should be) 29 | - Bringing back the fake crater from explosion 30 | - Allows the game to choose Extra6 component on a vehicle when created 31 | - Corona sprites draw distance is 3 times bigger (partially, traffic lights do work) 32 | - Static light shadows (from traffic lights, poles and more) draw distance is 3 times bigger 33 | - Correct render flag for Dodo Banner (does it work?) 34 | - Bumped a limit of static shadows! 35 | - FX particles draw distance scaler (default is x2.5) 36 | - Now it's possible to remove ZERO's from money text 37 | - 44100Hz audio support without a mod "OpenAL Update" 38 | 39 | ### ***GTA:VC v1.09*** 40 | **Planned/TODO (not ready or broken now)** 41 | - The fog is back (the water shader is broken???) 42 | - Pushing vehicles on a high FPS (just doesnt work.) 43 | - Fix fighting range 44 | - Probably, fix sprint speed? 45 | - Not sure, maybe timer-related bugs in save files 46 | 47 | **Since v1.8.1** 48 | - Fixing drunk camera on high FPS 49 | 50 | **Since v1.8** 51 | - GLAlphaFunc mod is now included (fixing a crash on Huawei phones) 52 | - Now it's possible to remove ZERO's from money text 53 | - 44100Hz audio support without a mod "OpenAL Update" 54 | 55 | **Since v1.7** 56 | - FX particles draw distance scaler (default is x2.5) 57 | 58 | **Since v1.5.1** 59 | - Bringing back a framelimiter (may be inaccurate) 60 | - Water texture scrolling speed fix on high FPS 61 | - Fixed incorrect physics target (fixes small physical glitches with the vehicles, but also probably creates some) 62 | - Clouds rotating speed on high FPS (it is few times faster than it should be) 63 | - Allows the game to choose Extra6 component on a vehicle when created 64 | - Bringing back the fake crater from explosion 65 | - Correct render flag for Dodo Banner (does it work?) 66 | - Corona sprites draw distance is 3 times bigger (partially, traffic lights do work) 67 | - Static light shadows (from traffic lights, poles and more) draw distance is 3 times bigger 68 | - Bumped a limit of static shadows! 69 | - Fixing a crash of "Unprotected" APK (FLA bug) 70 | 71 | **Since v1.5** 72 | - Vertex Weights 73 | - Fixed boat speed on high FPS 74 | - Fix wheels rotation speed on high FPS 75 | - Fix car slowdown on high FPS 76 | - Fix heli rotor rotation speed on high FPS 77 | - Streaming distance fix 78 | - Wide coronas/sprites fix (this fix is disabled if you have ViceSkies v1.0) 79 | - RE3: Fix R* optimization that prevents peds to spawn 80 | - RE3: Road reflections 81 | - Fix traffic lights 82 | 83 | ### ***GTA:SA v2.10 (64-bit)*** 84 | **Since v1.8.1** 85 | - SilentPatch: Impound garages 86 | - SilentPatch: Bigger mirror quality on medium-high settings 87 | - Fixed a glitch with the timer on high FPS 88 | - Allowes gang wars to have a wanted level (like on PC) 89 | - Fixing drunk camera on high FPS 90 | - When headlights are active, the windows are no longer transparent from one side 91 | 92 | **Since v1.8** 93 | - Some cut effects from the game are back 94 | - Able to skip "drive" (tripskip) 95 | - Fixed "collideable" particles such as gunshells (reversed from FxsFuncs) 96 | - GLAlphaFunc mod is now included (fixing a crash on Huawei phones) 97 | - RLEDecompress crash is fixed! (allocates more memory) 98 | - Fixes some stupid nearclipping issues that are caused by WarDrum's dirty hands 99 | - Fixes that some data in CollisionData is not being set to zero 100 | - Fixes a little Rockstar mistake with coronas rendering 101 | 102 | **Since v1.7.3** 103 | - Not only airplanes but also trains and boats have shadows 104 | - If car is far enough, shadow will be classic (instead of NO SHADOWS) 105 | - An experimental fix for crazy cruising speed for vehicles 106 | - Some other issues are fixed now... duh 107 | 108 | **Since v1.7.2** 109 | - Another crash fix... I hate myself... *facepalm* 110 | - A count of max loading screens can be changed now (default is 7) 111 | - Probably fixed walking AND aiming on high FPS 112 | - Fixed water cannons (firetruck/S.W.A.T.) on high FPS 113 | - An experimental fix of 034E opcode (move object) on high FPS 114 | - FramerateVigilante: Fixed physical objects push force 115 | - MTA: Increase intensity of vehicle tail light corona 116 | - MTA: Thrown projectiles throw more accurately 117 | - Fixed red marker cannot be placed on the right side of the screen 118 | - VitaPort: Fixed Heli/Plane camera 119 | - An ability to remove FOV-effect while driving a car (NoVehicleFOVEffect, not applied by default) 120 | - MTA: Disable GTA vehicle detachment at rotation 121 | - Now all airplanes have shadows 122 | - **Cars (only cars because of a limit)** now have a bigger shadow draw distance 123 | 124 | **Since v1.7.1** 125 | - Goddamn static light shadows from PC! 126 | - Bumped a limit of static shadows! 127 | - Static light shadows (from traffic lights, poles and more) draw distance is 3 times bigger 128 | - Fix accidentally broken "Colorpicker widget". I am sorry. 129 | 130 | **Since v1.7** 131 | - **Fix broken Swimming Speed Fix** (bruh) 132 | - CJ is now able to exit vehicle without closing the door (https://github.com/AndroidModLoader/JPatch/issues/28) 133 | - Removed "Please rate the game" message 134 | - Removed IDE flag "ExtraAirResistance" 135 | - Implement NoRadioCuts 136 | - Sprinting on any surface is allowed 137 | - Fix traffic lights 138 | - Adjustable detailed water draw distance (known as water quadrant fix) 139 | - PC-like money in HUD (disabled by default) 140 | - **Climb-dying glitch SHOULD be fixed** 141 | - RE3: Road reflections 142 | - Tell the game we allow it to create more peds 143 | - Tell the game we allow it to create more cars 144 | - re3: Fix R\* optimization that prevents peds from spawn 145 | - Fuzzy seek (the game does not load useless data from audio) 146 | - 44100Hz audio support without a mod "OpenAL Update" 147 | - Fixed emergency vehicles (FixStreamingDistScale) 148 | - Fixed an annoying glitch with colorpicker in Tenderfender 149 | - The camera is not rotating like a crazy when mouse/keyboard is connected (thanks AliAssassiN!) 150 | - The camera buffer is getting properly cleared. This is fixing "ghosting" underworld (thanks AliAssassiN!) 151 | - Lamppost coronas are now rotating like on PS2 152 | - Directional sunlight on entities (vehicles, peds) 153 | - CJ is no longer breathing with his ass underwater 154 | - FX particles draw distance scaler (default is x2.5) 155 | - Fixed coronas stretching while the weather is foggy 156 | - BengbuGuards: Second siren is now working 157 | - Weapon spread fix 158 | - Disable a flag to allow shadows to be drawed on all surfaces 159 | - Fix a little mistake that doesnt let player to crouch if he's ~1 HP 160 | - Vehicle sun glare 161 | - No minimap in interiors 162 | - Fixed green textures (moved from SkyGFX Mobile) 163 | - **Radar streaming should be fixed** 164 | - Allow license plates to render on all vehicles 165 | - Show muzzle flash for the last bullet 166 | - Vehicles license plates now random 167 | - "You have worked out enough for today, come back tomorrow!" glitch is fixed 168 | - Michelle dating fix 169 | - Parachute landing animation fix 170 | - Unused detonator animation is working 171 | - Taxi lights are activated 172 | - Fix Adjustable.cfg sizes lowering on smartphones with an aspect ratio bigger than 16:9 (has a lil glitch with x position shifting) 173 | - Classic CJ's shadow 174 | - FramerateVigilante: CarSlowDownSpeedFix 175 | - Skimmer Plane can be properly get out of water 176 | - Cinematic camera when double tapping the camera mode switch button 177 | - re3: Make cars and peds to not despawn when you look away 178 | - Dont kill peds when jacking their car, monster! 179 | - Fixed ped animation after being attacked with parachute (inspired *by Alexander Polyak*) 180 | - Cloud saves can be disabled (NOT disabled by default) 181 | - Always drawable wanted stars (disabled by default) 182 | - Better ForceDXT 183 | - Fix wheels rotation speed on high FPS 184 | - Reflections are now centered on a camera instead of *player's neck* 185 | - Reflections are now bigger in quality (1024x1024 instead of default 512x512 at **max quality**) 186 | - Fixed a small FX system leakage when using custom effects mod 187 | 188 | **Since v1.6.1** 189 | - A fix for vehicle's entering task (thanks AliAssassiN!) 190 | - **Wrong vehicle parts colors (thanks B1ack_&_Wh1te and AliAssassiN!)** 191 | - Planes now have a toggleable smoke/dust (thanks BengbuGuards!) 192 | - Falling star is now not a black line 193 | - BengbuGuards: Implement jetpack hover button, also "lockable" 194 | - Fixing a wrong value in carcols.dat (a mistakenly placed dot instead of comma, # 98 malachite poly) 195 | - Automatical streaming memory buff if not enough for the game 196 | - Fix planes generation coordinates (will partially fix planes that are crashing in front of a player) 197 | - Fix JPatch crash after CJ dies :( 198 | 199 | **Since v1.6** 200 | - Colored zone names are back 201 | - Sand/Dust particles from bullets are limited because they are creating a lot of lag 202 | - CJ magnetting to stealable objects only when very close 203 | - Moved save pickup in Madd Dogg's Mansion 204 | - Moved a bribe to the broken bridge from SF building 205 | - Moved a rifle pickup outside of the SF Stadium wall 206 | - CJ no more can drop JetPack while he's in air 207 | - CJ can leave any vehicle at high speeds 208 | - Weapon penalty clean-up when CJ dies 209 | - **A fix for 2.10 crash (thanks fastman92!)** 210 | - A fix for vehicle's entering task (thanks AliAssassiN!) 211 | - Fixed wall behind the fog (only for default shaders!) 212 | - Remove stupid specular from peds 213 | 214 | **Since v1.5.1** 215 | - **Crosshair should be placed at the correct place** 216 | - Aiming with Country Rifle is now in 3rd person 217 | 218 | **Since v1.5** 219 | - Animated textures (UVAnim) 220 | - Vertex Weights 221 | - Swimming speed 222 | - Fixed sky multitude (a glitch on high speeds) 223 | - Fixed vehicles backlight light state (should do vehicle tail light effect when ANY of the lights are broken) 224 | 225 | ### ***GTA:SA v2.00*** 226 | **Planned/TODO (not ready or broken now)** 227 | - Fix camera zoom is not that big (aspect ratio?) 228 | - FoodEatingFix by JuniorDjjr 229 | - Moon phases (probably far away...) 230 | - Doubled the directional light sources on models (to match the PC version) <- Shaders thingo :( 231 | - Fix opcode 08F8 that still shows "Updated stats" pop-up no matter what 232 | - Bring back saveable camera photos (framebuffer-related problems! The image is like... rotated, scaled and repeated?!) 233 | - Need to fix a framebuffer at the end of the rendering stage 234 | - Fixed a glitch with bushes/trees switching their color to black at some camera angles (camnorm issue) 235 | 236 | **Since v1.8.1** 237 | - SilentPatch: Impound garages 238 | - SilentPatch: Bigger mirror quality on medium-high settings 239 | - Fixed a glitch with the timer on high FPS 240 | - Allowes gang wars to have a wanted level (like on PC) 241 | - Fixing drunk camera on high FPS 242 | - When headlights are active, the windows are no longer transparent from one side 243 | 244 | **Since v1.8** 245 | - Some cut effects from the game are back 246 | - Able to skip "drive" (tripskip) 247 | - Fixed "collideable" particles such as gunshells (reversed from FxsFuncs) 248 | - GLAlphaFunc mod is now included (fixing a crash on Huawei phones) 249 | - Fixes some stupid nearclipping issues that are caused by WarDrum's dirty hands 250 | - Fixes that some data in CollisionData is not being set to zero 251 | - Fixes a little Rockstar mistake with coronas rendering 252 | 253 | **Since v1.7.3** 254 | - Not only airplanes but also trains and boats have shadows 255 | 256 | **Since v1.7.2** 257 | - Little fixes for previous JPatch fixes 258 | - An ability to remove FOV-effect while driving a car (NoVehicleFOVEffect, not applied by default) 259 | - Now all vehicles have shadows (Trains, some airplanes and etc) 260 | - **Cars (only cars because of a limit)** now have a bigger shadow draw distance 261 | 262 | **Since v1.7** 263 | - CJ is now able to exit vehicle without closing the door (https://github.com/AndroidModLoader/JPatch/issues/28) 264 | - Fix wheels rotation speed on high FPS 265 | - Reflections are now centered on a camera instead of *player's neck* 266 | - Reflections are now bigger in quality (1024x1024 instead of default 512x512 at **max quality**) 267 | - Fixed FX distance multiplier (caused a glitch, reworked) 268 | 269 | **Since v1.6.1** 270 | - Unused detonator animation is working 271 | - Improved AND fixed Dynamic Streaming Memory 272 | - Fixed a crash from **"Wrong vehicle parts colors"** fix 273 | - A fix for vehicle's entering task (thanks AliAssassiN!) 274 | - Fix planes generation coordinates (will partially fix planes that are crashing in front of a player) 275 | 276 | **Since v1.6** 277 | - Falling star is now not a black line 278 | - Jetpack hovering is now "lockable" 279 | - Planes now have a toggleable smoke/dust (thanks BengbuGuards!) 280 | - **Wrong vehicle parts colors (thanks B1ack_&_Wh1te and AliAssassiN!)** 281 | - The camera is not rotating like a crazy when mouse/keyboard is connected (thanks AliAssassiN!) 282 | - The camera buffer is getting properly cleared. This is fixing "ghosting" underworld (thanks AliAssassiN!) 283 | - A little mistake by WarDrum related to holding a finger on widgets (thanks AliAssassiN!) 284 | 285 | **Since v1.5.1** 286 | - Fixed a small FX system leakage when using custom effects mod 287 | - Rewrote cheats hashes, check **GTASA_CHEATS.md** file for more info 288 | - BengbuGuards: Implement jetpack hover button 289 | - **AFK/Idle camera!** 290 | 291 | **Since v1.5** 292 | - BengbuGuards: Second siren is now working 293 | - BengbuGuards: An animation fix for boats 294 | - BengbuGuards: Player's plane won't disappear after it explodes 295 | - CJ is no longer breathing with his ass underwater 296 | - Directional sunlight on entities (vehicles, peds) 297 | - Lamppost coronas are now rotating like on PS2 298 | - Vehicles license plates now random 299 | - Car generators in an interior now work properly 300 | - "You have worked out enough for today, come back tomorrow!" glitch is fixed 301 | - Fixing a wrong value in carcols.dat (a mistakenly placed dot instead of comma, # 98 malachite poly) 302 | - Inverse swimming controls to dive/go up (to match PC version) 303 | - Fix for the wrong position (from the beta) of Bravura in a mission "You've Had Your Chips" 304 | - Michelle dating fix 305 | - Stealth kill with a knife does NOT require to be crouched anymore (as on PC) 306 | - RLEDecompress crash is fixed! (allocates more memory) 307 | 308 | **Since v1.4.3** 309 | - Fixed coronas stretching while the weather is foggy 310 | - SCM fix by JuniorDjrr for "IsPedDead" (broken sometimes?) 311 | - Fixed water physics (includes swimming speed fix) 312 | - Sprint button after aiming and dropping to the water is always visible 313 | - Parachute landing animation fix 314 | - FX particles draw distance scaler (default is x2.5) 315 | - Boat radio antenna animation 316 | - MixSets: Crouch with any weapons 317 | 318 | **Since v1.4.2.2** 319 | - Fixed wall behind the fog (use default shaders!) 320 | 321 | **Since v1.4.2.1** 322 | - Fixed broken CrosshairFix after v1.4.2, fix for Country Rifle 323 | - Changed the values of CrosshairFix so it's more correct 324 | - Fixed the Country Rifle camera in 3rd person 325 | 326 | **Since v1.4.2** 327 | - Removed "Please rate the game" message 328 | - Removed IDE flag "ExtraAirResistance" 329 | - Implement NoRadioCuts 330 | - Smaller grenades collision 331 | - MTA: Fixed a glitch with projectiles (see https://github.com/multitheftauto/mtasa-blue/issues/1123) 332 | - MTA: Fix slippery floor (improved in v1.4.3) 333 | - Allow license plates to render on all vehicles 334 | - Fix a little mistake that doesnt let player to crouch if he's ~1 HP 335 | - Show muzzle flash for the last bullet 336 | - Disable a flag to allow shadows to be drawed on all surfaces 337 | - Weapon spread fix 338 | 339 | **Since v1.4.1** 340 | - Better ForceDXT 341 | - Vehicle sun glare 342 | - Wet roads reflections 343 | 344 | **Since v1.4** 345 | - Finally fixed BuffDistForLightCoronas! 346 | - Fixed peds are not speaking closer to the game end 347 | - Always draw wanted stars (disabled by default) 348 | - Rotor blur *by Peepo* 349 | - Cloud saves can be disabled (NOT disabled by default) 350 | - Always drawable wanted stars (disabled by default) 351 | - Fixed PED preloading (for Improved Streaming, disabled by default) 352 | - A count of max loading screens can be changed now (default is 7) 353 | - Fixed ped counting overflow for gang members calculating 354 | - Sprinting on any surface is allowed 355 | - Camera/Sniper zooming is faster and can be adjusted to be even faster! 356 | - Minimal FOV for Camera is adjustable (default is 70, set it to 90 or bigger if you need "fish eye" in a camera) 357 | 358 | **Since v1.3** 359 | - VitaPort: Fixed cheats hashtable 360 | - Cheats can now be entered using keyboard 361 | - Fix save loading crash (may work... no save with that glitch :( ) 362 | - Fix Adjustable.cfg sizes lowering on smartphones with an aspect ratio bigger than 16:9 (has a lil glitch with x position shifting) 363 | - Taxi lights are activated 364 | - No minimap in interiors 365 | - PC-like money in HUD (disabled by default) 366 | - Aiming with Country Rifle is now in 3rd person 367 | - Force the game's inner check always return that we have only touch (disabled by default) 368 | - Fixed ped animation after being attacked with parachute (inspired *by Alexander Polyak*) 369 | - MixSets: Hostile gangs 370 | - Adjustable detailed water draw distance (known as water quadrant fix) 371 | - Peepo: Traffic lights fix 372 | 373 | **Since v1.2.4** 374 | - Corona sprites draw distance is 3 times bigger 375 | - Static shadows are moved to the ground a bit 376 | - **Radar streaming should be fixed** 377 | - **Climb-dying glitch SHOULD be fixed** 378 | - Do not use bias in shaders, probably makes the game faster 379 | - Re-fixed emergency vehicles disappearing 380 | - Fixed bikes generator at driving school (for new players) 381 | - **Crosshair should be placed at the correct place** 382 | 383 | **Since v1.2.3** 384 | - Goddamn static light shadows from PC! 385 | - Bumped a limit of static shadows! 386 | - Fixed green textures (moved from SkyGFX Mobile) 387 | - Static light shadows (from traffic lights, poles and more) draw distance is 3 times bigger 388 | 389 | **Since v1.2.1** 390 | - Remove stupid specular from peds 391 | - Include objects in checks of FindGroundZ functions (may fix opcode 02CE after using 0107) 392 | - Automatical streaming memory buff if not enough for the game 393 | - Fixed an annoying glitch with colorpicker in Tenderfender 394 | - ImprovedStreaming: Preload LODs (causes the game to freeze for a few seconds) 395 | - ImprovedStreaming: Preload animations (disabled by default) 396 | - ImprovedStreaming: Unloading of unused entities 397 | 398 | **Since v1.2** 399 | - Give more space for opcodes 038D+038F 400 | - Lower threads sleeping timer 401 | - Dont kill peds when jacking their car, monster! 402 | - Colored zone names are back 403 | - Tell the game we allow it to create more peds 404 | - Tell the game we allow it to create more cars 405 | - re3: Fix R\* optimization that prevents peds from spawn 406 | - re3: Make cars and peds to not despawn when you look away 407 | - re3: Do not remove locked cars 408 | - re3: Correct clouds rotating speed 409 | - re3: Multiple instances of semaphore fix (may be not working or useless) 410 | - re3: Fix a little mistake by R\* in AskForObjectToBeRenderedInGlass 411 | - re3: Free the space for an object by deleting temporary objects from pool if not enough space 412 | 413 | **Since v1.1.5** 414 | - Hotfix of experimental fix of 034E opcode 415 | - Classic CJ's shadow 416 | - FramerateVigilante: CarSlowDownSpeedFix 417 | - FramerateVigilante: HeliRotorIncreaseSpeed 418 | 419 | **Since v1.1.4** 420 | - Hotfix of Skimmer plane 421 | 422 | **Since v1.1.3** 423 | - Bring back a missing shoot button on S.W.A.T. 424 | - Fuzzy seek (the game does not load useless data from audio) 425 | - Fixed water cannons (firetruck/S.W.A.T.) on high FPS 426 | - An experimental fix of 034E opcode (move object) on high FPS 427 | - FramerateVigilante: Fixed physical objects push force 428 | - VitaPort: Fixed Heli/Plane camera 429 | 430 | **Since v1.1.2** 431 | - Skimmer Plane can be properly get out of water (XMDS) 432 | - Streaming memory is buffed now 433 | - Helis/Planes can now fly higher 434 | - Jetpack can now fly higher 435 | - 44100Hz audio support without a mod "OpenAL Update" 436 | - MTA: Disable GTA vehicle detachment at rotation 437 | 438 | **Since v1.1.1** 439 | - Dont burn player that are driving burning bmx 440 | - A fix for possible crash from GetCompositeMatrix (may be useless) 441 | - Cinematic camera when double tapping the camera mode switch button 442 | - MTA: Increase intensity of vehicle tail light corona 443 | - MTA: Disable setting the occupied's vehicles health to 75.0f when a burning ped enters it 444 | - MTA: Thrown projectiles throw more accurately 445 | 446 | **Since v1.1** 447 | - Fixed emergency vehicles (FixStreamingDistScale) 448 | - Moved save pickup in Madd Dogg's Mansion 449 | - Moved a bribe to the broken bridge from SF building 450 | - Moved a rifle pickup outside of the SF Stadium wall 451 | - Fixed cutscene FOV (disabled by default, incomplete) 452 | - Fixed sky multitude (a glitch on high speeds) 453 | - Fixed vehicles backlight light state (should do vehicle tail light effect when ANY of the lights are broken) 454 | - Sand/Dust particles from bullets are limited because they are creating a lot of lag 455 | - Fixed red marker cannot be placed on the right side of the screen 456 | 457 | **Since v1.0** 458 | - Animated textures (UVAnim) 459 | - Vertex Weights 460 | - Swimming speed 461 | - CJ magnetting to stealable objects only when very close 462 | - Madd Dogg's Basketball glitch fixed by replacing save file 463 | - CJ can leave any vehicle at high speeds 464 | - CJ no more can drop JetPack while he's in air 465 | - Weapon penalty clean-up when CJ dies 466 | -------------------------------------------------------------------------------- /j_sa.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #define GL_GLEXT_PROTOTYPES 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #ifdef AML32 19 | #include "AArch64_ModHelper/Thumbv7_ASMHelper.h" 20 | #include "GTASA_STRUCTS.h" 21 | using namespace ThumbV7; 22 | #else 23 | #include "AArch64_ModHelper/ARMv8_ASMHelper.h" 24 | #include "GTASA_STRUCTS_210.h" 25 | using namespace ARMv8; 26 | #endif 27 | 28 | extern int androidSdkVer; 29 | extern uintptr_t pGTASA, pSC; 30 | extern void *hGTASA, *hSC; 31 | 32 | #define BUNCHTAILS_EX 6144 // More bunchtails because Project 2DFX may use it. 33 | 34 | namespace GTA_SA 35 | { 36 | 37 | union ScriptVariables 38 | { 39 | int i; 40 | float f; 41 | uint32_t u; 42 | void* p; 43 | }; 44 | 45 | // fMagic = 1.6666667: 46 | // ARM64: Closest is 1.665 at 0x739EF4 47 | 48 | static constexpr float ar43 = 4.0f / 3.0f; 49 | static constexpr float fMagic = 50.0f / 30.0f; 50 | static constexpr int nMaxScriptSprites = 384; // Changing it wont make it bigger. 51 | 52 | float fEmergencyVehiclesFix; 53 | CSprite2d** pNewScriptSprites = new CSprite2d*[nMaxScriptSprites] {NULL}; // 384*4=1536 0x600 54 | void* pNewIntroRectangles = new void*[15*nMaxScriptSprites] {NULL}; // 384*60=23040 0x5A00 55 | CRegisteredShadow* asShadowsStored_NEW; 56 | CStaticShadow* aStaticShadows_NEW; 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | /////////////////////////////// Vars /////////////////////////////// 60 | ///////////////////////////////////////////////////////////////////////////// 61 | float fAspectCorrection = 0.0f, fAspectCorrectionDiv = 0.0f; 62 | #define fAspectCorrection (*ms_fAspectRatio - ar43) 63 | #define fAspectCorrectionDiv (*ms_fAspectRatio / ar43) 64 | #define GetTimeStep() (*ms_fTimeStep) 65 | #define GetTimeStepInSeconds() (GetTimeStep() / 50.0f) 66 | #define GetTimeStepMagic() (GetTimeStep() / fMagic) 67 | #define GetTimeStepInvMagic() (fMagic / GetTimeStep()) 68 | 69 | struct RQRenderTarget; 70 | struct VehiclePartsPair 71 | { 72 | RpMaterial* material; 73 | uintptr_t color; 74 | RwTexture* texture; 75 | }; // 76 | VehiclePartsPair* gStoredMats; 77 | bool *ms_bIsPlayerOnAMission, *m_UserPause, *m_CodePause, *m_aCheatsActive, *bDidWeProcessAnyCinemaCam, *bRunningCutscene, *bProcessingCutscene, *ms_bTakePhoto, *bGameStarted, *m_bCCTV, *m_bFog, *m_bDisableAllPostEffect; 78 | uint8_t *ms_currentCol, *ms_nGameClockDays, *ms_nGameClockMonths, *_bf_12c; 79 | int32_t *DETAILEDWATERDIST, *ms_nNumGang, *StatTypesInt, *lastDevice, *NumberOfSearchLights, *ms_numAnimBlocks, *RasterExtOffset, *textureDetail, *ms_iActiveSequence; 80 | uint32_t *gbCineyCamProcessedOnFrame, *CloudsIndividualRotation, *m_ZoneFadeTimer, *ms_memoryUsed, *ms_memoryAvailable, *m_FrameCounter, *m_snTimeInMilliseconds, *SkipTimer; 81 | float *ms_fTimeStep, *ms_fFOV, *game_FPS, *CloudsRotation, *WeatherWind, *fSpriteBrightness, *m_fLightsOnGroundBrightness, *m_f3rdPersonCHairMultX, *m_f3rdPersonCHairMultY, *ms_fAspectRatio, *ms_fTimeScale, *mod_HandlingManager_off4; 82 | CVector *m_vecDirnLightToSun; 83 | CVector *m_VectorToSun; 84 | int *m_CurrentStoredValue, *currArea, *SkipState; 85 | float *fPlayerAimRotRate, *DrunkRotation; 86 | CVector2D *m_vecCachedPos; 87 | 88 | CPlayerInfo *WorldPlayers; 89 | CIntVector2D *windowSize; 90 | CCamera *TheCamera; 91 | RsGlobalType *RsGlobal; 92 | MobileMenu *gMobileMenu; 93 | CWidget **m_pWidgets; 94 | ScriptVariables* ScriptParams; 95 | CLinkList *m_alphaList; 96 | CPool **pObjectPool; 97 | CZoneInfo **m_pCurrZoneInfo; 98 | CWeaponInfo *aWeaponInfo; 99 | CPolyBunch *aPolyBunches; 100 | CBaseModelInfo **ms_modelInfoPtrs; 101 | CRGBA *ms_vehicleColourTable; 102 | CRGBA *HudColour; 103 | CTaskComplexSequence *ms_taskSequence; 104 | CRunningScript **pActiveScripts; 105 | void *g_surfaceInfos; 106 | RwTexture **ms_pRemapTexture; 107 | CIdleCam *gIdleCam; 108 | CLinkList *ms_colModelCache; 109 | TDBArray *detailTextures; 110 | RwRaster **pRasterFrontBuffer; 111 | GlobalSceneTag *Scene; 112 | void *TheText; 113 | RQRenderTarget **SelectedRQTarget, **backTarget, **oldTarget; 114 | CSprite2d *HudSprites; 115 | 116 | ///////////////////////////////////////////////////////////////////////////// 117 | /////////////////////////////// Funcs /////////////////////////////// 118 | ///////////////////////////////////////////////////////////////////////////// 119 | int ret0(int a, ...) { return 0; } // Generic 120 | int ret1(int a, ...) { return 1; } // Generic 121 | void crash_this() { __builtin_trap(); } // Used for redirected funcs, to get the function it's called from (virtual funcs are hard!) 122 | inline void* TryLoadAlphaFunc(const char* szlib) 123 | { 124 | void* lib = dlopen(szlib, RTLD_LAZY); 125 | if(!lib) return NULL; 126 | 127 | void* sym = dlsym(lib, "glAlphaFuncQCOM"); 128 | if(!sym) sym = dlsym(lib, "glAlphaFunc"); 129 | return sym; 130 | } 131 | 132 | void (*BrightLightsInit)(); 133 | void (*BrightLightsRender)(); 134 | bool (*IsOnAMission)(); 135 | void (*AddToCheatString)(char); 136 | void (*RwRenderStateSet)(RwRenderState, void*); 137 | void (*RwRenderStateGet)(RwRenderState, void*); 138 | void (*ClearPedWeapons)(CPed*); 139 | eBulletFxType (*GetBulletFx)(void* self, unsigned int surfaceId); 140 | void (*LIB_PointerGetCoordinates)(int, int*, int*, float*); 141 | bool (*Touch_IsDoubleTapped)(WidgetIDs, bool doTapEffect, int idkButBe1); 142 | bool (*Touch_IsHeldDown)(WidgetIDs, int idkButBe1); 143 | void (*Touch_ClearTapHistory)(WidgetIDs); 144 | void (*SetCameraDirectlyBehindForFollowPed)(CCamera*); 145 | void (*RestoreCamera)(CCamera*); 146 | CVehicle* (*FindPlayerVehicle)(int playerId, bool unk); 147 | CPlayerPed* (*FindPlayerPed)(int playerId); 148 | void (*PhysicalApplyForce)(CPhysical* self, CVector force, CVector point, bool updateTurnSpeed); 149 | char* (*GetFrameNodeName)(RwFrame*); 150 | int (*SpriteCalcScreenCoors)(const RwV3d& posn, RwV3d* out, float* w, float* h, bool checkMaxVisible, bool checkMinVisible); 151 | void (*WorldRemoveEntity)(CEntity*); 152 | void (*SetFontColor)(CRGBA* clr); 153 | bool (*ProcessVerticalLine)(const CVector& origin, float distance, CColPoint& outColPoint, CEntity*& outEntity, bool buildings, bool vehicles, bool peds, bool objects, bool dummies, bool doSeeThroughCheck, CStoredCollPoly* outCollPoly); 154 | void (*CreateEntityRwObject)(CEntity*); 155 | void (*RequestModel)(int id, int prio); 156 | bool (*RemoveLeastUsedModel)(unsigned int streamingFlags); 157 | void (*LoadAllRequestedModels)(bool bOnlyPriorityRequests); 158 | void (*AddAnimBlockRef)(int animBlock); 159 | void (*TimerStop)(); 160 | void (*TimerUpdate)(); 161 | #ifdef AML32 162 | void (*GetTouchPosition)(CVector2D*, int cachedPosNum); 163 | #else 164 | CVector2D (*GetTouchPosition)(int cachedPosNum); 165 | #endif 166 | bool (*StoreStaticShadow)(uintptr_t id, uint8_t type, RwTexture* texture, CVector* posn, float frontX, float frontY, float sideX, float sideY, int16_t intensity, uint8_t red, uint8_t green, uint8_t blue, float zDistane, float scale, float drawDistance, bool temporaryShadow, float upDistance); 167 | void (*TransformPoint)(RwV3d& point, const CSimpleTransform& placement, const RwV3d& vecPos); 168 | CAnimBlendAssociation* (*RpAnimBlendClumpGetAssociation)(RpClump*, const char*); 169 | CAnimBlendAssociation* (*RpAnimBlendClumpGetAssociationU)(RpClump*, uint32_t); 170 | CObject* (*CreateObject)(int mdlIdx, bool create); 171 | C2dEffect* (*Get2dEffect)(CBaseModelInfo*, int); 172 | void (*RwFrameForAllObjects)(RwFrame*, RwObject* (*)(RwObject*, void*), void*); 173 | RwObject* (*GetCurrentAtomicObjectCB)(RwObject*, void*); 174 | void (*RpGeometryForAllMaterials)(RpGeometry*, RpMaterial* (*)(RpMaterial*, void*), void*); 175 | void (*SetComponentAtomicAlpha)(RpAtomic*, int); 176 | void (*ApplyMoveForce)(CPhysical*,float,float,float); 177 | bool (*GetWaterLevel)(CVector, float&, bool, CVector*); 178 | CTask* (*GetTaskSwim)(CPedIntelligence*); 179 | CTask* (*TaskConstructor)(); 180 | void (*TaskStartNamedAnim)(CTask*, const char* animName, const char* animGroupName, uint32_t animFlags, float blendDelta, int32_t endTime, bool bDontInterrupt, bool bRunInSequence, bool bOffsetPed, bool bHoldLastFrame); 181 | void (*SetTask)(CTaskManager*, CTask*, int, bool); 182 | bool (*TaskComplexSequenceAddTask)(CTaskComplexSequence*, CTask*); 183 | CAnimBlendAssociation* (*BlendAnimation)(RpClump* clump, AssocGroupId groupId, AnimationId animId, float clumpAssocBlendData); 184 | CAnimBlendAssociation* (*RpAnimBlendGetNextAssociation)(CAnimBlendAssociation *pAssociation); 185 | RpAtomic* (*SetEditableMaterialsCB)(RpAtomic *pAtomic, void *pData); 186 | void (*RenderEntity)(CEntity*); 187 | void (*GeneratePlateText)(char*, int); 188 | char* (*GetCustomCarPlateText)(CVehicleModelInfo*); 189 | int (*GetVehicleRef)(CVehicle*); 190 | void (*RenderFontBuffer)(); 191 | void (*RwTextureDestroy)(RwTexture*); 192 | double (*OS_TimeAccurate)(); 193 | CVehicle* (*VehicleCheat)(int); 194 | bool (*WidgetIsTouched)(int, CVector2D*, int); 195 | void (*InitIdleCam)(CIdleCam*); 196 | void (*ProcessIdleCam)(CIdleCam*); 197 | void (*ResetIdleCam)(CIdleCam*, bool); 198 | void (*SetIdleCamTarget)(CIdleCam*, CEntity*); 199 | void (*RunIdleCam)(CIdleCam*); 200 | void (*SetColTrianglePlane)(CColTrianglePlane*, CVector*, CColTriangle*); 201 | void (*SetVehicleColour)(CVehicleModelInfo*, uint8_t, uint8_t, uint8_t, uint8_t); 202 | CTask* (*GetActiveTask)(CTaskManager*); 203 | int16_t (*GetPedWalkLR)(void*); 204 | int16_t (*GetPedWalkUD)(void*); 205 | void (*DoSunGlare)(CVehicle*); 206 | void (*SetTaxiLight)(CAutomobile*, bool); 207 | RwImage* (*RwImageCreate)(int, int, int); 208 | void (*RwImageAllocatePixels)(RwImage*); 209 | void (*RwImageSetFromRaster)(RwImage*, RwRaster*); 210 | void (*SetDirMyDocuments)(); 211 | void (*FileMgrSetDir)(const char* dirName); 212 | void (*JPegCompressScreenToFile)(RwCamera*, const char*); 213 | bool (*RwGrabScreen)(RwCamera*, const char*); 214 | void (*ApplyTurnForce)(CPhysical*, CVector, CVector); 215 | void (*StoreShadowForVehicle)(CVehicle*, int); 216 | void (*RsEventHandler)(int, int); 217 | void (*PostEffectsFog)(); 218 | void (*RenderWaterFog)(); 219 | void (*RenderMovingFog)(); 220 | void (*RenderVolumetricClouds)(); 221 | void (*SpeedFX)(float); 222 | void (*RwCameraEndUpdate)(RwCamera*); 223 | void (*RwRasterPushContext)(RwRaster*); 224 | void (*RwRasterRenderFast)(RwRaster*, int, int); 225 | void (*RwRasterPopContext)(); 226 | void (*RsCameraBeginUpdate)(RwCamera*); 227 | void (*OpenGLLockAndCopyRasters)(RwRaster*, RwRaster*, bool, bool); 228 | RwRaster* (*RwRasterCreate)(int, int, int, int); 229 | void (*RsCameraShowRaster)(RwCamera*); 230 | CTask* (*FindActiveTaskByType)(CTaskManager*, int); 231 | CPad* (*GetPad)(int); 232 | bool (*TouchInterfaceIsReleased)(int, CVector2D*, int); 233 | void (*SetFadeColour)(CCamera*, uint8_t, uint8_t, uint8_t); 234 | void (*CameraFade)(CCamera*, float, uint16_t); 235 | uint16_t* (*TextGet)(void*, const char*); 236 | void (*AddBigMessage)(uint16_t*, uint32_t, uint16_t); 237 | void (*SelectRQTarget)(RQRenderTarget *toSelect, bool force); 238 | void (*SetHelpMessage)(char const*,uint16_t *,bool,bool,bool,uint); 239 | void (*DrawSprite2D_Simple)(CSprite2d*, const CRect*, const CRGBA*); 240 | void (*FxInterpInfo32GetVal)(FxInterpInfo32_c *, float *values, float t); 241 | float (*RwV3dLength)(CVector*); 242 | void (*FlushSpriteBuffer)(); 243 | 244 | inline int GetSectorForCoord(int coord) 245 | { 246 | return floor(0.02f * coord + 60.0f); 247 | } 248 | inline int GetSectorForCoord(float coord) 249 | { 250 | return floor(0.02f * coord + 60.0f); 251 | } 252 | 253 | inline void TransformFromObjectSpace(CEntity* self, CVector& outPos, const CVector& offset) 254 | { 255 | if(self->m_matrix) 256 | { 257 | outPos = *self->m_matrix * offset; 258 | return; 259 | } 260 | TransformPoint((RwV3d&)outPos, self->m_placement, (RwV3d&)offset); 261 | } 262 | inline CVector TransformFromObjectSpace(CEntity* ent, const CVector& offset) 263 | { 264 | auto result = CVector(); 265 | if (ent->m_matrix) { 266 | result = *ent->m_matrix * offset; 267 | return result; 268 | } 269 | 270 | TransformPoint((RwV3d&)result, ent->m_placement, (RwV3d&)offset); 271 | return result; 272 | } 273 | int nMaxStreamingMemForDynamic, nDynamicStreamingMemBumpStep; 274 | inline void BumpStreamingMemory(int megabytes) 275 | { 276 | *ms_memoryAvailable += megabytes * 1024 * 1024; 277 | if(*ms_memoryAvailable > nMaxStreamingMemForDynamic) 278 | { 279 | *ms_memoryAvailable = nMaxStreamingMemForDynamic; 280 | } 281 | } 282 | 283 | // Global Hooks (no need to enable patches) 284 | double m_dblTimeInMicroseconds = 0.0f; 285 | double m_dblOldTimeInMicroseconds = 0.0f; 286 | uint32_t m_snOwnTimeInMilliseconds = 0; 287 | 288 | uint32_t m_LogicalFramesPassed = 0, m_LogicalFrameCounter = 0; 289 | DECL_HOOKv(Global_TimerUpdate) 290 | { 291 | Global_TimerUpdate(); 292 | 293 | m_dblOldTimeInMicroseconds = m_dblTimeInMicroseconds; 294 | m_dblTimeInMicroseconds = OS_TimeAccurate(); 295 | 296 | // re3: 297 | static double frameTimeLogical = 0.0, frameTimeFractionScaled = 0.0; 298 | 299 | m_LogicalFramesPassed = 0; 300 | frameTimeLogical += m_dblTimeInMicroseconds; 301 | while (frameTimeLogical >= 1.0 / 30.0) 302 | { 303 | frameTimeLogical -= 1.0 / 30.0; 304 | m_LogicalFramesPassed++; 305 | } 306 | m_LogicalFrameCounter += m_LogicalFramesPassed; 307 | 308 | if(!*m_UserPause && !*m_CodePause) 309 | { 310 | frameTimeFractionScaled += m_dblTimeInMicroseconds * *ms_fTimeScale; 311 | m_snOwnTimeInMilliseconds += (uint32_t)frameTimeFractionScaled; 312 | frameTimeFractionScaled -= (uint32_t)frameTimeFractionScaled; 313 | } 314 | } 315 | 316 | #ifdef AML32 317 | #include "patches_sa.inl" 318 | #else 319 | #include "patches_sa64.inl" 320 | #endif 321 | 322 | void JPatch() 323 | { 324 | cfg->Bind("IdeasFrom", "", "About")->SetString("MTA:SA Team, re3 contributors, JuniorDjjr, ThirteenAG, Blackbird88, 0x416c69, Whitetigerswt, XMDS, Peepo"); cfg->ClearLast(); 325 | 326 | // Functions Start // 327 | SET_TO(AddToCheatString, aml->GetSym(hGTASA, "_ZN6CCheat16AddToCheatStringEc")); 328 | SET_TO(RwRenderStateSet, aml->GetSym(hGTASA, "_Z16RwRenderStateSet13RwRenderStatePv")); 329 | SET_TO(RwRenderStateGet, aml->GetSym(hGTASA, "_Z16RwRenderStateGet13RwRenderStatePv")); 330 | SET_TO(ClearPedWeapons, aml->GetSym(hGTASA, "_ZN4CPed12ClearWeaponsEv")); 331 | SET_TO(GetBulletFx, aml->GetSym(hGTASA, "_ZN14SurfaceInfos_c11GetBulletFxEj")); 332 | SET_TO(LIB_PointerGetCoordinates, aml->GetSym(hGTASA, "_Z25LIB_PointerGetCoordinatesiPiS_Pf")); 333 | SET_TO(Touch_IsDoubleTapped, aml->GetSym(hGTASA, "_ZN15CTouchInterface14IsDoubleTappedENS_9WidgetIDsEbi")); 334 | SET_TO(Touch_IsHeldDown, aml->GetSym(hGTASA, "_ZN15CTouchInterface10IsHeldDownENS_9WidgetIDsEi")); 335 | SET_TO(Touch_ClearTapHistory, aml->GetSym(hGTASA, "_ZN15CTouchInterface15ClearTapHistoryENS_9WidgetIDsE")); 336 | SET_TO(SetCameraDirectlyBehindForFollowPed, aml->GetSym(hGTASA, "_ZN7CCamera48SetCameraDirectlyBehindForFollowPed_CamOnAStringEv")); 337 | SET_TO(RestoreCamera, aml->GetSym(hGTASA, "_ZN7CCamera7RestoreEv")); 338 | SET_TO(FindPlayerVehicle, aml->GetSym(hGTASA, "_Z17FindPlayerVehicleib")); 339 | SET_TO(FindPlayerPed, aml->GetSym(hGTASA, "_Z13FindPlayerPedi")); 340 | SET_TO(PhysicalApplyForce, aml->GetSym(hGTASA, "_ZN9CPhysical10ApplyForceE7CVectorS0_b")); 341 | SET_TO(GetFrameNodeName, aml->GetSym(hGTASA, "_Z16GetFrameNodeNameP7RwFrame")); 342 | SET_TO(SpriteCalcScreenCoors, aml->GetSym(hGTASA, "_ZN7CSprite15CalcScreenCoorsERK5RwV3dPS0_PfS4_bb")); 343 | SET_TO(WorldRemoveEntity, aml->GetSym(hGTASA, "_ZN6CWorld6RemoveEP7CEntity")); 344 | SET_TO(SetFontColor, aml->GetSym(hGTASA, "_ZN5CFont8SetColorE5CRGBA")); 345 | SET_TO(ProcessVerticalLine, aml->GetSym(hGTASA, "_ZN6CWorld19ProcessVerticalLineERK7CVectorfR9CColPointRP7CEntitybbbbbbP15CStoredCollPoly")); 346 | SET_TO(CreateEntityRwObject, aml->GetSym(hGTASA, "_ZN7CEntity14CreateRwObjectEv")); 347 | SET_TO(RequestModel, aml->GetSym(hGTASA, "_ZN10CStreaming12RequestModelEii")); 348 | SET_TO(LoadAllRequestedModels, aml->GetSym(hGTASA, "_ZN10CStreaming22LoadAllRequestedModelsEb")); 349 | SET_TO(AddAnimBlockRef, aml->GetSym(hGTASA, "_ZN12CAnimManager15AddAnimBlockRefEi")); 350 | SET_TO(TimerStop, aml->GetSym(hGTASA, "_ZN6CTimer4StopEv")); 351 | SET_TO(TimerUpdate, aml->GetSym(hGTASA, "_ZN6CTimer6UpdateEv")); 352 | SET_TO(RemoveLeastUsedModel, aml->GetSym(hGTASA, "_ZN10CStreaming20RemoveLeastUsedModelEj")); 353 | SET_TO(GetTouchPosition, aml->GetSym(hGTASA, "_ZN15CTouchInterface16GetTouchPositionEi")); 354 | SET_TO(StoreStaticShadow, aml->GetSym(hGTASA, BYBIT("_ZN8CShadows17StoreStaticShadowEjhP9RwTextureP7CVectorffffshhhfffbf", "_ZN8CShadows17StoreStaticShadowEyhP9RwTextureP7CVectorffffshhhfffbf"))); 355 | SET_TO(TransformPoint, aml->GetSym(hGTASA, "_Z14TransformPointR5RwV3dRK16CSimpleTransformRKS_")); 356 | SET_TO(IsOnAMission, aml->GetSym(hGTASA, "_ZN11CTheScripts18IsPlayerOnAMissionEv")); 357 | SET_TO(BrightLightsInit, aml->GetSym(hGTASA, "_ZN13CBrightLights4InitEv")); 358 | SET_TO(BrightLightsRender, aml->GetSym(hGTASA, "_ZN13CBrightLights6RenderEv")); 359 | SET_TO(CreateObject, aml->GetSym(hGTASA, "_ZN7CObject6CreateEib")); 360 | SET_TO(Get2dEffect, aml->GetSym(hGTASA, "_ZN14CBaseModelInfo11Get2dEffectEi")); 361 | SET_TO(RpAnimBlendClumpGetAssociation,aml->GetSym(hGTASA, "_Z30RpAnimBlendClumpGetAssociationP7RpClumpPKc")); 362 | SET_TO(RpAnimBlendClumpGetAssociationU,aml->GetSym(hGTASA, "_Z30RpAnimBlendClumpGetAssociationP7RpClumpj")); 363 | SET_TO(RwFrameForAllObjects, aml->GetSym(hGTASA, "_Z20RwFrameForAllObjectsP7RwFramePFP8RwObjectS2_PvES3_")); 364 | SET_TO(GetCurrentAtomicObjectCB,aml->GetSym(hGTASA, "_Z24GetCurrentAtomicObjectCBP8RwObjectPv")); 365 | SET_TO(RpGeometryForAllMaterials,aml->GetSym(hGTASA, "_Z25RpGeometryForAllMaterialsP10RpGeometryPFP10RpMaterialS2_PvES3_")); 366 | SET_TO(SetComponentAtomicAlpha, aml->GetSym(hGTASA, "_ZN8CVehicle23SetComponentAtomicAlphaEP8RpAtomici")); 367 | SET_TO(ApplyMoveForce, aml->GetSym(hGTASA, "_ZN9CPhysical14ApplyMoveForceE7CVector")); 368 | SET_TO(GetWaterLevel, aml->GetSym(hGTASA, "_ZN11CWaterLevel13GetWaterLevelEfffPfbP7CVector")); 369 | SET_TO(GetTaskSwim, aml->GetSym(hGTASA, "_ZNK16CPedIntelligence11GetTaskSwimEv")); 370 | SET_TO(TaskConstructor, aml->GetSym(hGTASA, BYBIT("_ZN5CTasknwEj", "_ZN5CTasknwEm"))); 371 | SET_TO(TaskStartNamedAnim, aml->GetSym(hGTASA, "_ZN23CTaskSimpleRunNamedAnimC2EPKcS1_ifibbbb")); 372 | SET_TO(SetTask, aml->GetSym(hGTASA, "_ZN12CTaskManager7SetTaskEP5CTaskib")); 373 | SET_TO(TaskComplexSequenceAddTask, aml->GetSym(hGTASA, "_ZN20CTaskComplexSequence7AddTaskEP5CTask")); 374 | SET_TO(BlendAnimation, aml->GetSym(hGTASA, "_ZN12CAnimManager14BlendAnimationEP7RpClump12AssocGroupId11AnimationIdf")); 375 | SET_TO(RpAnimBlendGetNextAssociation, aml->GetSym(hGTASA, "_Z29RpAnimBlendGetNextAssociationP21CAnimBlendAssociation")); 376 | SET_TO(SetEditableMaterialsCB, aml->GetSym(hGTASA, "_ZN17CVehicleModelInfo22SetEditableMaterialsCBEP8RpAtomicPv")); 377 | SET_TO(RenderEntity, *(uintptr_t*)(pGTASA + BYBIT(0x66F764, 0x83F610))); 378 | SET_TO(GeneratePlateText, aml->GetSym(hGTASA, "_ZN18CCustomCarPlateMgr17GeneratePlateTextEPci")); 379 | SET_TO(GetCustomCarPlateText, aml->GetSym(hGTASA, "_ZN17CVehicleModelInfo21GetCustomCarPlateTextEv")); 380 | SET_TO(GetVehicleRef, aml->GetSym(hGTASA, "_ZN6CPools13GetVehicleRefEP8CVehicle")); 381 | SET_TO(RenderFontBuffer, aml->GetSym(hGTASA, "_ZN5CFont16RenderFontBufferEv")); 382 | SET_TO(RwTextureDestroy, aml->GetSym(hGTASA, "_Z16RwTextureDestroyP9RwTexture")); 383 | SET_TO(OS_TimeAccurate, aml->GetSym(hGTASA, "_Z15OS_TimeAccuratev")); 384 | SET_TO(VehicleCheat, aml->GetSym(hGTASA, "_ZN6CCheat12VehicleCheatEi")); 385 | SET_TO(WidgetIsTouched, aml->GetSym(hGTASA, "_ZN15CTouchInterface9IsTouchedENS_9WidgetIDsEP9CVector2Di")); 386 | SET_TO(InitIdleCam, aml->GetSym(hGTASA, "_ZN8CIdleCam4InitEv")); 387 | SET_TO(ProcessIdleCam, aml->GetSym(hGTASA, "_ZN8CIdleCam7ProcessEv")); 388 | SET_TO(ResetIdleCam, aml->GetSym(hGTASA, "_ZN8CIdleCam5ResetEb")); 389 | SET_TO(SetIdleCamTarget, aml->GetSym(hGTASA, "_ZN8CIdleCam9SetTargetEP7CEntity")); 390 | SET_TO(RunIdleCam, aml->GetSym(hGTASA, "_ZN8CIdleCam3RunEv")); 391 | SET_TO(SetColTrianglePlane, aml->GetSym(hGTASA, "_ZN17CColTrianglePlane3SetEPK7CVectorR12CColTriangle")); 392 | SET_TO(GetActiveTask, aml->GetSym(hGTASA, "_ZNK12CTaskManager13GetActiveTaskEv")); 393 | SET_TO(GetPedWalkLR, aml->GetSym(hGTASA, "_ZN4CPad19GetPedWalkLeftRightEv")); 394 | SET_TO(GetPedWalkUD, aml->GetSym(hGTASA, "_ZN4CPad16GetPedWalkUpDownEv")); 395 | SET_TO(DoSunGlare, aml->GetSym(hGTASA, "_ZN8CVehicle10DoSunGlareEv")); 396 | SET_TO(SetTaxiLight, aml->GetSym(hGTASA, "_ZN11CAutomobile12SetTaxiLightEb")); 397 | SET_TO(RwImageCreate, aml->GetSym(hGTASA, "_Z13RwImageCreateiii")); 398 | SET_TO(RwImageAllocatePixels, aml->GetSym(hGTASA, "_Z21RwImageAllocatePixelsP7RwImage")); 399 | SET_TO(RwImageSetFromRaster, aml->GetSym(hGTASA, "_Z20RwImageSetFromRasterP7RwImageP8RwRaster")); 400 | SET_TO(SetDirMyDocuments, aml->GetSym(hGTASA, "_ZN8CFileMgr17SetDirMyDocumentsEv")); 401 | SET_TO(FileMgrSetDir, aml->GetSym(hGTASA, "_ZN8CFileMgr6SetDirEPKc")); 402 | SET_TO(JPegCompressScreenToFile, aml->GetSym(hGTASA, "_Z24JPegCompressScreenToFileP8RwCameraPKc")); 403 | SET_TO(RwGrabScreen, aml->GetSym(hGTASA, "_Z12RwGrabScreenP8RwCameraPc")); 404 | SET_TO(ApplyTurnForce, aml->GetSym(hGTASA, "_ZN9CPhysical14ApplyTurnForceE7CVectorS0_")); 405 | SET_TO(StoreShadowForVehicle, aml->GetSym(hGTASA, "_ZN8CShadows21StoreShadowForVehicleEP8CVehicle12VEH_SHD_TYPE")); 406 | SET_TO(RsEventHandler, aml->GetSym(hGTASA, "_Z14RsEventHandler7RsEventPv")); 407 | SET_TO(PostEffectsFog, aml->GetSym(hGTASA, "_ZN12CPostEffects3FogEv")); 408 | SET_TO(RenderWaterFog, aml->GetSym(hGTASA, "_ZN11CWaterLevel14RenderWaterFogEv")); 409 | SET_TO(RenderMovingFog, aml->GetSym(hGTASA, "_ZN7CClouds15MovingFogRenderEv")); 410 | SET_TO(RenderVolumetricClouds, aml->GetSym(hGTASA, "_ZN7CClouds22VolumetricCloudsRenderEv")); 411 | SET_TO(SpeedFX, aml->GetSym(hGTASA, "_ZN12CPostEffects7SpeedFXEf")); 412 | SET_TO(RwCameraEndUpdate, aml->GetSym(hGTASA, "_Z17RwCameraEndUpdateP8RwCamera")); 413 | SET_TO(RwRasterPushContext, aml->GetSym(hGTASA, "_Z19RwRasterPushContextP8RwRaster")); 414 | SET_TO(RwRasterRenderFast, aml->GetSym(hGTASA, "_Z18RwRasterRenderFastP8RwRasterii")); 415 | SET_TO(RwRasterPopContext, aml->GetSym(hGTASA, "_Z18RwRasterPopContextv")); 416 | SET_TO(RsCameraBeginUpdate, aml->GetSym(hGTASA, "_Z19RsCameraBeginUpdateP8RwCamera")); 417 | SET_TO(OpenGLLockAndCopyRasters,pGTASA + BYBIT(0x1B05BC, 0x242AA0)); 418 | SET_TO(RwRasterCreate, aml->GetSym(hGTASA, "_Z14RwRasterCreateiiii")); 419 | SET_TO(RsCameraShowRaster, aml->GetSym(hGTASA, "_Z18RsCameraShowRasterP8RwCamera")); 420 | SET_TO(FindActiveTaskByType, aml->GetSym(hGTASA, "_ZNK12CTaskManager20FindActiveTaskByTypeEi")); 421 | SET_TO(GetPad, aml->GetSym(hGTASA, "_ZN4CPad6GetPadEi")); 422 | SET_TO(TouchInterfaceIsReleased,aml->GetSym(hGTASA, "_ZN15CTouchInterface10IsReleasedENS_9WidgetIDsEP9CVector2Di")); 423 | SET_TO(SetFadeColour, aml->GetSym(hGTASA, "_ZN7CCamera13SetFadeColourEhhh")); 424 | SET_TO(CameraFade, aml->GetSym(hGTASA, "_ZN7CCamera4FadeEfs")); 425 | SET_TO(TextGet, aml->GetSym(hGTASA, "_ZN5CText3GetEPKc")); 426 | SET_TO(AddBigMessage, aml->GetSym(hGTASA, "_ZN9CMessages13AddBigMessageEPtjt")); 427 | SET_TO(SelectRQTarget, aml->GetSym(hGTASA, "_ZN14RQRenderTarget6SelectEPS_b")); 428 | SET_TO(SetHelpMessage, aml->GetSym(hGTASA, "_ZN4CHud14SetHelpMessageEPKcPtbbbj")); 429 | SET_TO(DrawSprite2D_Simple, aml->GetSym(hGTASA, "_ZN9CSprite2d4DrawERK5CRectRK5CRGBA")); 430 | SET_TO(FxInterpInfo32GetVal, aml->GetSym(hGTASA, "_ZN16FxInterpInfo32_c6GetValEPff")); 431 | SET_TO(RwV3dLength, aml->GetSym(hGTASA, "_Z11RwV3dLengthPK5RwV3d")); 432 | SET_TO(FlushSpriteBuffer, aml->GetSym(hGTASA, "_ZN7CSprite17FlushSpriteBufferEv")); 433 | #ifdef AML32 434 | SET_TO(RpLightCreate, aml->GetSym(hGTASA, "_Z13RpLightCreatei")); 435 | SET_TO(RpLightSetColor, aml->GetSym(hGTASA, "_Z15RpLightSetColorP7RpLightPK10RwRGBAReal")); 436 | SET_TO(RpLightSetRadius, aml->GetSym(hGTASA, "_Z16RpLightSetRadiusP7RpLightf")); 437 | SET_TO(RwFrameCreate, aml->GetSym(hGTASA, "_Z13RwFrameCreatev")); 438 | SET_TO(_rwObjectHasFrameSetFrame, aml->GetSym(hGTASA, "_Z25_rwObjectHasFrameSetFramePvP7RwFrame")); 439 | SET_TO(RpWorldAddLight, aml->GetSym(hGTASA, "_Z15RpWorldAddLightP7RpWorldP7RpLight")); 440 | SET_TO(RpWorldRemoveLight, aml->GetSym(hGTASA, "_Z18RpWorldRemoveLightP7RpWorldP7RpLight")); 441 | SET_TO(RwFrameDestroy, aml->GetSym(hGTASA, "_Z14RwFrameDestroyP7RwFrame")); 442 | SET_TO(RpLightDestroy, aml->GetSym(hGTASA, "_Z14RpLightDestroyP7RpLight")); 443 | #endif // AML32 444 | // Functions End // 445 | 446 | // Variables Start // 447 | SET_TO(ms_taskSequence, aml->GetSym(hGTASA, "_ZN14CTaskSequences15ms_taskSequenceE")); 448 | SET_TO(pActiveScripts, aml->GetSym(hGTASA, "_ZN11CTheScripts14pActiveScriptsE")); 449 | SET_TO(ms_fTimeStep, aml->GetSym(hGTASA, "_ZN6CTimer12ms_fTimeStepE")); 450 | SET_TO(WorldPlayers, *(void**)(pGTASA + BYBIT(0x6783C8, 0x84E7A8))); // Patched CWorld::Players will work now! 451 | SET_TO(ms_fFOV, aml->GetSym(hGTASA, "_ZN5CDraw7ms_fFOVE")); 452 | SET_TO(game_FPS, aml->GetSym(hGTASA, "_ZN6CTimer8game_FPSE")); 453 | SET_TO(TheCamera, aml->GetSym(hGTASA, "TheCamera")); 454 | SET_TO(RsGlobal, aml->GetSym(hGTASA, "RsGlobal")); 455 | SET_TO(g_surfaceInfos, aml->GetSym(hGTASA, "g_surfaceInfos")); 456 | SET_TO(m_snTimeInMilliseconds, aml->GetSym(hGTASA, "_ZN6CTimer22m_snTimeInMillisecondsE")); 457 | SET_TO(gMobileMenu, aml->GetSym(hGTASA, "gMobileMenu")); 458 | SET_TO(NumberOfSearchLights, aml->GetSym(hGTASA, "_ZN5CHeli20NumberOfSearchLightsE")); 459 | SET_TO(lastDevice, aml->GetSym(hGTASA, "lastDevice")); 460 | SET_TO(m_pWidgets, *(void**)(pGTASA + BYBIT(0x67947C, 0x850910))); // Patched CTouchInterface::m_pWidgets will work now! 461 | SET_TO(bDidWeProcessAnyCinemaCam, aml->GetSym(hGTASA, "bDidWeProcessAnyCinemaCam")); 462 | SET_TO(bRunningCutscene, aml->GetSym(hGTASA, "_ZN12CCutsceneMgr10ms_runningE")); 463 | SET_TO(bProcessingCutscene, aml->GetSym(hGTASA, "_ZN12CCutsceneMgr21ms_cutsceneProcessingE")); 464 | SET_TO(ScriptParams, *(void**)(pGTASA + BYBIT(0x676F7C, 0x84BF38))); // Patched ScriptParams will work now! 465 | SET_TO(m_alphaList, aml->GetSym(hGTASA, "_ZN18CVisibilityPlugins11m_alphaListE")); 466 | SET_TO(CloudsRotation, aml->GetSym(hGTASA, "_ZN7CClouds13CloudRotationE")); 467 | SET_TO(CloudsIndividualRotation, aml->GetSym(hGTASA, "_ZN7CClouds18IndividualRotationE")); 468 | SET_TO(WeatherWind, aml->GetSym(hGTASA, "_ZN8CWeather4WindE")); 469 | SET_TO(pObjectPool, *(void**)(pGTASA + BYBIT(0x676BBC, 0x84B7C0))); 470 | SET_TO(m_pCurrZoneInfo, aml->GetSym(hGTASA, "_ZN9CPopCycle15m_pCurrZoneInfoE")); 471 | SET_TO(m_ZoneFadeTimer, aml->GetSym(hGTASA, "_ZN4CHud15m_ZoneFadeTimerE")); 472 | SET_TO(ms_numAnimBlocks, aml->GetSym(hGTASA, "_ZN12CAnimManager16ms_numAnimBlocksE")); 473 | SET_TO(ms_memoryUsed, aml->GetSym(hGTASA, "_ZN10CStreaming13ms_memoryUsedE")); 474 | SET_TO(ms_memoryAvailable, aml->GetSym(hGTASA, "_ZN10CStreaming18ms_memoryAvailableE")); 475 | SET_TO(fSpriteBrightness, pGTASA + BYBIT(0x966590, 0xBD760C)); 476 | SET_TO(m_fLightsOnGroundBrightness, pGTASA + BYBIT(0x9665A4, 0xBD7620)); 477 | SET_TO(detailTextures, aml->GetSym(hGTASA, "_ZN22TextureDatabaseRuntime14detailTexturesE")); 478 | SET_TO(textureDetail, aml->GetSym(hGTASA, "textureDetail")); 479 | SET_TO(ms_iActiveSequence, aml->GetSym(hGTASA, "_ZN14CTaskSequences18ms_iActiveSequenceE")); 480 | SET_TO(RasterExtOffset, aml->GetSym(hGTASA, "RasterExtOffset")); 481 | SET_TO(m_f3rdPersonCHairMultX, aml->GetSym(hGTASA, "_ZN7CCamera22m_f3rdPersonCHairMultXE")); 482 | SET_TO(m_f3rdPersonCHairMultY, aml->GetSym(hGTASA, "_ZN7CCamera22m_f3rdPersonCHairMultYE")); 483 | SET_TO(ms_fAspectRatio, aml->GetSym(hGTASA, "_ZN5CDraw15ms_fAspectRatioE")); 484 | SET_TO(ms_fTimeScale, aml->GetSym(hGTASA, "_ZN6CTimer13ms_fTimeScaleE")); 485 | SET_TO(aWeaponInfo, aml->GetSym(hGTASA, "aWeaponInfo")); 486 | SET_TO(windowSize, aml->GetSym(hGTASA, "windowSize")); 487 | SET_TO(ms_bIsPlayerOnAMission, aml->GetSym(hGTASA, "_ZN10CPedGroups22ms_bIsPlayerOnAMissionE")); 488 | SET_TO(DETAILEDWATERDIST, aml->GetSym(hGTASA, "DETAILEDWATERDIST")); 489 | SET_TO(ms_nNumGang, aml->GetSym(hGTASA, "_ZN11CPopulation11ms_nNumGangE")); 490 | SET_TO(aPolyBunches, aml->GetSym(hGTASA, "_ZN8CShadows12aPolyBunchesE")); 491 | SET_TO(ms_modelInfoPtrs, aml->GetSym(hGTASA, "_ZN10CModelInfo16ms_modelInfoPtrsE")); 492 | SET_TO(ms_currentCol, aml->GetSym(hGTASA, "_ZN17CVehicleModelInfo13ms_currentColE")); 493 | SET_TO(ms_vehicleColourTable, aml->GetSym(hGTASA, "_ZN17CVehicleModelInfo21ms_vehicleColourTableE")); 494 | SET_TO(ms_pRemapTexture, aml->GetSym(hGTASA, "_ZN17CVehicleModelInfo16ms_pRemapTextureE")); 495 | SET_TO(ms_nGameClockDays, aml->GetSym(hGTASA, "_ZN6CClock17ms_nGameClockDaysE")); 496 | SET_TO(ms_nGameClockMonths, aml->GetSym(hGTASA, "_ZN6CClock19ms_nGameClockMonthsE")); 497 | SET_TO(StatTypesInt, aml->GetSym(hGTASA, "_ZN6CStats12StatTypesIntE")); 498 | SET_TO(HudColour, aml->GetSym(hGTASA, "HudColour")); 499 | SET_TO(m_UserPause, aml->GetSym(hGTASA, "_ZN6CTimer11m_UserPauseE")); 500 | SET_TO(m_CodePause, aml->GetSym(hGTASA, "_ZN6CTimer11m_CodePauseE")); 501 | SET_TO(m_aCheatsActive, aml->GetSym(hGTASA, "_ZN6CCheat15m_aCheatsActiveE")); 502 | SET_TO(gIdleCam, aml->GetSym(hGTASA, "gIdleCam")); 503 | SET_TO(m_FrameCounter, aml->GetSym(hGTASA, "_ZN6CTimer14m_FrameCounterE")); 504 | SET_TO(gbCineyCamProcessedOnFrame, aml->GetSym(hGTASA, "gbCineyCamProcessedOnFrame")); 505 | SET_TO(ms_colModelCache, aml->GetSym(hGTASA, "_ZN10CCollision16ms_colModelCacheE")); 506 | SET_TO(_bf_12c, pGTASA + BYBIT(0x9EF9D8 + 0x12C, 0xC8C180 + 0x14C)); 507 | SET_TO(SetVehicleColour, aml->GetSym(hGTASA, "_ZN17CVehicleModelInfo16SetVehicleColourEhhhh")); 508 | SET_TO(gStoredMats, pGTASA + BYBIT(0x99E53C, 0xB8DB50)); 509 | SET_TO(m_vecDirnLightToSun, aml->GetSym(hGTASA, "_ZN10CTimeCycle19m_vecDirnLightToSunE")); 510 | SET_TO(m_VectorToSun, aml->GetSym(hGTASA, "_ZN10CTimeCycle13m_VectorToSunE")); 511 | SET_TO(m_CurrentStoredValue, aml->GetSym(hGTASA, "_ZN10CTimeCycle20m_CurrentStoredValueE")); 512 | SET_TO(fPlayerAimRotRate, aml->GetSym(hGTASA, "fPlayerAimRotRate")); 513 | SET_TO(m_vecCachedPos, aml->GetSym(hGTASA, "_ZN15CTouchInterface14m_vecCachedPosE")); 514 | SET_TO(mod_HandlingManager_off4, (*(uintptr_t*)(pGTASA + BYBIT(0x6777C8, 0x84CFB8))) + 4); // FLA 515 | SET_TO(ms_bTakePhoto, aml->GetSym(hGTASA, "_ZN7CWeapon13ms_bTakePhotoE")); 516 | SET_TO(currArea, aml->GetSym(hGTASA, "_ZN5CGame8currAreaE")); 517 | SET_TO(bGameStarted, pGTASA + BYBIT(0x9599B8, 0xBC2880)); 518 | SET_TO(m_bCCTV, aml->GetSym(hGTASA, "_ZN12CPostEffects7m_bCCTVE")); 519 | SET_TO(m_bFog, aml->GetSym(hGTASA, "_ZN12CPostEffects6m_bFogE")); 520 | SET_TO(m_bDisableAllPostEffect, aml->GetSym(hGTASA, "_ZN12CPostEffects23m_bDisableAllPostEffectE")); 521 | SET_TO(pRasterFrontBuffer, aml->GetSym(hGTASA, "_ZN12CPostEffects18pRasterFrontBufferE")); 522 | SET_TO(Scene, aml->GetSym(hGTASA, "Scene")); 523 | SET_TO(SkipState, aml->GetSym(hGTASA, "_ZN10CGameLogic9SkipStateE")); 524 | SET_TO(SkipTimer, aml->GetSym(hGTASA, "_ZN10CGameLogic9SkipTimerE")); 525 | SET_TO(TheText, aml->GetSym(hGTASA, "TheText")); 526 | SET_TO(SelectedRQTarget, aml->GetSym(hGTASA, "_ZN14RQRenderTarget8selectedE")); 527 | SET_TO(backTarget, aml->GetSym(hGTASA, "backTarget")); 528 | SET_TO(oldTarget, aml->GetSym(hGTASA, "oldTarget")); 529 | SET_TO(HudSprites, aml->GetSym(hGTASA, "_ZN4CHud7SpritesE")); 530 | SET_TO(DrunkRotation, pGTASA + BYBIT(0x952EF0, 0xBBB950)); 531 | // Variables End // 532 | 533 | // We need it for future fixes. 534 | HOOK(Global_TimerUpdate, aml->GetSym(hGTASA, "_ZN6CTimer6UpdateEv")); 535 | 536 | #ifdef AML32 537 | #include "preparations_sa.inl" 538 | #else 539 | #include "preparations_sa64.inl" 540 | #endif 541 | } 542 | 543 | }; // namespace GTA_SA 544 | -------------------------------------------------------------------------------- /j_vc.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #ifdef AML32 6 | #include "AArch64_ModHelper/Thumbv7_ASMHelper.h" 7 | #include "GTAVC_STRUCTS.h" 8 | using namespace ThumbV7; 9 | #else 10 | #include "AArch64_ModHelper/ARMv8_ASMHelper.h" 11 | #include "GTAVC_STRUCTS_112.h" 12 | using namespace ARMv8; 13 | #endif 14 | 15 | extern int androidSdkVer; 16 | extern uintptr_t pGTAVC; 17 | extern void *hGTAVC; 18 | 19 | #define BUNCHTAILS_EX 6144 // More bunchtails because who knows about Project2DFX? 20 | 21 | // Usage of aligned memory chunks: 22 | // 9D1DCC, 9D301C : Clouds rotation patch 23 | 24 | namespace GTA_VC 25 | { 26 | 27 | float fAspectCorrection = 0.0f, fAspectCorrectionDiv = 0.0f; 28 | static constexpr float ar43 = 4.0f / 3.0f; 29 | static constexpr float fMagic = 50.0f / 30.0f; 30 | #define fAspectCorrection (*ms_fAspectRatio - ar43) 31 | #define fAspectCorrectionDiv (*ms_fAspectRatio / ar43) 32 | #define GetTimeStep() (*ms_fTimeStep) 33 | #define GetTimeStepInSeconds() (*ms_fTimeStep / 50.0f) 34 | #define GetTimeStepMagic() (*ms_fTimeStep / fMagic) 35 | 36 | union ScriptVariables 37 | { 38 | int i; 39 | float f; 40 | uint32_t u; 41 | void* p; 42 | }; 43 | 44 | ///////////////////////////////////////////////////////////////////////////// 45 | /////////////////////////////// Vars /////////////////////////////// 46 | ///////////////////////////////////////////////////////////////////////////// 47 | CStaticShadow* aStaticShadows_NEW; 48 | CPolyBunch *aPolyBunches; 49 | 50 | float *ms_fTimeStep, *fHeliRotorSpeed, *ms_fAspectRatio, *ms_fTimeScale, *DrunkRotation; 51 | char *mod_HandlingManager; 52 | int *fpsLimit; // a part of RsGlobal 53 | void *GTouchscreen; 54 | bool *m_PrefsFrameLimiter; 55 | uint32_t *m_snTimeInMilliseconds, *m_FrameCounter; 56 | float *m_fCurrentFarClip, *m_fCurrentFogStart; 57 | bool *m_UserPause, *m_CodePause; 58 | 59 | // CPhysical::ApplyCollision 60 | float *fl1679D4; 61 | // CClouds::Update 62 | float *fl1D4CF0, *fl1D4CF4; 63 | 64 | ///////////////////////////////////////////////////////////////////////////// 65 | /////////////////////////////// Funcs /////////////////////////////// 66 | ///////////////////////////////////////////////////////////////////////////// 67 | int ret0(int a, ...) { return 0; } // Generic 68 | int ret1(int a, ...) { return 1; } // Generic 69 | void crash_this() { __builtin_trap(); } // Used for redirected funcs, to get the function it's called from (virtual funcs are hard!) 70 | inline void* TryLoadAlphaFunc(const char* szlib) 71 | { 72 | void* lib = dlopen(szlib, RTLD_LAZY); 73 | if(!lib) return NULL; 74 | 75 | void* sym = dlsym(lib, "glAlphaFuncQCOM"); 76 | if(!sym) sym = dlsym(lib, "glAlphaFunc"); 77 | return sym; 78 | } 79 | 80 | void (*BrightLightsRender)(); 81 | void (*RsEventHandler)(int, void*); 82 | void (*TouchscreenUpdate)(void*, void*, bool); 83 | float (*GetCurrentTimeInCycles)(); 84 | uint32_t (*GetCyclesPerMillisecond)(); 85 | void (*OS_ThreadSleep)(int); 86 | void (*tbDisplay)(); 87 | void (*emu_DistanceFogSetEnabled)(bool); 88 | void (*emu_DistanceFogSetup)(float start, float end, float r, float g, float b); 89 | double (*OS_TimeAccurate)(); 90 | 91 | // Global Hooks (no need to enable patches) 92 | double m_dblTimeInMicroseconds = 0.0f; 93 | double m_dblOldTimeInMicroseconds = 0.0f; 94 | uint32_t m_snOwnTimeInMilliseconds = 0; 95 | 96 | uint32_t m_LogicalFramesPassed = 0, m_LogicalFrameCounter = 0; 97 | DECL_HOOKv(Global_TimerUpdate) 98 | { 99 | Global_TimerUpdate(); 100 | 101 | m_dblOldTimeInMicroseconds = m_dblTimeInMicroseconds; 102 | m_dblTimeInMicroseconds = OS_TimeAccurate(); 103 | 104 | // re3: 105 | static double frameTimeLogical = 0.0, frameTimeFractionScaled = 0.0; 106 | 107 | m_LogicalFramesPassed = 0; 108 | frameTimeLogical += m_dblTimeInMicroseconds; 109 | while (frameTimeLogical >= 1.0 / 30.0) 110 | { 111 | frameTimeLogical -= 1.0 / 30.0; 112 | m_LogicalFramesPassed++; 113 | } 114 | m_LogicalFrameCounter += m_LogicalFramesPassed; 115 | 116 | if(!*m_UserPause && !*m_CodePause) 117 | { 118 | frameTimeFractionScaled += m_dblTimeInMicroseconds * *ms_fTimeScale; 119 | m_snOwnTimeInMilliseconds += (uint32_t)frameTimeFractionScaled; 120 | frameTimeFractionScaled -= (uint32_t)frameTimeFractionScaled; 121 | } 122 | } 123 | 124 | #ifdef AML32 125 | #include "patches_vc.inl" 126 | #else 127 | #include "patches_vc64.inl" 128 | #endif 129 | 130 | void JPatch() 131 | { 132 | cfg->Bind("IdeasFrom", "", "About")->SetString("MTA:SA Team, re3 contributors, ThirteenAG, Peepo"); cfg->ClearLast(); 133 | 134 | // Functions Start // 135 | SET_TO(BrightLightsRender, aml->GetSym(hGTAVC, "_ZN13CBrightLights6RenderEv")); 136 | SET_TO(RsEventHandler, aml->GetSym(hGTAVC, "_Z14RsEventHandler7RsEventPv")); 137 | SET_TO(TouchscreenUpdate, aml->GetSym(hGTAVC, "_ZN11Touchscreen6UpdateEfb")); 138 | SET_TO(GetCurrentTimeInCycles, aml->GetSym(hGTAVC, "_ZN6CTimer22GetCurrentTimeInCyclesEv")); 139 | SET_TO(GetCyclesPerMillisecond, aml->GetSym(hGTAVC, "_ZN6CTimer23GetCyclesPerMillisecondEv")); 140 | SET_TO(OS_ThreadSleep, aml->GetSym(hGTAVC, "_Z14OS_ThreadSleepi")); 141 | SET_TO(tbDisplay, aml->GetSym(hGTAVC, "_Z9tbDisplayv")); 142 | SET_TO(emu_DistanceFogSetEnabled, aml->GetSym(hGTAVC, "_Z25emu_DistanceFogSetEnabledh")); 143 | SET_TO(emu_DistanceFogSetup, aml->GetSym(hGTAVC, "_Z20emu_DistanceFogSetupfffff")); 144 | SET_TO(OS_TimeAccurate, aml->GetSym(hGTAVC, "_Z15OS_TimeAccuratev")); 145 | // Functions End // 146 | 147 | // Variables Start // 148 | SET_TO(ms_fTimeStep, aml->GetSym(hGTAVC, "_ZN6CTimer12ms_fTimeStepE")); 149 | SET_TO(mod_HandlingManager, *(char**)(pGTAVC + BYBIT(0x3956B4, 0x578DE8))); 150 | SET_TO(fHeliRotorSpeed, pGTAVC + BYBIT(0x255000, 0x4CAEE0)); UNPROT(fHeliRotorSpeed, sizeof(float)); 151 | SET_TO(ms_fAspectRatio, aml->GetSym(hGTAVC, "_ZN5CDraw15ms_fAspectRatioE")); 152 | SET_TO(ms_fTimeScale, aml->GetSym(hGTAVC, "_ZN6CTimer13ms_fTimeScaleE")); 153 | SET_TO(fpsLimit, pGTAVC + BYBIT(0x714F1C, 0x991C38)); 154 | SET_TO(GTouchscreen, aml->GetSym(hGTAVC, "GTouchscreen")); 155 | SET_TO(m_PrefsFrameLimiter, aml->GetSym(hGTAVC, "_ZN12CMenuManager19m_PrefsFrameLimiterE")); 156 | SET_TO(m_snTimeInMilliseconds, aml->GetSym(hGTAVC, "_ZN6CTimer22m_snTimeInMillisecondsE")); 157 | SET_TO(m_FrameCounter, aml->GetSym(hGTAVC, "_ZN6CTimer14m_FrameCounterE")); 158 | SET_TO(m_fCurrentFarClip, aml->GetSym(hGTAVC, "_ZN10CTimeCycle17m_fCurrentFarClipE")); 159 | SET_TO(m_fCurrentFogStart, aml->GetSym(hGTAVC, "_ZN10CTimeCycle18m_fCurrentFogStartE")); 160 | SET_TO(aPolyBunches, aml->GetSym(hGTAVC, "_ZN8CShadows12aPolyBunchesE")); 161 | SET_TO(m_UserPause, aml->GetSym(hGTAVC, "_ZN6CTimer11m_UserPauseE")); 162 | SET_TO(m_CodePause, aml->GetSym(hGTAVC, "_ZN6CTimer11m_CodePauseE")); 163 | SET_TO(fl1679D4, pGTAVC + BYBIT(0x1679D4, 0x0)); UNPROT(fl1679D4, sizeof(float)); 164 | SET_TO(fl1D4CF0, pGTAVC + BYBIT(0x1D4CF0, 0x9D1DCC)); UNPROT(fl1D4CF0, sizeof(float)); 165 | SET_TO(fl1D4CF4, pGTAVC + BYBIT(0x1D4CF4, 0x9D301C)); UNPROT(fl1D4CF4, sizeof(float)); 166 | SET_TO(DrunkRotation, pGTAVC + BYBIT(0x595378, 0x7873D8)); 167 | // Variables End // 168 | 169 | // We need it for future fixes. 170 | HOOK(Global_TimerUpdate, aml->GetSym(hGTAVC, "_ZN6CTimer6UpdateEv")); 171 | 172 | #ifdef AML32 173 | #include "preparations_vc.inl" 174 | #else 175 | #include "preparations_vc64.inl" 176 | #endif 177 | } 178 | 179 | }; // namespace GTA_VC -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | #if !defined(IAML_VER) && IAML_VER < 1020100 8 | #error "You need to update your MOD folder to 1.2.1!" 9 | #endif 10 | 11 | MYMODCFG(net.rusjj.jpatch, JPatch, 1.8.1, RusJJ) 12 | BEGIN_DEPLIST() 13 | ADD_DEPENDENCY_VER(net.rusjj.aml, 1.2.1) 14 | END_DEPLIST() 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | /////////////////////////////// Saves /////////////////////////////// 18 | ///////////////////////////////////////////////////////////////////////////// 19 | int androidSdkVer = 0; 20 | uintptr_t pGTASA, pGTAVC, pSC; 21 | void *hGTASA, *hGTAVC, *hSC; 22 | 23 | ///////////////////////////////////////////////////////////////////////////// 24 | /////////////////////////////// Funcs /////////////////////////////// 25 | ///////////////////////////////////////////////////////////////////////////// 26 | namespace GTA_SA { void JPatch(); }; 27 | namespace GTA_VC { void JPatch(); }; 28 | 29 | /*extern "C" const char* OnUpdaterURLRequested() 30 | { 31 | return "https://raw.githubusercontent.com/AndroidModLoader/JPatch/main/updater.txt"; 32 | }*/ 33 | extern "C" void OnModLoad() 34 | { 35 | logger->SetTag("JPatch"); 36 | 37 | cfg->Bind("Author", "", "About")->SetString("[-=KILL MAN=-]"); cfg->ClearLast(); 38 | cfg->Bind("Discord", "", "About")->SetString("https://discord.gg/2MY7W39kBg"); cfg->ClearLast(); 39 | cfg->Bind("GitHub", "", "About")->SetString("https://github.com/AndroidModLoader/JPatch"); cfg->ClearLast(); 40 | 41 | pGTASA = aml->GetLib("libGTASA.so"); 42 | hGTASA = aml->GetLibHandle("libGTASA.so"); 43 | 44 | pGTAVC = aml->GetLib("libGTAVC.so"); 45 | hGTAVC = aml->GetLibHandle("libGTAVC.so"); 46 | 47 | pSC = aml->GetLib("libSCAnd.so"); 48 | hSC = aml->GetLibHandle("libSCAnd.so"); 49 | 50 | char sdk_ver_str[92]; // PROPERTY_VALUE_MAX 51 | if(__system_property_get("ro.build.version.sdk", sdk_ver_str)) 52 | { 53 | androidSdkVer = atoi(sdk_ver_str); 54 | } 55 | 56 | if(pGTASA) GTA_SA::JPatch(); 57 | else if(pGTAVC) GTA_VC::JPatch(); 58 | 59 | cfg->Save(); 60 | } 61 | -------------------------------------------------------------------------------- /patches/patches_sa64.inl: -------------------------------------------------------------------------------- 1 | bool bDynStreamingMem; 2 | float fDynamicStreamingMemPercentage; 3 | DECL_HOOKv(GameProcess) 4 | { 5 | GameProcess(); 6 | 7 | if(bDynStreamingMem) 8 | { 9 | if(*ms_memoryAvailable < nMaxStreamingMemForDynamic) 10 | { 11 | float memUsedPercent = (float)*ms_memoryUsed / (float)*ms_memoryAvailable; 12 | if(memUsedPercent >= fDynamicStreamingMemPercentage) 13 | { 14 | BumpStreamingMemory(nDynamicStreamingMemBumpStep); 15 | } 16 | } 17 | } 18 | } 19 | 20 | // Limit particles 21 | uintptr_t AddBulletImpactFx_BackTo; 22 | eBulletFxType nLimitWithSparkles = BULLETFX_NOTHING; 23 | DECL_HOOK(eBulletFxType, GetBulletFx_Limited, void* surfInfos, uint32_t surfId) 24 | { 25 | static uint32_t nextHeavyParticleTick = 0; 26 | eBulletFxType nParticlesType = GetBulletFx_Limited(surfInfos, surfId); 27 | if(nParticlesType == BULLETFX_SAND || nParticlesType == BULLETFX_DUST) 28 | { 29 | if(nextHeavyParticleTick < *m_snTimeInMilliseconds) 30 | { 31 | nextHeavyParticleTick = *m_snTimeInMilliseconds + 100; 32 | } 33 | else 34 | { 35 | return nLimitWithSparkles; 36 | } 37 | } 38 | return nParticlesType; 39 | } 40 | 41 | // Madd Dogg's Mansion Basketball glitch 42 | DECL_HOOK(ScriptHandle, GenerateNewPickup_MaddDogg, float x, float y, float z, int16_t modelId, ePickupType pickupType, int ammo, int16_t moneyPerDay, bool isEmpty, const char* msg) 43 | { 44 | if(modelId == 1277 && x == 1263.05f && y == -773.67f && z == 1091.39f) 45 | { 46 | return GenerateNewPickup_MaddDogg(1291.2f, -798.0f, 1089.39f, modelId, pickupType, ammo, moneyPerDay, isEmpty, msg); 47 | } 48 | return GenerateNewPickup_MaddDogg(x, y, z, modelId, pickupType, ammo, moneyPerDay, isEmpty, msg); 49 | } 50 | 51 | // Fix Star bribe which is missing minus sign in X coordinate and spawns inside the building 52 | DECL_HOOK(ScriptHandle, GenerateNewPickup_SFBribe, float x, float y, float z, int16_t modelId, ePickupType pickupType, int ammo, int16_t moneyPerDay, bool isEmpty, const char* msg) 53 | { 54 | if(modelId == 1247 && (int)x == -2120 && (int)y == 96) 55 | { 56 | return GenerateNewPickup_SFBribe(2120.0f, y, z, modelId, pickupType, ammo, moneyPerDay, isEmpty, msg); 57 | } 58 | return GenerateNewPickup_SFBribe(x, y, z, modelId, pickupType, ammo, moneyPerDay, isEmpty, msg); 59 | } 60 | 61 | // Fix a Rifle weapon pickup that is located inside the stadium wall since beta 62 | DECL_HOOK(ScriptHandle, GenerateNewPickup_SFRiflePickup, float x, float y, float z, int16_t modelId, ePickupType pickupType, int ammo, int16_t moneyPerDay, bool isEmpty, const char* msg) 63 | { 64 | if(modelId == 357 && x == -2094.0f && y == -488.0f) 65 | { 66 | return GenerateNewPickup_SFRiflePickup(x, -490.2f, z, modelId, pickupType, ammo, moneyPerDay, isEmpty, msg); 67 | } 68 | return GenerateNewPickup_SFRiflePickup(x, y, z, modelId, pickupType, ammo, moneyPerDay, isEmpty, msg); 69 | } 70 | 71 | // Do not drop-off jetpack in air 72 | DECL_HOOKv(DropJetPackTask, void* task, CPed* ped) 73 | { 74 | if(!ped->m_PedFlags.bIsStanding) return; 75 | DropJetPackTask(task, ped); 76 | } 77 | 78 | // Immediately leave the car 79 | DECL_HOOK(bool, CanPedStepOutCar, CVehicle* self, bool bIgnoreSpeedUpright) 80 | { 81 | float lookupAngle = self->m_matrix->at.z; 82 | if((lookupAngle <= 0.1f && lookupAngle >= -0.1f) || 83 | (self->m_nVehicleType != eVehicleType::VEHICLE_TYPE_BOAT && !bIgnoreSpeedUpright)) 84 | { 85 | if(fabs(self->m_vecMoveSpeed.z) > 0.05f || self->m_vecMoveSpeed.Magnitude2D() >= 0.01f) return false; 86 | } 87 | return true; 88 | } 89 | 90 | // Died penalty 91 | uintptr_t DiedPenalty_BackTo; 92 | extern "C" void DiedPenalty(void) 93 | { 94 | if(WorldPlayers[0].Score > 0) 95 | { 96 | WorldPlayers[0].Score = (WorldPlayers[0].Score - 100) < 0 ? 0 : (WorldPlayers[0].Score - 100); 97 | } 98 | ClearPedWeapons(WorldPlayers[0].pPed); 99 | } 100 | __attribute__((optnone)) __attribute__((naked)) void DiedPenalty_Inject(void) 101 | { 102 | asm("STR X1, [SP, #-16]!"); 103 | asm volatile("BL DiedPenalty"); 104 | asm volatile("MOV X16, %0" :: "r"(DiedPenalty_BackTo)); 105 | asm("LDR X1, [SP], #16\nBR X16"); 106 | } 107 | 108 | // AimingRifleWalkFix 109 | DECL_HOOKv(ControlGunMove, void* self, CVector2D* vec2D) 110 | { 111 | float save = *ms_fTimeStep; *ms_fTimeStep = fMagic; 112 | ControlGunMove(self, vec2D); 113 | *ms_fTimeStep = save; 114 | } 115 | 116 | // Water physics fix 117 | // https://github.com/gta-reversed/gta-reversed-modern/blob/163ddc6ab22181004afd57e017618d9e3953a734/source/game_sa/Tasks/TaskTypes/TaskSimpleSwim.cpp#L440 118 | #define SWIMSPEED_FIX 119 | DECL_HOOKv(ProcessSwimmingResistance, CTaskSimpleSwim* task, CPed* ped) 120 | { 121 | float fSubmergeZ = -1.0f; 122 | CVector vecPedMoveSpeed{}; 123 | 124 | switch (task->m_nSwimState) 125 | { 126 | case SWIM_TREAD: 127 | case SWIM_SPRINT: 128 | case SWIM_SPRINTING: { 129 | float fAnimBlendSum = 0.0f; 130 | float fAnimBlendDifference = 1.0f; 131 | 132 | CAnimBlendAssociation* animSwimBreast = RpAnimBlendClumpGetAssociationU(ped->m_pRwClump, ANIM_ID_SWIM_BREAST); 133 | if (animSwimBreast) { 134 | fAnimBlendSum = 0.4f * animSwimBreast->m_fBlendAmount; 135 | fAnimBlendDifference = 1.0f - animSwimBreast->m_fBlendAmount; 136 | } 137 | 138 | CAnimBlendAssociation* animSwimCrawl = RpAnimBlendClumpGetAssociationU(ped->m_pRwClump, ANIM_ID_SWIM_CRAWL); 139 | if (animSwimCrawl) { 140 | fAnimBlendSum += 0.2f * animSwimCrawl->m_fBlendAmount; 141 | fAnimBlendDifference -= animSwimCrawl->m_fBlendAmount; 142 | } 143 | if (fAnimBlendDifference < 0.0f) { 144 | fAnimBlendDifference = 0.0f; 145 | } 146 | 147 | fSubmergeZ = fAnimBlendDifference * 0.55f + fAnimBlendSum; 148 | 149 | vecPedMoveSpeed = ped->m_vecAnimMovingShiftLocal.x * ped->GetRight(); 150 | vecPedMoveSpeed += ped->m_vecAnimMovingShiftLocal.y * ped->GetForward(); 151 | break; 152 | } 153 | case SWIM_DIVE_UNDERWATER: { 154 | vecPedMoveSpeed = ped->m_vecAnimMovingShiftLocal.x * ped->GetRight(); 155 | vecPedMoveSpeed += ped->m_vecAnimMovingShiftLocal.y * ped->GetForward(); 156 | 157 | auto animSwimDiveUnder = RpAnimBlendClumpGetAssociationU(ped->m_pRwClump, ANIM_ID_SWIM_DIVE_UNDER); 158 | if (animSwimDiveUnder) { 159 | vecPedMoveSpeed.z = animSwimDiveUnder->m_fCurrentTime / animSwimDiveUnder->m_pAnimBlendHierarchy->m_fTotalTime * 160 | #ifndef SWIMSPEED_FIX 161 | -0.1f; 162 | #else 163 | (-0.1f * GetTimeStepMagic()); 164 | #endif 165 | } 166 | break; 167 | } 168 | case SWIM_UNDERWATER_SPRINTING: { 169 | vecPedMoveSpeed = ped->m_vecAnimMovingShiftLocal.x * ped->GetRight(); 170 | vecPedMoveSpeed += cosf(task->m_fRotationX) * ped->m_vecAnimMovingShiftLocal.y * ped->GetForward(); 171 | vecPedMoveSpeed.z += (sinf(task->m_fRotationX) * ped->m_vecAnimMovingShiftLocal.y + 0.01f) 172 | #ifdef SWIMSPEED_FIX 173 | / GetTimeStepMagic() 174 | #endif 175 | ; 176 | break; 177 | } 178 | case SWIM_BACK_TO_SURFACE: { 179 | auto animClimb = RpAnimBlendClumpGetAssociationU(ped->m_pRwClump, ANIM_ID_CLIMB_JUMP); 180 | if (!animClimb) 181 | animClimb = RpAnimBlendClumpGetAssociationU(ped->m_pRwClump, ANIM_ID_SWIM_JUMPOUT); 182 | 183 | if (animClimb) { 184 | if (animClimb->m_pAnimBlendHierarchy->m_fTotalTime > animClimb->m_fCurrentTime && 185 | (animClimb->m_fBlendAmount >= 1.0f || animClimb->m_fBlendDelta > 0.0f) 186 | ) { 187 | float fMoveForceZ = GetTimeStep() * ped->m_fMass * 0.3f * 0.008f; 188 | ApplyMoveForce(ped, 0.0f, 0.0f, fMoveForceZ); 189 | } 190 | } 191 | return; 192 | } 193 | default: { 194 | return; 195 | } 196 | } 197 | 198 | float fTheTimeStep = powf(0.9f, GetTimeStep()); 199 | vecPedMoveSpeed *= (1.0f - fTheTimeStep) 200 | #ifdef SWIMSPEED_FIX 201 | * GetTimeStepInvMagic() 202 | #endif 203 | ; 204 | ped->m_vecMoveSpeed *= fTheTimeStep; 205 | #ifdef SWIMSPEED_FIX 206 | if(ped->IsPlayer()) vecPedMoveSpeed *= 1.25f; 207 | #endif 208 | ped->m_vecMoveSpeed += vecPedMoveSpeed; 209 | 210 | auto& pedPos = ped->GetPosition(); 211 | bool bUpdateRotationX = true; 212 | CVector vecCheckWaterLevelPos = GetTimeStep() * ped->m_vecMoveSpeed + pedPos; 213 | float fWaterLevel = 0.0f; 214 | if (!GetWaterLevel(vecCheckWaterLevelPos, fWaterLevel, true, NULL)) { 215 | fSubmergeZ = -1.0f; 216 | bUpdateRotationX = false; 217 | } else { 218 | if (task->m_nSwimState != SWIM_UNDERWATER_SPRINTING || task->m_fStateChanger < 0.0f) { 219 | bUpdateRotationX = false; 220 | } else { 221 | if (pedPos.z + 0.65f > fWaterLevel && task->m_fRotationX > 0.7854f) { 222 | task->m_nSwimState = SWIM_TREAD; 223 | task->m_fStateChanger = 0.0f; 224 | bUpdateRotationX = false; 225 | } 226 | } 227 | } 228 | 229 | if (bUpdateRotationX) { 230 | if (task->m_fRotationX >= 0.0f) { 231 | if (pedPos.z + 0.65f <= fWaterLevel) { 232 | if (task->m_fStateChanger <= 0.001f) 233 | task->m_fStateChanger = 0.0f; 234 | else 235 | task->m_fStateChanger *= 0.95f; 236 | } else { 237 | float fMinimumSpeed = 0.05f * 0.5f; 238 | if (task->m_fStateChanger > fMinimumSpeed) { 239 | task->m_fStateChanger *= 0.95f; 240 | } 241 | if (task->m_fStateChanger < fMinimumSpeed) { 242 | task->m_fStateChanger += GetTimeStepInSeconds() / 10.0f; 243 | task->m_fStateChanger = std::min(fMinimumSpeed, task->m_fStateChanger); 244 | } 245 | task->m_fRotationX += GetTimeStep() * task->m_fStateChanger; 246 | fSubmergeZ = (0.55f - 0.2f) * (task->m_fRotationX * 4.0f / PI) * 0.75f + 0.2f; 247 | } 248 | } else { 249 | if (pedPos.z - sin(task->m_fRotationX) + 0.65f <= fWaterLevel) { 250 | if (task->m_fStateChanger > 0.001f) 251 | task->m_fStateChanger *= 0.95f; 252 | else 253 | task->m_fStateChanger = 0.0f; 254 | } else { 255 | task->m_fStateChanger += GetTimeStepInSeconds() / 10.0f; 256 | task->m_fStateChanger = std::min(task->m_fStateChanger, 0.05f); 257 | } 258 | task->m_fRotationX += GetTimeStep() * task->m_fStateChanger; 259 | } 260 | } 261 | 262 | if (fSubmergeZ > 0.0f) { 263 | fWaterLevel -= fSubmergeZ + pedPos.z; 264 | float fTimeStepMoveSpeedZ = fWaterLevel / GetTimeStep(); 265 | float fTimeStep = GetTimeStep() * 0.1f; 266 | fTimeStepMoveSpeedZ = std::clamp(fTimeStepMoveSpeedZ, -fTimeStep, fTimeStep); 267 | fTimeStepMoveSpeedZ -= ped->m_vecMoveSpeed.z; 268 | fTimeStep = GetTimeStepInSeconds(); 269 | fTimeStepMoveSpeedZ = std::clamp(fTimeStepMoveSpeedZ, -fTimeStep, fTimeStep); 270 | ped->m_vecMoveSpeed.z += fTimeStepMoveSpeedZ; 271 | } 272 | 273 | if (pedPos.z < -69.0f) { 274 | pedPos.z = -69.0f; 275 | ped->m_vecMoveSpeed.z = std::max(ped->m_vecMoveSpeed.z, 0.0f); 276 | } 277 | } 278 | float *buoyancyTimescaleReplacement; 279 | DECL_HOOKb(ProcessPedBuoyancy, void *self, CPed *pPed, float fBouyConst, CVector *pCentreOfBuoyancy, CVector *pBuoyancyForce) 280 | { 281 | if (pPed->IsPlayer()) 282 | { 283 | *buoyancyTimescaleReplacement = (1.0f + (GetTimeStepMagic() / 1.5f)) * GetTimeStepMagic(); 284 | } 285 | else 286 | { 287 | *buoyancyTimescaleReplacement = *ms_fTimeStep; 288 | } 289 | bool ret = ProcessPedBuoyancy(self, pPed, fBouyConst, pCentreOfBuoyancy, pBuoyancyForce); 290 | *buoyancyTimescaleReplacement = *ms_fTimeStep; 291 | return ret; 292 | } 293 | 294 | // Fixing a crosshair by very stupid math 295 | float fWideScreenWidthScale, fWideScreenHeightScale; 296 | DECL_HOOKv(DrawCrosshair) 297 | { 298 | static constexpr float XSVal = 1024.0f / 1920.0f; // prev. 0.530, now it's 0.533333..3 299 | static constexpr float YSVal = 768.0f / 1920.0f; // unchanged :p 300 | 301 | CPlayerPed* player = WorldPlayers[0].pPed; 302 | if(player->m_WeaponSlots[player->m_nCurrentWeapon].m_eWeaponType == WEAPON_COUNTRYRIFLE) 303 | { 304 | // Weirdo logic but ok 305 | float save1 = *m_f3rdPersonCHairMultX; *m_f3rdPersonCHairMultX = 0.530f - 0.84f * ar43 * 0.01115f; // 0.01125f; 306 | float save2 = *m_f3rdPersonCHairMultY; *m_f3rdPersonCHairMultY = 0.400f + 0.84f * ar43 * 0.038f; // 0.03600f; 307 | DrawCrosshair(); 308 | *m_f3rdPersonCHairMultX = save1; *m_f3rdPersonCHairMultY = save2; 309 | return; 310 | } 311 | 312 | float save1 = *m_f3rdPersonCHairMultX; *m_f3rdPersonCHairMultX = 0.530f - fAspectCorrection * 0.01115f; // 0.01125f; 313 | float save2 = *m_f3rdPersonCHairMultY; *m_f3rdPersonCHairMultY = 0.400f + fAspectCorrection * 0.038f; // 0.03600f; 314 | DrawCrosshair(); 315 | *m_f3rdPersonCHairMultX = save1; *m_f3rdPersonCHairMultY = save2; 316 | } 317 | 318 | // Enter-Vehicle tasks 319 | inline bool IsEnterVehicleTask(eTaskType type) 320 | { 321 | switch(type) 322 | { 323 | case TASK_COMPLEX_ENTER_CAR_AS_PASSENGER: 324 | case TASK_COMPLEX_ENTER_CAR_AS_DRIVER: 325 | case TASK_COMPLEX_ENTER_CAR_AS_PASSENGER_TIMED: 326 | case TASK_COMPLEX_ENTER_CAR_AS_DRIVER_TIMED: 327 | case TASK_COMPLEX_ENTER_BOAT_AS_DRIVER: 328 | case TASK_COMPLEX_ENTER_ANY_CAR_AS_DRIVER: 329 | case TASK_COMPLEX_ENTER_CAR_AS_PASSENGER_WAIT: 330 | case TASK_COMPLEX_ENTER_LEADER_CAR_AS_PASSENGER: 331 | case TASK_GROUP_ENTER_CAR: 332 | case TASK_GROUP_ENTER_CAR_AND_PERFORM_SEQUENCE: 333 | case TASK_SIMPLE_CAR_GET_IN: 334 | case TASK_COMPLEX_SWIM_AND_CLIMB_OUT: 335 | return true; 336 | 337 | default: return false; 338 | } 339 | } 340 | inline bool IsExitVehicleTask(eTaskType type) 341 | { 342 | switch(type) 343 | { 344 | case TASK_COMPLEX_LEAVE_CAR: 345 | case TASK_COMPLEX_LEAVE_CAR_AND_DIE: 346 | case TASK_COMPLEX_LEAVE_CAR_AND_FLEE: 347 | case TASK_COMPLEX_LEAVE_CAR_AND_WANDER: 348 | case TASK_COMPLEX_LEAVE_ANY_CAR: 349 | case TASK_COMPLEX_LEAVE_BOAT: 350 | case TASK_COMPLEX_LEAVE_CAR_AS_PASSENGER_WAIT: 351 | return true; 352 | 353 | default: return false; 354 | } 355 | } 356 | DECL_HOOKb(Patch_ExitVehicleJustDown, void* pad, bool bCheckTouch, CVehicle *pVehicle, bool bEntering, CVector *vecVehicle) 357 | { 358 | if(Patch_ExitVehicleJustDown(pad, bCheckTouch, pVehicle, bEntering, vecVehicle)) 359 | { 360 | CPlayerPed* player = FindPlayerPed(-1); 361 | if(!player) return false; 362 | 363 | CTask* task = GetActiveTask(&player->m_pPedIntelligence->m_taskManager); 364 | if(!task) return true; 365 | 366 | eTaskType type = task->GetTaskType(); 367 | /*return type != TASK_SIMPLE_JETPACK && type != TASK_SIMPLE_GANG_DRIVEBY && type != TASK_COMPLEX_EVASIVE_DIVE_AND_GET_UP && 368 | type != TASK_SIMPLE_NAMED_ANIM && task->MakeAbortable(player, ABORT_PRIORITY_URGENT, NULL);*/ 369 | if(type == TASK_COMPLEX_IN_WATER) return true; 370 | return !IsEnterVehicleTask(type) && !IsExitVehicleTask(type) && (type < TASK_COMPLEX_GO_TO_CAR_DOOR_AND_STAND_STILL || type > TASK_SIMPLE_CAR_FALL_OUT) && task->MakeAbortable(player, ABORT_PRIORITY_URGENT, NULL); 371 | } 372 | return false; 373 | } 374 | 375 | // Fixes farclip glitch with wall (wardumb be like) 376 | DECL_HOOKv(DistanceFogSetup_FogWall, float minDistance, float maxDistance, float red, float green, float blue) 377 | { 378 | DistanceFogSetup_FogWall(0.8f * minDistance, 0.95f * maxDistance, red, green, blue); 379 | } 380 | 381 | // Wrong vehicle's parts colors! 382 | DECL_HOOKv(ObjectRender_VehicleParts, CObject* self) 383 | { 384 | ObjectRender_VehicleParts(self); 385 | if(self->m_nParentModelIndex != -1 && self->objectFlags.bChangesVehColor && self->ObjectCreatedBy == eObjectType::OBJECT_TEMPORARY) 386 | { 387 | if(self->m_pRwAtomic && self->m_pRwAtomic->object.object.type == 1) 388 | { 389 | auto ptr = gStoredMats; 390 | while(ptr->material != NULL) 391 | { 392 | ptr->material->texture = ptr->texture; 393 | ++ptr; 394 | } 395 | gStoredMats->material = NULL; 396 | } 397 | } 398 | } 399 | 400 | // Stunt smoke 401 | DECL_HOOKb(Plane_ProcessControl_Horn, int a1) 402 | { 403 | return WidgetIsTouched(7, NULL, 2); 404 | } 405 | 406 | // Falling Star 407 | DECL_HOOKv(RenderState_Star, int a1, int a2) 408 | { 409 | RenderState_Star(a1, a2); 410 | RenderState_Star(1, 0); 411 | } 412 | 413 | // Jetpack hover 414 | DECL_HOOKb(Jetpack_IsHeldDown, int id, int enableWidget) 415 | { 416 | static bool holdTheButton = false; 417 | if(Touch_IsDoubleTapped(WIDGET_NITRO, true, 1)) 418 | { 419 | memset(m_pWidgets[WIDGET_NITRO]->tapTimes, 0, sizeof(float)*10); // CWidget::ClearTapHistory in a better way 420 | holdTheButton = !holdTheButton; 421 | return holdTheButton; 422 | } 423 | return WidgetIsTouched(WIDGET_NITRO, NULL, 1) ^ holdTheButton; 424 | } 425 | 426 | // Fixing a wrong value in carcols.dat 427 | DECL_HOOK(int, CarColsDatLoad_sscanf, const char* str, const char* fmt, int *v1, int *v2, int *v3) 428 | { 429 | if(CarColsDatLoad_sscanf(str, fmt, v1, v2, v3) != 3) 430 | { 431 | return CarColsDatLoad_sscanf(str, "%d.%d %d", v1, v2, v3); 432 | } 433 | return 3; 434 | } 435 | 436 | // Fix planes generation coordinates 437 | DECL_HOOKb(FindPlaneCoors_CheckCol, int X, int Y, CColBox* box, CColSphere* sphere, CColSphere* A, CColSphere* B) 438 | { 439 | return FindPlaneCoors_CheckCol(GetSectorForCoord(X), GetSectorForCoord(Y), box, sphere, A, B); 440 | } 441 | 442 | // Now CJ is able to exit a vehicle and start moving immediately, without being forced to close the door 443 | DECL_HOOKb(DoorClosing_PadTarget, void* pad) 444 | { 445 | return DoorClosing_PadTarget(pad) || GetPedWalkLR(pad) != 0x00 || GetPedWalkUD(pad) != 0x00; 446 | } 447 | 448 | // Peepo: Fix traffic lights 449 | DECL_HOOKv(TrFix_RenderEffects) 450 | { 451 | TrFix_RenderEffects(); 452 | BrightLightsRender(); 453 | } 454 | DECL_HOOKv(TrFix_InitGame2nd, const char* a1) 455 | { 456 | TrFix_InitGame2nd(a1); 457 | BrightLightsInit(); 458 | } 459 | 460 | // Money have 8 digits now? Exciting! 461 | DECL_HOOKi(DrawMoney_sprintf, char* buf, const char* fmt, int arg1) 462 | { 463 | static const char* positiveT = "$%08d"; 464 | static const char* negativeT = "-$%07d"; 465 | 466 | const char* newFmt = (arg1 >= 0) ? positiveT : negativeT; 467 | return DrawMoney_sprintf(buf, newFmt, arg1); 468 | } 469 | 470 | // ClimbDie 471 | DECL_HOOK(bool, ClimbProcessPed, CTask* self, CPed* target) 472 | { 473 | float save = *ms_fTimeStep; *ms_fTimeStep = fMagic; 474 | bool ret = ClimbProcessPed(self, target); 475 | *ms_fTimeStep = save; 476 | return ret; 477 | } 478 | 479 | // Colorpicker 480 | DECL_HOOK(float, GetColorPickerValue, CWidgetRegionColorPicker* self) 481 | { 482 | static float prevVal = 0.0f; 483 | if(self->IsTouched(NULL) != false) // IsTouched 484 | { 485 | CVector2D v = m_vecCachedPos[self->cachedPosNum]; 486 | 487 | float left = self->screenRect.left * 0.7f; 488 | float right = self->screenRect.right * 0.7f; 489 | 490 | float bottom = self->screenRect.bottom * 0.8f; 491 | float top = self->screenRect.top * 0.8f; 492 | 493 | if(v.x < left || v.x > right || v.y < top || v.y > bottom) return prevVal; 494 | 495 | float ret = (int)( 496 | 8.0f * ((v.x - left) / (right - left)) + 8 * (int)( 497 | 8.0f * ((v.y - top) / (bottom - top))) ); 498 | prevVal = ret; 499 | 500 | return ret; 501 | } 502 | return 0.0f; 503 | } 504 | 505 | // Fixes emergency vehicles 506 | uintptr_t EmergencyVeh_BackTo; 507 | __attribute__((optnone)) __attribute__((naked)) void EmergencyVeh_Inject(void) 508 | { 509 | asm volatile( 510 | "fmov s0, %w0\n" 511 | :: "r" (fEmergencyVehiclesFix)); 512 | asm volatile( 513 | "mov x8, %0\n" 514 | "br x8\n" 515 | :: "r" (EmergencyVeh_BackTo)); 516 | } 517 | DECL_HOOKv(SetFOV_Emergency, float factor, bool unused) 518 | { 519 | // Someone is using broken mods 520 | // So here is the workaround + a little value clamping 521 | if(factor < 1.0f) 522 | { 523 | fEmergencyVehiclesFix = 70.0f / 1.0f; 524 | } 525 | else if(factor > 170.0f) 526 | { 527 | fEmergencyVehiclesFix = 70.0f / 170.0f; 528 | } 529 | else 530 | { 531 | fEmergencyVehiclesFix = 70.0f / factor; 532 | } 533 | SetFOV_Emergency(factor, unused); 534 | } 535 | 536 | // PS2 coronas 537 | DECL_HOOKv(RenderOneXLUSprite_Rotate_Aspect_PS2, CVector pos, CVector2D size, uint8_t r, uint8_t g, uint8_t b, int16_t intensity, float rz, float rotation, uint8_t alpha) 538 | { 539 | RenderOneXLUSprite_Rotate_Aspect_PS2(pos, size, r, g, b, intensity, rz * 0.05f, rz, alpha); 540 | } 541 | 542 | // SilentPatch`s fix 543 | DECL_HOOKv(SetLightsWithTimeOfDayColour_DirLight) 544 | { 545 | *m_vecDirnLightToSun = m_VectorToSun[*m_CurrentStoredValue]; 546 | SetLightsWithTimeOfDayColour_DirLight(); 547 | } 548 | 549 | // FX particles distance multiplier! 550 | float fxMultiplier; 551 | DECL_HOOKv(LoadFX_sscanf, char* buf, char* fmt, char* randomAssBuffer, float* readVal) 552 | { 553 | LoadFX_sscanf(buf, fmt, randomAssBuffer, readVal); 554 | *readVal *= fxMultiplier; 555 | } 556 | 557 | // Spread fix 558 | DECL_HOOK(bool, FireInstantHit, CWeapon *self, CEntity *a2, CVector *a3, CVector *a4, CEntity *a5, CVector *a6, CVector *a7, int a8, int a9) 559 | { 560 | *fPlayerAimRotRate = (rand() * 2.0f * M_PI) / (float)RAND_MAX; 561 | return FireInstantHit(self, a2, a3, a4, a5, a6, a7, a8, a9); 562 | } 563 | 564 | // SunGlare 565 | DECL_HOOKv(RenderVehicle_SunGlare, CVehicle* self) 566 | { 567 | RenderVehicle_SunGlare(self); 568 | DoSunGlare(self); 569 | } 570 | 571 | // Interior radar 572 | DECL_HOOKv(DrawRadar, void* self) 573 | { 574 | if(*currArea == 0 || IsOnAMission()) 575 | { 576 | DrawRadar(self); 577 | } 578 | } 579 | 580 | // Green-ish detail texture 581 | #define GREEN_TEXTURE_ID 14 582 | inline void* GetDetailTexturePtr(int texId) 583 | { 584 | return *(void**)((uintptr_t)(&(detailTextures->data[texId - 1]->raster->parent)) + *RasterExtOffset); 585 | } 586 | DECL_HOOKv(emu_TextureSetDetailTexture, RwTexture* texture, unsigned int tilingScale) 587 | { 588 | if(texture == NULL) 589 | { 590 | emu_TextureSetDetailTexture(NULL, 0); 591 | return; 592 | } 593 | if(texture == GetDetailTexturePtr(GREEN_TEXTURE_ID)) 594 | { 595 | *textureDetail = 0; 596 | emu_TextureSetDetailTexture(NULL, 0); 597 | return; 598 | } 599 | emu_TextureSetDetailTexture(texture, tilingScale); 600 | *textureDetail = 1; 601 | } 602 | 603 | // Random license plates 604 | DECL_HOOK(char*, GetCustomCarPlateText_SetModelIdx, CVehicleModelInfo* mi) 605 | { 606 | char *text = GetCustomCarPlateText(mi); 607 | if(!text) 608 | { 609 | text = (char*)&mi->m_szPlateText[0]; 610 | GeneratePlateText(text, 8); 611 | text[8] = 0; 612 | } 613 | return text; 614 | } 615 | 616 | // Fix "You have worked out enough for today, come back tomorrow!" 617 | uintptr_t Opcode0835_BackTo; 618 | extern "C" uintptr_t Opcode0835_Patch(CRunningScript* script) 619 | { 620 | char *scriptName = script->ScriptName; 621 | if(!strncasecmp(scriptName, "gymbike", 8) || !strncasecmp(scriptName, "gymbenc", 8) || !strncasecmp(scriptName, "gymtrea", 8) || !strncasecmp(scriptName, "gymdumb", 8)) 622 | { 623 | ScriptParams[0].i = StatTypesInt[14]; // 134 = Days passed in game 624 | ScriptParams[1].i = -1; 625 | } 626 | else 627 | { 628 | ScriptParams[0].i = *ms_nGameClockDays; 629 | ScriptParams[1].i = *ms_nGameClockMonths; 630 | } 631 | return Opcode0835_BackTo; 632 | } 633 | __attribute__((optnone)) __attribute__((naked)) void Opcode0835_Inject(void) 634 | { 635 | asm volatile( 636 | "MOV X0, X19\n" 637 | "BL Opcode0835_Patch\n" 638 | "MOV W1, #2\n" 639 | "BR X0\n"); 640 | } 641 | 642 | // Michelle dating fix 643 | uintptr_t Opcode039E_BackTo; 644 | extern "C" uintptr_t Opcode039E_Patch(CRunningScript* script, CPed* ped) 645 | { 646 | char *scriptName = script->ScriptName; 647 | if(strncasecmp(scriptName, "gfdate", 7) != 0) 648 | { 649 | ped->m_PedFlags.bDontDragMeOutCar = ScriptParams[1].i; 650 | } 651 | return Opcode039E_BackTo; 652 | } 653 | __attribute__((optnone)) __attribute__((naked)) void Opcode039E_Inject(void) 654 | { 655 | asm volatile( 656 | "MOV X0, X19\n" 657 | "MOV X1, X8\n" 658 | "BL Opcode039E_Patch\n" 659 | "BR X0\n"); 660 | } 661 | 662 | // Inverse swimming controls to dive/go up (to match PC version) 663 | eSwimState curSwimState = SWIM_TREAD; 664 | DECL_HOOKv(TaskSwim_ProcessInput, CTaskSimpleSwim *self, CPlayerPed *ped) 665 | { 666 | curSwimState = self->m_nSwimState; 667 | TaskSwim_ProcessInput(self, ped); 668 | } 669 | DECL_HOOK(int, GetPedWalkUpDown_Swimming, void* pad) 670 | { 671 | switch(curSwimState) 672 | { 673 | case SWIM_UNDERWATER_SPRINTING: 674 | case SWIM_DIVE_UNDERWATER: 675 | return -GetPedWalkUpDown_Swimming(pad); 676 | 677 | default: 678 | return GetPedWalkUpDown_Swimming(pad); 679 | } 680 | } 681 | 682 | // ParaLand Anim fix 683 | DECL_HOOKv(PlayerInfoProcess_ParachuteAnim, CPlayerInfo* self, int playerNum) 684 | { 685 | CPed* ped = self->pPed; 686 | if(ped->m_WeaponSlots[ped->m_nCurrentWeapon].m_eWeaponType == eWeaponType::WEAPON_PARACHUTE) 687 | { 688 | auto anim = RpAnimBlendClumpGetAssociation(ped->m_pRwClump, "FALL_front"); 689 | if(anim != NULL) 690 | { 691 | anim->m_bitsFlag |= ANIMATION_FREEZE_LAST_FRAME; 692 | anim->m_fBlendDelta = -1000.0f; 693 | 694 | CTask* task = TaskConstructor(); 695 | TaskStartNamedAnim(task, "PARA_Land", "PARACHUTE", ANIMATION_UNLOCK_LAST_FRAME | ANIMATION_PARTIAL | ANIMATION_TRANSLATE_Y | ANIMATION_TRANSLATE_X, 10.0f, -1, true, *ms_iActiveSequence > -1, false, false); 696 | SetTask(&ped->m_pPedIntelligence->m_taskManager, task, TASK_PRIMARY_PRIMARY, false); 697 | } 698 | } 699 | PlayerInfoProcess_ParachuteAnim(self, playerNum); 700 | } 701 | 702 | // Unused detonator animation is in the ped.ifp, lol 703 | DECL_HOOKv(UseDetonator, CEntity* ent) 704 | { 705 | UseDetonator(ent); 706 | 707 | if(ent->m_nType == eEntityType::ENTITY_TYPE_PED) 708 | { 709 | CTask* task = TaskConstructor(); 710 | //TaskStartNamedAnim(task, "BOMBER", "DETONATOR", ANIMATION_UNLOCK_LAST_FRAME | ANIMATION_PARTIAL, 4.0f, -1, true, *ms_iActiveSequence > -1, false, false); 711 | TaskStartNamedAnim(task, "bomber", "ped", ANIMATION_UNLOCK_LAST_FRAME | ANIMATION_PARTIAL, 4.0f, -1, true, *ms_iActiveSequence > -1, false, false); 712 | SetTask(&((CPed*)ent)->m_pPedIntelligence->m_taskManager, task, TASK_PRIMARY_PRIMARY, false); 713 | } 714 | } 715 | 716 | // Taxi lights 717 | DECL_HOOKv(AutomobileRender, CAutomobile* self) 718 | { 719 | AutomobileRender(self); 720 | 721 | if(self->m_nModelIndex == 420 || 722 | self->m_nModelIndex == 438) 723 | { 724 | if(self->vehicleFlags.bEngineOn && 725 | self->m_pDriver && 726 | self->m_nNumPassengers == 0 && 727 | self->m_fHealth > 0) 728 | { 729 | SetTaxiLight(self, true); 730 | } 731 | else 732 | { 733 | SetTaxiLight(self, false); 734 | } 735 | } 736 | } 737 | 738 | // Car Slowdown Fix 739 | DECL_HOOKv(ProcessVehicleWheel, CVehicle* self, CVector& wheelFwd, CVector& wheelRight, CVector& wheelContactSpeed, CVector& wheelContactPoint, 740 | int32_t wheelsOnGround, float thrust, float brake, float adhesion, int8_t wheelId, float* wheelSpeed, void* wheelState, uint16_t wheelStatus) 741 | { 742 | *mod_HandlingManager_off4 = 0.9f * GetTimeStepMagic(); 743 | ProcessVehicleWheel(self, wheelFwd, wheelRight, wheelContactSpeed, wheelContactPoint, wheelsOnGround, thrust, brake, adhesion, wheelId, wheelSpeed, wheelState, wheelStatus); 744 | } 745 | DECL_HOOKv(ProcessBikeWheel, CVehicle* self, CVector& wheelFwd, CVector& wheelRight, CVector& wheelContactSpeed, CVector& wheelContactPoint, int32_t wheelsOnGround, 746 | float thrust, float brake, float adhesion, float sideadhesion, int8_t wheelId, float* wheelSpeed, void* wheelState, int wheelspecial, uint16_t wheelStatus) 747 | { 748 | *mod_HandlingManager_off4 = 0.9f * GetTimeStepMagic(); 749 | ProcessBikeWheel(self, wheelFwd, wheelRight, wheelContactSpeed, wheelContactPoint, wheelsOnGround, thrust, brake, adhesion, sideadhesion, wheelId, wheelSpeed, wheelState, wheelspecial, wheelStatus); 750 | } 751 | 752 | // SkimmerPlaneFix 753 | // Changed the way it works, because ms_fTimeStep cannot be the same at the mod start (it is 0 at the mod start anyway) 754 | // UPD: Changed the way again! 755 | DECL_HOOKv(ApplyBoatWaterResistance, CVehicle* self, tBoatHandlingData *boatHandling, float fImmersionDepth) 756 | { 757 | float fSpeedMult = sq(fImmersionDepth) * self->m_pHandling->fSuspensionForce * self->m_fMass / 1000.0F; 758 | if (self->m_nModelIndex == 460) // MODEL_SKIMMER 759 | { 760 | fSpeedMult *= 30.0F; 761 | } 762 | fSpeedMult *= GetTimeStepMagic(); 763 | 764 | auto fMoveDotProduct = DotProduct(self->m_vecMoveSpeed, self->GetForward()); 765 | fSpeedMult *= sq(fMoveDotProduct) + 0.05F; 766 | fSpeedMult += 1.0F; 767 | fSpeedMult = fabsf(fSpeedMult); 768 | fSpeedMult = 1.0F / fSpeedMult; 769 | 770 | float fUsedTimeStep = GetTimeStep() * 0.5F; 771 | auto vecSpeedMult = (boatHandling->vecMoveResistance * fSpeedMult).Pow(fUsedTimeStep); 772 | 773 | CVector vecMoveSpeedMatrixDotProduct = self->GetMatrix()->InverseTransformVector(self->m_vecMoveSpeed); 774 | self->m_vecMoveSpeed = vecMoveSpeedMatrixDotProduct * vecSpeedMult; 775 | 776 | auto fMassMult = (vecSpeedMult.y - 1.0F) * self->m_vecMoveSpeed.y * self->m_fMass; 777 | CVector vecTransformedMoveSpeed = self->GetMatrix()->TransformVector(self->m_vecMoveSpeed); 778 | self->m_vecMoveSpeed = vecTransformedMoveSpeed; 779 | 780 | auto vecDown = self->GetUp() * -1.0F; 781 | auto vecTurnForce = self->GetForward() * fMassMult; 782 | ApplyTurnForce(self, vecTurnForce, vecDown); 783 | 784 | if (self->m_vecMoveSpeed.z <= 0.0F) 785 | self->m_vecMoveSpeed.z *= ((1.0F - vecSpeedMult.z) * 0.5F + vecSpeedMult.z); 786 | else 787 | self->m_vecMoveSpeed.z *= vecSpeedMult.z; 788 | } 789 | 790 | // Cinematic camera 791 | bool toggledCinematic = false; 792 | DECL_HOOKv(PlayerInfoProcess_Cinematic, CPlayerInfo* info, int playerNum) 793 | { 794 | PlayerInfoProcess_Cinematic(info, playerNum); 795 | 796 | // Do it for the local player only. 797 | if(info == &WorldPlayers[0]) 798 | { 799 | if(!*bRunningCutscene && 800 | info->pRemoteVehicle == NULL && 801 | info->pPed->m_pVehicle != NULL && 802 | info->pPed->m_nPedState == PEDSTATE_DRIVING) 803 | { 804 | if(info->pPed->m_pVehicle->m_nVehicleType != VEHICLE_TYPE_TRAIN && 805 | Touch_IsDoubleTapped(WIDGET_CAM_TOGGLE, true, 1)) 806 | { 807 | toggledCinematic = !TheCamera->m_bForceCinemaCam; 808 | TheCamera->m_bForceCinemaCam = toggledCinematic; 809 | 810 | memset(m_pWidgets[WIDGET_CAM_TOGGLE]->tapTimes, 0, sizeof(float)*10); // CWidget::ClearTapHistory in a better way 811 | } 812 | } 813 | else 814 | { 815 | if(toggledCinematic) 816 | { 817 | TheCamera->m_bForceCinemaCam = false; 818 | *bDidWeProcessAnyCinemaCam = false; 819 | if(!*bRunningCutscene && 820 | TheCamera->pTargetEntity == NULL) 821 | { 822 | RestoreCamera(TheCamera); 823 | SetCameraDirectlyBehindForFollowPed(TheCamera); 824 | } 825 | m_pWidgets[WIDGET_CAM_TOGGLE]->enabled = false; 826 | toggledCinematic = false; 827 | } 828 | } 829 | } 830 | } 831 | 832 | // Para dmg anim fix 833 | DECL_HOOKv(ComputeDamageAnim, uintptr_t self, CPed* victim, bool a2) 834 | { 835 | bool bNeedFix = *(eWeaponType*)(self + 36) == WEAPON_PARACHUTE; 836 | 837 | if(bNeedFix) *(eWeaponType*)(self + 36) = WEAPON_UNARMED; 838 | ComputeDamageAnim(self, victim, a2); 839 | if(bNeedFix) *(eWeaponType*)(self + 36) = WEAPON_PARACHUTE; 840 | } 841 | 842 | // Force DXT 843 | DECL_HOOKv(LoadTexDBThumbs, const char* dbName, int unk, TextureDatabaseFormat format) 844 | { 845 | LoadTexDBThumbs(dbName, unk, (format == DF_Default) ? DF_DXT : format); 846 | } 847 | 848 | // Fix wheels rotation speed on high FPS 849 | DECL_HOOK(float, ProcessWheelRotation_FPS, CVehicle *self, tWheelState WheelState, const CVector *vecForward, const CVector *WheelSpeed, float fRadius) 850 | { 851 | return ProcessWheelRotation_FPS(self, WheelState, vecForward, WheelSpeed, fRadius) * GetTimeStep(); 852 | } 853 | 854 | // Fix FX memory leak 855 | DECL_HOOKv(FxInfoMan_FXLeak, uintptr_t self_x58) 856 | { 857 | RwTexture** texturePtr4 = (RwTexture**)(self_x58 - 0x58 + 0x30); 858 | if(*texturePtr4) 859 | { 860 | RwTextureDestroy(*texturePtr4); 861 | *texturePtr4 = NULL; 862 | } 863 | FxInfoMan_FXLeak(self_x58); 864 | } 865 | 866 | // Bring back light shadows from poles! 867 | float fLightDist = 40.0f; 868 | uintptr_t ProcessLightsForEntity_BackTo; 869 | CEntity* lastEntityEffect; 870 | C2dEffect* lastEffect; 871 | int lastEffectNum; 872 | DECL_HOOK(C2dEffect*, GetBaseEffect_AddLight, CBaseModelInfo* mi, int i) 873 | { 874 | lastEffect = GetBaseEffect_AddLight(mi, i); 875 | lastEffectNum = i; 876 | return lastEffect; 877 | } 878 | DECL_HOOKv(ProcessLightsForEntity_AddLight, UInt8 Type, CVector Coors, CVector Dir, float Range, float Red, float Green, float Blue, UInt8 FogEffect, bool bCastsShadowFromPlayerCarAndPed, CEntity *pArgCastingEntity) 879 | { 880 | ProcessLightsForEntity_AddLight(Type, Coors, Dir, Range, Red, Green, Blue, FogEffect, bCastsShadowFromPlayerCarAndPed, NULL); 881 | if(lastEffect->light.m_fShadowSize != 0) 882 | { 883 | float intensity = ((lastEffect->light.m_nShadowColorMultiplier * 0.125f * *fSpriteBrightness) / 256.0f); 884 | float zDist = lastEffect->light.m_nShadowZDistance ? lastEffect->light.m_nShadowZDistance : 15.0f; 885 | 886 | bool bCurrentlyActive = *(bool*)(&pArgCastingEntity); 887 | if(bCurrentlyActive) 888 | { 889 | StoreStaticShadow((uintptr_t)lastEntityEffect + lastEffectNum, 2, lastEffect->light.m_pShadowTex, &Coors, lastEffect->light.m_fShadowSize, 0.0f, 0.0f, -lastEffect->light.m_fShadowSize, 890 | 128, intensity * lastEffect->light.m_color.red, intensity * lastEffect->light.m_color.green, intensity * lastEffect->light.m_color.blue, zDist, 1.0f, fLightDist, false, 0.0f); 891 | } 892 | else 893 | { 894 | StoreStaticShadow((uintptr_t)lastEntityEffect + lastEffectNum, 2, lastEffect->light.m_pShadowTex, &Coors, lastEffect->light.m_fShadowSize, 0.0f, 0.0f, -lastEffect->light.m_fShadowSize, 895 | 0, 0, 0, 0, zDist, 1.0f, fLightDist, false, 0.0f); 896 | } 897 | } 898 | } 899 | DECL_HOOKv(ProcessLightsForEntity_ItSelf, CEntity* self) 900 | { 901 | lastEntityEffect = self; 902 | ProcessLightsForEntity_ItSelf(self); 903 | } 904 | 905 | // Static shadows 906 | DECL_HOOKv(RenderStaticShadows, bool a1) 907 | { 908 | for(int i = 48; i < 256; ++i) 909 | { 910 | aStaticShadows_NEW[i].m_bRendered = false; 911 | } 912 | RenderStaticShadows(a1); 913 | } 914 | DECL_HOOKv(InitShadows) 915 | { 916 | static CPolyBunch bunchezTail[BUNCHTAILS_EX]; 917 | 918 | InitShadows(); 919 | for(int i = 0; i < BUNCHTAILS_EX-1; ++i) 920 | { 921 | bunchezTail[i].pNext = &bunchezTail[i+1]; 922 | } 923 | bunchezTail[BUNCHTAILS_EX-1].pNext = NULL; 924 | aPolyBunches[360-1].pNext = &bunchezTail[0]; 925 | } 926 | 927 | // Max loading splashes 928 | int mobilescCount = 7; 929 | int DoRand(int max) 930 | { 931 | srand(time(NULL)); 932 | return (int)(((double)rand() / (double)RAND_MAX) * max); 933 | } 934 | DECL_HOOKv(LoadSplash_sscanf, char* buf, const char* fmt, int randArg) 935 | { 936 | LoadSplash_sscanf(buf, fmt, DoRand(mobilescCount)); 937 | } 938 | 939 | // Moving objs (opcode 034E) 940 | DECL_HOOKv(CollectParams_034E, CRunningScript* script, int count) 941 | { 942 | CollectParams_034E(script, count); 943 | 944 | float scale = 30.0f / *game_FPS; 945 | ScriptParams[4].f *= scale; 946 | ScriptParams[5].f *= scale; 947 | ScriptParams[6].f *= scale; 948 | } 949 | 950 | // Fix pushing force 951 | DECL_HOOKv(ApplyForce_Collision, CPhysical *self, CVector vecForce, CVector vecOffset, bool bValidTorque) 952 | { 953 | ApplyForce_Collision(self, vecForce * GetTimeStepMagic(), vecOffset, bValidTorque); 954 | } 955 | 956 | // Marker fix 957 | DECL_HOOKv(PlaceRedMarker_MarkerFix, bool canPlace) 958 | { 959 | if(canPlace) 960 | { 961 | int x, y; 962 | LIB_PointerGetCoordinates(*lastDevice, &x, &y, NULL); 963 | if(y > 0.88f * RsGlobal->maximumHeight && 964 | x > ((float)RsGlobal->maximumWidth - 0.87f * RsGlobal->maximumHeight)) return; 965 | } 966 | PlaceRedMarker_MarkerFix(canPlace); 967 | } 968 | 969 | // Now all vehicles should have a shadow 970 | DECL_HOOKv(TrainPreRender, CVehicle* self) 971 | { 972 | TrainPreRender(self); 973 | StoreShadowForVehicle(self, 6); // 6 = VEHICLE_TYPE_TRAIN 974 | } 975 | DECL_HOOKv(BoatPreRender, CVehicle* self) 976 | { 977 | BoatPreRender(self); 978 | StoreShadowForVehicle(self, 5); // 5 = VEHICLE_TYPE_BOAT 979 | } 980 | 981 | // This fixes black bushes and more things 982 | DECL_HOOKv(VTXShader_CamBasedNormal_snprintf, int a1, int a2, const char* str) 983 | { 984 | VTXShader_CamBasedNormal_snprintf(a1, a2, "Out_LightingColor = clamp(AmbientLightColor * MaterialAmbient.xyz, 0.5, 1.0);"); 985 | } 986 | 987 | // Searchlights are too fast! 988 | DECL_HOOK(float, SearchLight_sqrtf, float a) 989 | { 990 | return SearchLight_sqrtf(a) * GetTimeStepMagic(); 991 | } 992 | 993 | // Missing effects that are on PC but not on Mobile (from SkyGFX) 994 | RQRenderTarget* backupTarget = NULL; 995 | DECL_HOOKv(RenderPostEffects) 996 | { 997 | if(*m_bDisableAllPostEffect) return; 998 | 999 | RenderPostEffects(); 1000 | } 1001 | DECL_HOOKv(PostProcess_CCTV) 1002 | { 1003 | /*RwRenderStateSet(rwRENDERSTATETEXTURERASTER, NULL); 1004 | 1005 | RwCameraEndUpdate(Scene->camera); 1006 | RsCameraBeginUpdate(Scene->camera); 1007 | RsCameraShowRaster(Scene->camera); 1008 | backupTarget = *SelectedRQTarget; 1009 | SelectRQTarget(*backTarget, true); 1010 | 1011 | CVehicle* vehicle = FindPlayerVehicle(-1, false); 1012 | SpeedFX( (vehicle) ? vehicle->m_vecMoveSpeed.Magnitude() : FindPlayerPed(-1)->m_vecMoveSpeed.Magnitude() ); 1013 | 1014 | SelectRQTarget(backupTarget, true);*/ 1015 | 1016 | if(*m_bFog) PostEffectsFog(); 1017 | if(*m_bCCTV) PostProcess_CCTV(); 1018 | } 1019 | DECL_HOOKv(RenderEffects_WaterCannons) 1020 | { 1021 | RenderEffects_WaterCannons(); 1022 | 1023 | RenderWaterFog(); 1024 | RenderMovingFog(); 1025 | RenderVolumetricClouds(); 1026 | } 1027 | DECL_HOOKv(SpeedFX_Raster, int a1, RwRaster* raster) 1028 | { 1029 | /* oopsie */ 1030 | } 1031 | DECL_HOOKv(SpeedFX_RestoreStates) 1032 | { 1033 | RwRenderStateSet(rwRENDERSTATETEXTURERASTER, NULL); 1034 | SpeedFX_RestoreStates(); 1035 | } 1036 | 1037 | // Cant skip drive 1038 | bool *bDisplayedSkipTripMessage; 1039 | bool skiptripChangeTex = true; 1040 | RwTexture* origWidgetBak = NULL; 1041 | inline bool SkipButtonActivated() 1042 | { 1043 | //CPad* pad = GetPad(0); 1044 | CWidget* widget = m_pWidgets[WIDGET_SKIP_CUTSCENE]; 1045 | if(widget) 1046 | { 1047 | if(!origWidgetBak && skiptripChangeTex) 1048 | { 1049 | origWidgetBak = widget->widgetSprite.m_pTexture; 1050 | widget->widgetSprite.m_pTexture = HudSprites[5].m_pTexture; 1051 | } 1052 | bool ret = TouchInterfaceIsReleased(WIDGET_SKIP_CUTSCENE, NULL, 3); 1053 | if(ret && origWidgetBak) 1054 | { 1055 | widget->widgetSprite.m_pTexture = origWidgetBak; 1056 | origWidgetBak = NULL; 1057 | } 1058 | return ret; 1059 | } 1060 | return false; 1061 | } 1062 | inline void DrawTripSkipIcon() 1063 | { 1064 | if(!HudSprites[5].m_pTexture) return; 1065 | 1066 | CRect drawRect; 1067 | 1068 | drawRect.left = RsGlobal->maximumHeight * 0.02f; 1069 | drawRect.bottom = RsGlobal->maximumHeight * 0.95f; 1070 | 1071 | drawRect.right = drawRect.left + RsGlobal->maximumHeight * 0.12f; 1072 | drawRect.top = drawRect.top - RsGlobal->maximumHeight * 0.12f; 1073 | 1074 | DrawSprite2D_Simple(&HudSprites[5], &drawRect, &rgbaWhite); 1075 | } 1076 | DECL_HOOKb(UpdateSkip_SkipCanBeActivated) 1077 | { 1078 | if(UpdateSkip_SkipCanBeActivated() && SkipButtonActivated()) 1079 | { 1080 | CPlayerPed* player = FindPlayerPed(-1); 1081 | CTask* taskLeave = FindActiveTaskByType(&player->m_pPedIntelligence->m_taskManager, TASK_COMPLEX_LEAVE_CAR); 1082 | if(!taskLeave) 1083 | { 1084 | *SkipState = 2; 1085 | GetPad(0)->DisablePlayerControls |= 0x100; 1086 | 1087 | SetFadeColour(TheCamera, 0, 0, 0); 1088 | CameraFade(TheCamera, 2.5f, 0); 1089 | *SkipTimer = *m_snTimeInMilliseconds + 3000; 1090 | 1091 | uint16_t* gxtText = TextGet(TheText, "SKIP"); 1092 | if(gxtText) AddBigMessage(gxtText, 4500, 1); 1093 | } 1094 | return true; 1095 | } 1096 | return false; 1097 | } 1098 | DECL_HOOKb(DrawHud_SkipTrip) 1099 | { 1100 | if(*SkipState == 0 && origWidgetBak) 1101 | { 1102 | CWidget* widget = m_pWidgets[WIDGET_SKIP_CUTSCENE]; 1103 | if(widget) 1104 | { 1105 | widget->widgetSprite.m_pTexture = origWidgetBak; 1106 | origWidgetBak = NULL; 1107 | } 1108 | } 1109 | if(!DrawHud_SkipTrip()) return false; 1110 | 1111 | //DrawTripSkipIcon(); 1112 | if(!*bDisplayedSkipTripMessage) 1113 | { 1114 | uint16_t* skipTripTxt = TextGet(TheText, "SKIP_1"); 1115 | if(skipTripTxt) 1116 | { 1117 | SetHelpMessage("SKIP_1", skipTripTxt, true, false, false, 0); 1118 | } 1119 | } 1120 | return true; 1121 | } 1122 | 1123 | // A particles with "check ground" flag are falling through the world (JuniorDjjr's reversed FxsFuncs) 1124 | bool bCheckMoreObjects = true; 1125 | DECL_HOOKv(FXInfoGroundCollide_GetVal, FxInfoGroundCollide_c *self, float st, float pt, float dt, float len, uint8_t useConst, float *settings) 1126 | { 1127 | static CColPoint colpoint; 1128 | static CEntity* centity; 1129 | 1130 | MovementInfo_t* info = (MovementInfo_t*)settings; 1131 | 1132 | CVector testCoord = info->pos; 1133 | int timeModeParticle = self->m_timeModeParticle; 1134 | float interpValues[16]; 1135 | 1136 | float zEnd = fMagic * GetTimeStep() * settings[5] * 0.02f + testCoord.z; 1137 | if(ProcessVerticalLine(testCoord, zEnd, colpoint, centity, true, bCheckMoreObjects, bCheckMoreObjects, bCheckMoreObjects, false, false, NULL) && testCoord.z >= colpoint.m_vecPoint.z) 1138 | { 1139 | memset(interpValues, 0, sizeof(interpValues)); 1140 | FxInterpInfo32GetVal(&self->m_interpInfo, interpValues, timeModeParticle ? pt : (st / len)); 1141 | CVector vel = info->vel; vel.z *= 0.9f; 1142 | CVector normal = colpoint.m_vecNormal; 1143 | 1144 | float len2Sqr = 2.0f * ( (normal.x * vel.x) + (normal.y * vel.y) + (normal.z * vel.z) ); 1145 | CVector out = vel - len2Sqr * normal; 1146 | 1147 | CVector in((float)(rand() % 10000) / 10000.0f - 0.5f, (float)(rand() % 10000) / 10000.0f - 0.5f, (float)(rand() % 10000) / 10000.0f); 1148 | VectorNormalise(&in); 1149 | in *= interpValues[2] * dt * 5.0f; 1150 | 1151 | int outLen = RwV3dLength(&out); 1152 | out += in; 1153 | VectorNormalise(&out); 1154 | 1155 | info->vel = outLen * interpValues[1] * out; 1156 | info->pos.z = colpoint.m_vecPoint.z; 1157 | 1158 | float maxVelOffset = fMagic * GetTimeStep() * 0.3f; 1159 | if(info->vel.x < maxVelOffset && info->vel.x > -maxVelOffset) info->vel.x = 0.0f; 1160 | if(info->vel.y < maxVelOffset && info->vel.y > -maxVelOffset) info->vel.y = 0.0f; 1161 | } 1162 | } 1163 | 1164 | // Fixes that some data in CollisionData is not being set to zero 1165 | DECL_HOOKv(ColModel_AllocData, CColModel* self, int32 numSpheres, int32 numBoxes, int32 numLines, int32 numVertices, int32 numTriangles, bool bUseDisksNotLines) 1166 | { 1167 | ColModel_AllocData(self, numSpheres, numBoxes, numLines, numVertices, numTriangles, bUseDisksNotLines); 1168 | CCollisionData* data = self->m_pColData; 1169 | if(data) 1170 | { 1171 | data->m_nNoOfShadTriangles = 0; 1172 | data->m_nNoOfShadTriangleVerts = 0; 1173 | data->m_pTriCompressedShadVectorArray = NULL; 1174 | data->m_pShadTriangleArray = NULL; 1175 | data->m_modelSec = NULL; // new on mobile??? 1176 | } 1177 | } 1178 | 1179 | // Fixes a little Rockstar mistake with coronas rendering 1180 | DECL_HOOKv(CoronasRender_Headlight, void* a, void* b) 1181 | { 1182 | FlushSpriteBuffer(); 1183 | CoronasRender_Headlight(a, b); 1184 | } 1185 | 1186 | // Cruising speed (experimental...) 1187 | DECL_HOOKv(CurvePoint_SpeedFPS, const CVector *startCoors, const CVector *endCoors, const CVector *startDir, const CVector *endDir, float Time, Int32 TraverselTimeInMillis, CVector *resultCoor, CVector *resultSpeed) 1188 | { 1189 | CurvePoint_SpeedFPS(startCoors, endCoors, startDir, endDir, Time, TraverselTimeInMillis, resultCoor, resultSpeed); 1190 | *resultSpeed *= GetTimeStepMagic(); 1191 | } 1192 | 1193 | // Fixing drunk camera on high FPS 1194 | DECL_HOOKv(CameraProcess_HighFPS, void* self) 1195 | { 1196 | float DrunkRotationBak = *DrunkRotation; 1197 | CameraProcess_HighFPS(self); 1198 | if(DrunkRotationBak != *DrunkRotation) 1199 | { 1200 | *DrunkRotation = DrunkRotationBak + 5.0f * GetTimeStepMagic(); 1201 | } 1202 | } 1203 | 1204 | 1205 | 1206 | 1207 | 1208 | 1209 | 1210 | 1211 | 1212 | 1213 | 1214 | 1215 | 1216 | 1217 | // Camera is saving screenshots? 1218 | DECL_HOOK(RwImage*, Patch_psGrabScreen, RwCamera* camera) 1219 | { 1220 | if(!camera || !camera->framebuf) return NULL; 1221 | 1222 | RwImage* newImage = RwImageCreate(camera->framebuf->width, camera->framebuf->height, 32); 1223 | if(newImage) 1224 | { 1225 | RwImageAllocatePixels(newImage); 1226 | RwImageSetFromRaster(newImage, camera->framebuf); 1227 | } 1228 | return newImage; 1229 | } 1230 | DECL_HOOKb(TakePhoto, CWeapon* self, CEntity* unused, CVector* cameraPos) 1231 | { 1232 | static uint32_t nextAllowedPic = 0; 1233 | if(nextAllowedPic < *m_snTimeInMilliseconds) 1234 | { 1235 | nextAllowedPic = *m_snTimeInMilliseconds + 200; 1236 | 1237 | TimerStop(); 1238 | SetDirMyDocuments(); 1239 | JPegCompressScreenToFile(TheCamera->m_pRwCamera, "screenshot_test.jpg"); 1240 | FileMgrSetDir(""); 1241 | TimerUpdate(); 1242 | } 1243 | 1244 | return TakePhoto(self, unused, cameraPos); 1245 | } 1246 | DECL_HOOKv(ShowRasterIdle, RwCamera* camera) 1247 | { 1248 | static uint32_t nextAllowedPic = 0; 1249 | if(nextAllowedPic < *m_snTimeInMilliseconds) 1250 | { 1251 | nextAllowedPic = *m_snTimeInMilliseconds + 5000; 1252 | 1253 | TimerStop(); 1254 | SetDirMyDocuments(); 1255 | //JPegCompressScreenToFile(camera, "screenshot_test.jpg"); 1256 | RwGrabScreen(camera, "screenshot_test.bmp"); 1257 | FileMgrSetDir(""); 1258 | TimerUpdate(); 1259 | } 1260 | ShowRasterIdle(camera); 1261 | } 1262 | DECL_HOOKv(jpeg_samplecopy, uint8_t **input_array, int source_row, uint8_t **output_array, int dest_row, int num_rows, uint num_cols) 1263 | { 1264 | jpeg_samplecopy(input_array, source_row, output_array, dest_row, num_rows, num_cols); 1265 | logger->Info("jpeg_samplecopy: dest_row (i) = %d, num_rows (height) = %d, num_cols (width) = %d", dest_row, num_rows, num_cols); 1266 | } -------------------------------------------------------------------------------- /patches/patches_vc.inl: -------------------------------------------------------------------------------- 1 | // Boat and Skimmer on high FPS 2 | uintptr_t Boat_ApplyWaterResistance_BackTo; 3 | extern "C" float Boat_ApplyWaterResistance_Patch(float resistance) 4 | { 5 | return resistance * GetTimeStepMagic(); 6 | } 7 | __attribute__((optnone)) __attribute__((naked)) void Boat_ApplyWaterResistance_Inject(void) 8 | { 9 | asm volatile( 10 | "VMOV R0, S14\n" 11 | "BL Boat_ApplyWaterResistance_Patch\n" 12 | "VMOV S14, R0\n" 13 | "VLDR S13, [R4, #0x18]\n" 14 | "ADD R5, R4, #0x74"); 15 | asm volatile( 16 | "MOV PC, %0" 17 | :: "r" (Boat_ApplyWaterResistance_BackTo)); 18 | } 19 | 20 | // Fix wheels rotation speed on high FPS 21 | extern "C" float ProcessWheelRotation_Patch() 22 | { 23 | return GetTimeStepMagic(); 24 | } 25 | __attribute__((optnone)) __attribute__((naked)) void ProcessWheelRotation_Inject(void) 26 | { 27 | asm volatile( 28 | "PUSH {LR}\n" 29 | "BL ProcessWheelRotation_Patch\n" 30 | "POP {LR}\n" 31 | "VMOV S14, R0\n"); 32 | asm volatile( 33 | "VMUL.F32 S15, S15, S14\n" 34 | "VMOV R0, S15\n" 35 | "BX LR"); 36 | } 37 | 38 | // Car Slowdown Fix 39 | DECL_HOOKv(ProcessWheel_SlowDownFix, void *self, CVector &a1, CVector &a2, CVector &a3, CVector &a4, int a5, float a6, float a7, float a8, char a9, float *a10, void *a11, uint16_t a12) 40 | { 41 | float& fWheelFriction = *(float*)(mod_HandlingManager + 4); 42 | float save = fWheelFriction; fWheelFriction *= 2.0f * GetTimeStepMagic(); 43 | ProcessWheel_SlowDownFix(self, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); 44 | fWheelFriction = save; 45 | } 46 | DECL_HOOKv(ProcessBikeWheel_SlowDownFix, void *self, CVector &a1, CVector &a2, CVector &a3, CVector &a4, int a5, float a6, float a7, float a8, float a9, char a10, float *a11, void *a12, int a13, uint16_t a14) 47 | { 48 | float& fWheelFriction = *(float*)(mod_HandlingManager + 4); 49 | float save = fWheelFriction; fWheelFriction *= 2.0f * GetTimeStepMagic(); 50 | ProcessBikeWheel_SlowDownFix(self, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); 51 | fWheelFriction = save; 52 | } 53 | 54 | // Fix heli rotor rotation speed on high FPS 55 | DECL_HOOKv(HeliRender_MatrixUpdate, void *self) 56 | { 57 | HeliRender_MatrixUpdate(self); 58 | *fHeliRotorSpeed = 0.48307693f * GetTimeStepMagic(); 59 | } 60 | 61 | // Streaming distance fix 62 | float fStreamingDistFix; 63 | uintptr_t CameraProcess_StreamDist_BackTo; 64 | DECL_HOOKv(SetFOV_StreamingDistFix, float factor) 65 | { 66 | // Someone is using broken mods 67 | // So here is the workaround + a little value clamping 68 | if(factor < 5.0f) 69 | { 70 | fStreamingDistFix = 70.0f / 5.0f; 71 | } 72 | else if(factor > 170.0f) 73 | { 74 | fStreamingDistFix = 70.0f / 170.0f; 75 | } 76 | else 77 | { 78 | fStreamingDistFix = 70.0f / factor; 79 | } 80 | 81 | fStreamingDistFix *= (*ms_fAspectRatio / ar43); 82 | 83 | SetFOV_StreamingDistFix(factor); 84 | } 85 | extern "C" void CameraProcess_StreamDist_Patch(int camera) 86 | { 87 | *(float*)(camera + 0xF0) = fStreamingDistFix; 88 | } 89 | __attribute__((optnone)) __attribute__((naked)) void CameraProcess_StreamDist_Inject(void) 90 | { 91 | asm volatile( 92 | "MOV R0, R4\n" 93 | "BL CameraProcess_StreamDist_Patch\n"); 94 | asm volatile( 95 | "MOV PC, %0" 96 | :: "r" (CameraProcess_StreamDist_BackTo)); 97 | } 98 | 99 | // fat-ass coronas! 100 | DECL_HOOKb(CoronaSprite_CalcScreenCoors, CVector *worldPos, CVector *screenPos, float *scalex, float *scaley, bool a) 101 | { 102 | bool ret = CoronaSprite_CalcScreenCoors(worldPos, screenPos, scalex, scaley, a); 103 | *scalex /= *ms_fAspectRatio; 104 | return ret; 105 | } 106 | 107 | // Vertex weight fix 108 | uintptr_t VertexWeightFix_BackTo1, VertexWeightFix_BackTo2; 109 | extern "C" uintptr_t VertexWeightFix_Patch(RpSkin *skin) 110 | { 111 | return (skin->vertexMaps.maxWeights == 4) ? VertexWeightFix_BackTo2 : VertexWeightFix_BackTo1; 112 | } 113 | __attribute__((optnone)) __attribute__((naked)) void VertexWeightFix_Inject(void) 114 | { 115 | asm volatile( 116 | "LDR R3, [R0, #0x18]\n" 117 | "PUSH {R1-R5}\n" 118 | "BL VertexWeightFix_Patch\n" 119 | "POP {R1-R5}\n" 120 | "MOV PC, R0"); 121 | } 122 | 123 | // RE3: Road reflections 124 | uintptr_t RoadReflections_BackTo; 125 | __attribute__((optnone)) __attribute__((naked)) void RoadReflections_Inject(void) 126 | { 127 | asm volatile( 128 | "VLDR S15, [R4, #0x18]\n" 129 | "LDR R2, [SP, #0x40]\n" 130 | ); 131 | asm volatile( 132 | "MOV PC, %0" 133 | :: "r" (RoadReflections_BackTo)); 134 | } 135 | 136 | // Fix traffic lights 137 | DECL_HOOKv(TrFix_RenderEffects) 138 | { 139 | BrightLightsRender(); 140 | TrFix_RenderEffects(); 141 | } 142 | 143 | // Framelimiter 144 | static double frameMcs = (1.0 / 30.0); 145 | static double nextMcsTime = 0.0; 146 | DECL_HOOKv(GameTick_TouchscreenUpdate, void *self, float a1, bool a2) 147 | { 148 | if(*m_PrefsFrameLimiter) 149 | { 150 | // Touch handling is completely fucked up. 151 | // Pausing thread is the only way... 152 | double accurateTime = OS_TimeAccurate(); 153 | if(nextMcsTime < accurateTime - frameMcs) nextMcsTime = accurateTime + frameMcs; 154 | else nextMcsTime += frameMcs; 155 | 156 | OS_ThreadSleep(1000 * (nextMcsTime - accurateTime)); 157 | } 158 | 159 | RsEventHandler(0x1A, (void*)true); 160 | GameTick_TouchscreenUpdate(self, a1, a2); 161 | } 162 | DECL_HOOKv(OS_ScreenSetRefresh, int newLimit) 163 | { 164 | if(newLimit < 10) newLimit = 10; 165 | else if(newLimit > 240) newLimit = 240; 166 | 167 | *fpsLimit = newLimit; 168 | frameMcs = 1.0 / (double)newLimit; 169 | } 170 | 171 | // Water UV Scroll 172 | uintptr_t RenderWater_BackTo; 173 | extern "C" float RenderWater_Patch(float windScale) 174 | { 175 | return windScale * GetTimeStepMagic(); 176 | } 177 | __attribute__((optnone)) __attribute__((naked)) void RenderWater_Inject(void) 178 | { 179 | asm volatile( 180 | "VMOV R0, S18\n" 181 | "BL RenderWater_Patch\n" 182 | "VMOV S18, R0\n" 183 | 184 | "VCVT.F32.U32 S17, S14\n" 185 | "VMUL.F32 S30, S17, S30\n" 186 | "VADD.F32 S28, S18, S28\n"); 187 | 188 | asm volatile( 189 | "MOV PC, %0" 190 | :: "r" (RenderWater_BackTo)); 191 | } 192 | 193 | // Render States 194 | static int fogState = 0; 195 | CRGBA fogColor; 196 | DECL_HOOKb(RwRenderState_Patch, RwRenderState state, int val) 197 | { 198 | switch(state) 199 | { 200 | default: 201 | return RwRenderState_Patch(state, val); 202 | 203 | case rwRENDERSTATEFOGENABLE: 204 | if(fogState != val) 205 | { 206 | fogState = val; 207 | emu_DistanceFogSetEnabled(fogState != 0); 208 | if(val) 209 | { 210 | emu_DistanceFogSetup(*m_fCurrentFogStart, 0.7f * *m_fCurrentFarClip, (float)fogColor.b / 255.0f, (float)fogColor.g / 255.0f, (float)fogColor.r / 255.0f); 211 | } 212 | } 213 | return true; 214 | 215 | case rwRENDERSTATEFOGCOLOR: 216 | fogColor.val = val; 217 | return true; 218 | 219 | // Shader does not support any other type of the fog... 220 | // Always rwFOGTYPELINEAR, no exponential (is this even used tho?) 221 | case rwRENDERSTATEFOGTYPE: 222 | return true; 223 | } 224 | } 225 | 226 | // Speedo cloudz 227 | DECL_HOOKv(CloudsUpdate_Speedo) 228 | { 229 | *fl1D4CF0 = 0.001f * GetTimeStepMagic(); 230 | *fl1D4CF4 = 0.3f * GetTimeStepMagic(); 231 | CloudsUpdate_Speedo(); 232 | } 233 | 234 | // The Shadow. Of explosion. It's missing. Yup. 235 | DECL_HOOKv(AddExplosion_AddShadow, uint8_t ShadowType, RwTexture *pTexture, CVector *pPosn, 236 | float fFrontX, float fFrontY, float fSideX, float fSideY, 237 | int16_t nIntensity, uint8_t nRed, uint8_t nGreen, uint8_t nBlue, 238 | float fZDistance, uint32_t nTime, float fScale) 239 | { 240 | AddExplosion_AddShadow(ShadowType, pTexture, pPosn, 8.0f, 0.0f, 0.0f, -8.0f, 200, 0, 0, 0, 10.0f, 30000, 1.0f); 241 | } 242 | 243 | // Light shadow tweaked distance 244 | DECL_HOOKv(StoreShadowForVehicle, uint32_t nId, uint8_t ShadowType, void *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16_t nIntensity, uint8_t nRed, uint8_t nGreen, uint8_t nBlue, float fZDistance, float fScale, float fDrawDistance, bool bTempShadow, float fUpDistance) 245 | { 246 | StoreShadowForVehicle(nId, ShadowType, pTexture, pPosn, fFrontX, fFrontY, fSideX, fSideY, nIntensity, nRed, nGreen, nBlue, 15.0f, fScale, 120.0f, bTempShadow, 0.0f); 247 | } 248 | 249 | // Static shadows 250 | DECL_HOOKv(InitShadows) 251 | { 252 | static CPolyBunch bunchezTail[BUNCHTAILS_EX]; 253 | 254 | InitShadows(); 255 | for(int i = 0; i < BUNCHTAILS_EX-1; ++i) 256 | { 257 | bunchezTail[i].m_pNext = &bunchezTail[i+1]; 258 | } 259 | bunchezTail[BUNCHTAILS_EX-1].m_pNext = NULL; 260 | aPolyBunches[380-1].m_pNext = &bunchezTail[0]; // GTA:VC has 380 instead of 360 in SA?! LOL, DOWNGRADE 261 | } 262 | 263 | // Bigger distance for light shadows 264 | uintptr_t DoCollectableEffects_BackTo, DoPickUpEffects_BackTo; 265 | __attribute__((optnone)) __attribute__((naked)) void DoCollectableEffects_Inject(void) 266 | { 267 | asm volatile( 268 | "LDM.W R3, {R0-R2}\n" 269 | "MOVS R10, #0x0\n" 270 | "MOVT R10, #0x4220\n" 271 | "VMOV.F32 S17, R10\n" 272 | "SUB SP, SP, #0x54\n" 273 | "PUSH {R0}\n" 274 | ); 275 | asm volatile( 276 | "MOV R10, %0" 277 | :: "r" (DoCollectableEffects_BackTo)); 278 | asm volatile( 279 | "POP {R0}\n" 280 | "MOV PC, R10\n" 281 | ); 282 | } 283 | __attribute__((optnone)) __attribute__((naked)) void DoPickUpEffects_Inject(void) 284 | { 285 | asm volatile( 286 | "VLDR S13, [R4, #0x38]\n" 287 | "STM.W R7, {R0-R2}\n" 288 | "MOVS R11, #0x0\n" 289 | "MOVT R11, #0x41F0\n" 290 | "VMOV.F32 S17, R11\n" 291 | "PUSH {R0}\n" 292 | ); 293 | asm volatile( 294 | "MOV R11, %0" 295 | :: "r" (DoPickUpEffects_BackTo)); 296 | asm volatile( 297 | "POP {R0}\n" 298 | "MOV PC, R11\n" 299 | ); 300 | } 301 | 302 | // Bigger spawn distance for peds 303 | DECL_HOOK(float, PedCreationDistMult_Offscreen) 304 | { 305 | return 2.6f * PedCreationDistMult_Offscreen(); 306 | } 307 | 308 | // FX particles distance multiplier! 309 | float fxMultiplier; 310 | DECL_HOOK(float, LoadFX_atof, char* str) 311 | { 312 | return fxMultiplier * LoadFX_atof(str); 313 | } 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | // Fix pushing force 326 | DECL_HOOKb(ApplyCollision_HighFPS, void *A, void *B, void *colpoint, float *impulseA, float *impulseB) 327 | { 328 | *fl1679D4 = 0;//1.4f * GetTimeStepMagic(); 329 | return ApplyCollision_HighFPS(A, B, colpoint, impulseA, impulseB); 330 | } 331 | DECL_HOOKv(ApplyCollision_MoveForce, void *self, CVector force) 332 | { 333 | ApplyCollision_MoveForce(self, force * 0.0f); 334 | } 335 | DECL_HOOKv(ApplyCollision_TurnForce, void *self, CVector force, CVector center) 336 | { 337 | ApplyCollision_TurnForce(self, force * 0.0f, center); 338 | } 339 | uintptr_t ApplyCollision_BackTo; 340 | extern "C" float ApplyCollision_Patch(float invmass) 341 | { 342 | return invmass * GetTimeStepMagic(); 343 | } 344 | __attribute__((optnone)) __attribute__((naked)) void ApplyCollision_Inject(void) 345 | { 346 | asm volatile( 347 | "VLDR S11, [R6, #0x10]\n" 348 | "VDIV.F32 S13, S7, S13\n" 349 | "VMOV R0, S13\n" 350 | "BL ApplyCollision_Patch\n" 351 | "VMOV S13, R0\n"); 352 | asm volatile( 353 | "MOV PC, %0" 354 | :: "r" (ApplyCollision_BackTo)); 355 | } 356 | 357 | // Force DXT 358 | DECL_HOOKp(LoadEntries_DXT, TextureDatabaseRuntime *self, bool a1, bool a2) 359 | { 360 | self->loadedFormat = DF_DXT; 361 | return LoadEntries_DXT(self, a1, a2); 362 | } 363 | 364 | // Fixing drunk camera on high FPS 365 | DECL_HOOKv(CameraProcess_HighFPS, void* self) 366 | { 367 | float DrunkRotationBak = *DrunkRotation; 368 | CameraProcess_HighFPS(self); 369 | if(DrunkRotationBak != *DrunkRotation) 370 | { 371 | *DrunkRotation = DrunkRotationBak + 5.0f * GetTimeStepMagic(); 372 | } 373 | } -------------------------------------------------------------------------------- /patches/patches_vc64.inl: -------------------------------------------------------------------------------- 1 | // Boat and Skimmer on high FPS 2 | uintptr_t Boat_ApplyWaterResistance_BackTo; 3 | extern "C" float Boat_ApplyWaterResistance_Patch(float resistance) 4 | { 5 | return resistance * GetTimeStepMagic(); 6 | } 7 | __attribute__((optnone)) __attribute__((naked)) void Boat_ApplyWaterResistance_Inject(void) 8 | { 9 | asm volatile( 10 | "STR X8, [SP, #-16]!\n" 11 | "FMOV S11, #1.0\n" 12 | "FMADD S1, S2, S2, S1\n" 13 | "FCSEL S0, S3, S0, EQ\n" 14 | "FMOV W0, S0\n" 15 | "STR S1, [SP, #-16]!\n" 16 | "BL Boat_ApplyWaterResistance_Patch\n" 17 | "LDR S1, [SP], #16\n" 18 | "FMADD S0, S0, S1, S11\n"); 19 | asm volatile( 20 | "MOV X0, %0" 21 | :: "r" (Boat_ApplyWaterResistance_BackTo)); 22 | asm volatile( 23 | "LDR X8, [SP], #16\n" 24 | "BR X0"); 25 | } 26 | 27 | // Fix wheels rotation speed on high FPS 28 | DECL_HOOK(float, ProcessWheelRotation, void* self, int state, const CVector &fwd, const CVector &speed, float radius) 29 | { 30 | return ProcessWheelRotation(self, state, fwd, speed, radius) / fMagic; 31 | } 32 | 33 | // Car Slowdown Fix 34 | DECL_HOOKv(ProcessWheel_SlowDownFix, void *self, CVector &a1, CVector &a2, CVector &a3, CVector &a4, int a5, float a6, float a7, float a8, char a9, float *a10, void *a11, uint16_t a12) 35 | { 36 | float& fWheelFriction = *(float*)(mod_HandlingManager + 4); 37 | float save = fWheelFriction; fWheelFriction *= 2.0f * GetTimeStepMagic(); 38 | ProcessWheel_SlowDownFix(self, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); 39 | fWheelFriction = save; 40 | } 41 | DECL_HOOKv(ProcessBikeWheel_SlowDownFix, void *self, CVector &a1, CVector &a2, CVector &a3, CVector &a4, int a5, float a6, float a7, float a8, float a9, char a10, float *a11, void *a12, int a13, uint16_t a14) 42 | { 43 | float& fWheelFriction = *(float*)(mod_HandlingManager + 4); 44 | float save = fWheelFriction; fWheelFriction *= 2.0f * GetTimeStepMagic(); 45 | ProcessBikeWheel_SlowDownFix(self, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); 46 | fWheelFriction = save; 47 | } 48 | 49 | // Fix heli rotor rotation speed on high FPS 50 | DECL_HOOKv(HeliRender_MatrixUpdate, void *self) 51 | { 52 | HeliRender_MatrixUpdate(self); 53 | *fHeliRotorSpeed = 0.48307693f * GetTimeStepMagic(); 54 | } 55 | 56 | // Streaming distance fix 57 | float fStreamingDistFix; 58 | uintptr_t CameraProcess_StreamDist_BackTo; 59 | DECL_HOOKv(SetFOV_StreamingDistFix, float factor) 60 | { 61 | // Someone is using broken mods 62 | // So here is the workaround + a little value clamping 63 | if(factor < 5.0f) 64 | { 65 | fStreamingDistFix = 70.0f / 5.0f; 66 | } 67 | else if(factor > 170.0f) 68 | { 69 | fStreamingDistFix = 70.0f / 170.0f; 70 | } 71 | else 72 | { 73 | fStreamingDistFix = 70.0f / factor; 74 | } 75 | 76 | fStreamingDistFix *= (*ms_fAspectRatio / ar43); 77 | 78 | SetFOV_StreamingDistFix(factor); 79 | } 80 | extern "C" float CameraProcess_StreamDist_Patch() 81 | { 82 | return fStreamingDistFix; 83 | } 84 | __attribute__((optnone)) __attribute__((naked)) void CameraProcess_StreamDist_Inject(void) 85 | { 86 | asm volatile( 87 | "BL CameraProcess_StreamDist_Patch\n" 88 | "STR S0, [X20, #0xF4]!\n"); // "!" in ARMv8 assembly pushes an address of [..] to X20..?); 89 | asm volatile( 90 | "MOV X0, %0" 91 | :: "r" (CameraProcess_StreamDist_BackTo)); 92 | asm volatile( 93 | "BR X0\n"); 94 | } 95 | 96 | // fat-ass coronas! 97 | DECL_HOOKb(CoronaSprite_CalcScreenCoors, CVector *worldPos, CVector *screenPos, float *scalex, float *scaley, bool a) 98 | { 99 | bool ret = CoronaSprite_CalcScreenCoors(worldPos, screenPos, scalex, scaley, a); 100 | *scalex /= *ms_fAspectRatio; 101 | return ret; 102 | } 103 | 104 | // Fix traffic lights 105 | DECL_HOOKv(TrFix_RenderEffects) 106 | { 107 | BrightLightsRender(); 108 | TrFix_RenderEffects(); 109 | } 110 | 111 | // Framelimiter 112 | static double frameMcs = (1.0 / 30.0); 113 | static double nextMcsTime = 0.0; 114 | DECL_HOOKv(GameTick_TouchscreenUpdate, void *self, float a1, bool a2) 115 | { 116 | if(*m_PrefsFrameLimiter) 117 | { 118 | // Touch handling is completely fucked up. 119 | // Pausing thread is the only way... 120 | double accurateTime = OS_TimeAccurate(); 121 | if(nextMcsTime < accurateTime - frameMcs) nextMcsTime = accurateTime + frameMcs; 122 | else nextMcsTime += frameMcs; 123 | 124 | OS_ThreadSleep(1000 * (nextMcsTime - accurateTime)); 125 | } 126 | 127 | RsEventHandler(0x1A, (void*)true); 128 | GameTick_TouchscreenUpdate(self, a1, a2); 129 | } 130 | DECL_HOOKv(OS_ScreenSetRefresh, int newLimit) 131 | { 132 | if(newLimit < 10) newLimit = 10; 133 | else if(newLimit > 240) newLimit = 240; 134 | 135 | *fpsLimit = newLimit; 136 | frameMcs = 1.0 / (double)newLimit; 137 | } 138 | 139 | // Water UV Scroll 140 | uintptr_t RenderWater_BackTo; 141 | extern "C" float RenderWater_Patch(float windScale) 142 | { 143 | return windScale * GetTimeStepMagic(); 144 | } 145 | __attribute__((optnone)) __attribute__((naked)) void RenderWater_Inject(void) 146 | { 147 | asm volatile( 148 | "AND W8, W8, #0xFFF\n" 149 | "UCVTF S3, W8\n" 150 | "FMOV W0, S10\n" 151 | 152 | "STR S0, [SP, #-16]!\n" 153 | "STR S1, [SP, #-16]!\n" 154 | "BL RenderWater_Patch\n" 155 | "FMOV S10, S0\n" 156 | "LDR S1, [SP], #16\n" 157 | "LDR S0, [SP], #16\n" 158 | 159 | "FMADD S12, S10, S0, S1\n" 160 | "LDP S0, S1, [X19, #0x4]"); 161 | 162 | asm volatile( 163 | "MOV X8, %0" 164 | :: "r" (RenderWater_BackTo)); 165 | asm volatile( 166 | "BR X8\n"); 167 | } 168 | 169 | // Render States 170 | static int fogState = 0; 171 | CRGBA fogColor; 172 | DECL_HOOKb(RwRenderState_Patch, RwRenderState state, int val) 173 | { 174 | switch(state) 175 | { 176 | default: 177 | return RwRenderState_Patch(state, val); 178 | 179 | case rwRENDERSTATEFOGENABLE: 180 | if(fogState != val) 181 | { 182 | fogState = val; 183 | emu_DistanceFogSetEnabled(fogState != 0); 184 | if(val) 185 | { 186 | emu_DistanceFogSetup(*m_fCurrentFogStart, 0.7f * *m_fCurrentFarClip, (float)fogColor.b / 255.0f, (float)fogColor.g / 255.0f, (float)fogColor.r / 255.0f); 187 | } 188 | } 189 | return true; 190 | 191 | case rwRENDERSTATEFOGCOLOR: 192 | fogColor.val = val; 193 | return true; 194 | 195 | // Shader does not support any other type of the fog... 196 | // Always rwFOGTYPELINEAR, no exponential (is this even used tho?) 197 | case rwRENDERSTATEFOGTYPE: 198 | return true; 199 | } 200 | } 201 | 202 | // Speedo cloudz 203 | DECL_HOOKv(CloudsUpdate_Speedo) 204 | { 205 | *fl1D4CF0 = 0.001f * GetTimeStepMagic(); 206 | *fl1D4CF4 = 0.3f * GetTimeStepMagic(); 207 | CloudsUpdate_Speedo(); 208 | } 209 | 210 | // The Shadow. Of explosion. It's missing. Yup. 211 | DECL_HOOKv(AddExplosion_AddShadow, uint8_t ShadowType, RwTexture *pTexture, CVector *pPosn, 212 | float fFrontX, float fFrontY, float fSideX, float fSideY, 213 | int16_t nIntensity, uint8_t nRed, uint8_t nGreen, uint8_t nBlue, 214 | float fZDistance, uint32_t nTime, float fScale) 215 | { 216 | AddExplosion_AddShadow(ShadowType, pTexture, pPosn, 8.0f, 0.0f, 0.0f, -8.0f, 200, 0, 0, 0, 10.0f, 30000, 1.0f); 217 | } 218 | 219 | // Light shadow tweaked distance 220 | DECL_HOOKv(StoreShadowForVehicle, uint64_t nId, uint8_t ShadowType, void *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16_t nIntensity, uint8_t nRed, uint8_t nGreen, uint8_t nBlue, float fZDistance, float fScale, float fDrawDistance, bool bTempShadow, float fUpDistance) 221 | { 222 | StoreShadowForVehicle(nId, ShadowType, pTexture, pPosn, fFrontX, fFrontY, fSideX, fSideY, nIntensity, nRed, nGreen, nBlue, 15.0f, fScale, 120.0f, bTempShadow, 0.0f); 223 | } 224 | DECL_HOOKv(StoreStaticShadow_LS, uint64_t nId, uint8 ShadowType, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16_t nIntensity, uint8_t nRed, uint8_t nGreen, uint8_t nBlue, float fZDistance, float fScale, float fDrawDistance, bool bTempShadow, float fUpDistance) 225 | { 226 | StoreStaticShadow_LS(nId, ShadowType, pTexture, pPosn, fFrontX, fFrontY, fSideX, fSideY, nIntensity, nRed, nGreen, nBlue, 15.0f, fScale, 120.0f, bTempShadow, 0.0f); 227 | } 228 | 229 | // Static shadows 230 | DECL_HOOKv(InitShadows) 231 | { 232 | static CPolyBunch bunchezTail[BUNCHTAILS_EX]; 233 | 234 | InitShadows(); 235 | for(int i = 0; i < BUNCHTAILS_EX-1; ++i) 236 | { 237 | bunchezTail[i].m_pNext = &bunchezTail[i+1]; 238 | } 239 | bunchezTail[BUNCHTAILS_EX-1].m_pNext = NULL; 240 | aPolyBunches[380-1].m_pNext = &bunchezTail[0]; // GTA:VC has 380 instead of 360 in SA?! LOL, DOWNGRADE 241 | } 242 | 243 | #define MAX_STATIC_SHADOWS (0xFF) 244 | uintptr_t StoreStaticShadow_BackTo; 245 | extern "C" uint32_t StoreStaticShadow_Patch() 246 | { 247 | for(uint32_t i = 0; i < MAX_STATIC_SHADOWS; ++i) 248 | { 249 | if(aStaticShadows_NEW[i].m_pPolyBunch == NULL) return i; 250 | } 251 | return 1; 252 | } 253 | __attribute__((optnone)) __attribute__((naked)) void StoreStaticShadow_Inject(void) 254 | { 255 | asm volatile( 256 | "STR X0, [SP, #-16]!\n" 257 | //"STR X8, [SP, #-16]!\n" 258 | "BL StoreStaticShadow_Patch\n" 259 | "MOV W8, W0\n"); 260 | 261 | asm volatile( 262 | "MOV X11, %0" 263 | :: "r" (StoreStaticShadow_BackTo)); 264 | 265 | asm volatile( 266 | //"LDR X8, [SP], #16\n" 267 | "LDR X0, [SP], #16\n" 268 | "BR X11\n"); 269 | } 270 | 271 | // Bigger distance for light shadows 272 | uintptr_t DoCollectableEffects_BackTo, DoPickUpEffects_BackTo; 273 | extern "C" float GetNewShadowsDist() 274 | { 275 | return 120.0f; 276 | } 277 | __attribute__((optnone)) __attribute__((naked)) void DoCollectableEffects_Inject(void) 278 | { 279 | asm volatile( 280 | "STR X8, [SP, #0x20]\n" 281 | "LDR X9, [X9, #0x650]\n" // TheCamera_ptr@PAGEOFF 282 | "BL GetNewShadowsDist\n" 283 | "FMOV S8, S0\n" 284 | ); 285 | asm volatile( 286 | "MOV X16, %0" 287 | :: "r" (DoCollectableEffects_BackTo)); 288 | asm volatile( 289 | "LDR W8, [X19, #0x40]\n" 290 | "BR X16\n" 291 | ); 292 | } 293 | __attribute__((optnone)) __attribute__((naked)) void DoPickUpEffects_Inject(void) 294 | { 295 | asm volatile( 296 | "FSQRT S2, S1\n" 297 | "BL GetNewShadowsDist\n" 298 | "FCMP S2, S0\n" 299 | "FMOV S0, WZR\n" 300 | "FMOV S1, WZR\n" 301 | ); 302 | asm volatile( 303 | "MOV X16, %0" 304 | :: "r" (DoPickUpEffects_BackTo)); 305 | asm volatile( 306 | "BR X16\n" 307 | ); 308 | } 309 | 310 | // Bigger spawn distance for peds 311 | DECL_HOOK(float, PedCreationDistMult_Offscreen) 312 | { 313 | return 2.6f * PedCreationDistMult_Offscreen(); 314 | } 315 | 316 | // FX particles distance multiplier! 317 | float fxMultiplier; 318 | DECL_HOOK(float, LoadFX_atof, char* str) 319 | { 320 | return fxMultiplier * LoadFX_atof(str); 321 | } 322 | 323 | // Fixing drunk camera on high FPS 324 | DECL_HOOKv(CameraProcess_HighFPS, void* self) 325 | { 326 | float DrunkRotationBak = *DrunkRotation; 327 | CameraProcess_HighFPS(self); 328 | if(DrunkRotationBak != *DrunkRotation) 329 | { 330 | *DrunkRotation = DrunkRotationBak + 5.0f * GetTimeStepMagic(); 331 | } 332 | } -------------------------------------------------------------------------------- /patches/preparations_sa64.inl: -------------------------------------------------------------------------------- 1 | HOOKPLT(GameProcess, pGTASA + 0x840198); 2 | 3 | 4 | // I am using a function at 0x692B14 as my variables storage. 5 | // This function is unused and most likely never will be, 6 | // so should be safe 7 | 8 | 9 | // Animated textures 10 | if(cfg->GetBool("EnableAnimatedTextures", true, "Visual")) 11 | { 12 | aml->Write8(aml->GetSym(hGTASA, "RunUVAnim"), true); 13 | aml->PlaceNOP(pGTASA + 0x25EE0C, 1); 14 | aml->PlaceNOP(pGTASA + 0x25F5EC, 1); 15 | aml->PlaceNOP(pGTASA + 0x25EDC8, 1); 16 | } 17 | 18 | // Vertex weight 19 | if(cfg->GetBool("FixVertexWeight", true, "Visual")) 20 | { 21 | // openglSkinAllInOneAtomicInstanceCB 22 | aml->Write32(pGTASA + 0x25C278, MOVBits::Create(1, 27, false)); 23 | aml->PlaceNOP(pGTASA + 0x25C28C, 1); 24 | aml->Write32(pGTASA + 0x25C290, MOVBits::Create(1, 27, false)); 25 | } 26 | 27 | // Fix sky multitude 28 | if(cfg->GetBool("FixSkyMultitude", true, "Visual")) 29 | { 30 | aml->Unprot(pGTASA + 0x7630D8, sizeof(float)); *(float*)(pGTASA + 0x7630D8) = -10.0f; 31 | aml->PlaceNOP(pGTASA + 0x6C39F8, 1); 32 | aml->Write(pGTASA + 0x6C3A04, "\x03\x90\x24\x1E", 4); 33 | } 34 | 35 | // Fix vehicles backlights light state 36 | if(cfg->GetBool("FixCarsBacklightLightState", true, "Visual")) 37 | { 38 | aml->Write32(pGTASA + 0x6B52E0, MOVBits::Create(2, 1, false)); 39 | } 40 | 41 | // Limit sand/dust particles on bullet impact (they are EXTREMELY dropping FPS) 42 | if(cfg->GetBool("LimitSandDustBulletParticles", true, "Visual")) 43 | { 44 | HOOKPLT(GetBulletFx_Limited, pGTASA + 0x846068); 45 | if(cfg->GetBool("LimitSandDustBulletParticlesWithSparkles", false, "Visual")) 46 | { 47 | nLimitWithSparkles = BULLETFX_SPARK; 48 | } 49 | } 50 | 51 | // Fix walking while rifle-aiming 52 | if(cfg->GetBool("FixAimingWalkRifle", true, "Gameplay")) 53 | { 54 | HOOKPLT(ControlGunMove, pGTASA + 0x83F9D8); 55 | } 56 | 57 | // Fix water physics 58 | if(cfg->GetBool("FixWaterPhysics", true, "Gameplay")) 59 | { 60 | HOOK(ProcessSwimmingResistance, pGTASA + 0x657B88); 61 | HOOKBL(ProcessPedBuoyancy, pGTASA + 0x5980F0); 62 | SET_TO(buoyancyTimescaleReplacement, pGTASA + 0x692B14); UNPROT(buoyancyTimescaleReplacement, sizeof(float)); 63 | aml->Write32(pGTASA + 0x691E80, 0xB0000009); 64 | aml->Write32(pGTASA + 0x691E84, 0xBD4B1522); 65 | aml->Write32(pGTASA + 0x691E90, 0xD503201F); 66 | } 67 | 68 | // Fix stealable items sucking 69 | if(cfg->GetBool("ClampObjectToStealDist", true, "Gameplay")) 70 | { 71 | aml->Write(pGTASA + 0x4EF9C4, (uintptr_t)"\x00\x10\x2E\x1E", 4); 72 | } 73 | 74 | // Fix broken basketball minigame by placing the save icon away from it 75 | if(cfg->GetBool("MaddDoggMansionSaveFix", true, "SCMFixes")) 76 | { 77 | HOOKPLT(GenerateNewPickup_MaddDogg, pGTASA + 0x848278); 78 | } 79 | 80 | // Fix broken basketball minigame by placing the save icon away from it 81 | if(cfg->GetBool("FixStarBribeInSFBuilding", true, "SCMFixes")) 82 | { 83 | HOOKPLT(GenerateNewPickup_SFBribe, pGTASA + 0x848278); 84 | } 85 | 86 | // Fix rifle pickup that stuck inside the stadium 87 | if(cfg->GetBool("FixSFStadiumRiflePickup", true, "SCMFixes")) 88 | { 89 | HOOKPLT(GenerateNewPickup_SFRiflePickup, pGTASA + 0x848278); 90 | } 91 | 92 | // Remove jetpack leaving on widget press while in air? 93 | if(cfg->GetBool("DisableDropJetPackInAir", true, "Gameplay")) 94 | { 95 | HOOKPLT(DropJetPackTask, pGTASA + 0x849738); 96 | } 97 | 98 | // Dont stop the car before leaving it 99 | if(cfg->GetBool("ImmediatelyLeaveTheCar", true, "Gameplay")) 100 | { 101 | HOOK(CanPedStepOutCar, aml->GetSym(hGTASA, "_ZNK8CVehicle16CanPedStepOutCarEb")); 102 | } 103 | 104 | // Bring back penalty when CJ dies! 105 | if(cfg->GetBool("WeaponPenaltyIfDied", true, "Gameplay")) 106 | { 107 | DiedPenalty_BackTo = pGTASA + 0x3CE2A8; 108 | aml->Redirect(pGTASA + 0x3CE290, (uintptr_t)DiedPenalty_Inject); 109 | } 110 | 111 | // Fixing a crosshair position by very stupid math 112 | if(cfg->GetBool("FixCrosshair", true, "Visual")) 113 | { 114 | HOOK(DrawCrosshair, pGTASA + 0x51C694); 115 | } 116 | 117 | // Country. Rifle. Is. 3rd. Person. 118 | if(cfg->GetBool("FixCountryRifleAim", true, "Gameplay")) 119 | { 120 | aml->PlaceNOP(pGTASA + 0x653408, 2); 121 | aml->Write32(pGTASA + 0x6539E0, CMPBits::Create(0xFF, 28, false)); 122 | } 123 | 124 | // Colored zone names are back 125 | if(cfg->GetBool("ColoredZoneNames", true, "Visual")) 126 | { 127 | aml->Write32(pGTASA + 0x51D9D8, 0x39403102); 128 | aml->Write32(pGTASA + 0x51D9DC, 0x39403503); 129 | aml->Write32(pGTASA + 0x51D9E0, 0x35000061); 130 | aml->Write32(pGTASA + 0x51D9E4, 0x35000042); 131 | } 132 | 133 | // A fix for 2.10 crash (thanks fastman92!) 134 | if(cfg->GetBool("Fix210Crash", true, "Gameplay")) 135 | { 136 | aml->Write32(pGTASA + 0x278E50, 0x8B090108); 137 | aml->Write32(pGTASA + 0x278E60, 0x8B090108); 138 | aml->Write32(pGTASA + 0x278E70, 0xAA0903E9); 139 | } 140 | 141 | // Fix enter-vehicle tasks 142 | if(cfg->GetBool("FixEnterVehicleTasks", true, "Gameplay")) 143 | { 144 | aml->PlaceNOP(pGTASA + 0x4EF23C); 145 | aml->PlaceB(pGTASA + 0x4EF274, pGTASA + 0x4EF2F4); 146 | HOOKBL(Patch_ExitVehicleJustDown, pGTASA + 0x4EF414); 147 | } 148 | 149 | // Fixes farclip glitch with wall (wardumb be like) 150 | if(cfg->GetBool("FixFogWall", true, "Visual")) 151 | { 152 | aml->Write(pGTASA + 0x712095, "\x31\x2E\x30\x30", 4); 153 | HOOKPLT(DistanceFogSetup_FogWall, pGTASA + 0x8465E0); 154 | } 155 | 156 | // Frick your "improved characters models", War Dumb 157 | if(cfg->GetBool("FixPedSpecInShaders", true, "Visual")) 158 | { 159 | aml->Write32(pGTASA + 0x263810, ARMv8::MOVRegBits::Create(8, 23, false)); 160 | aml->PlaceB(pGTASA + 0x264A94, pGTASA + 0x264B34); 161 | } 162 | 163 | // Wrong vehicle's parts colors! 164 | if(cfg->GetBool("FixWrongCarDetailsColor", true, "Visual")) 165 | { 166 | HOOKBL(ObjectRender_VehicleParts, pGTASA + 0x53E17C); 167 | } 168 | 169 | // Stunt smoke 170 | if(cfg->GetBool("FixStuntSmoke", true, "Gameplay")) 171 | { 172 | HOOKBL(Plane_ProcessControl_Horn, pGTASA + 0x699418); 173 | } 174 | 175 | // Falling star. 176 | if(cfg->GetBool("FallingStarColor", true, "Visual")) 177 | { 178 | HOOKBL(RenderState_Star, pGTASA + 0x6C34C4); 179 | } 180 | 181 | // BengbuGuards: Jetpack Hover Button 182 | if(cfg->GetBool("JetpackHovering", true, "Gameplay")) 183 | { 184 | HOOKBL(Jetpack_IsHeldDown, pGTASA + 0x4DD104); 185 | } 186 | 187 | // Fix the issue that player cannot kill with a knife if not crouching 188 | if(cfg->GetBool("FixUncrouchedStealthKill", true, "Gameplay")) 189 | { 190 | aml->PlaceB(pGTASA + 0x65354C, pGTASA + 0x654A20); 191 | } 192 | 193 | // Fixing a wrong value in carcols.dat 194 | if(cfg->GetBool("CarColsDat_FixWrongValue", true, "Visual")) 195 | { 196 | HOOKBL(CarColsDatLoad_sscanf, pGTASA + 0x557F5C); 197 | } 198 | 199 | // Buff streaming memory (dynamic) 200 | bDynStreamingMem = cfg->GetBool("DynamicStreamingMem", true, "Gameplay"); 201 | if(bDynStreamingMem) 202 | { 203 | fDynamicStreamingMemPercentage = 0.01f * cfg->GetInt("DynamicStreamingMem_Percentage", 80, "Gameplay"); 204 | if(fDynamicStreamingMemPercentage < 0.01f || fDynamicStreamingMemPercentage > 0.99f) bDynStreamingMem = false; 205 | else 206 | { 207 | int valllue = cfg->GetInt("DynamicStreamingMem_MaxMBs", 1024, "Gameplay"); 208 | if(valllue < 32) valllue = 32; 209 | else if(valllue > 4096) valllue = 4096; 210 | 211 | nMaxStreamingMemForDynamic = 1024 * 1024 * valllue; 212 | 213 | valllue = cfg->GetInt("DynamicStreamingMem_BumpStep", 8, "Gameplay"); 214 | if(valllue < 2) valllue = 2; 215 | else if(valllue > 64) valllue = 64; 216 | nDynamicStreamingMemBumpStep = valllue; 217 | } 218 | } 219 | 220 | // Fix planes generation coordinates 221 | if(cfg->GetBool("FixPlanesGenerationCoords", true, "Gameplay")) 222 | { 223 | HOOKPLT(FindPlaneCoors_CheckCol, pGTASA + 0x844158); 224 | } 225 | 226 | // Now CJ is able to exit a vehicle and start moving immediately, without being forced to close the door 227 | if(cfg->GetBool("NotForcedToCloseVehDoor", true, "Gameplay")) 228 | { 229 | HOOKBL(DoorClosing_PadTarget, pGTASA + 0x60F990); 230 | } 231 | 232 | // Removes "plis give us 5 stars plis plis" 233 | if(cfg->GetBool("RemoveAskingToRate", true, "Others")) 234 | { 235 | aml->PlaceB(pGTASA + 0x411ACC, pGTASA + 0x411AD8); 236 | } 237 | 238 | // Remove "ExtraAirResistance" flag 239 | if(cfg->GetBool("NoExtraAirResistanceFlag", true, "Gameplay")) 240 | { 241 | aml->Redirect(aml->GetSym(hGTASA, "_ZN10CCullZones29DoExtraAirResistanceForPlayerEv"), (uintptr_t)ret0); 242 | } 243 | 244 | // Allow all radio tracks to be played! 245 | if(cfg->GetBool("NoRadioCuts", true, "Gameplay")) 246 | { 247 | aml->Redirect(aml->GetSym(hGTASA, "_Z14IsRemovedTracki"), (uintptr_t)ret0); 248 | aml->PlaceB(pGTASA + 0x47CEF4, pGTASA + 0x47CFC0); // QueueUpTracksForStation 249 | aml->PlaceB(pGTASA + 0x47F680, pGTASA + 0x47F738); // ChooseMusicTrackIndex 250 | aml->PlaceB(pGTASA + 0x47F844, pGTASA + 0x47F93C); // ChooseIdentIndex 251 | aml->PlaceB(pGTASA + 0x47FBE0, pGTASA + 0x47FC9C); // ChooseAdvertIndex 252 | aml->PlaceB(pGTASA + 0x4805EC, pGTASA + 0x4806B8); // ChooseTalkRadioShow 253 | aml->PlaceB(pGTASA + 0x4807A4, pGTASA + 0x480870); // ChooseDJBanterIndexFromList 254 | } 255 | 256 | // Some kind of "Sprint Everywhere" 257 | if(cfg->GetBool("SprintOnAnySurface", true, "Gameplay")) 258 | { 259 | aml->Redirect(aml->GetSym(hGTASA, "_ZN14SurfaceInfos_c12CantSprintOnEj"), (uintptr_t)ret0); 260 | } 261 | 262 | // Peepo: Fix traffic lights 263 | if(cfg->GetBool("FixTrafficLights", true, "Visual")) 264 | { 265 | HOOK(TrFix_RenderEffects, aml->GetSym(hGTASA, "_Z13RenderEffectsv")); 266 | HOOK(TrFix_InitGame2nd, aml->GetSym(hGTASA, "_ZN5CGame5Init2EPKc")); 267 | } 268 | 269 | // Water Quadrant 270 | int dist = cfg->GetInt("DetailedWaterDrawDistance", 48 * 2, "Visual"); 271 | if(dist > 0) 272 | { 273 | if(dist < 24) dist = 24; 274 | else if(dist >= 48 * 4) dist = 48 * 4; 275 | *DETAILEDWATERDIST = dist; 276 | } 277 | 278 | // Money have 8 digits now? Exciting! 279 | if(cfg->GetBool("PCStyledMoney", false, "Visual")) 280 | { 281 | HOOKBL(DrawMoney_sprintf, pGTASA + 0x37D4B8); 282 | } 283 | 284 | // Sweet's roof is not that tasty anymore 285 | if(cfg->GetBool("FixClimbDying", true, "Gameplay")) 286 | { 287 | HOOKPLT(ClimbProcessPed, pGTASA + 0x83A6A0); 288 | } 289 | 290 | // Fix color picker widget 291 | if(cfg->GetBool("FixColorPicker", true, "Visual")) 292 | { 293 | HOOKPLT(GetColorPickerValue, pGTASA + 0x829BE0); 294 | } 295 | 296 | // RE3: Road reflections 297 | if(cfg->GetBool("Re3_WetRoadsReflections", true, "Visual")) 298 | { 299 | aml->PlaceNOP(pGTASA + 0x6C6770); 300 | aml->Write32(pGTASA + 0x6C6774, 0xBD407BE2); 301 | } 302 | 303 | // Bigger max count of peds 304 | if(cfg->GetBool("BuffMaxPedsCount", true, "Gameplay")) 305 | { 306 | *(int*)aml->GetSym(hGTASA, "_ZN11CPopulation20MaxNumberOfPedsInUseE") = 0x23; 307 | aml->Write32(pGTASA + 0x4D71E4, 0x52800469); 308 | aml->Write32(pGTASA + 0x5CB4E4, 0x52800469); 309 | aml->Write32(pGTASA + 0x5CC0E8, 0x52800468); 310 | aml->Write32(pGTASA + 0x5CC0EC, 0x5280038A); 311 | } 312 | 313 | // Bigger max count of cars 314 | if(cfg->GetBool("BuffMaxCarsCount", true, "Gameplay")) 315 | { 316 | *(int*)aml->GetSym(hGTASA, "_ZN8CCarCtrl20MaxNumberOfCarsInUseE") = 0x14; 317 | aml->Write32(pGTASA + 0x4D71E8, 0x5280028B); 318 | } 319 | 320 | // RE3: Fix R* optimization that prevents peds to spawn 321 | if(cfg->GetBool("Re3_PedSpawnDeoptimize", true, "Gameplay")) 322 | { 323 | aml->Write32(pGTASA + 0x4D6420, 0x71000ABF); 324 | } 325 | 326 | // Just a fuzzy seek. Tell MPG123 to not load useless data. 327 | if(cfg->GetBool("FuzzySeek", true, "Gameplay")) 328 | { 329 | aml->Write32(pGTASA + 0x339134, 0x52846C02); 330 | aml->Write32(pGTASA + 0x339404, 0x52846C02); 331 | } 332 | 333 | // 44100 Hz Audio support (without a mod OpenAL Update but works with it anyway) 334 | if(cfg->GetBool("Allow44100HzAudio", true, "Gameplay")) 335 | { 336 | aml->Unprot(pGTASA + 0x749AA4, sizeof(int)); 337 | *(int*)(pGTASA + 0x749AA4) = 44100; 338 | } 339 | 340 | // Fixes emergency vehicles 341 | if(cfg->GetBool("FixStreamingDistScale", true, "Gameplay")) 342 | { 343 | EmergencyVeh_BackTo = pGTASA + 0x4BBB50; 344 | aml->Redirect(pGTASA + 0x4BBB38, (uintptr_t)EmergencyVeh_Inject); 345 | HOOKPLT(SetFOV_Emergency, pGTASA + 0x846898); 346 | aml->Write32(pGTASA + 0x4BBB70, 0x1E204002); // NOP "* 0.875f" 347 | aml->PlaceNOP(pGTASA + 0x4BBB68, 1); // NOP "* 0.8f" 348 | } 349 | 350 | // AliAssassiN: Camera does not go crazy with mouse connected 351 | if(cfg->GetBool("MouseFix", true, "Gameplay")) 352 | { 353 | aml->Write32(pGTASA + 0x4DB614, 0xD0001BAB); 354 | aml->Write32(pGTASA + 0x4DB618, 0xF947996B); 355 | } 356 | 357 | // AliAssassiN: Fixes "ghosting" when looking underground 358 | if(cfg->GetBool("CompletelyClearCameraBuffer", true, "Visual")) 359 | { 360 | aml->PlaceB(pGTASA + 0x4D7DB4, pGTASA + 0x4D7E2C); 361 | } 362 | 363 | // PS2 thingo 364 | if(cfg->GetBool("PS2CoronaRotation", true, "Visual")) 365 | { 366 | HOOKBL(RenderOneXLUSprite_Rotate_Aspect_PS2, pGTASA + 0x6C6158); 367 | } 368 | 369 | // SilentPatch fix 370 | if(cfg->GetBool("DirectionalSunLight", true, "Visual")) 371 | { 372 | HOOKPLT(SetLightsWithTimeOfDayColour_DirLight, pGTASA + 0x846C88); 373 | } 374 | 375 | // Fix airbubbles from the jaw (CJ is breathing with his ass, lololololol) 376 | if(cfg->GetBool("AirBubblesFromJaw", true, "Visual")) 377 | { 378 | aml->Write32(pGTASA + 0x6586E4, 0xF9411C08); 379 | aml->Write32(pGTASA + 0x6586EC, 0xF9411808); 380 | } 381 | 382 | // FX particles distance multiplier! 383 | fxMultiplier = cfg->GetFloat("FxDistanceMult", 2.5f, "Visual"); 384 | if(fxMultiplier != 1) 385 | { 386 | if(fxMultiplier < 0.1) fxMultiplier = 0.1f; 387 | else if(fxMultiplier > 20) fxMultiplier = 20.0f; 388 | HOOKBL(LoadFX_sscanf, pGTASA + 0x559AC8); 389 | HOOKBL(LoadFX_sscanf, pGTASA + 0x559F48); 390 | HOOKBL(LoadFX_sscanf, pGTASA + 0x559F78); 391 | } 392 | 393 | // Fixes Corona sprites stretching at foggy weather 394 | if(cfg->GetBool("FixCoronasStretching", true, "Visual")) 395 | { 396 | aml->Write32(pGTASA + 0x6C6120, 0x1E204044); 397 | } 398 | 399 | // BengbuGuards' idea #1 400 | if(cfg->GetBool("FixSecondSiren", true, "Gameplay")) 401 | { 402 | aml->PlaceNOP(pGTASA + 0x6B41E8, 1); 403 | aml->PlaceNOP(pGTASA + 0x6B4214, 1); 404 | } 405 | 406 | // Spread fix 407 | if(cfg->GetBool("WeaponSpreadFix", true, "Gameplay")) 408 | { 409 | HOOK(FireInstantHit, aml->GetSym(hGTASA, "_ZN7CWeapon14FireInstantHitEP7CEntityP7CVectorS3_S1_S3_S3_bb")); 410 | } 411 | 412 | // Renders shadows on all surfaces -> disables a flag 413 | if(cfg->GetBool("DrawShadowsOnAllSurfaces", true, "Visual")) 414 | { 415 | aml->Write32(pGTASA + 0x6DF67C, 0x52800033); 416 | } 417 | 418 | // Game is checking if HP is < 1.0 but it may be lower! 419 | if(cfg->GetBool("AllowCrouchWith1HP", true, "Gameplay")) 420 | { 421 | aml->Write32(pGTASA + 0x660DC8, 0x1E281001); 422 | } 423 | 424 | // Vehicle sun glare 425 | if(cfg->GetBool("VehicleSunGlare", true, "Visual")) 426 | { 427 | HOOK(RenderVehicle_SunGlare, aml->GetSym(hGTASA, "_ZN8CVehicle6RenderEv")); 428 | } 429 | 430 | // Minimap in interiors? Hell nah! 431 | if(cfg->GetBool("NoInteriorRadar", true, "Visual")) 432 | { 433 | HOOK(DrawRadar, pGTASA + 0x51CFF0); 434 | } 435 | 436 | // Fix greenish detail tex 437 | if(cfg->GetBool("FixGreenTextures", true, "Visual")) 438 | { 439 | aml->PlaceNOP(pGTASA + 0x2418B8, 1); // Dont set textureDetail variable! We'll handle it by ourselves! 440 | HOOK(emu_TextureSetDetailTexture, aml->GetSym(hGTASA, "_Z27emu_TextureSetDetailTexturePvj")); 441 | } 442 | 443 | // Radar 444 | if(cfg->GetBool("FixRadarStreaming", true, "Visual")) 445 | { 446 | aml->PlaceB(pGTASA + 0x5283D4, pGTASA + 0x5283EC); 447 | } 448 | 449 | // AllowLicensePlatesForAllCars 450 | if(cfg->GetBool("AllowLicensePlatesForAllCars", true, "Visual")) 451 | { 452 | aml->PlaceB(pGTASA + 0x6A5E84, pGTASA + 0x6A5EC8); 453 | aml->PlaceB(pGTASA + 0x6A5F58, pGTASA + 0x6A5F68); 454 | } 455 | 456 | // Show muzzle flash for the last bullet in magazine 457 | if(cfg->GetBool("MuzzleFlashForLastBullet", true, "Visual")) 458 | { 459 | aml->PlaceNOP(pGTASA + 0x5DFF28, 1); 460 | } 461 | 462 | // Random license plates 463 | if(cfg->GetBool("RandomLicensePlates", true, "Visual")) 464 | { 465 | HOOKBL(GetCustomCarPlateText_SetModelIdx, pGTASA + 0x6A6668); 466 | } 467 | 468 | // Fix "You have worked out enough for today, come back tomorrow!" 469 | if(cfg->GetBool("FixGymWorkoutDate", true, "SCMFixes")) 470 | { 471 | Opcode0835_BackTo = pGTASA + 0x403768; 472 | aml->Redirect(pGTASA + 0x401E84, (uintptr_t)Opcode0835_Inject); 473 | } 474 | 475 | // Michelle dating fix 476 | if(cfg->GetBool("MichelleDatingFix", true, "SCMFixes")) 477 | { 478 | Opcode039E_BackTo = pGTASA + 0x415DA0; 479 | aml->Redirect(pGTASA + 0x414798, (uintptr_t)Opcode039E_Inject); 480 | } 481 | 482 | // Inverse swimming controls to dive/go up (to match PC version) 483 | if(cfg->GetBool("InverseSwimmingDivingControl", true, "Gameplay")) 484 | { 485 | HOOK(TaskSwim_ProcessInput, pGTASA + 0x6569C4); 486 | HOOKBL(GetPedWalkUpDown_Swimming, pGTASA + 0x656A1C); 487 | aml->Write32(pGTASA + 0x6571F4, 0xD000072A); 488 | aml->Write32(pGTASA + 0x6571F8, 0xBD4E9D44); 489 | } 490 | 491 | // Guess by the name 492 | if(cfg->GetBool("FixParachuteLandingAnim", true, "Visual")) 493 | { 494 | HOOKPLT(PlayerInfoProcess_ParachuteAnim, pGTASA + 0x846998); 495 | } 496 | 497 | // Unused detonator animation is in the ped.ifp, lol 498 | if(cfg->GetBool("UnusedDetonatorAnimation", true, "Visual")) 499 | { 500 | HOOKPLT(UseDetonator, pGTASA + 0x840048); 501 | } 502 | 503 | // Taxi lights (obviously) 504 | if(cfg->GetBool("TaxiLights", true, "Visual")) 505 | { 506 | HOOK(AutomobileRender, aml->GetSym(hGTASA, "_ZN11CAutomobile6RenderEv")); 507 | } 508 | 509 | // Fix Adjustable.cfg loading? 510 | // UPD: Introduced another glitch, so its unfixed. yet. 511 | // UD2: Fixed with a much better way. But another glitch arrived with X-coord shifting 512 | if(cfg->GetBool("FixAdjustableSizeLowering", true, "Visual")) 513 | { 514 | aml->Write32(pGTASA + 0x33D6E8, 0x1E229000); 515 | } 516 | 517 | // Classic CJ shadow 518 | if(cfg->GetBool("FixClassicCJShadow", true, "Gameplay")) 519 | { 520 | aml->PlaceB(pGTASA + 0x6DCFF0, pGTASA + 0x6DD014); 521 | } 522 | 523 | // Car Slowdown Fix 524 | if(cfg->GetBool("FixCarSlowdownHighFPS", true, "Gameplay")) 525 | { 526 | HOOKPLT(ProcessVehicleWheel, pGTASA + 0x83FE78); 527 | HOOKPLT(ProcessBikeWheel, pGTASA + 0x846A90); 528 | } 529 | 530 | // Fix Skimmer plane 531 | if (cfg->GetBool("SkimmerPlaneFix", true, "Gameplay")) 532 | { 533 | //SkimmerWaterResistance_BackTo = pGTASA + 0x6AD4D8; 534 | //aml->Redirect(pGTASA + 0x6AD4C8, (uintptr_t)SkimmerWaterResistance_Inject); 535 | HOOK(ApplyBoatWaterResistance, pGTASA + 0x6AD450); 536 | } 537 | 538 | // Cinematic vehicle camera on double tap 539 | if(cfg->GetBool("CinematicCameraOnDoubleTap", true, "Gameplay")) 540 | { 541 | HOOKPLT(PlayerInfoProcess_Cinematic, pGTASA + 0x846998); 542 | } 543 | 544 | // RE3: Make cars and peds to not despawn when you look away 545 | if(cfg->GetBool("Re3_ExtOffscreenDespRange", true, "Gameplay")) 546 | { 547 | aml->PlaceB(pGTASA + 0x3B06E0, pGTASA + 0x3B0728); // Vehicles 548 | aml->PlaceB(pGTASA + 0x5CDAF8, pGTASA + 0x5CDBE4); // Peds 549 | } 550 | 551 | // Dont kill peds when jacking their car, monster! 552 | if(cfg->GetBool("DontKillPedsOnCarJacking", true, "Gameplay")) 553 | { 554 | aml->PlaceB(pGTASA + 0x5FF4C4, pGTASA + 0x5FF4DC); 555 | } 556 | 557 | // Equipped parachute attacked anim fix 558 | if(cfg->GetBool("EquippedParaAttackAnimFix", true, "Visual")) 559 | { 560 | HOOK(ComputeDamageAnim, aml->GetSym(hGTASA, "_ZN12CEventDamage17ComputeDamageAnimEP4CPedb")); 561 | } 562 | 563 | if(cfg->GetBool("DisableCloudSaves", false, "Gameplay")) 564 | { 565 | aml->Write8(aml->GetSym(hGTASA, "UseCloudSaves"), 0x00); 566 | } 567 | 568 | // Always show wanted stars even if we're not breakin the law 569 | if(cfg->GetBool("AlwaysDrawWantedStars", false, "Visual")) 570 | { 571 | aml->PlaceB(pGTASA + 0x37E174, pGTASA + 0x37E1A4); 572 | } 573 | 574 | // An improved ForceDXT 575 | if(cfg->GetBool("ForceLoadDXT", false, "Gameplay")) 576 | { 577 | HOOK(LoadTexDBThumbs, aml->GetSym(hGTASA, "_ZN22TextureDatabaseRuntime4LoadEPKcb21TextureDatabaseFormat")); 578 | } 579 | 580 | // Car generators in an interior now work properly 581 | if(cfg->GetBool("CorrectPoliceScannerLocations", true, "Gameplay")) 582 | { 583 | aml->Write(pGTASA + 0x74AC98, "WESTP", 6); 584 | aml->Write(pGTASA + 0x74AD40, "????", 5); 585 | } 586 | 587 | // Fix wheels rotation speed on high FPS 588 | if(cfg->GetBool("FixWheelsRotationSpeed", true, "Visual")) 589 | { 590 | HOOKBL(ProcessWheelRotation_FPS, pGTASA + 0x67875C); 591 | } 592 | 593 | // Reflections are based on player's neck when it's not a cutscene (WTF???) 594 | if(cfg->GetBool("FixReflectionsCenter", true, "Visual")) 595 | { 596 | aml->PlaceNOP(pGTASA + 0x6E9508); 597 | } 598 | 599 | // Reflection's quality 600 | if(cfg->GetBool("DoubleReflectionsRenderSize", true, "Visual")) 601 | { 602 | aml->Write32(pGTASA + 0x6E8F60, 0x52808009); 603 | } 604 | 605 | // Fix FX memory leak 606 | if(cfg->GetBool("FixFXLeak", true, "Gameplay")) 607 | { 608 | HOOKPLT(FxInfoMan_FXLeak, pGTASA + 0x841D00); 609 | } 610 | 611 | // Bigger distance for light coronas 612 | if(cfg->GetBool("BuffDistForLightCoronas", true, "Visual")) 613 | { 614 | aml->Write32(pGTASA + 0x6C7A68, 0xF0000389); // CEntity::ProcessLightsForEntity 615 | aml->Write32(pGTASA + 0x6C7A78, 0xBD4C1520); // CEntity::ProcessLightsForEntity 616 | 617 | aml->Write32(pGTASA + 0x4331A0, 0xF0001828); // CTrafficLights::DisplayActualLight 618 | aml->Write32(pGTASA + 0x4331A4, 0xBD4C1506); // CTrafficLights::DisplayActualLight 619 | 620 | aml->Write32(pGTASA + 0x6864C0, 0x900005AA); // CBike::PreRender 621 | aml->Write32(pGTASA + 0x6864E8, 0xBD4C1541); // CBike::PreRender 622 | 623 | aml->Write32(pGTASA + 0x686434, 0x900005AA); // CBike::PreRender 624 | aml->Write32(pGTASA + 0x68645C, 0xBD4C1541); // CBike::PreRender 625 | 626 | aml->Write32(pGTASA + 0x695F18, 0xB0000529); // CHeli::SearchLightCone 627 | aml->Write32(pGTASA + 0x695F3C, 0xBD4C1529); // CHeli::SearchLightCone 628 | 629 | aml->Write32(pGTASA + 0x67ADC0, 0x90000608); // CAutomobile::PreRender 630 | aml->Write32(pGTASA + 0x67ADD0, 0xBD4C1503); // CAutomobile::PreRender 631 | 632 | aml->Write32(pGTASA + 0x67B0B4, 0xF00005E9); // CAutomobile::PreRender 633 | aml->Write32(pGTASA + 0x67B0C8, 0xBD4C152B); // CAutomobile::PreRender 634 | 635 | aml->Write32(pGTASA + 0x67C1AC, 0xD00005E8); // CAutomobile::PreRender 636 | aml->Write32(pGTASA + 0x67C1B4, 0xBD4C1501); // CAutomobile::PreRender 637 | } 638 | 639 | // Bigger distance for light shadows 640 | if(cfg->GetBool("BuffDistForLightShadows", true, "Visual")) 641 | { 642 | aml->Write32(pGTASA + 0x4331A4, 0xBD419506); // CTrafficLights::DisplayActualLight, 40 -> 120 643 | aml->Write32(pGTASA + 0x4D3904, 0xBD419508); // CFireManager::Update, 40 -> 120 644 | fLightDist = 120.0f; // For thingies below \/ 645 | } 646 | 647 | // Bring back light shadows from poles! 648 | if(cfg->GetBool("BackPolesLightShadow", true, "Visual")) 649 | { 650 | HOOKBL(GetBaseEffect_AddLight, pGTASA + 0x6C7AC0); 651 | HOOKPLT(ProcessLightsForEntity_ItSelf, pGTASA + 0x849858); 652 | HOOKBL(ProcessLightsForEntity_AddLight, pGTASA + 0x6C8564); 653 | HOOKBL(ProcessLightsForEntity_AddLight, pGTASA + 0x6C84F8); 654 | 655 | // We are not passing argument "pArgCastingEntity" (always NULL) 656 | // We will use it for "bCurrentlyActive" variable. 657 | aml->Write32(pGTASA + 0x6C84EC, 0x2A1A03E3); 658 | aml->Write32(pGTASA + 0x6C8560, 0x2A1A03E3); 659 | } 660 | 661 | // Allows the game to render even more light shadows on the ground 662 | if(cfg->GetBool("BuffStaticShadowsCount", true, "Gameplay")) 663 | { 664 | // Static shadows? 665 | asShadowsStored_NEW = new CRegisteredShadow[0xFF + 1]; memset(asShadowsStored_NEW, 0, sizeof(CRegisteredShadow) * (0xFF + 1)); 666 | aStaticShadows_NEW = new CStaticShadow[0xFF + 1] {0}; memset(aStaticShadows_NEW, 0, sizeof(CStaticShadow) * (0xFF + 1)); 667 | aml->Write(pGTASA + 0x84D7F8, (uintptr_t)&asShadowsStored_NEW, sizeof(void*)); 668 | aml->Write(pGTASA + 0x8511F8, (uintptr_t)&aStaticShadows_NEW, sizeof(void*)); 669 | 670 | // Registered Shadows: 671 | // CShadows::StoreShadowToBeRendered 672 | aml->Write32(pGTASA + 0x6DDC3C, 0xF103F93F); 673 | aml->Write32(pGTASA + 0x6DDC5C, 0xF103F93F); 674 | aml->Write32(pGTASA + 0x6DDC7C, 0xF103F93F); 675 | aml->Write32(pGTASA + 0x6DDC9C, 0xF103F93F); 676 | aml->Write32(pGTASA + 0x6DDCBC, 0xF103F93F); 677 | aml->Write32(pGTASA + 0x6DDCE8, 0xF103F93F); 678 | // CShadows::StoreShadowToBeRendered (2nd arg is RwTexture*) 679 | aml->Write32(pGTASA + 0x6DDD74, 0xF103F93F); 680 | // CShadows::StoreShadowForVehicle 681 | aml->Write32(pGTASA + 0x6DE328, 0x7103F95F); 682 | aml->Write32(pGTASA + 0x6DE37C, 0x7103F95F); 683 | // CShadows::StoreShadowForPedObject 684 | aml->Write32(pGTASA + 0x6DE738, 0xF103F95F); 685 | // CShadows::StoreRealTimeShadow 686 | aml->Write32(pGTASA + 0x6DEA5C, 0xF103F93F); 687 | // CShadows::RenderExtraPlayerShadows 688 | aml->Write32(pGTASA + 0x6E2480, 0x7103F93F); 689 | aml->Write32(pGTASA + 0x6E24A4, 0x7103F93F); 690 | 691 | // Static Shadows: 692 | // CShadows::StoreStaticShadow 693 | aml->Write32(pGTASA + 0x6DD798, 0xF103FD1F); 694 | aml->Write32(pGTASA + 0x6DD7C4, 0x7103FD7F); 695 | // CShadows::RenderStaticShadows 696 | aml->Write32(pGTASA + 0x6E024C, 0xF104025F); 697 | aml->Write32(pGTASA + 0x6E0260, 0xF104029F); 698 | // CShadows::UpdateStaticShadows 699 | aml->Write32(pGTASA + 0x6E1BB4, 0xF104011F); 700 | 701 | HOOKPLT(RenderStaticShadows, pGTASA + 0x846A00); 702 | HOOKPLT(InitShadows, pGTASA + 0x83EFC0); 703 | } 704 | 705 | // Can now use a gun! 706 | if(cfg->GetBool("HighFPSAimingWalkingFix", true, "Gameplay")) 707 | { 708 | aml->Write32(pGTASA + 0x5DF790, 0x90000AA9); 709 | aml->Write32(pGTASA + 0x5DF794, 0xBD48D521); 710 | } 711 | 712 | // Max mobilesc0,mobilesc1,...,mobilesc### for us 713 | mobilescCount = cfg->GetInt("MaxLoadingScreens", 7, "Visual"); 714 | if(mobilescCount > 0 && mobilescCount != 7) 715 | { 716 | HOOKBL(LoadSplash_sscanf, pGTASA + 0x520154); 717 | } 718 | 719 | // Fix water cannon on a high fps 720 | if(cfg->GetBool("FixHighFPSWaterCannons", true, "Gameplay")) 721 | { 722 | aml->PlaceNOP(pGTASA + 0x6EF5AC); 723 | aml->Write32(pGTASA + 0x6EF598, 0xD0000249); 724 | aml->Write32(pGTASA + 0x6EF59C, 0xBD4EF520); 725 | } 726 | 727 | // Fix moving objects on a high fps (through the scripts) 728 | if(cfg->GetBool("FixHighFPSOpcode034E", true, "SCMFixes")) 729 | { 730 | HOOKBL(CollectParams_034E, pGTASA + 0x4129B8); 731 | } 732 | 733 | // Fix pushing force 734 | if(cfg->GetBool("FixPhysicalPushForce", true, "Gameplay")) 735 | { 736 | HOOKBL(ApplyForce_Collision, pGTASA + 0x4E6634); 737 | HOOKBL(ApplyForce_Collision, pGTASA + 0x4E6A04); 738 | } 739 | 740 | // Increase intensity of vehicle tail light corona (MTA:SA) 741 | // Is this even working on Android? 742 | if(cfg->GetBool("IncreaseTailLightIntensity", true, "Gameplay")) 743 | { 744 | aml->Write32(pGTASA + 0x6B503C, 0x52801E05); 745 | } 746 | 747 | // THROWN projectiles throw more accurately (MTA:SA) 748 | if(cfg->GetBool("ThrownProjectilesAccuracy", true, "Gameplay")) 749 | { 750 | aml->PlaceB(pGTASA + 0x700F70, pGTASA + 0x701074); 751 | } 752 | 753 | // Fix red marker that cannot be placed in a menu on ultrawide screens 754 | // Kinda trashy fix... 755 | // This glitch is annoying me on v2.10!!! Time to fix it!!! 756 | if(cfg->GetBool("FixRedMarkerUnplaceable", true, "Gameplay")) 757 | { 758 | aml->Write32(pGTASA + 0x368D20, 0xF0001E49); 759 | aml->Write32(pGTASA + 0x368D24, 0xBD48C920); 760 | aml->Write32(pGTASA + 0x368D54, 0x1E2D1863); 761 | HOOK(PlaceRedMarker_MarkerFix, pGTASA + 0x3688A0); 762 | } 763 | 764 | // Can now rotate the camera inside the heli/plane? 765 | // https://github.com/TheOfficialFloW/gtasa_vita/blob/6417775e182b0c8b789cc9a0c1161e6f1b43814f/loader/main.c#L736 766 | if(cfg->GetBool("UnstuckHeliCamera", true, "Gameplay")) 767 | { 768 | aml->Write32(pGTASA + 0x4A02E0, 0xD2800000); 769 | aml->Write32(pGTASA + 0x4A0E94, 0xD2800000); 770 | aml->Write32(pGTASA + 0x4A1258, 0xD2800000); 771 | aml->Write32(pGTASA + 0x4DF9F0, 0xD2800000); 772 | aml->Write32(pGTASA + 0x4DFDB4, 0xD2800000); 773 | } 774 | 775 | // An ability to remove FOV-effect while driving a car 776 | if(cfg->GetBool("NoVehicleFOVEffect", false, "Gameplay")) 777 | { 778 | aml->PlaceNOP(pGTASA + 0x4A025C, 1); 779 | aml->PlaceNOP(pGTASA + 0x4A02A4, 1); 780 | aml->PlaceNOP(pGTASA + 0x4A02C8, 1); 781 | } 782 | 783 | // Disable GTA vehicle detachment at rotation awkwardness 784 | if(cfg->GetBool("FixVehicleDetachmentAtRot", true, "Visual")) 785 | { 786 | aml->PlaceB(pGTASA + 0x4EA3B8, pGTASA + 0x4EA5D0); 787 | } 788 | 789 | // Now all vehicles should have a shadow 790 | if(cfg->GetBool("FixVehicleShadows", true, "Visual")) 791 | { 792 | aml->PlaceNOP(pGTASA + 0x6DDEFC); 793 | aml->PlaceNOP(pGTASA + 0x6DDF04); 794 | aml->PlaceNOP(pGTASA + 0x6DE028); 795 | aml->PlaceB(pGTASA + 0x6DDF14, pGTASA + 0x6DDFDC); 796 | HOOKPLT(TrainPreRender, pGTASA + 0x83D0E8); 797 | HOOKPLT(BoatPreRender, pGTASA + 0x83C330); 798 | } 799 | 800 | // That's for the fix above. Cuz they're ugly as hell by default, EWWW... 801 | if(cfg->GetBool("BiggerCarShadowsDistance", true, "Visual")) 802 | { 803 | aml->Write32(pGTASA + 0x6DDFE0, 0x900002E9); 804 | aml->Write32(pGTASA + 0x6DDFE4, 0xBD418922); 805 | aml->Write32(pGTASA + 0x6DDFE8, 0x1E204041); 806 | } 807 | 808 | // Drawing shadows as it's classic shadows for really far vehicles 809 | if(cfg->GetBool("DrawCarShadowsClassicAtDist", true, "Visual")) 810 | { 811 | aml->Write32(pGTASA + 0x6DDFFC, 0x5400220A); 812 | } 813 | 814 | // The fix "PCDirLightsCount" is not gonna work now. So lets remove an optimisation instead. 815 | if(cfg->GetBool("BiggerLightsCountOutside", true, "Visual")) 816 | { 817 | aml->Write32(pGTASA + 0x6F621C, 0x52800075); 818 | aml->PlaceNOP(pGTASA + 0x6F6220, 1); 819 | } 820 | 821 | // Missing effects that are on PC but not on Mobile (from SkyGFX) 822 | if(cfg->GetBool("CutEffects", true, "Visual")) 823 | { 824 | aml->PlaceNOP(pGTASA + 0x6DA9E0, 1); 825 | HOOKPLT(RenderPostEffects, pGTASA + 0x842CF0); 826 | HOOK(PostProcess_CCTV, pGTASA + 0x6DA0B4); 827 | HOOKPLT(RenderEffects_WaterCannons, pGTASA + 0x8426F0); 828 | HOOKBL(SpeedFX_Raster, pGTASA + 0x6D8E08); 829 | HOOKB(SpeedFX_RestoreStates, pGTASA + 0x6D8EC4); 830 | } 831 | 832 | // Cant skip drive 833 | if(cfg->GetBool("BringBackTripSkip", true, "Gameplay")) 834 | { 835 | skiptripChangeTex = cfg->GetBool("BringBackSkipButton_Texture", skiptripChangeTex, "Gameplay"); 836 | SET_TO(bDisplayedSkipTripMessage, pGTASA + 0xC20E90); 837 | HOOKB(UpdateSkip_SkipCanBeActivated, pGTASA + 0x3CEA24); 838 | HOOKPLT(DrawHud_SkipTrip, pGTASA + 0x848C48); 839 | } 840 | 841 | // A particles with "check ground" flag are falling through the world 842 | if(cfg->GetBool("ParticlesJumpOffGround", true, "Visual")) 843 | { 844 | HOOKPLT(FXInfoGroundCollide_GetVal, pGTASA + 0x82C6C0); 845 | bCheckMoreObjects = cfg->GetBool("ParticlesJumpOffGround_CheckObjects", true); 846 | } 847 | 848 | // OpenGL-related crash in huawei (poop ass phone moment) 849 | if(cfg->GetBool("FixHuaweiCrash", true, "Gameplay")) 850 | { 851 | void* sym; 852 | if((sym = TryLoadAlphaFunc("libGLESv2.so")) || (sym = TryLoadAlphaFunc("libGLESv3.so")) || 853 | (sym = TryLoadAlphaFunc("libGLESv2_mtk.so")) || (sym = TryLoadAlphaFunc("libGLES_mali.so")) || 854 | (sym = TryLoadAlphaFunc("libGLES_android.so")) || (sym = TryLoadAlphaFunc("libGLES.so"))) 855 | { 856 | *(void**)(pGTASA + 0x89A1B0) = sym; 857 | } 858 | } 859 | 860 | // Fix 861 | if(cfg->GetBool("FixCruisingVehiclesSpeed", true, "Gameplay")) 862 | { 863 | //HOOKBL(CurvePoint_SpeedFPS, pGTASA + 0x3AD0A4); 864 | //HOOKBL(CurvePoint_SpeedFPS, pGTASA + 0x3B0F60); 865 | HOOKPLT(CurvePoint_SpeedFPS, pGTASA + 0x844DA8); 866 | } 867 | 868 | // Fix a dumb Android 10+ RLEDecompress fix crash (that's an issue of TXD tools) 869 | if(cfg->GetBool("RLEDecompressCrashFix", androidSdkVer < 33, "Gameplay")) 870 | { 871 | aml->Write(pGTASA + 0x2858CC, "\x14\x81\x00\x11", 4); 872 | } 873 | 874 | // Fixes some stupid issues that are caused my WarDrum's dirty hands 875 | if(cfg->GetBool("FixNearClippingIssues", true, "Visual")) 876 | { 877 | aml->Write32(pGTASA + 0x4D8664, 0x1E204120); 878 | } 879 | 880 | // Fixes that some data in CollisionData is not being set to zero 881 | if(cfg->GetBool("FixCollisionAllocatingData", true, "Gameplay")) 882 | { 883 | HOOK(ColModel_AllocData, aml->GetSym(hGTASA, "_ZN9CColModel12AllocateDataEiiiiib")); 884 | // Maybe also in CColModel::MakeMultipleAlloc? 885 | } 886 | 887 | // Fixes a little Rockstar mistake with coronas rendering 888 | if(cfg->GetBool("FixSomeCoronasRendering", true, "Gameplay")) 889 | { 890 | HOOKBL(CoronasRender_Headlight, pGTASA + 0x6C6300); 891 | } 892 | 893 | // SilentPatchSA: ImpoundGarages 894 | if(cfg->GetBool("FixImpoundGarages", true, "Gameplay")) 895 | { 896 | aml->Write32(pGTASA + 0x3B05BC, 0x97F9C489); 897 | aml->Write32(pGTASA + 0x3B0674, 0x97F9C45B); 898 | aml->Write32(pGTASA + 0x3B07BC, 0x97F9C409); 899 | aml->PlaceNOP(pGTASA + 0x3CE088, 1); 900 | } 901 | 902 | // SilentPatchSA: Bigger mirrors quality 903 | if(cfg->GetBool("BiggerMirrorsQuality", true, "Visual")) 904 | { 905 | aml->Write32(pGTASA + 0x6E8EB4, 0x52810000); 906 | aml->Write32(pGTASA + 0x6E8EB8, 0x52808001); 907 | 908 | aml->Write32(pGTASA + 0x6E8ED0, 0x52810000); 909 | aml->Write32(pGTASA + 0x6E8ED4, 0x52808001); 910 | } 911 | 912 | // Faml->Write32weird ass glitches with the timer value clamping 913 | if(cfg->GetBool("FixHighFPSTimer", true, "Gameplay")) 914 | { 915 | aml->Write32(pGTASA + 0x5045F4, 0xD00010AB); 916 | aml->Write32(pGTASA + 0x504600, 0xBD41E161); 917 | } 918 | 919 | // Allowes gang wars to have a wanted level (like on PC) 920 | if(cfg->GetBool("AllowGangWarsWantedLvl", true, "Gameplay")) 921 | { 922 | aml->PlaceNOP4(pGTASA + 0x4DBB8C, 1); 923 | aml->PlaceNOP4(pGTASA + 0x4DBB9C, 1); 924 | aml->PlaceNOP4(pGTASA + 0x4DBBBC, 1); 925 | aml->PlaceNOP4(pGTASA + 0x4DBBCC, 1); 926 | } 927 | 928 | // Fixing drunk camera on high FPS 929 | if(cfg->GetBool("FixDrunkCameraHighFPS", true, "Visual")) 930 | { 931 | HOOKPLT(CameraProcess_HighFPS, pGTASA + 0x8429D8); 932 | } 933 | 934 | // When headlights are active, the windows are no longer transparent from one side. 935 | if(cfg->GetBool("FixWindowsCullingWithHeadlights", true, "Visual")) 936 | { 937 | aml->Write32(pGTASA + 0x6B4B00, 0x52800021); 938 | } 939 | 940 | // SilentPatch: Skimmer 20th Anniversary glitch (doesnt happen for us but set it to PC values) 941 | if(cfg->GetBool("Skimmer20HandlingLittleFix", true, "Gameplay")) 942 | { 943 | aml->Write32(pGTASA + 0x554EDC, 0x290D27E9); 944 | aml->Write32(pGTASA + 0x554ED0, 0x52A7E68A); 945 | } 946 | 947 | // Skip that dumb EULA. We accepted it years ago, shut up 948 | /*if(cfg->GetBool("SkipAnnoyingEULA", true, "Gameplay")) 949 | { 950 | aml->Write8(aml->GetSym(hSC, "LegalScreenShown"), 0x01); 951 | }*/ 952 | 953 | // This fixes black bushes and more things 954 | //if(cfg->GetBool("FixCamNormColorOverflow", true, "Visual")) 955 | { 956 | //HOOKBL(VTXShader_CamBasedNormal_snprintf, pGTASA + 0x264944); 957 | } 958 | 959 | 960 | 961 | 962 | 963 | 964 | 965 | 966 | 967 | 968 | 969 | // Searchlights are too fast... (TODO: untested lol, there's no sqrtf at these addresses) 970 | /*if(cfg->GetBool("FixSearchlightHighFPS", true, "Gameplay")) 971 | { 972 | HOOKBL(SearchLight_sqrtf, pGTASA + 0x425C2C); 973 | HOOKBL(SearchLight_sqrtf, pGTASA + 0x425D5C); 974 | HOOKBL(SearchLight_sqrtf, pGTASA + 0x425CA0); 975 | HOOKBL(SearchLight_sqrtf, pGTASA + 0x425CF8); 976 | }*/ 977 | 978 | // Fixes a weird glitch from there: https://github.com/multitheftauto/mtasa-blue/issues/1123 979 | //if(cfg->GetBool("MTA_FixProjectiles", true, "Gameplay")) 980 | //{ 981 | // aml->PlaceB(pGTASA + 0x6FEB6C, pGTASA + 0x6FEC84); 982 | //} 983 | 984 | // Camera is saving screenshots? 985 | /*if(cfg->GetBool("FixScreenGrabber", true, "Gameplay")) 986 | { 987 | // 821F20 988 | 989 | HOOK(Patch_psGrabScreen, aml->GetSym(hGTASA, "_Z12psGrabScreenP8RwCamera")); 990 | //HOOKBL(TakePhoto, pGTASA + 0x7010EC); 991 | //HOOKBL(ShowRasterIdle, pGTASA + 0x4D8FE0); 992 | HOOKBL(ShowRasterIdle, pGTASA + 0x4D9254); 993 | HOOKBL(jpeg_samplecopy, pGTASA + 0x56A0E8); 994 | HOOKBL(jpeg_samplecopy, pGTASA + 0x56A1EC); 995 | }*/ 996 | -------------------------------------------------------------------------------- /patches/preparations_vc.inl: -------------------------------------------------------------------------------- 1 | // Boat and Skimmer on high FPS 2 | if(cfg->GetBool("HighFPSBoatSpeed", true, "Gameplay")) 3 | { 4 | Boat_ApplyWaterResistance_BackTo = pGTAVC + 0x247650 + 0x1; 5 | aml->Redirect(pGTAVC + 0x247648 + 0x1, (uintptr_t)Boat_ApplyWaterResistance_Inject); 6 | } 7 | 8 | // Fix wheels rotation speed on high FPS 9 | if(cfg->GetBool("FixWheelsRotationSpeed", true, "Visual")) 10 | { 11 | aml->Redirect(pGTAVC + 0x2584EC + 0x1, (uintptr_t)ProcessWheelRotation_Inject); 12 | } 13 | 14 | // Car Slowdown Fix 15 | if(cfg->GetBool("FixCarSlowdownHighFPS", true, "Gameplay")) 16 | { 17 | HOOK(ProcessWheel_SlowDownFix, aml->GetSym(hGTAVC, "_ZN8CVehicle12ProcessWheelER7CVectorS1_S1_S1_ifffcPfP11tWheelStatet")); 18 | HOOK(ProcessBikeWheel_SlowDownFix, aml->GetSym(hGTAVC, "_ZN8CVehicle16ProcessBikeWheelER7CVectorS1_S1_S1_iffffcPfP11tWheelState17eBikeWheelSpecialt")); 19 | } 20 | 21 | // Fix heli rotor rotation speed on high FPS 22 | if(cfg->GetBool("FixRotorRotationSpeed", true, "Visual")) 23 | { 24 | HOOKBL(HeliRender_MatrixUpdate, pGTAVC + 0x254F76 + 0x1); 25 | } 26 | 27 | // Fixes a streaming distance that gets bugged because of dumb R* logic (aspect ratio moment) 28 | if(cfg->GetBool("FixStreamingDistance", true, "Visual")) 29 | { 30 | CameraProcess_StreamDist_BackTo = pGTAVC + 0x13FB34 + 0x1; 31 | aml->Redirect(pGTAVC + 0x13FB1A + 0x1, (uintptr_t)CameraProcess_StreamDist_Inject); 32 | HOOK(SetFOV_StreamingDistFix, aml->GetSym(hGTAVC, "_ZN5CDraw6SetFOVEf")); 33 | 34 | aml->PlaceNOP(pGTAVC + 0x13FB0C + 0x1, 1); 35 | aml->Write(pGTAVC + 0x13FB0E, "\x9F\xED\xBB\x7A", 4); 36 | aml->Write(pGTAVC + 0x13FB12, "\xD7\xED\x0E\x6A", 4); 37 | aml->Write(pGTAVC + 0x13FB16, "\xF4\xEE\xC7\x6A", 4); 38 | } 39 | 40 | // Fixing fat ass coronas 41 | if(cfg->GetBool("FixCoronasAspectRatio", true, "Visual")) 42 | { 43 | HOOK(CoronaSprite_CalcScreenCoors, aml->GetSym(hGTAVC, "_ZN7CSprite15CalcScreenCoorsERK5RwV3dPS0_PfS4_b")); 44 | } 45 | 46 | // Fix Vertex Weights 47 | if(cfg->GetBool("FixVertexWeight", true, "Visual")) 48 | { 49 | VertexWeightFix_BackTo1 = pGTAVC + 0x28EA7A + 0x1; 50 | VertexWeightFix_BackTo2 = pGTAVC + 0x28EAA4 + 0x1; 51 | aml->Redirect(pGTAVC + 0x28E970 + 0x1, (uintptr_t)VertexWeightFix_Inject); 52 | } 53 | 54 | // RE3: Fix R* optimization that prevents peds to spawn 55 | if(cfg->GetBool("Re3_PedSpawnDeoptimize", true, "Gameplay")) 56 | { 57 | aml->Write(pGTAVC + 0x14CA68, (uintptr_t)"\x02", 1); 58 | } 59 | 60 | // RE3: Road reflections 61 | if(cfg->GetBool("Re3_WetRoadsReflections", true, "Visual")) 62 | { 63 | aml->Write(pGTAVC + 0x1D6552, "\x10\x9A", 2); 64 | } 65 | 66 | // Fix traffic lights 67 | if(cfg->GetBool("FixTrafficLights", true, "Visual")) 68 | { 69 | HOOK(TrFix_RenderEffects, pGTAVC + 0x201FC4 + 0x1); 70 | 71 | // Why does vehicle's lights are in that list?! 72 | aml->PlaceNOP4(pGTAVC + 0x231138 + 0x1, 1); 73 | aml->PlaceNOP4(pGTAVC + 0x231198 + 0x1, 1); 74 | aml->PlaceNOP4(pGTAVC + 0x2334C4 + 0x1, 1); 75 | aml->PlaceNOP4(pGTAVC + 0x233C16 + 0x1, 1); 76 | aml->PlaceNOP4(pGTAVC + 0x233CDE + 0x1, 1); 77 | aml->PlaceNOP4(pGTAVC + 0x235574 + 0x1, 1); 78 | aml->PlaceNOP4(pGTAVC + 0x23579E + 0x1, 1); 79 | 80 | // Why does bike's lights are in that list?! 81 | aml->PlaceNOP4(pGTAVC + 0x240E98 + 0x1, 1); 82 | aml->PlaceNOP4(pGTAVC + 0x240FD2 + 0x1, 1); 83 | aml->PlaceNOP4(pGTAVC + 0x241052 + 0x1, 1); 84 | aml->PlaceNOP4(pGTAVC + 0x2410C8 + 0x1, 1); 85 | aml->PlaceNOP4(pGTAVC + 0x2414B8 + 0x1, 1); 86 | } 87 | 88 | // Fixes framelimiter (doesnt limit the FPS, ayo lol) 89 | // P.S. IT WAS NEVER WORKING, OH MY GOD 90 | if(cfg->GetBool("FixGameTimer", true, "Gameplay")) 91 | { 92 | aml->PlaceB(pGTAVC + 0x21E7C4 + 0x1, pGTAVC + 0x21E7CC + 0x1); 93 | HOOKBL(GameTick_TouchscreenUpdate, pGTAVC + 0x21E7D6 + 0x1); 94 | HOOK(OS_ScreenSetRefresh, aml->GetSym(hGTAVC, "_Z19OS_ScreenSetRefreshj")); 95 | 96 | aml->Write8(pGTAVC + 0x21E994, 0x1E); 97 | } 98 | 99 | // Fix water scroll speed on high FPS 100 | if(cfg->GetBool("FixWaterUVScrollSpeed", true, "Visual")) 101 | { 102 | RenderWater_BackTo = pGTAVC + 0x2645D2 + 0x1; 103 | aml->Redirect(pGTAVC + 0x2645C6 + 0x1, (uintptr_t)RenderWater_Inject); 104 | } 105 | 106 | // Bringing back missing render states (WarDumb`s optimization) 107 | /*if(cfg->GetBool("FixRenderStates", true, "Visual")) 108 | { 109 | // Disabled for now, dont let users to check broken things :P 110 | //HOOK(RwRenderState_Patch, aml->GetSym(hGTAVC, "_Z16RwRenderStateSet13RwRenderStatePv")); 111 | aml->Write(pGTAVC + 0x352A10 + 17, "fcolor.xyz ", 16); 112 | aml->Write(pGTAVC + 0x3533F0 + 103, "1.00", 4); 113 | aml->Write(pGTAVC + 0x3539CC + 65, "0.01111111", 10); 114 | aml->Write(pGTAVC + 0x353A84 + 42, "0.65000000", 10); 115 | 116 | // Not exactly like in GTA:SA. Should be a different thing. 117 | aml->Write(pGTAVC + 0x353978 + 44, "0.50000000", 10); 118 | aml->Write(pGTAVC + 0x353978 + 63, "0.50000000", 10); 119 | aml->Write(pGTAVC + 0x353924 + 42, "0.50000000", 10); 120 | aml->Write(pGTAVC + 0x353924 + 61, "0.50000000", 10); 121 | 122 | aml->PlaceNOP4(pGTAVC + 0x287526, 1); 123 | aml->PlaceNOP4(pGTAVC + 0x287554, 1); 124 | aml->PlaceNOP4(pGTAVC + 0x2874EE, 1); 125 | 126 | // shading 127 | aml->PlaceNOP4(pGTAVC + 0x286E44, 1); 128 | }*/ 129 | 130 | // Fixes a mistake by Rockstar (not WarDrum), a wrong physical target 131 | if(cfg->GetBool("FixPhysicsTargets", true, "Gameplay")) 132 | { 133 | aml->Write16(pGTAVC + 0x16777E, 0x4628); 134 | aml->Write16(pGTAVC + 0x1677A2, 0x4628); 135 | aml->Write8(pGTAVC + 0x16AC3C, 0x94); 136 | } 137 | 138 | // Fix clouds rotating speed 139 | if(cfg->GetBool("FixCloudsRotateSpeed", true, "Visual")) 140 | { 141 | HOOK(CloudsUpdate_Speedo, pGTAVC + 0x1D4C74 + 0x1); 142 | } 143 | 144 | // The explosion "shadow" is missing 145 | if(cfg->GetBool("FixExplosionCraterTexture", true, "Visual")) 146 | { 147 | HOOKBL(AddExplosion_AddShadow, pGTAVC + 0x2656B4 + 0x1); 148 | } 149 | 150 | // Allows the game to choose Extra6 component on a vehicle when created 151 | if(cfg->GetBool("AllowExtra6Part", true, "Visual")) 152 | { 153 | aml->Write8(pGTAVC + 0x20E3A4 + 2, 0x08); 154 | } 155 | 156 | // Bigger distance for light coronas 157 | if(cfg->GetBool("BuffDistForLightCoronas", true, "Visual")) 158 | { 159 | aml->WriteFloat(pGTAVC + 0x1D7450, 400.0f); // CEntity::ProcessLightsForEntity, 120 -> 400 160 | aml->Write(pGTAVC + 0x127EA2, "\xC4\xF2\xC8\x33", 4); // CTrafficLights::DisplayActualLight, 50 -> 400 161 | aml->Write(pGTAVC + 0x127A0A, "\xC4\xF2\xC8\x33", 4); // CTrafficLights::DisplayActualLight, 50 -> 400 162 | aml->Write(pGTAVC + 0x127BE8, "\xC4\xF2\xC8\x33", 4); // CTrafficLights::DisplayActualLight, 50 -> 400 163 | aml->Write(pGTAVC + 0x1280B4, "\xC4\xF2\xC8\x33", 4); // CTrafficLights::DisplayActualLight, 50 -> 400 164 | 165 | aml->Write(pGTAVC + 0x1D7842, "\x4F\xF0\x00\x0E", 4); // CEntity::ProcessLightsForEntity, Force off useNearDist 166 | aml->Write(pGTAVC + 0x1D74A6, "\x4F\xF0\x00\x0E", 4); // CEntity::ProcessLightsForEntity, Force off useNearDist 167 | } 168 | 169 | // Bigger distance for light shadows 170 | if(cfg->GetBool("BuffDistForLightShadows", true, "Visual")) 171 | { 172 | aml->WriteFloat(pGTAVC + 0x1D744C, 120.0f); // CEntity::ProcessLightsForEntity, 40 -> 120 173 | aml->Write(pGTAVC + 0x14BAD4, "\xC4\xF2\xF0\x2E", 4); // CFire::ProcessFire, 40 -> 120 174 | aml->Write(pGTAVC + 0x128440, "\xC4\xF2\xF0\x2E", 4); // CTrafficLights::DisplayActualLight, 40 -> 120 175 | aml->Write(pGTAVC + 0x127FB0, "\xC4\xF2\xF0\x2A", 4); // CTrafficLights::DisplayActualLight, 40 -> 120 176 | aml->Write(pGTAVC + 0x128150, "\xC4\xF2\xF0\x25", 4); // CTrafficLights::DisplayActualLight, 40 -> 120 177 | aml->WriteFloat(pGTAVC + 0x1FC780, 120.0f); // CShadows::StoreShadowForPole, 40 -> 120 178 | 179 | // We do count vehicle shadows as light shadows? 180 | // Yeah, why not! 181 | HOOKBL(StoreShadowForVehicle, pGTAVC + 0x1FC2F4 + 0x1); 182 | // still need patch at 1FC420 and 1FC424 183 | aml->WriteFloat(pGTAVC + 0x1FC5EC, 120.0f * 120.0f); // CShadows::StoreCarLightShadow, 27 -> 120 184 | aml->WriteFloat(pGTAVC + 0x1FC5E4, 120.0f * 0.75f); // CShadows::StoreCarLightShadow, 27 -> 120 185 | aml->Write(pGTAVC + 0x1FC5AA, "\xC4\xF2\xF0\x24", 4); // CShadows::StoreCarLightShadow, 27 -> 120 186 | aml->PlaceB(pGTAVC + 0x1FBEE8 + 0x1, pGTAVC + 0x1FC09A + 0x1); 187 | 188 | DoCollectableEffects_BackTo = pGTAVC + 0xFF058 + 0x1; 189 | aml->Redirect(pGTAVC + 0xFF04E + 0x1, (uintptr_t)DoCollectableEffects_Inject); 190 | DoPickUpEffects_BackTo = pGTAVC + 0xFFF8A + 0x1; 191 | aml->Redirect(pGTAVC + 0xFFF7E + 0x1, (uintptr_t)DoPickUpEffects_Inject); 192 | } 193 | 194 | // Just a little fix for banner 195 | if(cfg->GetBool("CorrectBannerRenderFlag", true, "Visual")) 196 | { 197 | aml->Write16(pGTAVC + 0x1DF904, 0x2319); 198 | } 199 | 200 | // Fixing a weird error with access error in Unprotected version of VC apk 201 | if(cfg->GetBool("FixUnprotectedAccessCrash", true, "Gameplay")) 202 | { 203 | UNPROT(pGTAVC + 0x3D20B4, 1); 204 | } 205 | 206 | // Allows the game to render even more light shadows on the ground 207 | if(cfg->GetBool("BuffStaticShadowsCount", true, "Gameplay")) 208 | { 209 | aStaticShadows_NEW = new CStaticShadow[0xFF + 1] {0}; memset(aStaticShadows_NEW, 0, sizeof(CStaticShadow) * (0xFF + 1)); 210 | aml->Write(pGTAVC + 0x394750, (uintptr_t)&aStaticShadows_NEW, sizeof(void*)); 211 | 212 | // Static Shadows: 213 | // CShadows::StoreStaticShadow 214 | aml->Write(pGTAVC + 0x1FBBDE, (uintptr_t)"\xFE", 1); 215 | aml->Write(pGTAVC + 0x1FBC8C, (uintptr_t)"\xFF", 1); 216 | aml->Write(pGTAVC + 0x1FBCA0, (uintptr_t)"\xFF", 1); 217 | aml->Write(pGTAVC + 0x1FBBB8, (uintptr_t)"\x09\xF5\x1B\x5E", 4); // ADD.W LR, R9, #0x26C0 218 | // CShadows::RenderStaticShadows 219 | aml->Write(pGTAVC + 0x1FCB00, (uintptr_t)"\xFF", 1); 220 | aml->Write(pGTAVC + 0x1FCB2C, (uintptr_t)"\xFE", 1); 221 | aml->Write(pGTAVC + 0x1FCB54, (uintptr_t)"\xFF", 1); 222 | aml->Write(pGTAVC + 0x1FCEBA, (uintptr_t)"\xFF", 1); 223 | // CShadows::UpdateStaticShadows 224 | aml->Write(pGTAVC + 0x1F92D6, (uintptr_t)"\x04\xF5\x1B\x55", 4); // ADD.W R5, R4, #0x26C0 225 | 226 | HOOK(InitShadows, pGTAVC + 0x1F8C5C + 0x1); 227 | } 228 | 229 | // Bigger max count of peds 230 | if(cfg->GetBool("BuffMaxPedsCount", true, "Gameplay")) 231 | { 232 | *(int*)aml->GetSym(hGTAVC, "_ZN11CPopulation20MaxNumberOfPedsInUseE") = 0x23; 233 | //aml->Write(pGTASA + 0x3F4DE0, (uintptr_t)"\x23", 1); 234 | //aml->Write(pGTASA + 0x4CC284, (uintptr_t)"\x23", 1); 235 | //aml->Write(pGTASA + 0x4CCBE0, (uintptr_t)"\x23", 1); 236 | //aml->Write(pGTASA + 0x4CCBEA, (uintptr_t)"\x1C", 1); 237 | } 238 | 239 | // Bigger spawn distance for peds 240 | if(cfg->GetBool("BuffPedsDistance", true, "Gameplay")) 241 | { 242 | aml->WriteFloat(pGTAVC + 0x1D413C, 50.0f); 243 | aml->WriteFloat(pGTAVC + 0x1D4140, 90.0f); 244 | HOOKBL(PedCreationDistMult_Offscreen, pGTAVC + 0x1D40EE + 0x1); 245 | HOOKBL(PedCreationDistMult_Offscreen, pGTAVC + 0x1D40F6 + 0x1); 246 | } 247 | 248 | // An attempt to fix fighting... (incomplete, the radius is small tho) 249 | if(cfg->GetBool("FixFighting", true, "Gameplay")) 250 | { 251 | aml->Write(pGTAVC + 0x1C2E3C, "\xB1\xEE\x00\x7A", 4); // CPed::Fight -> unlock move FIGHTMOVE_KNEE 252 | aml->Write8(pGTAVC + 0x1C5520, 0x01); // CheckForPedsOnGroundToAttack -> 4 >> PED_IN_FRONT_OF_ATTACKER 253 | } 254 | 255 | // FX particles distance multiplier! 256 | fxMultiplier = cfg->GetFloat("FxDistanceMult", 2.5f, "Visual"); 257 | if(fxMultiplier != 1) 258 | { 259 | if(fxMultiplier < 0.1) fxMultiplier = 0.1f; 260 | else if(fxMultiplier > 20) fxMultiplier = 20.0f; 261 | HOOKBLX(LoadFX_atof, pGTAVC + 0x1F6500); 262 | } 263 | 264 | // Skip that dumb EULA. We accepted it years ago, shut up 265 | if(cfg->GetBool("SkipAnnoyingEULA", true, "Gameplay")) 266 | { 267 | aml->Write8(aml->GetSym(hGTAVC, "shownLegalScreen"), 0x01); 268 | } 269 | 270 | // A style of a SA mobile 271 | if(cfg->GetBool("MoneysWithoutZeros", false, "Visual")) 272 | { 273 | aml->Write(pGTAVC + 0x34D178, "$%d", 4); 274 | } 275 | 276 | // OpenGL-related crash in huawei (poop ass phone moment) 277 | if(cfg->GetBool("FixHuaweiCrash", true, "Gameplay")) 278 | { 279 | void* sym; 280 | if((sym = TryLoadAlphaFunc("libGLESv2.so")) || (sym = TryLoadAlphaFunc("libGLESv3.so")) || 281 | (sym = TryLoadAlphaFunc("libGLESv2_mtk.so")) || (sym = TryLoadAlphaFunc("libGLES_mali.so")) || 282 | (sym = TryLoadAlphaFunc("libGLES_android.so")) || (sym = TryLoadAlphaFunc("libGLES.so"))) 283 | { 284 | *(void**)(pGTAVC + 0x7300E0) = sym; 285 | } 286 | } 287 | 288 | // 44100 Hz Audio support (without a mod OpenAL Update but works with it anyway) 289 | if(cfg->GetBool("Allow44100HzAudio", true, "Gameplay")) 290 | { 291 | aml->Write(pGTAVC + 0x613E0A, "\x4A\xF6\x44\x47", 4); 292 | } 293 | 294 | // Fixing drunk camera on high FPS 295 | if(cfg->GetBool("FixDrunkCameraHighFPS", true, "Visual")) 296 | { 297 | HOOK(CameraProcess_HighFPS, pGTAVC + 0x13F26C + 0x1); 298 | } 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | // Do camera tweaks, get a better camera! 312 | //if(cfg->GetBool("CameraTweaks", true, "Gameplay")) 313 | //{ 314 | // // Need to check WellBufferMe 315 | //} 316 | 317 | // Fix pushing force 318 | //if(cfg->GetBool("FixPhysicalPushForce", true, "Gameplay")) 319 | //{ 320 | // HOOK(ApplyCollision_HighFPS, aml->GetSym(hGTAVC, "_ZN9CPhysical14ApplyCollisionEPS_R9CColPointRfS3_")); 321 | // //ApplyCollision_BackTo = pGTAVC + 0x167588 + 0x1; 322 | // //aml->Redirect(pGTAVC + 0x167580 + 0x1, (uintptr_t)ApplyCollision_Inject); 323 | // //HOOKBL(ApplyCollision_MoveForce, pGTAVC + 0x166C60 + 0x1); 324 | // //HOOKBL(ApplyCollision_TurnForce, pGTAVC + 0x166C84 + 0x1); 325 | //} 326 | 327 | // An improved ForceDXT (everything goes black, no textures! :( ) 328 | /*if(cfg->GetBool("ForceLoadDXT", false, "Gameplay")) 329 | { 330 | aml->Write8(pGTAVC + 0x2A8F70, 0x01); 331 | aml->Write8(pGTAVC + 0x2A8EBE, 0x01); 332 | HOOKBL(LoadEntries_DXT, pGTAVC + 0x2A8EC8 + 0x1); 333 | }*/ -------------------------------------------------------------------------------- /patches/preparations_vc64.inl: -------------------------------------------------------------------------------- 1 | // Boat and Skimmer on high FPS 2 | if(cfg->GetBool("HighFPSBoatSpeed", true, "Gameplay")) 3 | { 4 | Boat_ApplyWaterResistance_BackTo = pGTAVC + 0x3418F8; 5 | aml->Redirect(pGTAVC + 0x3418E8, (uintptr_t)Boat_ApplyWaterResistance_Inject); 6 | } 7 | 8 | // Fix wheels rotation speed on high FPS 9 | if(cfg->GetBool("FixWheelsRotationSpeed", true, "Visual")) 10 | { 11 | HOOK(ProcessWheelRotation, aml->GetSym(hGTAVC, "_ZN8CVehicle20ProcessWheelRotationE11tWheelStateRK7CVectorS3_f")); 12 | } 13 | 14 | // Car Slowdown Fix 15 | if(cfg->GetBool("FixCarSlowdownHighFPS", true, "Gameplay")) 16 | { 17 | HOOK(ProcessWheel_SlowDownFix, aml->GetSym(hGTAVC, "_ZN8CVehicle12ProcessWheelER7CVectorS1_S1_S1_ifffcPfP11tWheelStatet")); 18 | HOOK(ProcessBikeWheel_SlowDownFix, aml->GetSym(hGTAVC, "_ZN8CVehicle16ProcessBikeWheelER7CVectorS1_S1_S1_iffffcPfP11tWheelState17eBikeWheelSpecialt")); 19 | } 20 | 21 | // Fix heli rotor rotation speed on high FPS 22 | if(cfg->GetBool("FixRotorRotationSpeed", true, "Visual")) 23 | { 24 | HOOKBL(HeliRender_MatrixUpdate, pGTAVC + 0x3489B0); 25 | } 26 | 27 | // Fixes a streaming distance that gets bugged because of dumb R* logic (aspect ratio moment) 28 | if(cfg->GetBool("FixStreamingDistance", true, "Visual")) 29 | { 30 | CameraProcess_StreamDist_BackTo = pGTAVC + 0x1D8310; 31 | aml->Redirect(pGTAVC + 0x1D8300, (uintptr_t)CameraProcess_StreamDist_Inject); 32 | HOOK(SetFOV_StreamingDistFix, aml->GetSym(hGTAVC, "_ZN5CDraw6SetFOVEf")); 33 | 34 | aml->Write32(pGTAVC + 0x1D83BC, 0xF0001649); 35 | aml->Write32(pGTAVC + 0x1D83C0, 0xBD43A122); 36 | } 37 | 38 | // Fixing fat ass coronas 39 | if(cfg->GetBool("FixCoronasAspectRatio", true, "Visual")) 40 | { 41 | HOOK(CoronaSprite_CalcScreenCoors, aml->GetSym(hGTAVC, "_ZN7CSprite15CalcScreenCoorsERK5RwV3dPS0_PfS4_b")); 42 | } 43 | 44 | // Fix Vertex Weights 45 | if(cfg->GetBool("FixVertexWeight", true, "Visual")) 46 | { 47 | aml->Write32(pGTAVC + 0x39058C, 0x540005A0); 48 | aml->Write32(pGTAVC + 0x390640, MOVBits::Create(1, 27, false)); 49 | } 50 | 51 | // RE3: Fix R* optimization that prevents peds to spawn 52 | if(cfg->GetBool("Re3_PedSpawnDeoptimize", true, "Gameplay")) 53 | { 54 | aml->Write(pGTAVC + 0x1EE2A8, "\x7F\x0A\x00\x71", 4); 55 | } 56 | 57 | // RE3: Road reflections 58 | if(cfg->GetBool("Re3_WetRoadsReflections", true, "Visual")) 59 | { 60 | aml->Write(pGTAVC + 0x1D6552, "\xE2\x6B\x40\xBD", 4); 61 | } 62 | 63 | // Fix traffic lights 64 | if(cfg->GetBool("FixTrafficLights", true, "Visual")) 65 | { 66 | HOOK(TrFix_RenderEffects, pGTAVC + 0x2DFB64); 67 | 68 | // Why does vehicle's lights are in that list?! 69 | aml->PlaceNOP4(pGTAVC + 0x32DB34, 1); 70 | aml->PlaceNOP4(pGTAVC + 0x32E2CC, 1); 71 | aml->PlaceNOP4(pGTAVC + 0x32E330, 1); 72 | aml->PlaceNOP4(pGTAVC + 0x32E6F0, 1); 73 | aml->PlaceNOP4(pGTAVC + 0x32E74C, 1); 74 | aml->PlaceNOP4(pGTAVC + 0x32EB54, 1); 75 | aml->PlaceNOP4(pGTAVC + 0x32EBB0, 1); 76 | 77 | // Why does bike's lights are in that list?! 78 | aml->PlaceNOP4(pGTAVC + 0x339394, 1); 79 | aml->PlaceNOP4(pGTAVC + 0x339770, 1); 80 | aml->PlaceNOP4(pGTAVC + 0x3398E0, 1); 81 | } 82 | 83 | // Fixes framelimiter (doesnt limit the FPS, ayo lol) 84 | // P.S. IT WAS NEVER WORKING, OH MY GOD 85 | if(cfg->GetBool("FixGameTimer", true, "Gameplay")) 86 | { 87 | aml->PlaceNOP(pGTAVC + 0x30C930, 1); 88 | HOOKBL(GameTick_TouchscreenUpdate, pGTAVC + 0x30C948); 89 | HOOK(OS_ScreenSetRefresh, aml->GetSym(hGTAVC, "_Z19OS_ScreenSetRefreshj")); 90 | 91 | aml->Write(pGTAVC + 0x30C9A0, "\xE0\x0F\x1F\x32", 4); 92 | } 93 | 94 | // Fix water scroll speed on high FPS 95 | if(cfg->GetBool("FixWaterUVScrollSpeed", true, "Visual")) 96 | { 97 | RenderWater_BackTo = pGTAVC + 0x357920; 98 | aml->Redirect(pGTAVC + 0x357910, (uintptr_t)RenderWater_Inject); 99 | } 100 | 101 | // Bringing back missing render states (WarDumb`s optimization) 102 | /*if(cfg->GetBool("FixRenderStates", true, "Visual")) 103 | { 104 | // Disabled for now, dont let users to check broken things :P 105 | //HOOK(RwRenderState_Patch, aml->GetSym(hGTAVC, "_Z16RwRenderStateSet13RwRenderStatePv")); 106 | aml->Write(pGTAVC + 0x352A10 + 17, "fcolor.xyz ", 16); 107 | aml->Write(pGTAVC + 0x3533F0 + 103, "1.00", 4); 108 | aml->Write(pGTAVC + 0x3539CC + 65, "0.01111111", 10); 109 | aml->Write(pGTAVC + 0x353A84 + 42, "0.65000000", 10); 110 | 111 | // Not exactly like in GTA:SA. Should be a different thing. 112 | aml->Write(pGTAVC + 0x353978 + 44, "0.50000000", 10); 113 | aml->Write(pGTAVC + 0x353978 + 63, "0.50000000", 10); 114 | aml->Write(pGTAVC + 0x353924 + 42, "0.50000000", 10); 115 | aml->Write(pGTAVC + 0x353924 + 61, "0.50000000", 10); 116 | 117 | aml->PlaceNOP4(pGTAVC + 0x287526, 1); 118 | aml->PlaceNOP4(pGTAVC + 0x287554, 1); 119 | aml->PlaceNOP4(pGTAVC + 0x2874EE, 1); 120 | 121 | // shading 122 | aml->PlaceNOP4(pGTAVC + 0x286E44, 1); 123 | }*/ 124 | 125 | // Fix clouds rotating speed 126 | if(cfg->GetBool("FixCloudsRotateSpeed", true, "Visual")) 127 | { 128 | aml->Write32(pGTAVC + 0x2AA5A0, 0xF0003928); 129 | aml->Write32(pGTAVC + 0x2AA5A4, 0xBD4DCD01); 130 | 131 | aml->Write32(pGTAVC + 0x2AA5C8, 0xB0003949); 132 | aml->Write32(pGTAVC + 0x2AA5CC, 0xBD401D24); 133 | 134 | HOOKPLT(CloudsUpdate_Speedo, pGTAVC + 0x56F1A8); 135 | } 136 | 137 | // The explosion "shadow" is missing 138 | if(cfg->GetBool("FixExplosionCraterTexture", true, "Visual")) 139 | { 140 | HOOKBL(AddExplosion_AddShadow, pGTAVC + 0x35E610); 141 | } 142 | 143 | // Allows the game to choose Extra6 component on a vehicle when created 144 | if(cfg->GetBool("AllowExtra6Part", true, "Visual")) 145 | { 146 | aml->Write(pGTAVC + 0x2F5FD0, "\x01\x10\x23\x1E", 4); 147 | } 148 | 149 | // Bigger distance for light coronas 150 | if(cfg->GetBool("BuffDistForLightCoronas", true, "Visual")) 151 | { 152 | 153 | aml->Write32(pGTAVC + 0x2AD0A8, 0xBD487520); // CEntity::ProcessLightsForEntity, 120 -> 400 154 | aml->Write32(pGTAVC + 0x1C2B80, 0xB0001709); // CTrafficLights::DisplayActualLight, 50 -> 400 155 | aml->Write32(pGTAVC + 0x1C2BAC, 0xBD487521); // CTrafficLights::DisplayActualLight, 50 -> 400 156 | aml->Write32(pGTAVC + 0x1C2B14, 0xB0001709); // CTrafficLights::DisplayActualLight, 50 -> 400 157 | aml->Write32(pGTAVC + 0x1C2B40, 0xBD487521); // CTrafficLights::DisplayActualLight, 50 -> 400 158 | aml->Write32(pGTAVC + 0x1C2F54, 0xB0001709); // CTrafficLights::DisplayActualLight, 50 -> 400 159 | aml->Write32(pGTAVC + 0x1C2F58, 0xBD487521); // CTrafficLights::DisplayActualLight, 50 -> 400 160 | aml->Write32(pGTAVC + 0x1C2F7C, 0xB0001709); // CTrafficLights::DisplayActualLight, 50 -> 400 161 | aml->Write32(pGTAVC + 0x1C2F80, 0xBD487521); // CTrafficLights::DisplayActualLight, 50 -> 400 162 | 163 | aml->Write32(pGTAVC + 0x2AD3BC, MOVBits::Create(0, 8, false)); // CEntity::ProcessLightsForEntity, Force off useNearDist 164 | aml->Write32(pGTAVC + 0x2AD67C, MOVBits::Create(0, 8, false)); // CEntity::ProcessLightsForEntity, Force off useNearDist 165 | } 166 | 167 | // Bigger distance for light shadows 168 | if(cfg->GetBool("BuffDistForLightShadows", true, "Visual")) 169 | { 170 | aml->Write32(pGTAVC + 0x2AD0A0, 0xD0000FAB); // \/ 171 | aml->Write32(pGTAVC + 0x2AD0B0, 0xBD47796C); // CEntity::ProcessLightsForEntity, 40 -> 120 172 | aml->Write32(pGTAVC + 0x1EC830, 0xF00015A8); // \/ 173 | aml->Write32(pGTAVC + 0x1EC834, 0xBD477906); // CFire::ProcessFire, 40 -> 120 174 | aml->Write32(pGTAVC + 0x1C27C4, 0xB0001708); // \/ 175 | aml->Write32(pGTAVC + 0x1C27D0, 0xBD477906); // CTrafficLights::DisplayActualLight, 40 -> 120 176 | aml->Write32(pGTAVC + 0x1C2A58, 0xB0001708); // \/ 177 | aml->Write32(pGTAVC + 0x1C2A64, 0xBD477906); // CTrafficLights::DisplayActualLight, 40 -> 120 178 | aml->Write32(pGTAVC + 0x1C2E68, 0xF00015A8); // \/ 179 | aml->Write32(pGTAVC + 0x1C2E74, 0xBD477906); // CTrafficLights::DisplayActualLight, 40 -> 120 180 | aml->Write32(pGTAVC + 0x2D8F7C, 0xF0000E48); // \/ 181 | aml->Write32(pGTAVC + 0x2D8F90, 0xBD477906); // CShadows::StoreShadowForPole, 40 -> 120 182 | 183 | // We do count vehicle shadows as light shadows? 184 | // Yeah, why not! 185 | HOOKBL(StoreShadowForVehicle, pGTAVC + 0x2D82C4); 186 | HOOKBL(StoreStaticShadow_LS, pGTAVC + 0x2D84A8); 187 | // still need patch at 1FC420 and 1FC424 (VC1.09) 188 | aml->Write32(pGTAVC + 0x2D83F4, 0xF0000E4A); // \/ 189 | aml->Write32(pGTAVC + 0x2D83F8, 0xBD477542); // CShadows::StoreCarLightShadow, 27*27 -> 120*120 190 | aml->WriteFloat(pGTAVC + 0x4C61B4, 120.0f * 0.75f); // CShadows::StoreCarLightShadow, 27 -> 120 191 | aml->PlaceNOP(pGTAVC + 0x2D7F4C, 1); 192 | 193 | DoCollectableEffects_BackTo = pGTAVC + 0x18F7B0; 194 | aml->Redirect(pGTAVC + 0x18F7A0, (uintptr_t)DoCollectableEffects_Inject); 195 | DoPickUpEffects_BackTo = pGTAVC + 0x18EDD0; 196 | aml->Redirect(pGTAVC + 0x18EDC0, (uintptr_t)DoPickUpEffects_Inject); 197 | } 198 | 199 | // Just a little fix for banner 200 | if(cfg->GetBool("CorrectBannerRenderFlag", true, "Visual")) 201 | { 202 | aml->Write(pGTAVC + 0x2B812C, "\x23\x03\x80\x52", 4); 203 | } 204 | 205 | // Allows the game to render even more light shadows on the ground 206 | if(cfg->GetBool("BuffStaticShadowsCount", true, "Gameplay")) 207 | { 208 | aStaticShadows_NEW = new CStaticShadow[MAX_STATIC_SHADOWS + 1] {0}; memset(aStaticShadows_NEW, 0, sizeof(CStaticShadow) * (MAX_STATIC_SHADOWS + 1)); 209 | aml->Write(pGTAVC + 0x576FF0, (uintptr_t)&aStaticShadows_NEW, sizeof(void*)); 210 | 211 | // Static Shadows: 212 | // CShadows::StoreStaticShadow 213 | aml->Write32(pGTAVC + 0x2D7530, CMPBits::Create(MAX_STATIC_SHADOWS-1, 8, true)); // CMP X8, #0x2F 214 | // CShadows::RenderStaticShadows 215 | aml->Write32(pGTAVC + 0x2DA10C, CMPBits::Create(MAX_STATIC_SHADOWS, 28, true)); // CMP X28, #0x30 216 | aml->Write32(pGTAVC + 0x2DA120, CMPBits::Create(MAX_STATIC_SHADOWS, 28, true)); // CMP X28, #0x30 217 | // CShadows::UpdateStaticShadows 218 | aml->Write32(pGTAVC + 0x2DB4D8, CMPBits::Create(MAX_STATIC_SHADOWS, 8, true)); // CMP X8, #0x30 219 | 220 | HOOKPLT(InitShadows, pGTAVC + 0x574740); 221 | 222 | StoreStaticShadow_BackTo = pGTAVC + 0x2D76B8; 223 | aml->Redirect(pGTAVC + 0x2D7538, (uintptr_t)StoreStaticShadow_Inject); 224 | aml->Write32(pGTAVC + 0x2D76B8, 0x3100051F); 225 | aml->Write32(pGTAVC + 0x2D76BC, 0x54001780); 226 | } 227 | 228 | // Bigger max count of peds 229 | if(cfg->GetBool("BuffMaxPedsCount", true, "Gameplay")) 230 | { 231 | *(int*)aml->GetSym(hGTAVC, "_ZN11CPopulation20MaxNumberOfPedsInUseE") = 0x23; 232 | } 233 | 234 | // An attempt to fix fighting... (incomplete, the radius is small tho) 235 | if(cfg->GetBool("FixFighting", true, "Gameplay")) 236 | { 237 | aml->Write(pGTAVC + 0x291FC0, "\x01\x10\x22\x1E", 4); // CPed::Fight -> unlock move FIGHTMOVE_KNEE 238 | aml->Write(pGTAVC + 0x293458, "\x1F\x05\x00\x71", 4); // CheckForPedsOnGroundToAttack -> 4 >> PED_IN_FRONT_OF_ATTACKER 239 | } 240 | 241 | // FX particles distance multiplier! 242 | fxMultiplier = cfg->GetFloat("FxDistanceMult", 2.5f, "Visual"); 243 | if(fxMultiplier != 1) 244 | { 245 | if(fxMultiplier < 0.1) fxMultiplier = 0.1f; 246 | else if(fxMultiplier > 20) fxMultiplier = 20.0f; 247 | HOOKBL(LoadFX_atof, pGTAVC + 0x2D4034); 248 | } 249 | 250 | // Skip that dumb EULA. We accepted it years ago, shut up 251 | if(cfg->GetBool("SkipAnnoyingEULA", true, "Gameplay")) 252 | { 253 | aml->Write8(aml->GetSym(hGTAVC, "shownLegalScreen"), 0x01); 254 | } 255 | 256 | // A style of a SA mobile 257 | if(cfg->GetBool("MoneysWithoutZeros", false, "Visual")) 258 | { 259 | aml->Write(pGTAVC + 0x4C599E, "$%d", 4); 260 | } 261 | 262 | // OpenGL-related crash in huawei (poop ass phone moment) 263 | if(cfg->GetBool("FixHuaweiCrash", true, "Gameplay")) 264 | { 265 | void* sym; 266 | if((sym = TryLoadAlphaFunc("libGLESv2.so")) || (sym = TryLoadAlphaFunc("libGLESv3.so")) || 267 | (sym = TryLoadAlphaFunc("libGLESv2_mtk.so")) || (sym = TryLoadAlphaFunc("libGLES_mali.so")) || 268 | (sym = TryLoadAlphaFunc("libGLES_android.so")) || (sym = TryLoadAlphaFunc("libGLES.so"))) 269 | { 270 | *(void**)(pGTAVC + 0x9AEA70) = sym; 271 | } 272 | } 273 | 274 | // 44100 Hz Audio support (without a mod OpenAL Update but works with it anyway) 275 | if(cfg->GetBool("Allow44100HzAudio", true, "Gameplay")) 276 | { 277 | aml->Unprot(pGTAVC + 0x4AED68, sizeof(int)); 278 | *(int*)(pGTAVC + 0x4AED68) = 44100; 279 | } 280 | 281 | // Fix threads performance 282 | if(cfg->GetBool("FixFPS", true, "Gameplay")) 283 | { 284 | aml->Write32(pGTAVC + 0x460330, 0x52801E40); 285 | aml->Write32(pGTAVC + 0x460384, 0x52801E20); 286 | } 287 | 288 | // Fixing drunk camera on high FPS 289 | if(cfg->GetBool("FixDrunkCameraHighFPS", true, "Visual")) 290 | { 291 | HOOKPLT(CameraProcess_HighFPS, pGTAVC + 0x5705C0); 292 | } -------------------------------------------------------------------------------- /updater.txt: -------------------------------------------------------------------------------- 1 | myself:1.4.1:https://github.com/AndroidModLoader/JPatch/releases/download/1.4.1/libJPatch.so --------------------------------------------------------------------------------