From e3c07e09342cb4ae98fe3fb43e398bd47c3cb8b1 Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Wed, 24 Apr 2019 02:25:15 -0700 Subject: [PATCH] Clearing property list will now free all stat objects --- core/src/com/riiablo/item/PropertyList.java | 1 + core/src/com/riiablo/item/Stat.java | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/core/src/com/riiablo/item/PropertyList.java b/core/src/com/riiablo/item/PropertyList.java index 69f8c605..e1b2bca5 100644 --- a/core/src/com/riiablo/item/PropertyList.java +++ b/core/src/com/riiablo/item/PropertyList.java @@ -50,6 +50,7 @@ public class PropertyList implements Iterable { } public void clear() { + for (Stat stat : props.values()) Stat.free(stat); props.clear(); } diff --git a/core/src/com/riiablo/item/Stat.java b/core/src/com/riiablo/item/Stat.java index 0e55c296..2a8cd302 100644 --- a/core/src/com/riiablo/item/Stat.java +++ b/core/src/com/riiablo/item/Stat.java @@ -3,6 +3,7 @@ package com.riiablo.item; import com.google.common.primitives.UnsignedInts; import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Pool; import com.badlogic.gdx.utils.Pools; import com.riiablo.CharData; @@ -475,6 +476,14 @@ public class Stat implements Comparable, Pool.Poolable { return POOL.obtain()._obtain(src); } + static void free(Stat stat) { + POOL.free(stat); + } + + static void freeAll(Array stats) { + POOL.freeAll(stats); + } + public int id; public int param; public ItemStatCost.Entry entry;