From a23ff4e9c4d2ad90af3c05090acfce405dfc1b1f Mon Sep 17 00:00:00 2001 From: EngineerYo Date: Sat, 15 Jun 2019 13:06:41 -0700 Subject: [PATCH 1/2] effects gets set to undefined if array length is 0 Right now, there is a discrepency in how the `.effects` property on RoomObjects is handled. If there are no effects on an object, an object that has never had an effect on it has an undefined `effects` property, whereas objects that have had an effect on them in the past have an `effects` property of `[]` This change sets `effects` to undefined if there are no effects on the object, making this property consistent for all room objects. --- src/game/rooms.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/game/rooms.js b/src/game/rooms.js index cff0dd22..767e2e8e 100644 --- a/src/game/rooms.js +++ b/src/game/rooms.js @@ -1604,6 +1604,10 @@ exports.makePos = function(_register) { ticksRemaining: i.endTime - runtimeData.time })).filter(i => i.ticksRemaining > 0).value(); } + + if (Array.isArray(this.effects) && this.effects.length === 0) { + this.effects = undefined; + } }); Object.defineProperty(globals, 'RoomObject', {enumerable: true, value: RoomObject}); From d9187c8f46729a7b25db28cbbfadadd6d3d50b57 Mon Sep 17 00:00:00 2001 From: EngineerYo Date: Sat, 15 Jun 2019 13:27:48 -0700 Subject: [PATCH 2/2] effects property now defaults to empty array After some delibaration and advice, code was changed so `effects` is never undefined, but defaults to an empty array instead. This way, the `effects` property never changes data type. --- src/game/rooms.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/game/rooms.js b/src/game/rooms.js index 767e2e8e..cc9b9e2c 100644 --- a/src/game/rooms.js +++ b/src/game/rooms.js @@ -1604,9 +1604,8 @@ exports.makePos = function(_register) { ticksRemaining: i.endTime - runtimeData.time })).filter(i => i.ticksRemaining > 0).value(); } - - if (Array.isArray(this.effects) && this.effects.length === 0) { - this.effects = undefined; + else { + this.effects = [] } });