From 7b70ff819b1cd596a3610e43e9e5c0ab795b6fd8 Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Sun, 20 Oct 2019 17:02:02 -0700 Subject: [PATCH] Removed possible vector for errors by calling reset in constructor to set initial values Removed possible vector for errors by calling reset in constructor to set initial values I do not expect issues here, but this component is complex enough to warrant it --- .../engine/component/CofComponent.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/core/src/com/riiablo/engine/component/CofComponent.java b/core/src/com/riiablo/engine/component/CofComponent.java index c60fbe56..6297193a 100644 --- a/core/src/com/riiablo/engine/component/CofComponent.java +++ b/core/src/com/riiablo/engine/component/CofComponent.java @@ -50,15 +50,21 @@ public class CofComponent implements Component, Pool.Poolable { Arrays.fill(DEFAULT_TRANSFORM, TRANSFORM_NULL); } - public String token = null; - public int mode = MODE_NULL; - public int wclass = WEAPON_NIL; - public COF cof = null; - public int dirty = Dirty.NONE; - public int load = Dirty.NONE; + public String token; + public int mode; + public int wclass; + public COF cof; + public int dirty; + public int load; - public final int[] component = DEFAULT_COMPONENT.clone(); - public final int[] transform = DEFAULT_TRANSFORM.clone(); + public final int[] component; + public final int[] transform; + + public CofComponent() { + component = new int[COF.Component.NUM_COMPONENTS]; + transform = new int[COF.Component.NUM_COMPONENTS]; + reset(); + } @SuppressWarnings("unchecked") public final AssetDescriptor[] layer = (AssetDescriptor[]) new AssetDescriptor[COF.Component.NUM_COMPONENTS];