0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-12 22:30:43 -05:00

Fix RecursiveCloner Null Value Handling (!338)

This PR fixes an issue in RecursiveCloner where null value properties of any type (i.e. arrays, nullable primitives) were being converted to empty objects.

An example of where this is a problem can occur when starting a raid in 3.9. The client would attempt to convert the empty object (created by the RecursiveCloner) to an Array and it would result in a JSON error.

Reviewed-on: SPT-AKI/Server#338
Co-authored-by: paulov <v2k4gameplay@outlook.com>
Co-committed-by: paulov <v2k4gameplay@outlook.com>
This commit is contained in:
paulov 2024-05-18 09:28:50 +00:00 committed by chomp
parent 2d299b99d2
commit 0d2afc9c49

View File

@ -35,6 +35,14 @@ export class RecursiveCloner implements ICloner
const newObj = {};
for (const propOf1 in obj)
{
// If the value of the original property is null, ensure the cloned value is also null
// This fixes an issue where null arrays were incorrectly being converted to empty objects
if (obj[propOf1] === null)
{
newObj[propOf1.toString()] = null;
continue;
}
newObj[propOf1.toString()] = this.clone(obj[propOf1]);
}
return newObj as T;