From 6729f2decc94a78f3fe52d6c726d7ceb3a9b3987 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 22 May 2024 19:03:11 +0700 Subject: [PATCH] BasicNetworkedElement.bumpVersion call from outside now properly notifies listeners --- .../network/syncher/BasicNetworkedElement.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/network/syncher/BasicNetworkedElement.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/network/syncher/BasicNetworkedElement.kt index bbcccffa..b8f1d0b3 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/network/syncher/BasicNetworkedElement.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/network/syncher/BasicNetworkedElement.kt @@ -42,11 +42,16 @@ open class BasicNetworkedElement(private var value: TYPE, protecte val old = value value = t queue.clear() - bumpVersion() + super.bumpVersion() valueListeners.forEach { it.callable.invoke(t, old) } } } + override fun bumpVersion() { + super.bumpVersion() + valueListeners.forEach { it.callable.invoke(value, value) } + } + override fun addListener(listener: Consumer): Listenable.L { return Listener(listener) } @@ -68,7 +73,7 @@ open class BasicNetworkedElement(private var value: TYPE, protecte val old = value value = if (isLegacy) fromLegacy(legacyCodec.read(data)) else codec.read(data) queue.clear() - bumpVersion() + super.bumpVersion() if (value != old) { valueListeners.forEach { it.callable.invoke(value, old) } @@ -85,7 +90,7 @@ open class BasicNetworkedElement(private var value: TYPE, protecte override fun readDelta(data: DataInputStream, interpolationDelay: Double, isLegacy: Boolean) { val read = if (isLegacy) fromLegacy(legacyCodec.read(data)) else codec.read(data) - bumpVersion() + super.bumpVersion() if (isInterpolating) { queue.push(read, interpolationDelay)