This PR won't affect modders who have already updated their mods to 3.8.0. They just need to re-compile.
This is a resubmission of my previous PR (SPT-AKI/Modules#99) with additional code cleanup and fixes.
Instead of outright removing the functionality, this time I deprecate it instead (marked for removal in next release).
Requires SPT-AKI/Server#274 to function.
## Overview
- HTTP modernization
- Adds `Aki.Common.Http.Client`, a replacement for `Aki.Common.Http.Request` and builds on top of `System.Net.Http.HttpClient`
- Implements failsafe retries when requesting during busy connections
- Improved debugging
- Improved performance
- Deprecades old request code
- Bundle system
- Fixes remote downloaded bundles using external IP
- Implements functional bundle caching from remote sources
- Implements multi-threaded bundle downloads
- Implements Unity-compatible bundle format support
- Extensive cleanup
- Deprecated unneccecary models
## Why?
In it's current state, the bundle system is ducktaped together in 2021, fundumentally broken and in desperate need of a cleanup and fixes.
The HTTP code hasn't been updated since 2021, and `HttpWebRequest` has been deprecated by Microsoft for a while now.
There was also a lot of opportunity left for simple performance gains that even reduces the complexity of the code.
As for why not two separate PRs (HTTP modernization, bundle rework): both were deeply interconnected. A change in one requires modification in the other. Hence the current approach.
## Testing
The code has been validated and tested by @TheSparta and me.
A large section of the code has been implemented and tested extensively by modders.
### Local
1. Start the game from 127.0.0.1
2. The game starts loading bundles from the mods path
### Remote, full re-aquire
1. Start the server from LAN IP (http.json, set host to `cmd > ipconfig` address, example: `192.168.178.32`)
2. Start the game from LAN IP
3. A folder named `user/cache/bundles` is created
### Remote, partial-aquire (deleted)
1. Ensure all bundles are cached
2. Delete one of the aquired bundles from cache
3. Start the server from LAN IP (http.json, set host to `cmd > ipconfig` address, example: `192.168.178.32`)
4. Start the game from LAN IP
5. The bundle is redownloaded
### Remote, partial-aquire (invalid crc)
1. Ensure all bundles are cached
2. Update a bundle mod with a new bundle on the same path
3. Start the server from LAN IP (http.json, set host to `cmd > ipconfig` address, example: `192.168.178.32`)
4. Start the game from LAN IP
5. The bundle is redownloaded
### Remote, use cache
1. Ensure all bundles are cached
2. Start the server from LAN IP (http.json, set host to `cmd > ipconfig` address, example: `192.168.178.32`)
3. Start the game from LAN IP
4. The game starts loading bundles from the cache path
## Risk assessment
In order to reduce friction between releases, this PR introduces a deprecation system.
Obsolete classes and methods have been marked deprecated.
These will remain available for the current release and continue to function as normal for this release.
A warning will be displayed during build when a modder relies on the deprecated functionality.
The marked classes and methods are to be removed in the next release.
The server-side changes have no impact on modders.
## Deprecation
The following classes are affected:
- `Aki.Common.Http.Request`: Replaced by `Aki.Common.Http.Request`
- `Aki.Common.Http.WebConstants`: Replaced by functionality from `System.Net.Http`
- `Aki.Custom.Models.BundleInfo`: Replaced by `Aki.Custom.Models.BundleItem`
The following methods are affected:
- `Aki.Common.Http.RequestHandler.GetData(path, hasHost)`: `hasHost` enables connection outside intended host.
- `Aki.Common.Http.RequestHandler.GetJson(path, hasHost)`: `hasHost` enables connection outside intended host.
- `Aki.Common.Http.RequestHandler.PostJson(path, json, hasHost)`: `hasHost` enables connection outside intended host.
- `Aki.Common.Http.RequestHandler.PutJson(path, json, hasHost)`: `hasHost` enables connection outside intended host.
The deprecated methods and `Aki.Custom.Models.BundleInfo` are self-contained and can be removed independently.
The deprecated classes require removal of all deprecated code at once.
Reviewed-on: SPT-AKI/Modules#104
Reviewed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-authored-by: Merijn Hendriks <merijn.d.hendriks@gmail.com>
Co-committed-by: Merijn Hendriks <merijn.d.hendriks@gmail.com>
Most of this code was (re-)written in 0.12.9, almost 3 years ago.
Current understanding of how it worked was limited, so I went back and broke it until I understood it properly.
I added comments where I could and slightly altered the logic of `GetManifestJson` to make it easier to read.
Regarding removal of `GetManifestBundle`: you can't. While `Windows.json` contains most of the bundle info, some info (like `Doge`) resides outside of this. Removing `GetManifestBundle` results in the game failing to load.
Reviewed-on: SPT-AKI/Modules#101
Co-authored-by: Merijn Hendriks <merijn.d.hendriks@gmail.com>
Co-committed-by: Merijn Hendriks <merijn.d.hendriks@gmail.com>
Added a patch to handle Closing all extracts but 1 for when cultist ritual succeeds in halloween event.
Halloween Event doesnt seem to work well when map has newspawn system enabled. I think bots are getting stuck getting loaded. causing delayed spawns of cultists.
Needs merged with: SPT-AKI/Server#262
Short story first: Last night I was poking around the code as I always do looking for the cause of an exception and got sick and tired of the generic bad exceptions we always work off of. So I fixed it.
This allows us access to BSG's internal logging using Nlog. This is useful for everybody. Not just SPT dev's, but mod dev's alike. It can be enabled from `core.json` with the option to send the output to the server.
Here's an example of the improvement, its huge. Bepinex console is the gerneric logging we always use, the editor behind it is the improved logging from Nlog. Its night and day.
![image](/attachments/491dd8b6-e89a-4809-b19e-c5906ab6989e)
The levels are based off of Nlog ordinals where low is more logging, high is less. (Stupid I know, but what can you do)
Verbosity is as follows:
* In all cases, except off, better exceptions will be logged.
* to see the logging output in your bepinex logs, make sure you have debug logging enabled in bepinex.
* WARNING: trace-info logging will quickly create log files in the megabytes.
* 0 - trace
* 1 - debug
* 2 - info
* 3 - warn
* 4 - error
* 5 - fatal
* 6 - off
Co-authored-by: Cj <161484149+CJ-SPT@users.noreply.github.com>
Reviewed-on: SPT-AKI/Modules#96
Co-authored-by: Cj <cj@noreply.dev.sp-tarkov.com>
Co-committed-by: Cj <cj@noreply.dev.sp-tarkov.com>
needs merged with: SPT-AKI/Server#258
Shows if mods are loaded in the cool debug message, will show if either server mods or client mods are present.
Co-authored-by: Cj <161484149+CJ-SPT@users.noreply.github.com>
Reviewed-on: SPT-AKI/Modules#95
Co-authored-by: Cj <cj@noreply.dev.sp-tarkov.com>
Co-committed-by: Cj <cj@noreply.dev.sp-tarkov.com>
Rewrite the BTRTurretView attach patch, so we no longer need the BotInit patch
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: SPT-AKI/Modules#92
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Needs merged with: SPT-AKI/Server#249
Added
- Moved beta disclaimer text to the server
- Moved `PreventClientModsPatch` to AKI.Debugging as it makes more sense here after this PR. People who need to know, know why.
- Ability to show a release note summary to users in-game
- Cool debug message only shows build hash.
Instructions for testing
- Since I opted to store properties in the registry, its not as straight forward as deleting a file. (Thanks Drakia for the suggestion). So in order to test you need to open up regedit and navigate to `Computer\HKEY_CURRENT_USER\Software\Battlestate Games\EscapeFromTarkov` inside of that directory are 3 values stored in relation to this PR.
`SPT_AcceptedBETerms` - `REG_DWORD` that stores a value of 0 or 1
`SPT_ShownReleaseNotes` - `REG_DWORD` that stores a value of 0 or 1
`SPT_Version` - `REG_BINARY` that stores a binary converted string.
In order to reset after first run for a second test, you just delete all 3 entries.
Co-authored-by: Cj <161484149+CJ-SPT@users.noreply.github.com>
Reviewed-on: SPT-AKI/Modules#90
Co-authored-by: Cj <cj@noreply.dev.sp-tarkov.com>
Co-committed-by: Cj <cj@noreply.dev.sp-tarkov.com>
1) The called bot's enemy position is being passed to TryCall, instead of the calling bot's enemy position. This is both incorrect and can lead to an NRE if the called bot has no enemy. Fix by passing in the calling bot's enemy position
2) In the TryCall method, the caller's enemy is added to the called bot, however the code doesn't verify that it was added before accessing it in the `EnemyInfos` array. This can throw a missing key exception if the bot failed to add to the enemies list. Fix by making sure the enemy is added to the enemy list before executing TryCall
3) When a BotOwner is disposed, the CalledData is never properly cleaned up, resulting in a bot's OnEnemyAdd being triggered after the bot has been killed, this can throw an NRE. Fix by calling CalledData.SetOff before BotOwner.Dispose
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: SPT-AKI/Modules#84
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Fixes an NRE when the BTR kills an enemy while using cover fire service
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: SPT-AKI/Modules#82
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
- Move clearing trader service data to raid end instead of as part of BTR Manager
- Fix data type for TraderServices ItemsToPay property
- Add ItemsToReceive property to TraderServices (Used for LK amulet)
- Don't throw NRE when nothing is bound to OnTraderServicePurchased
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: SPT-AKI/Modules#79
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
By multiplying `moveSpeed` by `Time.deltaTime` in `BTRVehicle.Update()`, it prevents the BTR movement from desyncing, and possibly going faster or slower than expected.
Reviewed-on: SPT-AKI/Modules#73
Co-authored-by: Arys <arys@noreply.dev.sp-tarkov.com>
Co-committed-by: Arys <arys@noreply.dev.sp-tarkov.com>
- Before `Application.targetFrameRate` is used in the BTR code, set it to 60. Then set it back afterwards
- Remove an unnecessary error from BTRExtractPassengersPatch, not actually an error state
All credit goes to Ngst for figuring out that NVidia Reflex was causing the BTR issues
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: SPT-AKI/Modules#71
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Honestly this is just a shot in the dark hotfix. I've tested it and these changes still work fine for me.
Let me know if this fixes the BTR not working, Chomp
Reviewed-on: SPT-AKI/Modules#69
Co-authored-by: Arys <arys@noreply.dev.sp-tarkov.com>
Co-committed-by: Arys <arys@noreply.dev.sp-tarkov.com>
Todo:
* Make BTR spawn at random time during raid instead of at start
* ~~Fix BTR trader services not working for subsequent raids in Streets~~ Drakia provided me with a fix and it's included in this PR
TL;DR - It's ready for testing
Co-authored-by: Nympfonic <arys.steam@gmail.com>
Reviewed-on: SPT-AKI/Modules#68
Co-authored-by: Arys <arys@noreply.dev.sp-tarkov.com>
Co-committed-by: Arys <arys@noreply.dev.sp-tarkov.com>
Todo:
* Make BTR spawn at random time during raid instead of at the start
* Find out why some players receive error relating to `BTRBotAttachPatch` resulting BTR failing to initialise
Co-authored-by: Nympfonic <arys.steam@gmail.com>
Reviewed-on: SPT-AKI/Modules#67
Co-authored-by: Arys <arys@noreply.dev.sp-tarkov.com>
Co-committed-by: Arys <arys@noreply.dev.sp-tarkov.com>