It now returns an empty array if the pool is initially empty.
This function does not guarantee the number of elements returned because it will break out the loop early if the pool is exhausted.
Co-authored-by: qe201020335 <qe201020335@sina.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/227
Co-authored-by: qe201020335 <qe201020335@noreply.dev.sp-tarkov.com>
Co-committed-by: qe201020335 <qe201020335@noreply.dev.sp-tarkov.com>
A similar field can also be seen in static container generation which the value is respected
Also Limited the amount of random draws to avoid going over the `desiredSpawnpointCount`
- Consider a potential mod that changes every spawn point's `IsAlwaysSpawn` to true, then there is absolute no point for the generator to draw them again and only to have them removed during dedupe
Co-authored-by: qe201020335 <qe201020335@sina.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/226
Co-authored-by: qe201020335 <qe201020335@noreply.dev.sp-tarkov.com>
Co-committed-by: qe201020335 <qe201020335@noreply.dev.sp-tarkov.com>
The server expects that the total "Progress" when a bitcoin is complete to be the "ProductionTime" value (145000 by default). However the server was using a modified target value, while only adding the actual time change to the Progress.
This results in a drift over time between the client/server while the server is stopped, as the client gets an incorrect value on startup.
If we instead scale the addition to Progress based on the adjusted craft time, and target the base productionTime for completion, we can get a much more accurate progress while offline that matches the client
I used the profile from this ticket for testing: https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/496
The user has both an upgrade and bitcoin going at the same time, so they should progress at the same rate. This is what the code was previously resulting in:
![image](/attachments/fe428a3b-d271-40e1-a3f6-08ef936224b6)
While the server was shut down for 50 minutes (As noted by the upgrade), only 36 minutes was deducted from the bitcoin craft.
This is the result of that same profile after these changes were made:
![image](/attachments/d2ce44e6-1a0e-4991-aa51-3eb340c22ca5)
You can see that ~2 hours 25 minutes was deducted from both the upgrade, as well as the bitcoin craft timer. There is still a slight discrepancy, but in a total bitcoin run it should be minimal
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/225
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
As far as I can tell, there's no need to strip backslashes, as they should only exist to escape other characters (Double quotes, for example). Stripping them will more often than not result in invalid JSON
NOTE: Due to the loss of git history, I'm unable to see _why_ exactly this replacement was done in the first place. There may be some valid reason I'm not thinking of. If this is the case, I can look at other solutions
Resolves: https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/488
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/222
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Clone flea items prior to passing them off to the createSingleOfferForItem method
This change results in more armor on the flea having 100% durability, and less having identical non-max durability values
Resolves: https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/447
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/223
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
- Fix data type for TraderServiceModel
- Add LK Service price/item data
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/221
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Updated `getItemQualityModifierForOfferItems()` to return root items quality modifer when its a weapon
Fixed `getItemQualityModifierForOfferItems()` assuming quality started at 1
Bundle up profile save time and display in one line + do not log to file
Don't log when each profile is saved
Do not log to file how much fuel is left in generator
The rewardItem.target has to be set after the item IDs are regenerated, so it gets the new root item ID
Resolves: https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/470
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/219
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Only check if progress was only `great than` craft time, not `great than or equal to`
Didn't take into account developer accounts have reduce craft timers
Fewer assorts on discount assort
Fewer weapons/armors on discount assort
Higher min dura for presets
Higher max dura for presets
Reduce price limit for marksmen rifles
Added small optimisations to skip full rows when looking for a free slot to put item in
Added small optimisation to skip looking for a free slot when entire container is full
Fixed error messages not properly being passed back up chain
Removed unused legacy function `placeItemInInventoryLegacy()`
Dont return stash layout as result in `fillContainerMapWithItem()`
Added small optimisation to `fillContainerMapWithItem()`, check if all slots of failled before trying to fit item
If the item handed in for a quest has a numeric `location` property, this indicates it's inside a magazine or other "sequential" container.
Re-calculate the `location` property of all children in the items parent in this case, to avoid gaps which break the profile
Resolves: https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/455
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/218
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Split item generation values up, separate value for item/equipment/weapon
Fixed more assorts being generated than were being deleted each partial refresh
Added assort item options to discount assort config
Larger number of weapon presets
Larger stack size for ammos (override stack size of ammo by parent id, not item id)
Removed ammo boxes from blacklist + add max limit of 2
Removed fence debug logging
Make weapon picker check if weapon is on blacklist before adding
Fixed incorrect weapon mod removal check
Reduced chances mods are removed from weapons
Notable coding Changes:
- Added `getRootItemParentID` method in `InsuranceService` to standardize the determination of the root insurance container.
- Added `IInsuranceEquipmentPkg` model for structuring insurance packages, a type used to store insurance item data before it's saved in the profile.
- Added `HashUtil` in `InsuranceController` and `InsuranceService` for generating an ID for the root insurance container in the case that the root ID cannot be found.
- Updated and normalized item map generation and usage across `InsuranceService` and `InsuranceController`.
- Updated `ItemHelper` with new methods `adoptOrphanedItems` and `generateItemsMap`, facilitating better management of item relationships and efficient item look-ups.
- Updated `InsuranceController.findItemsToDelete` and related methods to use the new `rootItemParentID` parameter to ensure that all root level items share the same parent ID.
- Updated logic in `InsuranceService` for creating insurance packages and handling orphaned items.
Uh-huh, but what would you say you do here?
- Resolves an issue that arose when `lostondeath.json` equipment configuration options were set to `false`. On death, the equipment's children items would be sent back to the player through insurance, duplicating them.
- Resolves an issue that prevented items from appearing in an insurance return even though they passed an insurance roll.
- Improved debug logging.
Remaining Oopses:
- We do not have data on items that were dropped in a raid. This means we have to pull item data from the profile at the start of the raid to return to the player in insurance. Because of this, the item positioning may differ from the position the item was in when the player died. Apart from removing all positioning, this is the best we can do.
Resolves#425
In the project/assets/database/locales/server/en.json file, in the "launcher-profile_spteasystart" key, the description of the profile being created has changed from level 69 to level 15. The description of this key has been corrected in other localizations
Co-authored-by: Krinkels <krinkels@krinkels.org>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/217
Co-authored-by: Krinkels <krinkels@noreply.dev.sp-tarkov.com>
Co-committed-by: Krinkels <krinkels@noreply.dev.sp-tarkov.com>
Expanded `condition` config system to separate out current and max durability
Added missing armor config settings
Rewrote weapon durability method `randomiseWeaponDurabilityValues()` to do work similar to `randomiseArmorDurabilityValues()`
Fixed various items being classified as ARMORED_EQUIPMENT and using the wrong category config values
Moved ARMORED_EQUIPMENT to bottom of config so its chosen last, fixes vests being flagged as wrong item
Resolved by having the client send the sell price instead of trying to calculate it on the server. Same route, just with an extra parameter passed in
Removed unnecessary value calculation code, and renamed method to match new behaviour
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/216
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
[The wiki specifies](https://escapefromtarkov.fandom.com/wiki/Scavs#Scav_karma) that, between 6 and 8, Fence rep is reset to 6 before penalties are applied (i.e. killing someone at 7.5 rep leaves you at 5.9), but the current fix just subtracts a flat 1 reputation instead (i.e. a kill at 7.5 leaves you at 6.4)
this should change that.
Co-authored-by: Azrael <Azrael@noneofyourbusiness.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/215
Co-authored-by: Azrael1123 <azrael1123@noreply.dev.sp-tarkov.com>
Co-committed-by: Azrael1123 <azrael1123@noreply.dev.sp-tarkov.com>
Made several improvements to the `InsuranceController` to ensure a more reliable and logical handling of insured items and their attachments.
- Updates `parentAttachmentsMap` declaration to `let` for mutability, enabling dynamic updates during processing.
- Updates `parentAttachmentsMap` to initially include all attachments (including attachments that should not be in-raid moddable).
- Updates `processRegularItems` logic to include `parentAttachmentsMap` in its parameters and logic. Now better ensures that attachments are correctly identified and processed alongside their parent items.
- Adds `removeNonModdableAttachments` method to filter out non-moddable attachments from processing.
- Updates deletion logic to better handle cases where items, such as armour vests and their non-removable plates, are processed to prevent orphaned items post-deletion.
Resolves#401
Resolved an issue that caused insurance packages that were created/lost in the same raid with different traders to be removed all at once instead of one-by-one after they were processed. This shouldn't have been causing any notable issues as the packages were already cached/queued up for processing elsewhere in the code, but it was never the original intent to have them removed before they were processed. The fix was simply to also match the trader ID when the package removal takes place.
Possibly related to #401#425
- Implemented deep cloning of input Items to prevent mutation.
- Reordered parameters: Items (required) now precede PMC data (optional).
- Updated method calls to bring them inline with these changes.
Two changes:
Calcualte the quality of an item and its mods, not just root item
Calcualte the average price of an offer using item + mods, not just root item
**Description**
This pull request changes the WebSocket connection `handle lost` log message in the `wsOnConnection` method of the `GameSocket` class. The original log message was:
```typescript
this.logger.debug(this.localisationService.getText("websocket-socket_lost_deleting_handle");
>>> [WS] Socket lost, deleting handle, status: %s
```
Which was inconsistent with most other languages. It can be understood from context that the socket was lost, therefor deleted and closed. Instead now;
```typescript
this.logger.debug(this.localisationService.getText("websocket-socket_lost_deleting_handle");
>>> [WS] Socket lost, deleting handle
```
This is achieved through editing the languages one by one and removing the "`status: %s`" component.
**Related**
- Closes: https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/421
Co-authored-by: Deadly <info.saddiki@gmail.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/214
Co-authored-by: Deadly Alden <deadly@noreply.dev.sp-tarkov.com>
Co-committed-by: Deadly Alden <deadly@noreply.dev.sp-tarkov.com>
- Resolves an issue in bot generation caused by a missing parameter when calling the `shouldModBeSpawned` method.
- Adds a optional chaining operator within a condition to safeguard against undefined errors.
Contributed by: barlog_m
Thank you! :D
Resolves an issue where the error message in `getItemsToListOnFleaFromInventory` did not propagate as expected due to the pass-by-value behaviour in JavaScript. The solution was to refactor the method to return an object that includes both the items and the error message.
Fixed some instances of:
- Unordered imports
- Reassigning function parameters
- Modifying values in assignment/return statements
- Array.forEach being used instead of for...of
- Simplified control logic
Better handling of item rewards that need to be split into root + child (ammo boxes)
Use `addItemsToStash()`
move `recipe.isEncoded` check to earlier in function
make use of `getItem()` inside `splitStack()` instead of direct db access
Keep completed dailies inside "activeQuests" array until dailies are refreshed
Adjust post-raid quest handling to ensure previously completed/failed quests keep their original status