mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-21 08:42:53 +02:00
BUGFIX: Properly deep copy array data for coding contracts (#1064)
This commit is contained in:
@@ -67,17 +67,8 @@ export function NetscriptCodingContract(): InternalAPI<ICodingContract> {
|
||||
const contract = getCodingContract(ctx, hostname, filename);
|
||||
const data = contract.getData();
|
||||
if (Array.isArray(data)) {
|
||||
// For two dimensional arrays, we have to copy the internal arrays using
|
||||
// slice() as well. As of right now, no contract has arrays that have
|
||||
// more than two dimensions
|
||||
const copy = data.slice();
|
||||
for (let i = 0; i < copy.length; ++i) {
|
||||
if (data[i].constructor === Array) {
|
||||
copy[i] = data[i].slice();
|
||||
}
|
||||
}
|
||||
|
||||
return copy;
|
||||
// For multi-dimensional arrays, we have to copy the internal arrays as well
|
||||
return JSON.parse(JSON.stringify(data));
|
||||
} else return data;
|
||||
},
|
||||
getDescription: (ctx) => (_filename, _hostname?) => {
|
||||
|
||||
Reference in New Issue
Block a user